draw refactoring #1
This commit is contained in:
@@ -48,10 +48,10 @@ public:
|
||||
u8 isOnSquare(Vector3 &t_min, Vector3 &t_max);
|
||||
float length();
|
||||
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);
|
||||
void set(Vector3 &v);
|
||||
void set(float x, float y, float z);
|
||||
void set(const Vector3 &v);
|
||||
void set(const float &x, const float &y, const float &z);
|
||||
void copy(Vector3 &v);
|
||||
float distanceTo(Vector3 &v);
|
||||
void print();
|
||||
|
||||
@@ -42,7 +42,6 @@ public:
|
||||
void allocateMemory();
|
||||
|
||||
private:
|
||||
Vector3 calcVector;
|
||||
Vector3 calc3Vectors[3];
|
||||
};
|
||||
|
||||
|
||||
@@ -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,13 +14,21 @@
|
||||
#include <tamtypes.h>
|
||||
#include <math3d.h>
|
||||
#include "math/vector3.hpp"
|
||||
#include "utils/debug.hpp"
|
||||
#include "./anim_state.hpp"
|
||||
#include "./mesh_material.hpp"
|
||||
|
||||
struct ObjMaterial
|
||||
class Frame2
|
||||
{
|
||||
char *materialName;
|
||||
u32 facesCount;
|
||||
u32 *verticeFaces, *coordinateFaces, *normalFaces;
|
||||
public:
|
||||
Frame2() { printf("Frame2 constructor\n"); };
|
||||
~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
|
||||
@@ -30,7 +38,7 @@ struct Frame
|
||||
Vector3 *vertices __attribute__((aligned(16))),
|
||||
*coordinates __attribute__((aligned(16))),
|
||||
*normals __attribute__((aligned(16)));
|
||||
ObjMaterial *materials;
|
||||
MeshMaterial *materials;
|
||||
};
|
||||
|
||||
/** Class which have common types for all 3D objects */
|
||||
@@ -46,14 +54,13 @@ public:
|
||||
|
||||
ObjModel(char *t_objFile);
|
||||
~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 getFacesCount();
|
||||
u8 isMemoryAllocated;
|
||||
|
||||
private:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user