nxdk_pgraph_tests
A collection of tests for the Xbox nv2a graphics processor
 
Loading...
Searching...
No Matches
model_builder.h
1#ifndef NXDK_PGRAPH_TESTS_SRC_MODELS_MODEL_BUILDER_H_
2#define NXDK_PGRAPH_TESTS_SRC_MODELS_MODEL_BUILDER_H_
3
4#include <cstdint>
5#include <vector>
6
7#include "vertex_buffer.h"
8#include "xbox_math_types.h"
9
12 public:
13 virtual ~ModelBuilder() = default;
14
16 [[nodiscard]] virtual uint32_t GetVertexCount() const = 0;
17
19 virtual void PopulateVertexBuffer(const std::shared_ptr<VertexBuffer> &vertices);
20
21 virtual void PopulateVertexBuffer(const std::shared_ptr<VertexBuffer> &vertices, const float *transformation);
22
23 protected:
24 [[nodiscard]] virtual const float *GetVertexPositions() = 0;
25 [[nodiscard]] virtual const float *GetVertexNormals() = 0;
26
27 // Called after vertex arrays have been consumed.
28 virtual void ReleaseData() {};
29};
30
33 public:
34 SolidColorModelBuilder() = default;
35 SolidColorModelBuilder(const vector_t &diffuse, const vector_t &specular);
36 SolidColorModelBuilder(const vector_t &diffuse, const vector_t &specular, const vector_t &back_diffuse,
37 const vector_t &back_specular);
38
40 void PopulateVertexBuffer(const std::shared_ptr<VertexBuffer> &vertices) override;
41
43 void PopulateVertexBuffer(const std::shared_ptr<VertexBuffer> &vertices, const float *transformation) override;
44
45 private:
46 void ApplyColors(const std::shared_ptr<VertexBuffer> &vertices) const;
47
48 protected:
49 vector_t diffuse_{1.0f, 1.0f, 1.0f, 1.0f};
50 vector_t specular_{0.0f, 0.0f, 0.0f, 1.0f};
51 vector_t back_diffuse_{1.0f, 1.0f, 1.0f, 1.0f};
52 vector_t back_specular_{0.0f, 0.0f, 0.0f, 1.0f};
53};
54
55#endif // NXDK_PGRAPH_TESTS_SRC_MODELS_MODEL_BUILDER_H_
A factory for model meshes.
Definition model_builder.h:11
virtual uint32_t GetVertexCount() const =0
Returns the number of kPositions required to hold the model.
virtual void PopulateVertexBuffer(const std::shared_ptr< VertexBuffer > &vertices)
Populates the given VertexBuffer with model data.
Definition model_builder.cpp:7
Builder for untextured models.
Definition model_builder.h:32
void PopulateVertexBuffer(const std::shared_ptr< VertexBuffer > &vertices) override
Populates the given VertexBuffer with model data.
Definition model_builder.cpp:62