draw refactoring #1

This commit is contained in:
Sandro Sobczyński
2020-10-29 17:47:28 +01:00
parent 9e00ef3634
commit 5320d7f84d
15 changed files with 267 additions and 78 deletions
+3 -3
View File
@@ -48,10 +48,10 @@ public:
u8 isOnSquare(Vector3 &t_min, Vector3 &t_max); u8 isOnSquare(Vector3 &t_min, Vector3 &t_max);
float length(); float length();
void normalize(); void normalize();
void setByLerp(const Vector3 &v1, const Vector3 &v2, const float t_interp); void setByLerp(const Vector3 &v1, const Vector3 &v2, const float &t_interp, const float &t_scale);
float innerProduct(Vector3 &v); float innerProduct(Vector3 &v);
void set(Vector3 &v); void set(const Vector3 &v);
void set(float x, float y, float z); void set(const float &x, const float &y, const float &z);
void copy(Vector3 &v); void copy(Vector3 &v);
float distanceTo(Vector3 &v); float distanceTo(Vector3 &v);
void print(); void print();
-1
View File
@@ -42,7 +42,6 @@ public:
void allocateMemory(); void allocateMemory();
private: private:
Vector3 calcVector;
Vector3 calc3Vectors[3]; Vector3 calc3Vectors[3];
}; };
+26
View File
@@ -0,0 +1,26 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#ifndef _TYRA_MESH_FRAME_
#define _TYRA_MESH_FRAME_
#include <tamtypes.h>
class MeshFrame
{
public:
MeshFrame();
~MeshFrame();
private:
};
#endif
@@ -0,0 +1,64 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#ifndef _TYRA_MESH_MATERIAL_
#define _TYRA_MESH_MATERIAL_
#include <tamtypes.h>
class MeshMaterial
{
public:
MeshMaterial();
~MeshMaterial();
/** Material name. */
char *getName() const { return name; };
const u32 &getFacesCount() const { return facesCount; };
/** Indexes of vertices. Each 3 faces will give you vertices of next triangle. */
const u32 &getVertexFace(const u32 &i) const { return vertexFaces[i]; };
/** Indexes of texture coords. Each 3 faces will give you texture coords of next triangle. */
const u32 &getStFace(const u32 &i) const { return stFaces[i]; };
/** Indexes of normal vectors used for lighting. Each 3 faces will give you normal vectors of next triangle. */
const u32 &getNormalFace(const u32 &i) const { return normalFaces[i]; };
/** Array of vertex faces. Size of getFacesCount() */
const u32 *getVertexFaces() const { return vertexFaces; };
/** Array of texture coords faces. Size of getFacesCount() */
const u32 *getStFaces() const { return stFaces; };
/** Array of normal vector faces. Size of getFacesCount() */
const u32 *getNormalFaces() const { return normalFaces; };
/** Set faces count and allocate faces memory. */
void setFacesCount(const u32 &t_val);
/** Set vertex face. Do not call this method until you know what you do.
* Should be called by data loader. */
void setVertexFace(const u32 &t_index, const u32 &t_val) { vertexFaces[t_index] = t_val; }
/** Set st face. Do not call this method until you know what you do.
* Should be called by data loader. */
void setStFace(const u32 &t_index, const u32 &t_val) { stFaces[t_index] = t_val; }
/** Set vertex face. Do not call this method until you know what you do.
* Should be called by data loader. */
void setNormalFace(const u32 &t_index, const u32 &t_val) { normalFaces[t_index] = t_val; }
/** Set material name. */
void setName(char *t_val);
private:
u32 facesCount;
u32 *vertexFaces, *stFaces, *normalFaces;
u8 isNameAllocated, areFacesAllocated;
char *name;
};
#endif
+14 -7
View File
@@ -14,13 +14,21 @@
#include <tamtypes.h> #include <tamtypes.h>
#include <math3d.h> #include <math3d.h>
#include "math/vector3.hpp" #include "math/vector3.hpp"
#include "utils/debug.hpp"
#include "./anim_state.hpp" #include "./anim_state.hpp"
#include "./mesh_material.hpp"
struct ObjMaterial class Frame2
{ {
char *materialName; public:
u32 facesCount; Frame2() { printf("Frame2 constructor\n"); };
u32 *verticeFaces, *coordinateFaces, *normalFaces; ~Frame2() { printf("Frame2 destructor\n"); };
u16 number;
u32 verticesCount, coordinatesCount, normalsCount, materialsCount;
Vector3 *vertices __attribute__((aligned(16))),
*coordinates __attribute__((aligned(16))),
*normals __attribute__((aligned(16)));
MeshMaterial *materials;
}; };
struct Frame struct Frame
@@ -30,7 +38,7 @@ struct Frame
Vector3 *vertices __attribute__((aligned(16))), Vector3 *vertices __attribute__((aligned(16))),
*coordinates __attribute__((aligned(16))), *coordinates __attribute__((aligned(16))),
*normals __attribute__((aligned(16))); *normals __attribute__((aligned(16)));
ObjMaterial *materials; MeshMaterial *materials;
}; };
/** Class which have common types for all 3D objects */ /** Class which have common types for all 3D objects */
@@ -46,14 +54,13 @@ public:
ObjModel(char *t_objFile); ObjModel(char *t_objFile);
~ObjModel(); ~ObjModel();
void animate();
u32 getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, VECTOR *o_colors, Vector3 &t_cameraPos, float t_scale, u8 t_shouldBeBackfaceCulled); u32 getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, VECTOR *o_colors, Vector3 &t_cameraPos, float t_scale, u8 t_shouldBeBackfaceCulled);
u32 getFacesCount(); u32 getFacesCount();
u8 isMemoryAllocated; u8 isMemoryAllocated;
private: private:
Vector3 calc3Vectors[3]; Vector3 calc3Vectors[3];
Vector3 calcVector;
void fillNextFace(VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, VECTOR *o_colors, u32 t_materialI, u32 t_getI, u32 t_setI);
}; };
#endif #endif
+20 -20
View File
@@ -67,7 +67,7 @@ void ObjLoader::load(Frame *o_result, char *t_filename, float t_scale)
{ {
char temp[30]; char temp[30];
fscanf(file, "%s\n", temp); fscanf(file, "%s\n", temp);
o_result->materials[++materialsI].materialName = String::createCopy(temp); o_result->materials[++materialsI].setName(temp);
faceI = 0; faceI = 0;
} }
else if (strcmp(lineHeader, "f") == 0) else if (strcmp(lineHeader, "f") == 0)
@@ -80,17 +80,17 @@ void ObjLoader::load(Frame *o_result, char *t_filename, float t_scale)
PRINT_ERR(".obj can't be read by this simple parser. Try exporting with other options"); PRINT_ERR(".obj can't be read by this simple parser. Try exporting with other options");
else else
{ {
o_result->materials[materialsI].verticeFaces[faceI] = vertexIndex[0] - 1; o_result->materials[materialsI].setVertexFace(faceI, vertexIndex[0] - 1);
o_result->materials[materialsI].verticeFaces[faceI + 1] = vertexIndex[1] - 1; o_result->materials[materialsI].setVertexFace(faceI + 1, vertexIndex[1] - 1);
o_result->materials[materialsI].verticeFaces[faceI + 2] = vertexIndex[2] - 1; o_result->materials[materialsI].setVertexFace(faceI + 2, vertexIndex[2] - 1);
o_result->materials[materialsI].coordinateFaces[faceI] = coordIndex[0] - 1; o_result->materials[materialsI].setStFace(faceI, coordIndex[0] - 1);
o_result->materials[materialsI].coordinateFaces[faceI + 1] = coordIndex[1] - 1; o_result->materials[materialsI].setStFace(faceI + 1, coordIndex[1] - 1);
o_result->materials[materialsI].coordinateFaces[faceI + 2] = coordIndex[2] - 1; o_result->materials[materialsI].setStFace(faceI + 2, coordIndex[2] - 1);
o_result->materials[materialsI].normalFaces[faceI] = normalIndex[0] - 1; o_result->materials[materialsI].setNormalFace(faceI, normalIndex[0] - 1);
o_result->materials[materialsI].normalFaces[faceI + 1] = normalIndex[1] - 1; o_result->materials[materialsI].setNormalFace(faceI + 1, normalIndex[1] - 1);
o_result->materials[materialsI].normalFaces[faceI + 2] = normalIndex[2] - 1; o_result->materials[materialsI].setNormalFace(faceI + 2, normalIndex[2] - 1);
faceI += 3; faceI += 3;
} }
} }
@@ -128,11 +128,11 @@ void ObjLoader::allocateObjMemory(FILE *t_file, Frame *o_result)
break; break;
} }
o_result->materials = new ObjMaterial[o_result->materialsCount]; o_result->materials = new MeshMaterial[o_result->materialsCount];
s16 currentMatI = -1; s16 currentMatI = -1;
fseek(t_file, 0, SEEK_SET); fseek(t_file, 0, SEEK_SET);
u32 facesCounter = 0;
while (1) while (1)
{ {
char lineHeader[128]; char lineHeader[128];
@@ -140,20 +140,20 @@ void ObjLoader::allocateObjMemory(FILE *t_file, Frame *o_result)
if (res != EOF) if (res != EOF)
{ {
if (strcmp(lineHeader, "usemtl") == 0) if (strcmp(lineHeader, "usemtl") == 0)
o_result->materials[++currentMatI].facesCount = 0; {
if (currentMatI >= 0) // Skip -1
o_result->materials[currentMatI].setFacesCount(facesCounter);
currentMatI++;
}
else if (strcmp(lineHeader, "f") == 0) else if (strcmp(lineHeader, "f") == 0)
o_result->materials[currentMatI].facesCount += 3; facesCounter += 3;
} }
else else
break; break;
} }
for (u16 i = 0; i < o_result->materialsCount; i++) o_result->materials[currentMatI].setFacesCount(facesCounter); // Allocate last one
{
o_result->materials[i].coordinateFaces = new u32[o_result->materials[i].facesCount];
o_result->materials[i].normalFaces = new u32[o_result->materials[i].facesCount];
o_result->materials[i].verticeFaces = new u32[o_result->materials[i].facesCount];
}
o_result->vertices = new Vector3[o_result->verticesCount]; o_result->vertices = new Vector3[o_result->verticesCount];
o_result->coordinates = new Vector3[o_result->coordinatesCount]; o_result->coordinates = new Vector3[o_result->coordinatesCount];
o_result->normals = new Vector3[o_result->normalsCount]; o_result->normals = new Vector3[o_result->normalsCount];
+6 -3
View File
@@ -33,7 +33,7 @@ Vector3::Vector3(const Vector3 &another)
z = another.z; z = another.z;
} }
void Vector3::setByLerp(const Vector3 &v1, const Vector3 &v2, const float t_interp) void Vector3::setByLerp(const Vector3 &v1, const Vector3 &v2, const float &t_interp, const float &t_scale)
{ {
asm volatile( asm volatile(
"lqc2 vf4, 0x0(%1) \n\t" // vf4 = v1 "lqc2 vf4, 0x0(%1) \n\t" // vf4 = v1
@@ -47,6 +47,9 @@ void Vector3::setByLerp(const Vector3 &v1, const Vector3 &v2, const float t_inte
: :
: "r"(&this->xyz), "r"(&v1.xyz), "r"(&v2.xyz), "f"(t_interp) : "r"(&this->xyz), "r"(&v1.xyz), "r"(&v2.xyz), "f"(t_interp)
: "$8"); : "$8");
x *= t_scale;
y *= t_scale;
z *= t_scale;
} }
/** Create empty vector */ /** Create empty vector */
@@ -245,14 +248,14 @@ float Vector3::innerProduct(Vector3 &v)
// return (x * v.x + y * v.y + z * v.z); // return (x * v.x + y * v.y + z * v.z);
} }
void Vector3::set(float x, float y, float z) void Vector3::set(const float &x, const float &y, const float &z)
{ {
this->x = x; this->x = x;
this->y = y; this->y = y;
this->z = z; this->z = z;
} }
void Vector3::set(Vector3 &v) void Vector3::set(const Vector3 &v)
{ {
this->x = v.x; this->x = v.x;
this->y = v.y; this->y = v.y;
+1 -4
View File
@@ -83,10 +83,7 @@ u32 MD2Model::getCurrentFrameData(VECTOR *o_vertices, VECTOR *o_normals, VECTOR
const u32 NEXT_VERTICE = const u32 NEXT_VERTICE =
triangles[iTri].verticeIndexes[iVert] + triangles[iTri].verticeIndexes[iVert] +
(verticesPerFrameCount * animState.nextFrame); (verticesPerFrameCount * animState.nextFrame);
calcVector.setByLerp(vertices[CURR_VERTICE], vertices[NEXT_VERTICE], animState.interpolation); calc3Vectors[iVert].setByLerp(vertices[CURR_VERTICE], vertices[NEXT_VERTICE], animState.interpolation, t_scale);
calc3Vectors[iVert].x = calcVector.x * t_scale;
calc3Vectors[iVert].y = calcVector.y * t_scale;
calc3Vectors[iVert].z = calcVector.z * t_scale;
} }
} }
if (!t_shouldBeBackfaceCulled || Vector3::shouldBeBackfaceCulled(&t_cameraPos, &calc3Vectors[2], &calc3Vectors[1], &calc3Vectors[0]) == 0) if (!t_shouldBeBackfaceCulled || Vector3::shouldBeBackfaceCulled(&t_cameraPos, &calc3Vectors[2], &calc3Vectors[1], &calc3Vectors[0]) == 0)
+2 -1
View File
@@ -93,6 +93,7 @@ void Mesh::loadObj(char *t_subfolder, char *t_objFile, Vector3 &t_initPos, float
for (u16 i = 0; i < framesAmount; i++) for (u16 i = 0; i < framesAmount; i++)
{ {
// obj->frames[i] = Frame();
char *part3 = String::createU32ToString(i + 1); // 0 -> "1" char *part3 = String::createU32ToString(i + 1); // 0 -> "1"
char *part4 = String::createWithLeadingZeros(part3); // "000001" char *part4 = String::createWithLeadingZeros(part3); // "000001"
char *part5 = String::createConcatenated(part2, part4); // "folder/object_000001" char *part5 = String::createConcatenated(part2, part4); // "folder/object_000001"
@@ -182,7 +183,7 @@ void Mesh::loadTextures(char *t_subfolder, char *t_extension)
spec->textures = new Texture[obj->frames[0].materialsCount]; spec->textures = new Texture[obj->frames[0].materialsCount];
for (u8 i = 0; i < obj->frames[0].materialsCount; i++) for (u8 i = 0; i < obj->frames[0].materialsCount; i++)
{ {
bmpLoader.load(spec->textures[i], t_subfolder, obj->frames[0].materials[i].materialName, t_extension); bmpLoader.load(spec->textures[i], t_subfolder, obj->frames[0].materials[i].getName(), t_extension);
setDefaultWrapSettings(spec->textures[i].wrapSettings); setDefaultWrapSettings(spec->textures[i].wrapSettings);
} }
} }
+24
View File
@@ -0,0 +1,24 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#include "../include/models/mesh_frame.hpp"
#include "../include/utils/debug.hpp"
// ----
// Constructors/Destructors
// ----
MeshFrame::MeshFrame() {}
MeshFrame::~MeshFrame() {}
// ----
// Methods
// ----
+68
View File
@@ -0,0 +1,68 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#include "../include/models/mesh_material.hpp"
#include "../include/utils/debug.hpp"
#include "../include/utils/string.hpp"
// ----
// Constructors/Destructors
// ----
MeshMaterial::MeshMaterial()
{
facesCount = 0;
isNameAllocated = false;
areFacesAllocated = false;
}
MeshMaterial::~MeshMaterial()
{
if (areFacesAllocated)
{
delete[] vertexFaces;
delete[] stFaces;
delete[] normalFaces;
}
if (isNameAllocated)
{
delete[] name;
}
}
// ----
// Methods
// ----
void MeshMaterial::setFacesCount(const u32 &t_val)
{
if (areFacesAllocated)
{
PRINT_ERR("Can't set faces, because faces were already set!");
return;
}
facesCount = t_val;
stFaces = new u32[t_val];
normalFaces = new u32[t_val];
vertexFaces = new u32[t_val];
areFacesAllocated = true;
}
void MeshMaterial::setName(char *t_val)
{
if (isNameAllocated)
{
PRINT_ERR("Can't set name, because was already set!");
return;
}
name = String::createCopy(t_val);
isNameAllocated = true;
}
+30 -39
View File
@@ -56,15 +56,13 @@ u32 ObjModel::getFacesCount()
{ {
u32 result = 0; // TODO u32 result = 0; // TODO
for (u16 i = 0; i < frames[0].materialsCount; i++) for (u16 i = 0; i < frames[0].materialsCount; i++)
result += frames[0].materials[i].facesCount; result += frames[0].materials[i].getFacesCount();
return result; return result;
} }
u32 ObjModel::getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, VECTOR *o_colors, Vector3 &t_cameraPos, float t_scale, u8 t_shouldBeBackfaceCulled) void ObjModel::animate()
{ {
u32 addedFaces = 0; animState.interpolation += animState.speed;
animState.interpolation += animState.speed; // TODO move it out
if (animState.interpolation >= 1.0F) if (animState.interpolation >= 1.0F)
{ {
animState.interpolation = 0.0F; animState.interpolation = 0.0F;
@@ -72,44 +70,42 @@ u32 ObjModel::getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_nor
if (++animState.nextFrame > animState.endFrame) if (++animState.nextFrame > animState.endFrame)
animState.nextFrame = animState.startFrame; animState.nextFrame = animState.startFrame;
} }
}
for (u32 j = 0; j < frames[animState.currentFrame].materials[t_materialIndex].facesCount; j += 3) u32 ObjModel::getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, VECTOR *o_colors, Vector3 &t_cameraPos, float t_scale, u8 t_shouldBeBackfaceCulled)
{
#define CURR_FRAME frames[animState.currentFrame]
#define NEXT_FRAME frames[animState.nextFrame]
#define MATERIAL CURR_FRAME.materials[t_materialIndex]
#define CURR_VERT CURR_FRAME.vertices[MATERIAL.getVertexFace(matI + vertI)]
#define NEXT_VERT NEXT_FRAME.vertices[MATERIAL.getVertexFace(matI + vertI)]
u32 addedFaces = 0;
for (u32 matI = 0; matI < MATERIAL.getFacesCount(); matI += 3)
{ {
for (u32 iVert = 0; iVert < 3; iVert++) for (u32 vertI = 0; vertI < 3; vertI++)
{
const ObjMaterial CURR_MAT = frames[animState.currentFrame].materials[t_materialIndex];
const Vector3 CURR_VERT = frames[animState.currentFrame].vertices[CURR_MAT.verticeFaces[j + iVert]];
if (animState.startFrame == animState.endFrame) if (animState.startFrame == animState.endFrame)
{ calc3Vectors[vertI].set(CURR_VERT * t_scale);
calc3Vectors[iVert].x = CURR_VERT.x * t_scale;
calc3Vectors[iVert].y = CURR_VERT.y * t_scale;
calc3Vectors[iVert].z = CURR_VERT.z * t_scale;
}
else else
calc3Vectors[vertI].setByLerp(CURR_VERT, NEXT_VERT, animState.interpolation, t_scale);
if (!t_shouldBeBackfaceCulled ||
Vector3::shouldBeBackfaceCulled(&t_cameraPos, &calc3Vectors[2], &calc3Vectors[1], &calc3Vectors[0]))
for (u32 vertI = 0; vertI < 3; vertI++)
{ {
const Vector3 NEXT_VERT = frames[animState.nextFrame].vertices[CURR_MAT.verticeFaces[j + iVert]]; o_vertices[addedFaces][0] = calc3Vectors[vertI].x;
calcVector.setByLerp(CURR_VERT, NEXT_VERT, animState.interpolation); o_vertices[addedFaces][1] = calc3Vectors[vertI].y;
calc3Vectors[iVert].x = calcVector.x * t_scale; o_vertices[addedFaces][2] = calc3Vectors[vertI].z;
calc3Vectors[iVert].y = calcVector.y * t_scale;
calc3Vectors[iVert].z = calcVector.z * t_scale;
}
}
if (!t_shouldBeBackfaceCulled || Vector3::shouldBeBackfaceCulled(&t_cameraPos, &calc3Vectors[2], &calc3Vectors[1], &calc3Vectors[0]) == 0)
for (u32 iVert = 0; iVert < 3; iVert++)
{
const u32 CURR_FRAME = animState.currentFrame;
o_vertices[addedFaces][0] = calc3Vectors[iVert].x;
o_vertices[addedFaces][1] = calc3Vectors[iVert].y;
o_vertices[addedFaces][2] = calc3Vectors[iVert].z;
o_vertices[addedFaces][3] = 1.0F; o_vertices[addedFaces][3] = 1.0F;
o_normals[addedFaces][0] = frames[CURR_FRAME].normals[frames[CURR_FRAME].materials[t_materialIndex].normalFaces[j]].x; o_normals[addedFaces][0] = CURR_FRAME.normals[MATERIAL.getNormalFace(matI + vertI)].x;
o_normals[addedFaces][1] = frames[CURR_FRAME].normals[frames[CURR_FRAME].materials[t_materialIndex].normalFaces[j]].y; o_normals[addedFaces][1] = CURR_FRAME.normals[MATERIAL.getNormalFace(matI + vertI)].y;
o_normals[addedFaces][2] = frames[CURR_FRAME].normals[frames[CURR_FRAME].materials[t_materialIndex].normalFaces[j]].z; o_normals[addedFaces][2] = CURR_FRAME.normals[MATERIAL.getNormalFace(matI + vertI)].z;
o_normals[addedFaces][3] = 1.0F; o_normals[addedFaces][3] = 1.0F;
o_coordinates[addedFaces][0] = frames[CURR_FRAME].coordinates[frames[CURR_FRAME].materials[t_materialIndex].coordinateFaces[j]].x; o_coordinates[addedFaces][0] = CURR_FRAME.coordinates[MATERIAL.getStFace(matI + vertI)].x;
o_coordinates[addedFaces][1] = frames[CURR_FRAME].coordinates[frames[CURR_FRAME].materials[t_materialIndex].coordinateFaces[j]].y; o_coordinates[addedFaces][1] = CURR_FRAME.coordinates[MATERIAL.getStFace(matI + vertI)].y;
o_coordinates[addedFaces][2] = 1.0F; o_coordinates[addedFaces][2] = 1.0F;
o_coordinates[addedFaces][3] = 1.0F; o_coordinates[addedFaces][3] = 1.0F;
@@ -118,11 +114,6 @@ u32 ObjModel::getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_nor
o_colors[addedFaces][2] = 1.0F; o_colors[addedFaces][2] = 1.0F;
o_colors[addedFaces++][3] = 1.0F; o_colors[addedFaces++][3] = 1.0F;
} }
// fillNextFace(o_vertices, o_normals, o_coordinates, o_colors, t_materialIndex, j, addedFaces++);
} }
return addedFaces; return addedFaces;
} }
void ObjModel::fillNextFace(VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, VECTOR *o_colors, u32 t_materialI, u32 t_getI, u32 t_setI)
{
}
+3
View File
@@ -181,12 +181,15 @@ void Renderer::draw(Mesh *t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
VECTOR *coordinates = new VECTOR[vertCount]; VECTOR *coordinates = new VECTOR[vertCount];
VECTOR *colors = new VECTOR[vertCount]; VECTOR *colors = new VECTOR[vertCount];
if (t_mesh->isObjLoaded) if (t_mesh->isObjLoaded)
{
t_mesh->obj->animate();
for (u32 i = 0; i < t_mesh->obj->frames[0].materialsCount; i++) for (u32 i = 0; i < t_mesh->obj->frames[0].materialsCount; i++)
{ {
changeTexture(t_mesh, i); changeTexture(t_mesh, i);
vertCount = t_mesh->getDrawData(i, vertices, normals, coordinates, colors, *renderData.cameraPosition); vertCount = t_mesh->getDrawData(i, vertices, normals, coordinates, colors, *renderData.cameraPosition);
vifSender->drawMesh(&renderData, perspective, vertCount, vertices, normals, coordinates, colors, t_mesh, t_bulbs, t_bulbsCount); vifSender->drawMesh(&renderData, perspective, vertCount, vertices, normals, coordinates, colors, t_mesh, t_bulbs, t_bulbsCount);
} }
}
else if (t_mesh->isMd2Loaded) else if (t_mesh->isMd2Loaded)
{ {
changeTexture(t_mesh, 0); changeTexture(t_mesh, 0);
+2
View File
@@ -7,6 +7,8 @@ EE_OBJS = \
../../engine/models/math/vector3.o \ ../../engine/models/math/vector3.o \
../../engine/models/dff_model.o \ ../../engine/models/dff_model.o \
../../engine/models/md2_model.o \ ../../engine/models/md2_model.o \
../../engine/models/mesh_frame.o \
../../engine/models/mesh_material.o \
../../engine/models/mesh.o \ ../../engine/models/mesh.o \
../../engine/models/mesh_spec.o \ ../../engine/models/mesh_spec.o \
../../engine/models/obj_model.o \ ../../engine/models/obj_model.o \
+4
View File
@@ -65,6 +65,8 @@ void calcSpiral(int X, int Y)
} }
// TEST END // TEST END
#include "models/mesh_frame.hpp"
void Ari::onInit() void Ari::onInit()
{ {
player = new Player(); player = new Player();
@@ -91,6 +93,7 @@ void Ari::onInit()
Vector3 testpos = Vector3(0.0F, 10.0F, 0.0F); Vector3 testpos = Vector3(0.0F, 10.0F, 0.0F);
test->loadObj("objanim/", "untitled", testpos, 10.0F, 2); test->loadObj("objanim/", "untitled", testpos, 10.0F, 2);
test->playAnimation(0, 1); test->playAnimation(0, 1);
test->shouldBeBackfaceCulled = true;
// test->shouldBeFrustumCulled = true; // test->shouldBeFrustumCulled = true;
// skybox = new Mesh(); // skybox = new Mesh();
@@ -130,6 +133,7 @@ void Ari::initBulb()
void Ari::onUpdate() void Ari::onUpdate()
{ {
if (engine.pad.isCrossClicked) if (engine.pad.isCrossClicked)
printf("FPS:%f\n", engine.fps); printf("FPS:%f\n", engine.fps);
camera->update(engine.pad, player->mesh); camera->update(engine.pad, player->mesh);