removed md2_model

This commit is contained in:
Sandro Sobczyński
2020-11-01 18:13:24 +01:00
parent 200fa3e4d5
commit 138ab762ba
14 changed files with 154 additions and 358 deletions
+3 -2
View File
@@ -11,7 +11,7 @@
#ifndef _TYRA_MD2_LOADER_
#define _TYRA_MD2_LOADER_
#include "../models/md2_model.hpp"
#include "../models/mesh_frame.hpp"
#include <stdio.h>
// magic number "IDP2" or 844121161
@@ -83,7 +83,8 @@ public:
MD2Loader();
~MD2Loader();
void load(MD2Model *o_result, char *t_fileName, float t_scale);
/** Returns frames count */
u32 load(MeshFrame *o_result, char *t_subpath, char *t_nameWithoutExtension, float t_scale, u8 t_invertT);
private:
};
@@ -22,6 +22,10 @@ public:
ObjLoader();
~ObjLoader();
/** Parse .obj file, allocate output data and store it. Multitexture support
* Notice: At this moment textures names are MATERIAL names from .obj file!
* Notice 2: Faces MUST be triangulated (check out blender export settings).
*/
void load(MeshFrame *o_result, char *t_fileName, float t_scale, u8 t_invertT);
private:
-48
View File
@@ -1,48 +0,0 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#ifndef _TYRA_MD2_MODEL_
#define _TYRA_MD2_MODEL_
#include <tamtypes.h>
#include <math3d.h>
#include "math/vector3.hpp"
#include "math/point.hpp"
#include "./anim_state.hpp"
typedef struct
{
u16 verticeIndexes[3];
u16 coordIndexes[3];
} MD2Triangle;
/** Class which have common types for all 3D objects */
class MD2Model
{
public:
u32 verticesPerFrameCount, framesCount, coordinatesCount, trianglesCount;
Vector3 *vertices __attribute__((aligned(16)));
Point *coordinates;
u32 *normalIndexes;
MD2Triangle *triangles;
AnimState animState;
/** File name without extension */
char *filename;
MD2Model(char *t_md2File);
~MD2Model();
u32 getCurrentFrameData(VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, Vector3 &t_cameraPos, float t_scale, u8 t_shouldBeBackfaceCulled);
void allocateMemory();
private:
Vector3 calc3Vectors[3];
};
#endif
+6 -10
View File
@@ -8,18 +8,18 @@
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#ifndef _TYRA_OBJECT3D_
#define _TYRA_OBJECT3D_
#ifndef _TYRA_MESH_
#define _TYRA_MESH_
#include "math/vector3.hpp"
#include "math/plane.hpp"
#include "md2_model.hpp"
#include "./mesh_texture.hpp"
#include "./mesh_frame.hpp"
#include <tamtypes.h>
#include <draw_types.h>
#include <draw_buffers.h>
#include <draw_sampling.h>
#include "./anim_state.hpp"
/** Class which have common types for all 3D objects */
class Mesh
@@ -29,7 +29,6 @@ public:
Vector3 position, rotation;
u8 shouldBeLighted, shouldBeBackfaceCulled, shouldBeFrustumCulled;
MD2Model *md2;
float scale;
color_t color;
@@ -38,14 +37,13 @@ public:
void loadObj(char *t_subfolder, char *t_objFile, Vector3 &t_initPos, float t_scale, u16 t_framesCount, u8 t_invertT);
// void setObj(Vector3 &t_initPos); // TODO
void loadDff(char *t_subfolder, char *t_dffFile, Vector3 &t_initPos, float t_scale);
void loadDff(char *t_subfolder, char *t_dffFile, Vector3 &t_initPos, float t_scale, u8 t_invertT);
// void setDff(Vector3 &t_initPos, DffModel *t_dffModel);
void loadMD2(char *t_subfolder, char *t_md2File, Vector3 &t_initPos, float t_scale);
void loadMD2(char *t_subfolder, char *t_md2File, Vector3 &t_initPos, float t_scale, u8 t_invertT);
void getMinMax(Vector3 *t_min, Vector3 *t_max);
void playAnimation(u32 t_startFrame, u32 t_endFrame);
u32 getVertexCount();
void setAnimSpeed(float t_value);
u32 getDrawData(u32 splitIndex, VECTOR *t_vertices, VECTOR *t_normals, VECTOR *t_coordinates, Vector3 &t_cameraPos);
u8 isInFrustum(Plane *t_frustumPlanes);
u8 isMd2Loaded, isObjLoaded, isSpecInitialized;
@@ -60,7 +58,7 @@ public:
MeshFrame *frames;
AnimState animState;
void animate();
u32 getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, Vector3 &t_cameraPos, float t_scale, u8 t_shouldBeBackfaceCulled);
u32 getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, Vector3 &t_cameraPos);
u32 getFacesCount();
u8 isMemoryAllocated;
@@ -84,9 +82,7 @@ private:
void setDefaultWrapSettings(texwrap_t &t_wrapSettings);
u32 verticesCount;
Vector3 *vertices;
void loadTextures(char *t_subfolder, char *t_extension);
void setVerticesReference(u32 t_verticesCount, Vector3 *t_verticesRef);
void createSpecIfNotCreated();
void setDefaultColor();
void getFarthestVertex(Vector3 *o_result, int t_offset);
};
+16 -1
View File
@@ -15,7 +15,22 @@
#include <math3d.h>
#include <stdio.h>
class Debug
{
public:
static void errTrap(char *t_text, char *t_file)
{
printf("\n");
printf("====================================\n");
printf("| ERROR: %s\n", t_text);
printf("| File : %s\n", t_file);
printf("====================================\n\n");
for (;;)
;
}
};
#define PRINT_LOG(TEXT) printf("LOG: " TEXT " (" __FILE__ ")\n")
#define PRINT_ERR(TEXT) printf("\n====================================\n| ERROR: " TEXT "\n| File : " __FILE__ "\n====================================\n\n")
#define PRINT_ERR(TEXT) Debug::errTrap(TEXT, __FILE__)
#endif