diff --git a/include/geometry.h b/include/geometry.h index e43fdab..dbe03a7 100644 --- a/include/geometry.h +++ b/include/geometry.h @@ -55,7 +55,7 @@ struct UVList struct Vertex { - Point point; + Point position; Vector normal; ColorF32 color; }; diff --git a/src/engine.cpp b/src/engine.cpp index 8ff18c0..d6bc82d 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -64,8 +64,8 @@ int EngineInit(char *objFilename, char *mtlFilename) // Mesh configuration - mesh.position.z = 50; - mesh.position.y = -175; + mesh.position.z = 125; + mesh.position.y = -125; mesh.scale = 1.0f; @@ -208,8 +208,8 @@ static void ComputeNormals(void) Vertex &vert2 = verts.data[face.vertIndex[2]]; - Vector v01 = vert1.point - vert0.point; - Vector v02 = vert2.point - vert0.point; + Vector v01 = vert1.position - vert0.position; + Vector v02 = vert2.position - vert0.position; Vector normal = VectorCross(v01, v02); @@ -253,8 +253,8 @@ static void TransformToClipSpace(void) for (size_t v = 0; v < localVerts.size; ++v) { - transVerts.data[v].point = - localVerts.data[v].point * tScale * tRotate * tTranslate * tView * tPersp; + transVerts.data[v].position = + localVerts.data[v].position * tScale * tRotate * tTranslate * tView * tPersp; transVerts.data[v].normal = localVerts.data[v].normal * tScale * tRotate * tTranslate; @@ -273,9 +273,9 @@ void ClipAndCull(void) { Face &face = localFaces.data[f]; - Point &p0 = verts.data[face.vertIndex[0]].point; - Point &p1 = verts.data[face.vertIndex[1]].point; - Point &p2 = verts.data[face.vertIndex[2]].point; + Point &p0 = verts.data[face.vertIndex[0]].position; + Point &p1 = verts.data[face.vertIndex[1]].position; + Point &p2 = verts.data[face.vertIndex[2]].position; // Ignore this face if its Z is outside the Z clip planes if ( (p0.z < -p0.w) @@ -315,10 +315,10 @@ static void TransformToScreenSpace(void) for (size_t v = 0; v < verts.size; ++v) { - verts.data[v].point *= tScreen; - verts.data[v].point.x /= verts.data[v].point.w; - verts.data[v].point.y /= verts.data[v].point.w; - verts.data[v].point.z /= verts.data[v].point.w; + verts.data[v].position *= tScreen; + verts.data[v].position.x /= verts.data[v].position.w; + verts.data[v].position.y /= verts.data[v].position.w; + verts.data[v].position.z /= verts.data[v].position.w; } } diff --git a/src/light.cpp b/src/light.cpp index 78e7367..824e96e 100644 --- a/src/light.cpp +++ b/src/light.cpp @@ -20,7 +20,7 @@ ColorF32 ComputeLight( Vertex &vert, Material &material, Light &light, Camera &camera) { // Distance from light to vertex - Vector direction = light.position - vert.point; + Vector direction = light.position - vert.position; float distance = VectorLength(direction); @@ -65,7 +65,7 @@ static ColorF32 ComputeDiffuseLight( Material &material, ColorF32 &intensity, Vertex &vert, Light &light) { // Vector from the light to the vertex - Vector direction = light.position - vert.point; + Vector direction = light.position - vert.position; VectorNormalize(direction); float normalDotDirection = VectorDot(vert.normal, direction); @@ -82,12 +82,12 @@ static ColorF32 ComputeSpecularLight( Camera &camera) { // Vector from the camera to the vertex - Vector view = camera.position - vert.point; + Vector view = camera.position - vert.position; VectorNormalize(view); // Vector from the light to the vertex - Vector direction = light.position - vert.point; + Vector direction = light.position - vert.position; VectorNormalize(direction); diff --git a/src/loader.cpp b/src/loader.cpp index 0214108..feaa075 100644 --- a/src/loader.cpp +++ b/src/loader.cpp @@ -69,11 +69,11 @@ int ParseOBJ(char *filename, EngineMemory &memory) if (strcmp(type, "v") == 0) { sscanf( data, "%f %f %f", - &verts.data[vertIndex].point.x, - &verts.data[vertIndex].point.y, - &verts.data[vertIndex].point.z); + &verts.data[vertIndex].position.x, + &verts.data[vertIndex].position.y, + &verts.data[vertIndex].position.z); - verts.data[vertIndex].point.w = 1.0f; + verts.data[vertIndex].position.w = 1.0f; ++vertIndex; } diff --git a/src/render.cpp b/src/render.cpp index 1b4fa70..9a90d33 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -41,9 +41,9 @@ void Render(EngineBuffer &buffer, EngineMemory &memory) { Face &face = faces.data[f]; - Point &p0 = verts.data[face.vertIndex[0]].point; - Point &p1 = verts.data[face.vertIndex[1]].point; - Point &p2 = verts.data[face.vertIndex[2]].point; + Point &p0 = verts.data[face.vertIndex[0]].position; + Point &p1 = verts.data[face.vertIndex[1]].position; + Point &p2 = verts.data[face.vertIndex[2]].position; // Bounding box for barycentric calculations (top-left fill convention)