removed mesh_spec
This commit is contained in:
@@ -13,12 +13,14 @@
|
||||
|
||||
#include "math/vector3.hpp"
|
||||
#include "math/plane.hpp"
|
||||
#include "mesh_spec.hpp"
|
||||
#include "obj_model.hpp"
|
||||
#include "dff_model.hpp"
|
||||
#include "md2_model.hpp"
|
||||
#include "./mesh_texture.hpp"
|
||||
#include <tamtypes.h>
|
||||
#include <draw_types.h>
|
||||
#include <draw_buffers.h>
|
||||
#include <draw_sampling.h>
|
||||
|
||||
/** Class which have common types for all 3D objects */
|
||||
class Mesh
|
||||
@@ -28,7 +30,6 @@ public:
|
||||
Vector3 position, rotation;
|
||||
u8 shouldBeLighted, shouldBeBackfaceCulled, shouldBeFrustumCulled;
|
||||
|
||||
MeshSpec *spec;
|
||||
MD2Model *md2;
|
||||
ObjModel *obj;
|
||||
DffModel *dff;
|
||||
@@ -40,9 +41,9 @@ public:
|
||||
~Mesh();
|
||||
|
||||
void loadObj(char *t_subfolder, char *t_objFile, Vector3 &t_initPos, float t_scale, u16 framesAmount);
|
||||
void setObj(Vector3 &t_initPos, ObjModel *t_objModel, MeshSpec *t_spec);
|
||||
void setObj(Vector3 &t_initPos, ObjModel *t_objModel);
|
||||
void loadDff(char *t_subfolder, char *t_dffFile, Vector3 &t_initPos, float t_scale);
|
||||
void setDff(Vector3 &t_initPos, DffModel *t_dffModel, MeshSpec *t_spec);
|
||||
void setDff(Vector3 &t_initPos, DffModel *t_dffModel);
|
||||
void loadMD2(char *t_subfolder, char *t_md2File, Vector3 &t_initPos, float t_scale);
|
||||
void getMinMax(Vector3 *t_min, Vector3 *t_max);
|
||||
void playAnimation(u32 t_startFrame, u32 t_endFrame);
|
||||
@@ -52,8 +53,12 @@ public:
|
||||
u8 isInFrustum(Plane *t_frustumPlanes);
|
||||
|
||||
u8 isMd2Loaded, isObjLoaded, isDffLoaded, isSpecInitialized;
|
||||
clutbuffer_t clut;
|
||||
lod_t lod;
|
||||
MeshTexture *textures;
|
||||
|
||||
private:
|
||||
void setupLodAndClut();
|
||||
void setDefaultWrapSettings(texwrap_t &t_wrapSettings);
|
||||
u32 verticesCount;
|
||||
Vector3 *vertices;
|
||||
|
||||
@@ -1,38 +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_OBJECT3D_SPEC_
|
||||
#define _TYRA_OBJECT3D_SPEC_
|
||||
|
||||
#include "math/vector3.hpp"
|
||||
#include "./mesh_texture.hpp"
|
||||
#include <tamtypes.h>
|
||||
#include <draw_buffers.h>
|
||||
#include <draw_sampling.h>
|
||||
|
||||
/** Class which contain 3D object specification */
|
||||
class MeshSpec
|
||||
{
|
||||
|
||||
public:
|
||||
clutbuffer_t clut;
|
||||
lod_t lod;
|
||||
|
||||
MeshSpec();
|
||||
~MeshSpec();
|
||||
|
||||
void allocateMemory();
|
||||
void setupLodAndClut();
|
||||
MeshTexture *textures;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,16 +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_TEXTURE_
|
||||
#define _TYRA_TEXTURE_
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
+27
-15
@@ -65,10 +65,9 @@ void Mesh::loadDff(char *t_subfolder, char *t_dffFile, Vector3 &t_initPos, float
|
||||
loadTextures(t_subfolder, ".bmp");
|
||||
}
|
||||
|
||||
void Mesh::setDff(Vector3 &t_initPos, DffModel *t_dffModel, MeshSpec *t_spec)
|
||||
void Mesh::setDff(Vector3 &t_initPos, DffModel *t_dffModel)
|
||||
{
|
||||
position = t_initPos;
|
||||
spec = t_spec;
|
||||
isSpecInitialized = 1;
|
||||
dff = t_dffModel;
|
||||
setVerticesReference(
|
||||
@@ -114,10 +113,9 @@ void Mesh::loadObj(char *t_subfolder, char *t_objFile, Vector3 &t_initPos, float
|
||||
loadTextures(t_subfolder, ".bmp");
|
||||
}
|
||||
|
||||
void Mesh::setObj(Vector3 &t_initPos, ObjModel *t_objModel, MeshSpec *t_spec)
|
||||
void Mesh::setObj(Vector3 &t_initPos, ObjModel *t_objModel)
|
||||
{
|
||||
position = t_initPos;
|
||||
spec = t_spec;
|
||||
isSpecInitialized = true;
|
||||
obj = t_objModel;
|
||||
setVerticesReference(obj->getFacesCount(), obj->frames[0].getVertices());
|
||||
@@ -127,11 +125,6 @@ void Mesh::setObj(Vector3 &t_initPos, ObjModel *t_objModel, MeshSpec *t_spec)
|
||||
|
||||
void Mesh::createSpecIfNotCreated()
|
||||
{
|
||||
if (!isSpecInitialized)
|
||||
{
|
||||
isSpecInitialized = true;
|
||||
spec = new MeshSpec();
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::setAnimSpeed(float t_value)
|
||||
@@ -179,26 +172,26 @@ void Mesh::loadTextures(char *t_subfolder, char *t_extension)
|
||||
BmpLoader bmpLoader = BmpLoader();
|
||||
if (isObjLoaded)
|
||||
{
|
||||
spec->textures = new MeshTexture[obj->frames[0].getMaterialsCount()];
|
||||
textures = new MeshTexture[obj->frames[0].getMaterialsCount()];
|
||||
for (u8 i = 0; i < obj->frames[0].getMaterialsCount(); i++)
|
||||
{
|
||||
bmpLoader.load(spec->textures[i], t_subfolder, obj->frames[0].getMaterial(i).getName(), t_extension);
|
||||
bmpLoader.load(textures[i], t_subfolder, obj->frames[0].getMaterial(i).getName(), t_extension);
|
||||
// setDefaultWrapSettings(spec->textures[i].wrapSettings);
|
||||
}
|
||||
}
|
||||
else if (isMd2Loaded)
|
||||
{
|
||||
spec->textures = new MeshTexture[1];
|
||||
bmpLoader.load(spec->textures[0], t_subfolder, md2->filename, t_extension);
|
||||
textures = new MeshTexture[1];
|
||||
bmpLoader.load(textures[0], t_subfolder, md2->filename, t_extension);
|
||||
// setDefaultWrapSettings(spec->textures[0].wrapSettings);
|
||||
}
|
||||
else if (isDffLoaded)
|
||||
{
|
||||
spec->textures = new MeshTexture[dff->clump.geometryList.geometries[0].materialList.data.materialCount];
|
||||
textures = new MeshTexture[dff->clump.geometryList.geometries[0].materialList.data.materialCount];
|
||||
for (u8 i = 0; i < dff->clump.geometryList.geometries[0].materialList.data.materialCount; i++)
|
||||
for (u8 j = 0; j < dff->clump.geometryList.geometries[0].materialList.materials[i].data.textureCount; j++)
|
||||
{
|
||||
bmpLoader.load(spec->textures[i], t_subfolder, dff->clump.geometryList.geometries[0].materialList.materials[i].textures[j].textureName.text, t_extension);
|
||||
bmpLoader.load(textures[i], t_subfolder, dff->clump.geometryList.geometries[0].materialList.materials[i].textures[j].textureName.text, t_extension);
|
||||
// setDefaultWrapSettings(spec->textures[i].wrapSettings);
|
||||
}
|
||||
}
|
||||
@@ -303,6 +296,25 @@ void Mesh::getFarthestVertex(Vector3 *o_result, int t_offset)
|
||||
o_result->z = boxVertices[t_offset].z + position.z;
|
||||
}
|
||||
|
||||
/** Sets texture level of details settings and CLUT settings */
|
||||
void Mesh::setupLodAndClut()
|
||||
{
|
||||
PRINT_LOG("Setting LOD, CLUT");
|
||||
lod.calculation = LOD_USE_K;
|
||||
lod.max_level = 0;
|
||||
lod.mag_filter = LOD_MAG_NEAREST;
|
||||
lod.min_filter = LOD_MIN_NEAREST;
|
||||
lod.l = 0;
|
||||
lod.k = 0.0F;
|
||||
|
||||
clut.storage_mode = CLUT_STORAGE_MODE1;
|
||||
clut.start = 0;
|
||||
clut.psm = 0;
|
||||
clut.load_method = CLUT_NO_LOAD;
|
||||
clut.address = 0;
|
||||
PRINT_LOG("LOD, CLUT set!");
|
||||
}
|
||||
|
||||
/** Check if box is visible in view frustum */
|
||||
u8 Mesh::isInFrustum(Plane *t_frustumPlanes)
|
||||
{
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# 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_spec.hpp"
|
||||
|
||||
#include "../include/utils/debug.hpp"
|
||||
#include "../include/utils/math.hpp"
|
||||
#include <graph_vram.h>
|
||||
#include <gs_psm.h>
|
||||
|
||||
// ----
|
||||
// Constructors/Destructors
|
||||
// ----
|
||||
|
||||
MeshSpec::MeshSpec()
|
||||
{
|
||||
PRINT_LOG("Creating object 3D spec");
|
||||
this->setupLodAndClut();
|
||||
PRINT_LOG("Object 3D spec created!");
|
||||
}
|
||||
|
||||
/** Release memory if object was initialized */
|
||||
MeshSpec::~MeshSpec()
|
||||
{
|
||||
}
|
||||
|
||||
// ----
|
||||
// Methods
|
||||
// ----
|
||||
|
||||
/** Sets texture level of details settings and CLUT settings */
|
||||
void MeshSpec::setupLodAndClut()
|
||||
{
|
||||
PRINT_LOG("Setting LOD, CLUT");
|
||||
this->lod.calculation = LOD_USE_K;
|
||||
this->lod.max_level = 0;
|
||||
this->lod.mag_filter = LOD_MAG_NEAREST;
|
||||
this->lod.min_filter = LOD_MIN_NEAREST;
|
||||
this->lod.l = 0;
|
||||
this->lod.k = 0.0F;
|
||||
|
||||
this->clut.storage_mode = CLUT_STORAGE_MODE1;
|
||||
this->clut.start = 0;
|
||||
this->clut.psm = 0;
|
||||
this->clut.load_method = CLUT_NO_LOAD;
|
||||
this->clut.address = 0;
|
||||
PRINT_LOG("LOD, CLUT set!");
|
||||
}
|
||||
@@ -140,8 +140,8 @@ void GifSender::addObjects(RenderData *t_renderData, Mesh **t_objects3D, u32 t_a
|
||||
tempDMATag = q;
|
||||
q++;
|
||||
|
||||
q = draw_texture_sampling(q, 0, &t_objects3D[0]->spec->lod);
|
||||
q = draw_texturebuffer(q, 0, textureBuffer, &t_objects3D[0]->spec->clut);
|
||||
q = draw_texture_sampling(q, 0, &t_objects3D[0]->lod);
|
||||
q = draw_texturebuffer(q, 0, textureBuffer, &t_objects3D[0]->clut);
|
||||
dw = (u64 *)draw_prim_start(q, 0, t_renderData->prim, &t_objects3D[0]->color);
|
||||
|
||||
for (u32 i = 0; i < t_amount; i++)
|
||||
|
||||
@@ -115,12 +115,12 @@ void Renderer::deallocateTextureBuffer()
|
||||
|
||||
void Renderer::changeTexture(Mesh *t_mesh, u8 t_textureIndex)
|
||||
{
|
||||
if (t_mesh->spec->textures[t_textureIndex].getId() != lastTextureId)
|
||||
if (t_mesh->textures[t_textureIndex].getId() != lastTextureId)
|
||||
{
|
||||
lastTextureId = t_mesh->spec->textures[t_textureIndex].getId();
|
||||
lastTextureId = t_mesh->textures[t_textureIndex].getId();
|
||||
deallocateTextureBuffer();
|
||||
allocateTextureBuffer(t_mesh->spec->textures[t_textureIndex].getWidth(), t_mesh->spec->textures[t_textureIndex].getHeight());
|
||||
GifSender::sendTexture(t_mesh->spec->textures[t_textureIndex], &textureBuffer);
|
||||
allocateTextureBuffer(t_mesh->textures[t_textureIndex].getWidth(), t_mesh->textures[t_textureIndex].getHeight());
|
||||
GifSender::sendTexture(t_mesh->textures[t_textureIndex], &textureBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,13 +89,13 @@ void VifSender::drawVertices(Mesh *t_mesh, u32 t_start, u32 t_end, VECTOR *t_ver
|
||||
|
||||
vu1.add128( // tex -> lod
|
||||
GS_SET_TEX1(
|
||||
t_mesh->spec->lod.calculation,
|
||||
t_mesh->spec->lod.max_level,
|
||||
t_mesh->spec->lod.mag_filter,
|
||||
t_mesh->spec->lod.min_filter,
|
||||
t_mesh->spec->lod.mipmap_select,
|
||||
t_mesh->spec->lod.l,
|
||||
(int)(t_mesh->spec->lod.k * 16.0F)),
|
||||
t_mesh->lod.calculation,
|
||||
t_mesh->lod.max_level,
|
||||
t_mesh->lod.mag_filter,
|
||||
t_mesh->lod.min_filter,
|
||||
t_mesh->lod.mipmap_select,
|
||||
t_mesh->lod.l,
|
||||
(int)(t_mesh->lod.k * 16.0F)),
|
||||
GS_REG_TEX1);
|
||||
|
||||
vu1.add128( // tex -> buff + clut
|
||||
@@ -107,11 +107,11 @@ void VifSender::drawVertices(Mesh *t_mesh, u32 t_start, u32 t_end, VECTOR *t_ver
|
||||
textureBuffer->info.height,
|
||||
textureBuffer->info.components,
|
||||
textureBuffer->info.function,
|
||||
t_mesh->spec->clut.address >> 6,
|
||||
t_mesh->spec->clut.psm,
|
||||
t_mesh->spec->clut.storage_mode,
|
||||
t_mesh->spec->clut.start,
|
||||
t_mesh->spec->clut.load_method),
|
||||
t_mesh->clut.address >> 6,
|
||||
t_mesh->clut.psm,
|
||||
t_mesh->clut.storage_mode,
|
||||
t_mesh->clut.start,
|
||||
t_mesh->clut.load_method),
|
||||
GS_REG_TEX0);
|
||||
|
||||
vu1.add128(
|
||||
|
||||
@@ -10,7 +10,6 @@ EE_OBJS = \
|
||||
../../engine/models/mesh_frame.o \
|
||||
../../engine/models/mesh_material.o \
|
||||
../../engine/models/mesh.o \
|
||||
../../engine/models/mesh_spec.o \
|
||||
../../engine/models/mesh_texture.o \
|
||||
../../engine/models/obj_model.o \
|
||||
../../engine/modules/audio.o \
|
||||
|
||||
@@ -37,7 +37,6 @@ Player::Player()
|
||||
|
||||
Player::~Player()
|
||||
{
|
||||
delete[] this->spec;
|
||||
}
|
||||
|
||||
// ----
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
#include "../camera.hpp"
|
||||
#include <modules/pad.hpp>
|
||||
#include <models/mesh_spec.hpp>
|
||||
#include <tamtypes.h>
|
||||
|
||||
/** Player 3D object class */
|
||||
@@ -24,7 +23,6 @@ public:
|
||||
float gravity, velocity, lift;
|
||||
u8 isOnFloor, isCollideFloor, indexOfCurrentFloor;
|
||||
Mesh mesh;
|
||||
MeshSpec *spec;
|
||||
Player();
|
||||
~Player();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user