fixing rendering issue on real PS2
This commit is contained in:
@@ -104,7 +104,7 @@ void Engine::gameLoop()
|
|||||||
timer.primeTimer();
|
timer.primeTimer();
|
||||||
renderer->endFrame(fps);
|
renderer->endFrame(fps);
|
||||||
/** -6~ FPS */
|
/** -6~ FPS */
|
||||||
SetAlarm(fps > 49.0F ? 24 : 48, &Engine::wakeup, &mainThreadId);
|
SetAlarm(150, &Engine::wakeup, &mainThreadId);
|
||||||
SleepThread();
|
SleepThread();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public:
|
|||||||
DffLoader();
|
DffLoader();
|
||||||
~DffLoader();
|
~DffLoader();
|
||||||
|
|
||||||
|
// void im_not_used_anywhere(MeshFrame *o_result, char *t_fileName, float t_scale, u8 t_invertT);
|
||||||
void load(MeshFrame *o_result, char *t_fileName, float t_scale, u8 t_invertT);
|
void load(MeshFrame *o_result, char *t_fileName, float t_scale, u8 t_invertT);
|
||||||
void serialize(MeshFrame *o_result, u8 t_invertT, u8 *t_data, float t_scale);
|
void serialize(MeshFrame *o_result, u8 t_invertT, u8 *t_data, float t_scale);
|
||||||
|
|
||||||
|
|||||||
@@ -147,10 +147,8 @@ private:
|
|||||||
_isBoundingBoxCalculated;
|
_isBoundingBoxCalculated;
|
||||||
u32 vertexCount, stsCount, normalsCount, materialsCount;
|
u32 vertexCount, stsCount, normalsCount, materialsCount;
|
||||||
MeshMaterial *materials;
|
MeshMaterial *materials;
|
||||||
Point *sts __attribute__((aligned(16)));
|
Point __attribute__((aligned(16))) * sts;
|
||||||
Vector3
|
Vector3 __attribute__((aligned(16))) * vertices, *normals;
|
||||||
*vertices __attribute__((aligned(16))),
|
|
||||||
*normals __attribute__((aligned(16)));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,10 +32,12 @@ BmpLoader::~BmpLoader() {}
|
|||||||
*/
|
*/
|
||||||
void BmpLoader::load(MeshTexture &o_texture, char *t_subfolder, char *t_name, char *t_extension)
|
void BmpLoader::load(MeshTexture &o_texture, char *t_subfolder, char *t_name, char *t_extension)
|
||||||
{
|
{
|
||||||
char *t_path_part = String::createConcatenated(t_subfolder, t_name);
|
char *path_part1 = String::createConcatenated(t_subfolder, t_name);
|
||||||
char *t_path = String::createConcatenated(t_path_part, t_extension);
|
char *path_part2 = String::createConcatenated("host:", path_part1);
|
||||||
delete[] t_path_part;
|
char *path = String::createConcatenated(path_part2, t_extension);
|
||||||
FILE *file = fopen(t_path, "rb");
|
delete[] path_part1;
|
||||||
|
delete[] path_part2;
|
||||||
|
FILE *file = fopen(path, "rb");
|
||||||
|
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
@@ -46,8 +48,8 @@ void BmpLoader::load(MeshTexture &o_texture, char *t_subfolder, char *t_name, ch
|
|||||||
unsigned char header[54];
|
unsigned char header[54];
|
||||||
fread(header, sizeof(unsigned char), 54, file);
|
fread(header, sizeof(unsigned char), 54, file);
|
||||||
|
|
||||||
u32 width = *(u32 *)&header[18];
|
u32 width = (u32)header[18];
|
||||||
u32 height = *(u32 *)&header[22];
|
u32 height = (u32)header[22];
|
||||||
o_texture.setSize(width, height);
|
o_texture.setSize(width, height);
|
||||||
printf("BMPLoader - width: %d | height: %d\n", width, height);
|
printf("BMPLoader - width: %d | height: %d\n", width, height);
|
||||||
if (width > 128 || height > 128)
|
if (width > 128 || height > 128)
|
||||||
@@ -55,27 +57,21 @@ void BmpLoader::load(MeshTexture &o_texture, char *t_subfolder, char *t_name, ch
|
|||||||
|
|
||||||
u64 rowPadded = (width * 3 + 3) & (~3);
|
u64 rowPadded = (width * 3 + 3) & (~3);
|
||||||
|
|
||||||
unsigned char *data = new unsigned char[rowPadded];
|
unsigned char row[rowPadded];
|
||||||
unsigned char tmp;
|
|
||||||
|
|
||||||
u32 x = 0;
|
u32 x = 0;
|
||||||
for (u32 i = 0; i < height; i++)
|
for (u32 i = 0; i < height; i++)
|
||||||
{
|
{
|
||||||
fread(data, sizeof(unsigned char), rowPadded, file);
|
fread(&row, sizeof(unsigned char), rowPadded, file);
|
||||||
for (u32 j = 0; j < width * 3; j += 3)
|
for (u32 j = 0; j < width * 3; j += 3)
|
||||||
{
|
{
|
||||||
// Convert (B, G, R) to (R, G, B)
|
// Convert (B, G, R) to (R, G, B)
|
||||||
tmp = data[j];
|
o_texture.setData(x, row[j + 2]);
|
||||||
data[j] = data[j + 2];
|
o_texture.setData(x + 1, row[j + 1]);
|
||||||
data[j + 2] = tmp;
|
o_texture.setData(x + 2, row[j]);
|
||||||
|
|
||||||
o_texture.setData(x, data[j]);
|
|
||||||
o_texture.setData(x + 1, data[j + 1]);
|
|
||||||
o_texture.setData(x + 2, data[j + 2]);
|
|
||||||
x += 3;
|
x += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete[] t_path;
|
delete[] path;
|
||||||
delete[] data;
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ DffLoader::~DffLoader() {}
|
|||||||
void DffLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT)
|
void DffLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Loading dff file");
|
PRINT_LOG("Loading dff file");
|
||||||
FILE *file = fopen(t_filename, "rb");
|
char *path = String::createConcatenated("host:", t_filename);
|
||||||
|
FILE *file = fopen(path, "rb");
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
PRINT_ERR("Failed to load .dff file!");
|
PRINT_ERR("Failed to load .dff file!");
|
||||||
fseek(file, 0L, SEEK_END);
|
fseek(file, 0L, SEEK_END);
|
||||||
@@ -48,9 +49,29 @@ void DffLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
serialize(o_result, t_invertT, data, t_scale);
|
serialize(o_result, t_invertT, data, t_scale);
|
||||||
o_result->calculateBoundingBoxes();
|
o_result->calculateBoundingBoxes();
|
||||||
|
delete[] path;
|
||||||
PRINT_LOG("Dff file loaded!");
|
PRINT_LOG("Dff file loaded!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void DffLoader::im_not_used_anywhere(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT)
|
||||||
|
// {
|
||||||
|
// PRINT_LOG("Loading dff file");
|
||||||
|
// char *path = String::createConcatenated("host:", t_filename);
|
||||||
|
// FILE *file = fopen(path, "rb");
|
||||||
|
// if (file == NULL)
|
||||||
|
// PRINT_ERR("Failed to load .dff file!");
|
||||||
|
// fseek(file, 0L, SEEK_END);
|
||||||
|
// long fileSize = ftell(file);
|
||||||
|
// u8 data[fileSize];
|
||||||
|
// rewind(file);
|
||||||
|
// fread(&data, sizeof(u8), fileSize, file);
|
||||||
|
// fclose(file);
|
||||||
|
// serialize(o_result, t_invertT, data, t_scale);
|
||||||
|
// o_result->calculateBoundingBoxes();
|
||||||
|
// delete[] path;
|
||||||
|
// PRINT_LOG("Dff file loaded!");
|
||||||
|
// }
|
||||||
|
|
||||||
void DffLoader::serialize(MeshFrame *o_result, u8 t_invertT, u8 *t_data, float t_scale)
|
void DffLoader::serialize(MeshFrame *o_result, u8 t_invertT, u8 *t_data, float t_scale)
|
||||||
{
|
{
|
||||||
u32 ptrPos = 0;
|
u32 ptrPos = 0;
|
||||||
|
|||||||
@@ -46,8 +46,10 @@ MeshFrame *MD2Loader::load(u32 &o_framesCount, char *t_subpath, char *t_nameWith
|
|||||||
{
|
{
|
||||||
PRINT_LOG("Loading new MD2 file");
|
PRINT_LOG("Loading new MD2 file");
|
||||||
char *part1 = String::createConcatenated(t_subpath, t_nameWithoutExtension);
|
char *part1 = String::createConcatenated(t_subpath, t_nameWithoutExtension);
|
||||||
char *finalPath = String::createConcatenated(part1, ".md2"); // "folder/object.md2"
|
char *part2 = String::createConcatenated("host:", part1);
|
||||||
|
char *finalPath = String::createConcatenated(part2, ".md2"); // "folder/object.md2"
|
||||||
delete[] part1;
|
delete[] part1;
|
||||||
|
delete[] part2;
|
||||||
md2_t header;
|
md2_t header;
|
||||||
|
|
||||||
FILE *file = fopen(finalPath, "rb");
|
FILE *file = fopen(finalPath, "rb");
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ ObjLoader::~ObjLoader() {}
|
|||||||
|
|
||||||
void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT)
|
void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT)
|
||||||
{
|
{
|
||||||
FILE *file = fopen(t_filename, "rb");
|
char *path = String::createConcatenated("host:", t_filename);
|
||||||
|
FILE *file = fopen(path, "rb");
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
PRINT_ERR("Failed to load .obj file!");
|
PRINT_ERR("Failed to load .obj file!");
|
||||||
allocateObjMemory(file, o_result);
|
allocateObjMemory(file, o_result);
|
||||||
@@ -98,6 +99,7 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
|
|||||||
}
|
}
|
||||||
o_result->calculateBoundingBoxes();
|
o_result->calculateBoundingBoxes();
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
delete[] path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Calculate how many vertices(v), coordinates(vt), normals(vn) and faces(f) have .obj file */
|
/** Calculate how many vertices(v), coordinates(vt), normals(vn) and faces(f) have .obj file */
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "../include/utils/math.hpp"
|
#include "../include/utils/math.hpp"
|
||||||
#include "../include/utils/debug.hpp"
|
#include "../include/utils/debug.hpp"
|
||||||
#include "../include/modules/light.hpp"
|
#include "../include/modules/light.hpp"
|
||||||
|
#include <kernel.h>
|
||||||
#include <dma.h>
|
#include <dma.h>
|
||||||
#include <draw.h>
|
#include <draw.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -61,6 +62,7 @@ void GifSender::sendTexture(MeshTexture &texture, texbuffer_t *t_texBuffer)
|
|||||||
q++;
|
q++;
|
||||||
q = draw_texture_wrapping(q, 0, texture.getWrapSettings());
|
q = draw_texture_wrapping(q, 0, texture.getWrapSettings());
|
||||||
q = draw_texture_flush(q);
|
q = draw_texture_flush(q);
|
||||||
|
FlushCache(0);
|
||||||
dma_channel_send_chain(DMA_CHANNEL_GIF, packet->data, q - packet->data, 0, 0);
|
dma_channel_send_chain(DMA_CHANNEL_GIF, packet->data, q - packet->data, 0, 0);
|
||||||
dma_wait_fast();
|
dma_wait_fast();
|
||||||
packet_free(packet);
|
packet_free(packet);
|
||||||
@@ -79,6 +81,7 @@ void GifSender::sendClear(zbuffer_t *t_zBuffer)
|
|||||||
q = draw_enable_tests(q, 0, t_zBuffer);
|
q = draw_enable_tests(q, 0, t_zBuffer);
|
||||||
q = draw_finish(q);
|
q = draw_finish(q);
|
||||||
DMATAG_END(packet->data, q - packet->data - 1, 0, 0, 0);
|
DMATAG_END(packet->data, q - packet->data - 1, 0, 0, 0);
|
||||||
|
FlushCache(0);
|
||||||
dma_channel_send_chain(DMA_CHANNEL_GIF, packet->data, q - packet->data, 0, 0);
|
dma_channel_send_chain(DMA_CHANNEL_GIF, packet->data, q - packet->data, 0, 0);
|
||||||
dma_wait_fast();
|
dma_wait_fast();
|
||||||
packet_free(packet);
|
packet_free(packet);
|
||||||
@@ -108,8 +111,9 @@ void GifSender::sendPacket()
|
|||||||
}
|
}
|
||||||
q = draw_finish(q);
|
q = draw_finish(q);
|
||||||
DMATAG_END(dmatag, q - dmatag - 1, 0, 0, 0);
|
DMATAG_END(dmatag, q - dmatag - 1, 0, 0, 0);
|
||||||
dma_wait_fast();
|
FlushCache(0);
|
||||||
dma_channel_send_chain(DMA_CHANNEL_GIF, currentPacket->data, q - currentPacket->data, 0, 0);
|
dma_channel_send_chain(DMA_CHANNEL_GIF, currentPacket->data, q - currentPacket->data, 0, 0);
|
||||||
|
dma_wait_fast();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds clear screen to current packet */
|
/** Adds clear screen to current packet */
|
||||||
|
|||||||
@@ -222,15 +222,12 @@ void Renderer::draw(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
|
|||||||
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;
|
return;
|
||||||
u32 vertCount = t_mesh.getMaterial(i).getFacesCount();
|
u32 vertCount = t_mesh.getMaterial(i).getFacesCount();
|
||||||
VECTOR *vertices = new VECTOR[vertCount];
|
VECTOR __attribute__((aligned(16))) vertices[vertCount];
|
||||||
VECTOR *normals = new VECTOR[vertCount];
|
VECTOR __attribute__((aligned(16))) normals[vertCount];
|
||||||
VECTOR *coordinates = new VECTOR[vertCount];
|
VECTOR __attribute__((aligned(16))) coordinates[vertCount];
|
||||||
changeTexture(t_mesh, t_mesh.getMaterial(i).getId());
|
changeTexture(t_mesh, t_mesh.getMaterial(i).getId());
|
||||||
vertCount = t_mesh.getDrawData(i, vertices, normals, coordinates, rotatedCamera);
|
vertCount = t_mesh.getDrawData(i, vertices, normals, coordinates, rotatedCamera);
|
||||||
vifSender->drawMesh(&renderData, perspective, vertCount, vertices, normals, coordinates, t_mesh, t_bulbs, t_bulbsCount, &textureBuffer);
|
vifSender->drawMesh(&renderData, perspective, vertCount, vertices, normals, coordinates, t_mesh, t_bulbs, t_bulbsCount, &textureBuffer);
|
||||||
delete[] vertices;
|
|
||||||
delete[] normals;
|
|
||||||
delete[] coordinates;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void VifSender::sendMatrices(const RenderData &t_renderData, const Vector3 &t_po
|
|||||||
vec3ToNative(rotation, t_rotation, 1.0F);
|
vec3ToNative(rotation, t_rotation, 1.0F);
|
||||||
create_local_world(localWorld, position, rotation);
|
create_local_world(localWorld, position, rotation);
|
||||||
create_local_screen(localScreen, localWorld, t_renderData.worldView->data, t_renderData.perspective->data);
|
create_local_screen(localScreen, localWorld, t_renderData.worldView->data, t_renderData.perspective->data);
|
||||||
vu1.sendSingleRefList(0, &localScreen, 4);
|
vu1.sendSingleRefList(0, &localScreen, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
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)
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ void VU1::addReferenceList(u32 t_offset, void *t_data, u32 t_size, u8 t_useTops)
|
|||||||
*((u64 *)currentBuffer)++ = DMA_REF_TAG((u32)t_data, t_size);
|
*((u64 *)currentBuffer)++ = DMA_REF_TAG((u32)t_data, t_size);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_STCYL, 0, 0x0101);
|
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_STCYL, 0, 0x0101);
|
||||||
*((u32 *)currentBuffer)++ =
|
*((u32 *)currentBuffer)++ =
|
||||||
AddUnpack(V4_32, t_useTops == 1 ? buildList.dmaSize / 16 : t_offset / 16, t_size, t_useTops);
|
AddUnpack(V4_32, t_useTops == 1 ? buildList.dmaSize >> 4 : t_offset >> 4, t_size, t_useTops);
|
||||||
buildList.dmaSize += t_size * 8;
|
buildList.dmaSize += t_size * 8;
|
||||||
buildList.dmaSizeAll += buildList.dmaSize;
|
buildList.dmaSizeAll += buildList.dmaSize;
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ void VU1::addReferenceList(u32 t_offset, void *t_data, u32 t_size, u8 t_useTops)
|
|||||||
/** Start VU1 program */
|
/** Start VU1 program */
|
||||||
void VU1::addStartProgram()
|
void VU1::addStartProgram()
|
||||||
{
|
{
|
||||||
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(8 >> 4);
|
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(0);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_MSCAL, 0, 0);
|
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_MSCAL, 0, 0);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
|
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
|
||||||
;
|
;
|
||||||
@@ -144,7 +144,7 @@ void VU1::addStartProgram()
|
|||||||
/** Continue VU1 program from "--cont" line */
|
/** Continue VU1 program from "--cont" line */
|
||||||
void VU1::addContinueProgram()
|
void VU1::addContinueProgram()
|
||||||
{
|
{
|
||||||
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(8 >> 4);
|
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(0);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_MSCAL, 0, 0);
|
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_MSCAL, 0, 0);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
|
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
|
||||||
;
|
;
|
||||||
@@ -156,8 +156,9 @@ void VU1::sendList()
|
|||||||
*((u64 *)currentBuffer)++ = DMA_END_TAG(0);
|
*((u64 *)currentBuffer)++ = DMA_END_TAG(0);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_NOP, 0, 0);
|
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_NOP, 0, 0);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_NOP, 0, 0);
|
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_NOP, 0, 0);
|
||||||
dma_channel_wait(DMA_CHANNEL_VIF1, VU1_DMA_CHAN_TIMEOUT);
|
FlushCache(0);
|
||||||
dma_channel_send_chain(DMA_CHANNEL_VIF1, buildList.kickBuffer, (u32 *)currentBuffer - (u32 *)buildList.kickBuffer, DMA_FLAG_TRANSFERTAG, 0);
|
dma_channel_send_chain(DMA_CHANNEL_VIF1, buildList.kickBuffer, (u32 *)currentBuffer - (u32 *)buildList.kickBuffer, DMA_FLAG_TRANSFERTAG, 0);
|
||||||
|
dma_channel_wait(DMA_CHANNEL_VIF1, VU1_DMA_CHAN_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VU1::addDoubleBufferSetting()
|
void VU1::addDoubleBufferSetting()
|
||||||
|
|||||||
@@ -52,5 +52,14 @@ all: $(EE_BIN)
|
|||||||
clean:
|
clean:
|
||||||
rm -f $(EE_OBJS)
|
rm -f $(EE_OBJS)
|
||||||
|
|
||||||
|
run: $(EE_BIN)
|
||||||
|
killall -v ps2client || true
|
||||||
|
ps2client reset
|
||||||
|
ps2client reset
|
||||||
|
$(EE_STRIP) --strip-all $(EE_BIN)
|
||||||
|
mv $(EE_BIN) bin/$(EE_BIN)
|
||||||
|
rm $(EE_OBJS)
|
||||||
|
cd bin/ && ps2client execee host:$(EE_BIN)
|
||||||
|
|
||||||
include $(PS2SDK)/samples/Makefile.pref
|
include $(PS2SDK)/samples/Makefile.pref
|
||||||
include $(PS2SDK)/samples/Makefile.eeglobal
|
include $(PS2SDK)/samples/Makefile.eeglobal
|
||||||
|
|||||||
+31
-29
@@ -32,12 +32,10 @@ Ari::~Ari() {}
|
|||||||
|
|
||||||
void Ari::onInit()
|
void Ari::onInit()
|
||||||
{
|
{
|
||||||
|
|
||||||
engine->renderer->setCameraDefinitions(&camera.worldView, &camera.position, camera.planes);
|
engine->renderer->setCameraDefinitions(&camera.worldView, &camera.position, camera.planes);
|
||||||
engine->audio.init(0);
|
engine->audio.init(0);
|
||||||
engine->audio.setVolume(40);
|
engine->audio.setVolume(40);
|
||||||
engine->audio.loadSong("MOV-CIRC.WAV");
|
engine->audio.loadSong("MOV-CIRC.WAV");
|
||||||
engine->audio.play();
|
|
||||||
|
|
||||||
texRepo = engine->renderer->getTextureRepository();
|
texRepo = engine->renderer->getTextureRepository();
|
||||||
|
|
||||||
@@ -52,31 +50,35 @@ void Ari::onInit()
|
|||||||
islandAddons.rotation.x = -1.6F;
|
islandAddons.rotation.x = -1.6F;
|
||||||
islandAddons.position.set(0.0F, 10.0F, 20.0F);
|
islandAddons.position.set(0.0F, 10.0F, 20.0F);
|
||||||
|
|
||||||
skybox.loadObj("skybox/", "skybox", 100.0F, false);
|
// skybox.loadObj("skybox/", "skybox", 100.0F, false);
|
||||||
skybox.shouldBeFrustumCulled = false;
|
// skybox.shouldBeFrustumCulled = false;
|
||||||
|
|
||||||
waterFloors[0].loadObj("water/", "water", 5.0F, false);
|
// waterFloors[0].loadObj("water/", "water", 5.0F, false);
|
||||||
waterFloors[0].position.set(0.0F, 8.0F, 0.0F);
|
// waterFloors[0].position.set(0.0F, 8.0F, 0.0F);
|
||||||
texRepo->addByMesh("water/", waterFloors[0]);
|
// texRepo->addByMesh("water/", waterFloors[0]);
|
||||||
for (u8 i = 0; i < WATER_TILES_COUNT; i++)
|
// for (u8 i = 0; i < WATER_TILES_COUNT; i++)
|
||||||
{
|
// {
|
||||||
spirals[i].x = 1.0F;
|
// spirals[i].x = 1.0F;
|
||||||
spirals[i].y = 2.0F;
|
// spirals[i].y = 2.0F;
|
||||||
}
|
// }
|
||||||
u32 spiralOffset = (u32)Math::sqrt(WATER_TILES_COUNT);
|
// u32 spiralOffset = (u32)Math::sqrt(WATER_TILES_COUNT);
|
||||||
calcSpiral(spiralOffset, spiralOffset);
|
// calcSpiral(spiralOffset, spiralOffset);
|
||||||
for (u8 i = 1; i < WATER_TILES_COUNT; i++)
|
// for (u8 i = 1; i < WATER_TILES_COUNT; i++)
|
||||||
{
|
// {
|
||||||
waterFloors[i].loadFrom(waterFloors[0]);
|
// waterFloors[i].loadFrom(waterFloors[0]);
|
||||||
waterFloors[i].position.set(10.0F * spirals[i].x, 8.0F, 10.0F * spirals[i].y);
|
// waterFloors[i].position.set(10.0F * spirals[i].x, 8.0F, 10.0F * spirals[i].y);
|
||||||
texRepo->getByMesh(waterFloors[0].getId(), waterFloors[0].getMaterial(0).getId())
|
// texRepo->getByMesh(waterFloors[0].getId(), waterFloors[0].getMaterial(0).getId())
|
||||||
->addLink(waterFloors[i].getId(), waterFloors[i].getMaterial(0).getId());
|
// ->addLink(waterFloors[i].getId(), waterFloors[i].getMaterial(0).getId());
|
||||||
}
|
// }
|
||||||
|
|
||||||
texRepo->addByMesh("sunnyisl/", island);
|
texRepo->addByMesh("sunnyisl/", island);
|
||||||
texRepo->addByMesh("sunnyisl/", islandAddons);
|
// texRepo->addByMesh("sunnyisl/", islandAddons);
|
||||||
texRepo->addByMesh("skybox/", skybox);
|
|
||||||
texRepo->addByMesh("ari/", player.mesh);
|
// texRepo->addByMesh("skybox/", skybox);
|
||||||
|
|
||||||
|
// texRepo->addByMesh("ari/", player.mesh);
|
||||||
|
|
||||||
|
// engine->audio.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ari::initBulb()
|
void Ari::initBulb()
|
||||||
@@ -90,12 +92,12 @@ void Ari::onUpdate()
|
|||||||
if (engine->pad.isCrossClicked)
|
if (engine->pad.isCrossClicked)
|
||||||
printf("FPS:%f\n", engine->fps);
|
printf("FPS:%f\n", engine->fps);
|
||||||
camera.update(engine->pad, player.mesh);
|
camera.update(engine->pad, player.mesh);
|
||||||
engine->renderer->draw(skybox);
|
// engine->renderer->draw(skybox);
|
||||||
engine->renderer->draw(island);
|
engine->renderer->draw(island);
|
||||||
engine->renderer->draw(islandAddons);
|
// engine->renderer->draw(islandAddons);
|
||||||
engine->renderer->draw(player.mesh);
|
// engine->renderer->draw(player.mesh);
|
||||||
for (u8 i = 0; i < WATER_TILES_COUNT; i++)
|
// for (u8 i = 0; i < WATER_TILES_COUNT; i++)
|
||||||
engine->renderer->draw(waterFloors[i]);
|
// engine->renderer->draw(waterFloors[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ari::calcSpiral(int X, int Y)
|
void Ari::calcSpiral(int X, int Y)
|
||||||
|
|||||||
@@ -22,16 +22,16 @@
|
|||||||
|
|
||||||
Player::Player()
|
Player::Player()
|
||||||
{
|
{
|
||||||
PRINT_LOG("Creating player object");
|
// PRINT_LOG("Creating player object");
|
||||||
this->gravity = 0.1F;
|
// this->gravity = 0.1F;
|
||||||
this->lift = -1.0F;
|
// this->lift = -1.0F;
|
||||||
this->mesh.loadMD2("ari/", "ari", 0.0001F, true);
|
// this->mesh.loadMD2("ari/", "ari", 0.0001F, true);
|
||||||
this->mesh.position.set(0.0F, 10.0F, 0.0F);
|
// this->mesh.position.set(0.0F, 10.0F, 0.0F);
|
||||||
this->mesh.shouldBeBackfaceCulled = true;
|
// this->mesh.shouldBeBackfaceCulled = true;
|
||||||
this->mesh.shouldBeFrustumCulled = false;
|
// this->mesh.shouldBeFrustumCulled = false;
|
||||||
this->mesh.shouldBeLighted = true;
|
// this->mesh.shouldBeLighted = true;
|
||||||
this->mesh.setAnimSpeed(0.05F);
|
// this->mesh.setAnimSpeed(0.05F);
|
||||||
this->mesh.playAnimation(0, 1);
|
// this->mesh.playAnimation(0, 1);
|
||||||
PRINT_LOG("Player object created!");
|
PRINT_LOG("Player object created!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user