static game #1
This commit is contained in:
@@ -66,8 +66,8 @@ void Engine::setDefaultScreen()
|
||||
void Engine::init(Game *t_game, u32 t_gifPacketSize)
|
||||
{
|
||||
if (!isScreenInitialized)
|
||||
PRINT_ERR("Cant init because screen was not set!");
|
||||
else if (isInitialized)
|
||||
setDefaultScreen();
|
||||
if (isInitialized)
|
||||
PRINT_ERR("Already initialized!");
|
||||
else
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
~GifSender();
|
||||
|
||||
void initPacket(u8 context);
|
||||
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 addObject(RenderData *t_renderData, Mesh &t_mesh, 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);
|
||||
|
||||
@@ -35,22 +35,22 @@ public:
|
||||
prim_t prim;
|
||||
|
||||
/** PATH3 Many + lighting */
|
||||
void drawByPath3(Mesh **t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
void drawByPath3(Mesh *t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
/** PATH3 Single + lighting */
|
||||
void drawByPath3(Mesh *t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
void drawByPath3(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
/** PATH3 Many */
|
||||
void drawByPath3(Mesh **t_meshes, u16 t_amount);
|
||||
void drawByPath3(Mesh *t_meshes, u16 t_amount);
|
||||
/** PATH3 Single */
|
||||
void drawByPath3(Mesh *t_mesh);
|
||||
void drawByPath3(Mesh &t_mesh);
|
||||
|
||||
/** PATH1 Many + lighting */
|
||||
void draw(Mesh **t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
void draw(Mesh *t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
/** PATH1 Single + lighting */
|
||||
void draw(Mesh *t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
void draw(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
/** PATH1 Many */
|
||||
void draw(Mesh **t_meshes, u16 t_amount);
|
||||
void draw(Mesh *t_meshes, u16 t_amount);
|
||||
/** PATH1 Single */
|
||||
void draw(Mesh *t_mesh);
|
||||
void draw(Mesh &t_mesh);
|
||||
|
||||
void setCameraDefinitions(Matrix *t_worldView, Vector3 *t_cameraPos, Plane *t_planes);
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
TextureRepository *getTextureRepository() { return &textureRepo; };
|
||||
|
||||
private:
|
||||
void changeTexture(Mesh *t_mesh, u32 t_materialId);
|
||||
void changeTexture(const Mesh &t_mesh, u32 t_materialId);
|
||||
u32 lastTextureId;
|
||||
texbuffer_t textureBuffer;
|
||||
u8 isTextureVRAMAllocated;
|
||||
|
||||
@@ -28,11 +28,11 @@ public:
|
||||
~VifSender();
|
||||
|
||||
// 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 drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 vertCount2, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, const 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);
|
||||
void drawVertices(const 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;
|
||||
|
||||
@@ -129,7 +129,7 @@ void GifSender::addClear(zbuffer_t *t_zBuffer)
|
||||
* @param objects3D Array of 3D objects pointers
|
||||
* @param amount Amount of 3D objects
|
||||
*/
|
||||
void GifSender::addObject(RenderData *t_renderData, Mesh *t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer)
|
||||
void GifSender::addObject(RenderData *t_renderData, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer)
|
||||
{
|
||||
if (!isAnyObjectAdded)
|
||||
{
|
||||
@@ -140,14 +140,14 @@ void GifSender::addObject(RenderData *t_renderData, Mesh *t_mesh, u32 vertexCoun
|
||||
tempDMATag = q;
|
||||
q++;
|
||||
|
||||
q = draw_texture_sampling(q, 0, &t_mesh->lod);
|
||||
q = draw_texturebuffer(q, 0, textureBuffer, &t_mesh->clut);
|
||||
dw = (u64 *)draw_prim_start(q, 0, t_renderData->prim, &t_mesh->color);
|
||||
q = draw_texture_sampling(q, 0, &t_mesh.lod);
|
||||
q = draw_texturebuffer(q, 0, textureBuffer, &t_mesh.clut);
|
||||
dw = (u64 *)draw_prim_start(q, 0, t_renderData->prim, &t_mesh.color);
|
||||
|
||||
xyz = new xyz_t[vertexCount];
|
||||
rgbaq = new color_t[vertexCount];
|
||||
st = new texel_t[vertexCount];
|
||||
calc3DObject(*t_renderData->perspective, *t_mesh, vertexCount, vertices, normals, coordinates, t_renderData, t_bulbs, t_bulbsCount);
|
||||
calc3DObject(*t_renderData->perspective, t_mesh, vertexCount, vertices, normals, coordinates, t_renderData, t_bulbs, t_bulbsCount);
|
||||
addCurrentCalcs(vertexCount);
|
||||
delete[] xyz;
|
||||
delete[] rgbaq;
|
||||
@@ -205,7 +205,7 @@ void GifSender::calc3DObject(Matrix t_perspective, Mesh &t_mesh, u32 vertexCount
|
||||
colors[i][0] = (t_mesh.color.r * lights[i][0] / 128.0F);
|
||||
colors[i][1] = (t_mesh.color.g * lights[i][1] / 128.0F);
|
||||
colors[i][2] = (t_mesh.color.b * lights[i][2] / 128.0F);
|
||||
vector_clamp(colors[i], colors[i], 0.00f, 1.99f);
|
||||
vector_clamp(colors[i], colors[i], 0.00F, 1.99F);
|
||||
}
|
||||
|
||||
delete[] lightDirections;
|
||||
|
||||
@@ -81,10 +81,10 @@ void Renderer::deallocateTextureBuffer()
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::changeTexture(Mesh *t_mesh, u32 t_materialId)
|
||||
void Renderer::changeTexture(const Mesh &t_mesh, u32 t_materialId)
|
||||
{
|
||||
|
||||
MeshTexture *tex = textureRepo.getByMesh(t_mesh->getId(), t_materialId);
|
||||
MeshTexture *tex = textureRepo.getByMesh(t_mesh.getId(), t_materialId);
|
||||
if (tex != NULL)
|
||||
{
|
||||
if (tex->getId() != lastTextureId)
|
||||
@@ -161,31 +161,31 @@ void Renderer::allocateBuffers(float t_screenW, float t_screenH)
|
||||
/// --- Draw: PATH3
|
||||
|
||||
/** PATH3 Many + lighting */
|
||||
void Renderer::drawByPath3(Mesh **t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||
void Renderer::drawByPath3(Mesh *t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||
{
|
||||
for (u16 i = 0; i < t_amount; i++)
|
||||
drawByPath3(t_meshes[i], t_bulbs, t_bulbsCount);
|
||||
}
|
||||
|
||||
/** PATH3 Single + lighting */
|
||||
void Renderer::drawByPath3(Mesh *t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||
void Renderer::drawByPath3(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||
{
|
||||
beginFrameIfNeeded();
|
||||
if (!t_mesh->isDataLoaded())
|
||||
if (!t_mesh.isDataLoaded())
|
||||
PRINT_ERR("Can't draw, because no mesh data was loaded!");
|
||||
if (t_mesh->getCurrentAnimationFrame() != t_mesh->getNextAnimationFrame())
|
||||
t_mesh->animate();
|
||||
for (u32 i = 0; i < t_mesh->getMaterialsCount(); i++)
|
||||
if (t_mesh.getCurrentAnimationFrame() != t_mesh.getNextAnimationFrame())
|
||||
t_mesh.animate();
|
||||
for (u32 i = 0; i < t_mesh.getMaterialsCount(); i++)
|
||||
{
|
||||
if (t_mesh->shouldBeFrustumCulled && !t_mesh->getMaterial(i).isInFrustum(renderData.frustumPlanes, t_mesh->position))
|
||||
if (t_mesh.shouldBeFrustumCulled && !t_mesh.getMaterial(i).isInFrustum(renderData.frustumPlanes, t_mesh.position))
|
||||
return;
|
||||
changeTexture(t_mesh, t_mesh->getMaterial(i).getId());
|
||||
changeTexture(t_mesh, t_mesh.getMaterial(i).getId());
|
||||
gifSender->initPacket(context);
|
||||
u32 vertCount = t_mesh->getMaterial(i).getFacesCount();
|
||||
u32 vertCount = t_mesh.getMaterial(i).getFacesCount();
|
||||
VECTOR *vertices = new VECTOR[vertCount];
|
||||
VECTOR *normals = new VECTOR[vertCount];
|
||||
VECTOR *coordinates = new VECTOR[vertCount];
|
||||
vertCount = t_mesh->getDrawData(i, vertices, normals, coordinates, *renderData.cameraPosition);
|
||||
vertCount = t_mesh.getDrawData(i, vertices, normals, coordinates, *renderData.cameraPosition);
|
||||
gifSender->addObject(&renderData, t_mesh, vertCount, vertices, normals, coordinates, t_bulbs, t_bulbsCount, &textureBuffer);
|
||||
gifSender->sendPacket();
|
||||
delete[] vertices;
|
||||
@@ -195,40 +195,40 @@ void Renderer::drawByPath3(Mesh *t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||
}
|
||||
|
||||
/** PATH3 Many */
|
||||
void Renderer::drawByPath3(Mesh **t_meshes, u16 t_amount) { drawByPath3(t_meshes, t_amount, NULL, 0); }
|
||||
void Renderer::drawByPath3(Mesh *t_meshes, u16 t_amount) { drawByPath3(t_meshes, t_amount, NULL, 0); }
|
||||
|
||||
/** PATH3 Single */
|
||||
void Renderer::drawByPath3(Mesh *t_mesh) { drawByPath3(t_mesh, NULL, 0); }
|
||||
void Renderer::drawByPath3(Mesh &t_mesh) { drawByPath3(t_mesh, NULL, 0); }
|
||||
|
||||
/// --- Draw: PATH1
|
||||
|
||||
/** PATH1 Many + lighting */
|
||||
void Renderer::draw(Mesh **t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||
void Renderer::draw(Mesh *t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||
{
|
||||
for (u16 i = 0; i < t_amount; i++)
|
||||
draw(t_meshes[i], t_bulbs, t_bulbsCount);
|
||||
}
|
||||
|
||||
/** PATH1 Single + lighting */
|
||||
void Renderer::draw(Mesh *t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||
void Renderer::draw(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||
{
|
||||
beginFrameIfNeeded();
|
||||
vifSender->sendMatrices(renderData, t_mesh->position, t_mesh->rotation);
|
||||
if (!t_mesh->isDataLoaded())
|
||||
vifSender->sendMatrices(renderData, t_mesh.position, t_mesh.rotation);
|
||||
if (!t_mesh.isDataLoaded())
|
||||
PRINT_ERR("Can't draw, because no mesh data was loaded!");
|
||||
|
||||
if (t_mesh->getCurrentAnimationFrame() != t_mesh->getNextAnimationFrame())
|
||||
t_mesh->animate();
|
||||
for (u32 i = 0; i < t_mesh->getMaterialsCount(); i++)
|
||||
if (t_mesh.getCurrentAnimationFrame() != t_mesh.getNextAnimationFrame())
|
||||
t_mesh.animate();
|
||||
for (u32 i = 0; i < t_mesh.getMaterialsCount(); i++)
|
||||
{
|
||||
if (t_mesh->shouldBeFrustumCulled && !t_mesh->getMaterial(i).isInFrustum(renderData.frustumPlanes, t_mesh->position))
|
||||
if (t_mesh.shouldBeFrustumCulled && !t_mesh.getMaterial(i).isInFrustum(renderData.frustumPlanes, t_mesh.position))
|
||||
return;
|
||||
u32 vertCount = t_mesh->getMaterial(i).getFacesCount();
|
||||
u32 vertCount = t_mesh.getMaterial(i).getFacesCount();
|
||||
VECTOR *vertices = new VECTOR[vertCount];
|
||||
VECTOR *normals = new VECTOR[vertCount];
|
||||
VECTOR *coordinates = new VECTOR[vertCount];
|
||||
changeTexture(t_mesh, t_mesh->getMaterial(i).getId());
|
||||
vertCount = t_mesh->getDrawData(i, vertices, normals, coordinates, *renderData.cameraPosition);
|
||||
changeTexture(t_mesh, t_mesh.getMaterial(i).getId());
|
||||
vertCount = t_mesh.getDrawData(i, vertices, normals, coordinates, *renderData.cameraPosition);
|
||||
vifSender->drawMesh(&renderData, perspective, vertCount, vertices, normals, coordinates, t_mesh, t_bulbs, t_bulbsCount, &textureBuffer);
|
||||
delete[] vertices;
|
||||
delete[] normals;
|
||||
@@ -237,10 +237,10 @@ void Renderer::draw(Mesh *t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||
}
|
||||
|
||||
/** PATH1 Many */
|
||||
void Renderer::draw(Mesh **t_objects3D, u16 t_amount) { draw(t_objects3D, t_amount, NULL, 0); }
|
||||
void Renderer::draw(Mesh *t_meshes, u16 t_amount) { draw(t_meshes, t_amount, NULL, 0); }
|
||||
|
||||
/** PATH1 Single */
|
||||
void Renderer::draw(Mesh *t_mesh) { draw(t_mesh, NULL, 0); }
|
||||
void Renderer::draw(Mesh &t_mesh) { draw(t_mesh, NULL, 0); }
|
||||
|
||||
/// ---
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ void VifSender::sendMatrices(const RenderData &t_renderData, const Vector3 &t_po
|
||||
vu1.sendSingleRefList(0, &localScreen, 4);
|
||||
}
|
||||
|
||||
void VifSender::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 VifSender::drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 vertCount2, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, const Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer)
|
||||
{
|
||||
// we have to split 3D object into small parts, because of small memory of VU1
|
||||
for (u32 i = 0; i < vertCount2;)
|
||||
@@ -72,7 +72,7 @@ void VifSender::drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 ver
|
||||
}
|
||||
|
||||
/** Draw using PATH1 */
|
||||
void VifSender::drawVertices(Mesh *t_mesh, u32 t_start, u32 t_end, VECTOR *t_vertices, VECTOR *t_coordinates, prim_t *t_prim, texbuffer_t *textureBuffer)
|
||||
void VifSender::drawVertices(const Mesh &t_mesh, u32 t_start, u32 t_end, VECTOR *t_vertices, VECTOR *t_coordinates, prim_t *t_prim, texbuffer_t *textureBuffer)
|
||||
{
|
||||
const u32 vertCount = t_end - t_start;
|
||||
vu1.addListBeginning();
|
||||
@@ -87,13 +87,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->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)),
|
||||
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
|
||||
@@ -105,11 +105,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->clut.address >> 6,
|
||||
t_mesh->clut.psm,
|
||||
t_mesh->clut.storage_mode,
|
||||
t_mesh->clut.start,
|
||||
t_mesh->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(
|
||||
|
||||
Reference in New Issue
Block a user