Inverted sky
This commit is contained in:
parent
b4527edbcc
commit
b5f0f9119d
2
haloo3d
2
haloo3d
@ -1 +1 @@
|
|||||||
Subproject commit d19e5e7fbd3b1024c178f0c1c575ecb16625ffcb
|
Subproject commit cca7ec456909732e051a00aef5319dd452955299
|
12
scene.c
12
scene.c
@ -73,10 +73,12 @@ int main(int argc, char **argv) {
|
|||||||
haloo3d_fb textures[NUMOBJECTS];
|
haloo3d_fb textures[NUMOBJECTS];
|
||||||
haloo3d_obj_loadfile(models, argv[1]);
|
haloo3d_obj_loadfile(models, argv[1]);
|
||||||
haloo3d_img_loadppmfile(textures, argv[2]);
|
haloo3d_img_loadppmfile(textures, argv[2]);
|
||||||
haloo3d_gen_1pxgradient(textures + 1, 0xF44F, 0xF001, 32);
|
haloo3d_fb_init_tex(textures + 1, 32, 32);
|
||||||
|
haloo3d_apply_vgradient(textures + 1, 0xF001, 0xF44F);
|
||||||
haloo3d_gen_skybox(models + 1);
|
haloo3d_gen_skybox(models + 1);
|
||||||
uint16_t checkcols[2] = {0xF0A0, 0xF270};
|
uint16_t checkcols[2] = {0xF0A0, 0xF270};
|
||||||
haloo3d_gen_checkerboard(textures + 2, checkcols, 2, 32);
|
haloo3d_fb_init_tex(textures + 2, 32, 32);
|
||||||
|
haloo3d_apply_alternating(textures + 2, checkcols, 2);
|
||||||
haloo3d_gen_sloped(models + 2, PLANESIZE, 1.0, 1.25);
|
haloo3d_gen_sloped(models + 2, PLANESIZE, 1.0, 1.25);
|
||||||
haloo3d_fb_init_tex(textures + 3, 8, 8);
|
haloo3d_fb_init_tex(textures + 3, 8, 8);
|
||||||
memcpy(textures[3].buffer, redflower, sizeof(uint16_t) * 64);
|
memcpy(textures[3].buffer, redflower, sizeof(uint16_t) * 64);
|
||||||
@ -111,7 +113,7 @@ int main(int argc, char **argv) {
|
|||||||
} else { // Setup the flowers
|
} else { // Setup the flowers
|
||||||
haloo3d_objin_init(objects + i, models + FLOWERIND, textures + FLOWERIND);
|
haloo3d_objin_init(objects + i, models + FLOWERIND, textures + FLOWERIND);
|
||||||
objects[i].cullbackface = 0;
|
objects[i].cullbackface = 0;
|
||||||
objects[i].scale = 0.5;
|
vec3(objects[i].scale.v, 0.5, 0.5, 0.5);
|
||||||
int rvi = rand() % models[2].numvertices;
|
int rvi = rand() % models[2].numvertices;
|
||||||
vec3_assign(objects[i].pos.v, models[2].vertices[rvi].v);
|
vec3_assign(objects[i].pos.v, models[2].vertices[rvi].v);
|
||||||
objects[i].pos.y += 0.5;
|
objects[i].pos.y += 0.5;
|
||||||
@ -124,7 +126,7 @@ int main(int argc, char **argv) {
|
|||||||
objects[2].lighting = &light;
|
objects[2].lighting = &light;
|
||||||
#endif
|
#endif
|
||||||
objects[0].pos.y = 1;
|
objects[0].pos.y = 1;
|
||||||
objects[1].scale = SKYSCALE;
|
vec3(objects[1].scale.v, SKYSCALE, SKYSCALE, SKYSCALE);
|
||||||
|
|
||||||
// Now we create a framebuffer to draw the triangle into
|
// Now we create a framebuffer to draw the triangle into
|
||||||
haloo3d_fb fb;
|
haloo3d_fb fb;
|
||||||
@ -205,7 +207,7 @@ int main(int argc, char **argv) {
|
|||||||
// Setup final model matrix and the precalced vertices
|
// Setup final model matrix and the precalced vertices
|
||||||
vec3_add(tmp1.v, objects[i].pos.v, objects[i].lookvec.v);
|
vec3_add(tmp1.v, objects[i].pos.v, objects[i].lookvec.v);
|
||||||
haloo3d_my_lookat(matrixmodel, objects[i].pos.v, tmp1.v, camera.up.v);
|
haloo3d_my_lookat(matrixmodel, objects[i].pos.v, tmp1.v, camera.up.v);
|
||||||
haloo3d_mat4_scale(matrixmodel, objects[i].scale);
|
haloo3d_mat4_scalev(matrixmodel, objects[i].scale.v);
|
||||||
mat4_multiply(matrix3d, matrixscreen, matrixmodel);
|
mat4_multiply(matrix3d, matrixscreen, matrixmodel);
|
||||||
haloo3d_precalc_verts(objects[i].model, matrix3d, vert_precalc);
|
haloo3d_precalc_verts(objects[i].model, matrix3d, vert_precalc);
|
||||||
rendersettings.texture = objects[i].texture;
|
rendersettings.texture = objects[i].texture;
|
||||||
|
@ -71,10 +71,12 @@ int main(int argc, char **argv) {
|
|||||||
haloo3d_fb textures[NUMOBJECTS];
|
haloo3d_fb textures[NUMOBJECTS];
|
||||||
haloo3d_obj_loadfile(models, argv[1]);
|
haloo3d_obj_loadfile(models, argv[1]);
|
||||||
haloo3d_img_loadppmfile(textures, argv[2]);
|
haloo3d_img_loadppmfile(textures, argv[2]);
|
||||||
haloo3d_gen_1pxgradient(textures + 1, 0xF44F, 0xF001, 32);
|
haloo3d_fb_init_tex(textures + 1, 32, 32);
|
||||||
|
haloo3d_apply_vgradient(textures + 1, 0xF001, 0xF44F);
|
||||||
haloo3d_gen_skybox(models + 1);
|
haloo3d_gen_skybox(models + 1);
|
||||||
uint16_t checkcols[2] = {0xF0A0, 0xF270};
|
uint16_t checkcols[2] = {0xF0A0, 0xF270};
|
||||||
haloo3d_gen_checkerboard(textures + 2, checkcols, 2, 32);
|
haloo3d_fb_init_tex(textures + 2, 32, 32);
|
||||||
|
haloo3d_apply_alternating(textures + 2, checkcols, 2);
|
||||||
haloo3d_gen_sloped(models + 2, PLANESIZE, 1.0, 1.25);
|
haloo3d_gen_sloped(models + 2, PLANESIZE, 1.0, 1.25);
|
||||||
haloo3d_fb_init_tex(textures + 3, 8, 8);
|
haloo3d_fb_init_tex(textures + 3, 8, 8);
|
||||||
memcpy(textures[3].buffer, redflower, sizeof(uint16_t) * 64);
|
memcpy(textures[3].buffer, redflower, sizeof(uint16_t) * 64);
|
||||||
@ -112,7 +114,7 @@ int main(int argc, char **argv) {
|
|||||||
} else { // Setup the flowers
|
} else { // Setup the flowers
|
||||||
haloo3d_objin_init(objects + i, models + FLOWERIND, textures + FLOWERIND);
|
haloo3d_objin_init(objects + i, models + FLOWERIND, textures + FLOWERIND);
|
||||||
objects[i].cullbackface = 0;
|
objects[i].cullbackface = 0;
|
||||||
objects[i].scale = 0.5;
|
vec3(objects[i].scale.v, 0.5, 0.5, 0.5);
|
||||||
int rvi = rand() % models[2].numvertices;
|
int rvi = rand() % models[2].numvertices;
|
||||||
vec3_assign(objects[i].pos.v, models[2].vertices[rvi].v);
|
vec3_assign(objects[i].pos.v, models[2].vertices[rvi].v);
|
||||||
objects[i].pos.y += 0.5;
|
objects[i].pos.y += 0.5;
|
||||||
@ -125,7 +127,7 @@ int main(int argc, char **argv) {
|
|||||||
objects[2].lighting = &light;
|
objects[2].lighting = &light;
|
||||||
#endif
|
#endif
|
||||||
objects[0].pos.y = 1;
|
objects[0].pos.y = 1;
|
||||||
objects[1].scale = SKYSCALE;
|
vec3(objects[1].scale.v, SKYSCALE, SKYSCALE, SKYSCALE);
|
||||||
|
|
||||||
// Now we create a framebuffer to draw the triangle into
|
// Now we create a framebuffer to draw the triangle into
|
||||||
haloo3d_fb fb;
|
haloo3d_fb fb;
|
||||||
@ -158,6 +160,9 @@ int main(int argc, char **argv) {
|
|||||||
float msperframe = 1000.0 / TARGETFPS;
|
float msperframe = 1000.0 / TARGETFPS;
|
||||||
int totaldrawn = 0;
|
int totaldrawn = 0;
|
||||||
|
|
||||||
|
haloo3d_trirender rendersettings;
|
||||||
|
haloo3d_trirender_init(&rendersettings);
|
||||||
|
|
||||||
eprintf("Scene has %d tris, %d verts\n", totalfaces, totalverts);
|
eprintf("Scene has %d tris, %d verts\n", totalfaces, totalverts);
|
||||||
|
|
||||||
// Init unigi system
|
// Init unigi system
|
||||||
@ -192,7 +197,7 @@ int main(int argc, char **argv) {
|
|||||||
case unigi_enum_event_input_mouse_move:
|
case unigi_enum_event_input_mouse_move:
|
||||||
camera.yaw += ROTSPEED * event.data.input_mouse_move.rel_x;
|
camera.yaw += ROTSPEED * event.data.input_mouse_move.rel_x;
|
||||||
camera.pitch += ROTSPEED * event.data.input_mouse_move.rel_y;
|
camera.pitch += ROTSPEED * event.data.input_mouse_move.rel_y;
|
||||||
CLAMP(camera.pitch, LOOKLOCK, MPI - LOOKLOCK);
|
camera.pitch = CLAMP(camera.pitch, LOOKLOCK, MPI - LOOKLOCK);
|
||||||
break;
|
break;
|
||||||
case unigi_enum_event_input_mouse_button:
|
case unigi_enum_event_input_mouse_button:
|
||||||
mouseheld[event.data.input_mouse_button.button] =
|
mouseheld[event.data.input_mouse_button.button] =
|
||||||
@ -233,7 +238,7 @@ int main(int argc, char **argv) {
|
|||||||
// Setup final model matrix and the precalced vertices
|
// Setup final model matrix and the precalced vertices
|
||||||
vec3_add(tmp1.v, objects[i].pos.v, objects[i].lookvec.v);
|
vec3_add(tmp1.v, objects[i].pos.v, objects[i].lookvec.v);
|
||||||
haloo3d_my_lookat(matrixmodel, objects[i].pos.v, tmp1.v, camera.up.v);
|
haloo3d_my_lookat(matrixmodel, objects[i].pos.v, tmp1.v, camera.up.v);
|
||||||
haloo3d_mat4_scale(matrixmodel, objects[i].scale);
|
haloo3d_mat4_scalev(matrixmodel, objects[i].scale.v);
|
||||||
mat4_multiply(matrix3d, matrixscreen, matrixmodel);
|
mat4_multiply(matrix3d, matrixscreen, matrixmodel);
|
||||||
haloo3d_precalc_verts(objects[i].model, matrix3d, vert_precalc);
|
haloo3d_precalc_verts(objects[i].model, matrix3d, vert_precalc);
|
||||||
// Iterate over object faces
|
// Iterate over object faces
|
||||||
@ -242,22 +247,23 @@ int main(int argc, char **argv) {
|
|||||||
haloo3d_make_facef(objects[i].model->faces[fi], vert_precalc,
|
haloo3d_make_facef(objects[i].model->faces[fi], vert_precalc,
|
||||||
objects[i].model->vtexture, face);
|
objects[i].model->vtexture, face);
|
||||||
int tris = haloo3d_facef_clip(face, outfaces);
|
int tris = haloo3d_facef_clip(face, outfaces);
|
||||||
|
rendersettings.texture = objects[i].texture;
|
||||||
for (int ti = 0; ti < tris; ti++) {
|
for (int ti = 0; ti < tris; ti++) {
|
||||||
int backface = !haloo3d_facef_finalize(outfaces[ti]);
|
int backface = !haloo3d_facef_finalize(outfaces[ti]);
|
||||||
if (objects[i].cullbackface && backface) {
|
if (objects[i].cullbackface && backface) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
totaldrawn++;
|
totaldrawn++;
|
||||||
mfloat_t intensity = 1.0;
|
rendersettings.intensity = 1.0;
|
||||||
if (objects[i].lighting) {
|
if (objects[i].lighting) {
|
||||||
haloo3d_obj_facef(objects[i].model, objects[i].model->faces[fi],
|
haloo3d_obj_facef(objects[i].model, objects[i].model->faces[fi],
|
||||||
baseface);
|
baseface);
|
||||||
intensity =
|
rendersettings.intensity =
|
||||||
haloo3d_calc_light(objects[i].lighting->v, MINLIGHT, baseface);
|
haloo3d_calc_light(objects[i].lighting->v, MINLIGHT, baseface);
|
||||||
}
|
}
|
||||||
// We still have to convert the points into the view
|
// We still have to convert the points into the view
|
||||||
haloo3d_facef_viewport_into(outfaces[ti], WIDTH, HEIGHT);
|
haloo3d_facef_viewport_into(outfaces[ti], WIDTH, HEIGHT);
|
||||||
TRIFUNC(&fb, objects[i].texture, intensity, outfaces[ti]);
|
TRIFUNC(&fb, &rendersettings, outfaces[ti]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user