fixed floors sample

This commit is contained in:
Sandro Sobczyński
2020-11-03 16:44:39 +01:00
parent 5aa2a9bdb5
commit b75b2d6e4f
30 changed files with 331 additions and 224 deletions
+8 -5
View File
@@ -79,11 +79,14 @@ public:
*/
MeshMaterial *getMaterialById(const u32 &t_id) const { return frames[0].getMaterialById(t_id); }
/** Returns bounding box vertex at given index with added mesh position.
* @param o_result Result
* @param offset 0-7. Because, bounding box have 8 corners
/**
* Returns bounding vertex of current frame.
* @param i 0-7. Because, bounding box have 8 corners
*/
void getCurrentBoundingBoxVertex(Vector3 &o_result, const u32 &t_index);
Vector3 &getCurrentBoundingBoxVertex(const u8 &i) { return frames[animState.currentFrame].getBoundingBoxVertex(i); };
/** Returns bounding box of current frame. Size: 8 */
Vector3 *getCurrentBoundingBox() const { return frames[animState.currentFrame].getBoundingBox(); };
// ----
// Setters
@@ -171,7 +174,7 @@ public:
*/
const u8 &isStayAnimationSet() const { return animState.isStayFrameSet; };
/** Check if mesh is visible in view frustum */
/** True when mesh is in view frustum */
u8 isInFrustum(Plane *t_frustumPlanes);
/**
+9 -3
View File
@@ -75,11 +75,17 @@ public:
/** Array of materials. Size of getMaterialsCount() */
MeshMaterial *getMaterials() const { return materials; };
/**
* Returns bounding box (AABB).
* Total length: 8
*/
Vector3 *getBoundingBox() { return boundingBox; };
/**
* Returns bounding box (AABB) vertex.
* Total length: 8
*/
Vector3 &getBoundingBox(const u8 &i) { return boundingBox[i]; };
Vector3 &getBoundingBoxVertex(const u8 &i) { return boundingBox[i]; };
// ----
// Setters
@@ -126,11 +132,11 @@ public:
void allocateMaterials(const u32 &t_val);
/**
* Calculates bounding box (AABB).
* Calculates bounding box (AABB) for frame and for materiaals.
* Should be called by data loader,
* so there is no need to run it again.
*/
void calculateBoundingBox();
void calculateBoundingBoxes();
private:
Vector3 boundingBox[8];
+26 -1
View File
@@ -12,6 +12,8 @@
#define _TYRA_MESH_MATERIAL_
#include <tamtypes.h>
#include "./math/vector3.hpp"
#include "./math/plane.hpp"
/** Class which contains draw instructions for part mesh of mesh.
* Mesh can have many materials.
@@ -58,6 +60,18 @@ public:
/** Array of normal vector faces. Size of getFacesCount() */
u32 *getNormalFaces() const { return normalFaces; };
/**
* Returns bounding box (AABB).
* Total length: 8
*/
Vector3 *getBoundingBox() { return boundingBox; };
/**
* Returns bounding box (AABB) vertex.
* Total length: 8
*/
Vector3 &getBoundingBoxVertex(const u8 &i) { return boundingBox[i]; };
// ----
// Setters
// ----
@@ -93,10 +107,21 @@ public:
/** Set faces count and allocate memory. */
void allocateFaces(const u32 &t_val);
/**
* Do not call this method unless you know what you do.
* Calculates bounding box (AABB).
* Called automatically in mesh frame class on data loading.
*/
void calculateBoundingBox(Vector3 *t_vertices, u32 t_vertCount);
/** True when mesh is in view frustum */
u8 isInFrustum(Plane *t_frustumPlanes, const Vector3 &position);
private:
Vector3 boundingBox[8];
u32 facesCount, id;
u32 *vertexFaces, *stFaces, *normalFaces;
u8 _isNameSet, _areFacesAllocated;
u8 _isNameSet, _areFacesAllocated, _isBoundingBoxCalculated;
char *name;
};
+2 -2
View File
@@ -33,7 +33,7 @@ public:
~GifSender();
void initPacket(u8 context);
void addObjects(RenderData *t_renderData, Mesh **t_objects3D, u32 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer);
void addObject(RenderData *t_renderData, Mesh *t_objects3D, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer);
void addClear(zbuffer_t *t_zBuffer);
void sendPacket();
void sendClear(zbuffer_t *t_zBuffer);
@@ -54,7 +54,7 @@ private:
float halfScreenW, halfScreenH;
MATRIX localWorld, localScreen, localLight;
u32 calc3DObject(Matrix t_perspective, Mesh &t_mesh, RenderData *t_renderData, LightBulb *t_bulbs, u16 t_bulbsCount);
void calc3DObject(Matrix t_perspective, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, RenderData *t_renderData, LightBulb *t_bulbs, u16 t_bulbsCount);
void convertCalcs(u32 t_vertCount, VECTOR *t_vertices, VECTOR *t_colors, VECTOR *t_sts, color_t &t_color);
void addCurrentCalcs(u32 &t_vertexCount);
};
@@ -80,13 +80,16 @@ public:
// ----
/** Add unlinked texture.
* NOTICE: BMP (RGB 888 24bit, without color information) is suppored only!
* @param t_subfolder Relative path. Ex.: "textures/"
* @param t_name Filename without extension. Ex.: "water"
*
*/
MeshTexture *add(char *t_subfolder, char *t_name);
/**
* Add linked textures in given subpath for mesh material names.
* NOTICE: BMP (RGB 888 24bit, without color information) is suppored only!
* @param t_path Relative path where textures should be searched
*/
void addByMesh(char *t_path, Mesh &mesh);
+2 -2
View File
@@ -29,14 +29,14 @@ public:
// TODO refactor
void drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 vertCount2, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, Mesh *t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer);
void sendMatrices(const RenderData &t_renderData, const Vector3 &t_position, const Vector3 &t_rotation);
private:
void drawVertices(Mesh *t_mesh, u32 t_start, u32 t_end, VECTOR *t_vertices, VECTOR *t_coordinates, prim_t *t_prim, texbuffer_t *textureBuffer);
VU1 vu1; // TODO
MATRIX localWorld, localScreen;
VECTOR position, rotation;
u32 vertCount;
VU1 vu1;
};
#endif
+1 -1
View File
@@ -18,7 +18,7 @@
class Vector3; // Forward definition
void manyVec3ToNative(VECTOR *t_result, Vector3 *t_vec, int t_amount, float t_fourthVal);
void vec3ToNative(VECTOR t_result, Vector3 &t_vec, float t_fourthVal);
void vec3ToNative(VECTOR t_result, const Vector3 &t_vec, float t_fourthVal);
class Math
{