
Added Camera Class Added *= operator to the matrix class Added Transformation Queue vector to the Model Class Added Get Vertex, Polygon and Polygon Vertex methods to the Model Class Added DehomogenizeAllVerticies method to the Model Class Added GetPolygonVertexCount method to Polygon Class Added Ability to have multiple models in a "scene" in the Rasterizer Added DrawWireFrame method to the Rasterizer Class Added Aspect Ratio and View Matrix to the Rasterizer Class Added TransformTools namespace to hold shared transformation functions Added Dehomogenize method to the Vector Class Moved Transformation methods to a new shared name space
99 lines
1.7 KiB
C++
99 lines
1.7 KiB
C++
#include "Model.h"
|
|
|
|
Model::Model()
|
|
{
|
|
}
|
|
|
|
Model::~Model()
|
|
{
|
|
}
|
|
|
|
const vector<Polygon3D>& Model::GetPolygons()
|
|
{
|
|
return _polygons;
|
|
}
|
|
|
|
const vector<Vertex>& Model::GetVertices()
|
|
{
|
|
return _vertices;
|
|
}
|
|
|
|
const vector<Matrix>& Model::GetPendingTransforms()
|
|
{
|
|
return _pendingTransforms;
|
|
}
|
|
|
|
size_t Model::GetPolygonCount()
|
|
{
|
|
return _polygons.size();
|
|
}
|
|
|
|
size_t Model::GetVerticesCount()
|
|
{
|
|
return _vertices.size();
|
|
}
|
|
|
|
size_t Model::GetPendingTransformCount()
|
|
{
|
|
return _pendingTransforms.size();
|
|
}
|
|
|
|
void Model::AddVertex(float x, float y, float z)
|
|
{
|
|
_vertices.push_back(Vertex(x, y, z));
|
|
_transformedVertices.push_back(Vertex(x, y, z));
|
|
}
|
|
|
|
void Model::AddPolygon(int index0, int index1, int index2)
|
|
{
|
|
_polygons.push_back(Polygon3D(index0, index1, index2));
|
|
}
|
|
|
|
void Model::EnqueueTransform(Matrix transform)
|
|
{
|
|
_pendingTransforms.push_back(transform);
|
|
}
|
|
|
|
void Model::ClearPendingTransforms()
|
|
{
|
|
_pendingTransforms.clear();
|
|
}
|
|
|
|
Polygon3D Model::GetPolygon(int index)
|
|
{
|
|
return _polygons[index];
|
|
}
|
|
|
|
Vertex Model::GetVertex(int polygonIndex, int vertexPolygonIndex)
|
|
{
|
|
return GetVertex(GetPolygon(polygonIndex).GetIndex(vertexPolygonIndex));
|
|
}
|
|
|
|
Vertex Model::GetVertex(int index)
|
|
{
|
|
return _transformedVertices[index];
|
|
}
|
|
|
|
void Model::ApplyTransformToLocalVertices(const Matrix& transform)
|
|
{
|
|
for (int i = 0; i < GetVerticesCount(); i++)
|
|
{
|
|
_transformedVertices[i] = transform * _vertices[i];
|
|
}
|
|
}
|
|
|
|
void Model::ApplyTransformToTransformedVertices(const Matrix& transform)
|
|
{
|
|
for (int i = 0; i < GetVerticesCount(); i++)
|
|
{
|
|
_transformedVertices[i] = transform * _transformedVertices[i];
|
|
}
|
|
}
|
|
|
|
void Model::DehomogenizeAllVertices()
|
|
{
|
|
for (Vertex ¤tVertex : _transformedVertices)
|
|
{
|
|
currentVertex.Dehomogenize();
|
|
}
|
|
} |