Fix a bug on model conversion

This commit is contained in:
Lucas S. Vieira 2024-09-21 18:18:20 -03:00
parent 8f86855a4d
commit 9960219f82
4 changed files with 17 additions and 8 deletions

Binary file not shown.

View file

@ -188,6 +188,7 @@ render_model(Model *m)
case TYPE_F3: {
OBJF3 *info = (OBJF3 *)op->info;
POLY_F3 *poly = (POLY_F3 *)get_next_prim();
setPolyF3(poly);
nclip = RotAverageNclip3(
&m->vertices[info->iv0],
&m->vertices[info->iv1],
@ -199,7 +200,6 @@ render_model(Model *m)
if((nclip < 0) || (otz < 0) || (otz >= OT_LENGTH))
continue;
setPolyF3(poly);
setRGB0(poly, info->r0, info->g0, info->b0);
sort_prim(poly, otz);
increment_prim(sizeof(POLY_F3));
@ -207,6 +207,7 @@ render_model(Model *m)
case TYPE_G3: {
OBJG3 *info = (OBJG3 *)op->info;
POLY_G3 *poly = (POLY_G3 *)get_next_prim();
setPolyG3(poly);
nclip = RotAverageNclip3(
&m->vertices[info->iv0],
&m->vertices[info->iv1],
@ -218,7 +219,6 @@ render_model(Model *m)
if((nclip < 0) || (otz < 0) || (otz >= OT_LENGTH))
continue;
setPolyG3(poly);
setRGB0(poly, info->r0, info->g0, info->b0);
setRGB1(poly, info->r1, info->g1, info->b1);
setRGB2(poly, info->r2, info->g2, info->b2);
@ -228,6 +228,7 @@ render_model(Model *m)
case TYPE_F4: {
OBJF4 *info = (OBJF4 *)op->info;
POLY_F4 *poly = (POLY_F4 *)get_next_prim();
setPolyF4(poly);
nclip = RotAverageNclip4(
&m->vertices[info->iv0],
&m->vertices[info->iv1],
@ -241,7 +242,6 @@ render_model(Model *m)
if((nclip < 0) || (otz < 0) || (otz >= OT_LENGTH))
continue;
setPolyF4(poly);
setRGB0(poly, info->r0, info->g0, info->b0);
sort_prim(poly, otz);
increment_prim(sizeof(POLY_F4));
@ -249,6 +249,7 @@ render_model(Model *m)
case TYPE_G4: {
OBJG4 *info = (OBJG4 *)op->info;
POLY_G4 *poly = (POLY_G4 *)get_next_prim();
setPolyG4(poly);
nclip = RotAverageNclip4(
&m->vertices[info->iv0],
&m->vertices[info->iv1],
@ -262,7 +263,6 @@ render_model(Model *m)
if((nclip < 0) || (otz < 0) || (otz >= OT_LENGTH))
continue;
setPolyG4(poly);
setRGB0(poly, info->r0, info->g0, info->b0);
setRGB1(poly, info->r1, info->g1, info->b1);
setRGB2(poly, info->r2, info->g2, info->b2);

View file

@ -54,11 +54,11 @@ screen_modeltest_update(void *d)
}
if(pad_pressing(PAD_RIGHT)) {
data->ring->rot.vz += 10;
data->ring->rot.vz -= 30;
}
if(pad_pressing(PAD_LEFT)) {
data->ring->rot.vz -= 10;
data->ring->rot.vz += 30;
}
if(pad_pressing(PAD_TRIANGLE)) {
@ -72,6 +72,10 @@ screen_modeltest_update(void *d)
data->ring->scl.vy -= 10;
data->ring->scl.vz -= 10;
}
if(pad_pressed(PAD_SELECT)) {
scene_change(SCREEN_TITLE);
}
}
void

View file

@ -88,7 +88,7 @@ def _parse_face(buffer: str) -> Face:
v.in0 = c_ushort(int(buffer[5]))
v.in1 = c_ushort(int(buffer[6]))
v.in2 = c_ushort(int(buffer[7]))
v.iv3 = c_ushort(int(buffer[8]))
v.in3 = c_ushort(int(buffer[8]))
return v
elif ftype == FaceType.LINE:
v = LineFace()
@ -150,7 +150,12 @@ def parse_ply(filename: str) -> PlyData:
elif step == 1:
if vertices > 0:
values = buffer.split()
values = [tofixed12(float(x)) for x in values]
# print(f"Buffered values: {values}")
values = [float(x) for x in values]
# print(f"Float values: {values}")
values = [tofixed12(x) for x in values]
# print(f"Fixed values: {values}")
# print("---------------")
vertex = VECTOR()
vertex.vx = c_int(values[0])
vertex.vy = c_int(values[1])