1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/small3dlib.git synced 2024-11-21 20:39:57 +01:00

Fix normals bug

This commit is contained in:
Miloslav Číž 2019-06-14 04:08:44 +02:00
parent 133900b923
commit ca4e42c511
2 changed files with 9 additions and 5 deletions

View file

@ -3,7 +3,7 @@
#define S3L_PIXEL_FUNCTION drawPixel
#define S3L_PERSPECTIVE_CORRECTION 1
#define S3L_PERSPECTIVE_CORRECTION 0
#define S3L_SORT 0
#define S3L_Z_BUFFER 1
@ -135,6 +135,10 @@ void drawPixel(S3L_PixelInfo *p)
color[2] = light / 2 + p->modelIndex * 127;
}
color[0] = S3L_clamp(127 + normal.x / 4,0,255);
color[1] = S3L_clamp(127 + normal.y / 4,0,255);
color[2] = S3L_clamp(127 + normal.z / 4,0,255);
frameBuffer[index] = color[0];
frameBuffer[index + 1] = color[1];
frameBuffer[index + 2] = color[2];
@ -236,13 +240,13 @@ int main()
GRID_TRIANGLES,
&(models[MODELS - 1]));
S3L_initScene(models,MODELS,&scene);
S3L_initScene(models,/*MODELS*/1,&scene);
animateWater(0);
scene.camera.transform.translation.x = 4 * S3L_FRACTIONS_PER_UNIT;
scene.camera.transform.translation.y = 6 * S3L_FRACTIONS_PER_UNIT;
scene.camera.transform.translation.z = -7 * S3L_FRACTIONS_PER_UNIT;
scene.camera.transform.translation.y = 8 * S3L_FRACTIONS_PER_UNIT;
scene.camera.transform.translation.z = -10 * S3L_FRACTIONS_PER_UNIT;
scene.camera.transform.rotation.x = -S3L_FRACTIONS_PER_UNIT / 8;
scene.camera.transform.rotation.y = -S3L_FRACTIONS_PER_UNIT / 8;

View file

@ -930,7 +930,7 @@ void S3L_computeModelNormals(S3L_Model3D model, S3L_Unit *dst,
n.x = 0;
for (uint8_t i = 0; i < MAX_NORMALS; ++i)
for (uint8_t i = 0; i < normalCount; ++i)
{
n.x += ns[i].x;
n.y += ns[i].y;