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

Add material to objtool

This commit is contained in:
Miloslav Číž 2019-06-24 18:00:26 +02:00
parent 162f825508
commit 31a33480dd
8 changed files with 1425 additions and 582 deletions

View file

@ -34,7 +34,6 @@
#include "levelModel.h"
#include "levelTextures.h"
S3L_Model3D models[3];
S3L_Scene scene;
S3L_Vec4 teleportPoint;
@ -43,8 +42,6 @@ uint32_t pixels[S3L_RESOLUTION_X * S3L_RESOLUTION_Y];
uint32_t frame = 0;
uint8_t *texture = 0;
S3L_Unit *uvs = 0;
S3L_Index *uvIndices = 0;
uint32_t previousTriangle = 1000;
S3L_Vec4 uv0, uv1, uv2;
@ -125,29 +122,25 @@ void drawPixel(S3L_PixelInfo *p)
#if TEXTURES
if (p->triangleID != previousTriangle)
{
switch (p->modelIndex)
uint8_t material = levelMaterials[p->triangleIndex];
switch (material)
{
case 0:
uvs = levelWallsUVs;
uvIndices = levelWallsUVIndices;
texture = level1Texture;
break;
case 1:
uvs = levelFloorUVs;
uvIndices = levelFloorUVIndices;
texture = level2Texture;
break;
case 2:
default:
uvs = levelCeilingUVs;
uvIndices = levelCeilingUVIndices;
texture = level3Texture;
break;
}
S3L_getIndexedTriangleValues(p->triangleIndex,uvIndices,uvs,2,&uv0,&uv1,&uv2);
S3L_getIndexedTriangleValues(p->triangleIndex,levelUVIndices,levelUVs,2,&uv0,&uv1,&uv2);
previousTriangle = p->triangleID;
}
@ -241,27 +234,17 @@ int main()
nextT = clock();
levelWallsModelInit();
levelFloorModelInit();
levelCeilingModelInit();
levelModelInit();
S3L_initScene(models,3,&scene);
S3L_initScene(&levelModel,1,&scene);
scene.models[0] = levelWallsModel;
scene.models[1] = levelFloorModel;
scene.models[2] = levelCeilingModel;
S3L_Unit s = S3L_FRACTIONS_PER_UNIT / 3;
S3L_Unit scale = S3L_FRACTIONS_PER_UNIT / 3;
S3L_Vec4 scale;
S3L_Vec4 s;
S3L_setVec4(&scale,s,s,s,S3L_FRACTIONS_PER_UNIT);
s.x = scale;
s.y = scale;
s.z = scale;
scene.models[0].transform.scale = s;
scene.models[1].transform.scale = s;
scene.models[2].transform.scale = s;
scene.models[0].transform.scale = scale;
int running = 1;

View file

@ -1,88 +0,0 @@
#ifndef LEVELCEILING_MODEL_H
#define LEVELCEILING_MODEL_H
#define LEVELCEILING_VERTEX_COUNT 143
const S3L_Unit levelCeilingVertices[LEVELCEILING_VERTEX_COUNT * 3] = {
-0x10cf,-0x54,-0x6bc,-0x8cf,-0x54,-0xebc,-0x18cf,-0x54,-0x6bc,-0xcf,-0x54,
-0x1ebc,-0xcf,-0x54,-0xebc,-0x8cf,-0x54,0x143,-0xcf,-0x54,-0x6bc,-0x18cf,-0x54,
0x143,-0x12cf,-0x54,-0x8bc,0x730,-0x854,-0x1ebc,-0x12cf,0xfab,-0x8bc,0x730,
-0x854,-0xebc,-0x1acf,-0x54,0x1f43,-0x10cf,-0x54,0x943,0x130,0xfab,0x1943,-0x8cf,
-0x54,0x943,0x1730,-0x854,-0xebc,0x1930,-0x854,-0x8bc,0x2130,0xfab,-0x8bc,0x2130,
-0x854,-0x8bc,0x1730,-0x854,-0x6bc,0x1930,0xfab,-0x1ebc,0x130,-0x54,0x943,-0xcf,
-0x1854,-0xebc,-0xcf,-0x1854,-0x6bc,0xf30,-0x1854,-0xebc,-0x8cf,-0x1854,0x143,
0x130,-0x54,0x1943,-0x10cf,-0x1854,0x143,0xf30,-0x1854,-0x6bc,0x1f30,-0x854,
-0x6bc,0x1730,-0x1854,0x143,0x1f30,-0x1854,0x143,-0x24cf,-0x254,0xb43,-0x24cf,
-0x254,0x143,0x2f30,-0x854,-0x8bc,0x1730,-0x1854,-0x6bc,-0x1acf,-0x54,-0x8bc,
-0x1acf,-0x54,0x343,-0x12cf,-0x54,0xb43,-0x12cf,-0x54,0x1743,0x1f30,-0x54,0x943,
0x1930,0xfab,-0x8bc,-0x10cf,0xfab,0x943,0x130,0xfab,0x943,-0x24cf,0xfab,-0x6bc,
-0x24cf,-0x54,-0xebc,-0xcf,0xfab,0x1743,-0x12cf,0xfab,0x1743,-0x12cf,0xfab,0xb43,
-0x10cf,0xfab,-0x6bc,-0x18cf,0xfab,0x143,-0x8cf,0xfab,-0xebc,-0x8cf,0xfab,
-0x1ebc,-0x18cf,0xfab,-0x6bc,0x1f30,0xfab,0x943,0x1f30,0xfab,-0x6bc,0x2130,-0x54,
0x943,0x2130,0xfab,0x943,0x1730,0xfab,-0x1ebc,0x1730,0xfab,-0x6bc,0x2f30,-0x54,
0x943,0x2f30,-0x54,0x1943,-0x8cf,-0x254,0x943,0x2f30,0xfab,0x1943,0x2730,-0x854,
-0x1ebc,0x2f30,-0x854,-0x16bc,0x2730,0xfab,-0x1ebc,0x2f30,0xfab,-0x16bc,-0x18cf,
-0x1054,0x1143,-0x8cf,-0x1854,0x1143,-0x10cf,-0x1854,0x1143,0x1730,-0x1854,
0x1143,0x1f30,-0x1854,0x1143,0x1730,-0x854,0x1943,0x1f30,-0x854,0x1943,0x1730,
-0x1854,0x1943,0x1f30,-0x1854,0x1943,0x1f30,-0x1854,-0x6bc,-0x1acf,0xfab,0x343,
-0x1acf,0xfab,-0x8bc,-0x24cf,0xfab,-0xebc,-0x34cf,-0x54,-0xebc,-0x18cf,-0x1054,
0x143,-0x24cf,-0x1054,0x143,-0x34cf,-0x1054,0x143,-0x34cf,-0x1054,0x1143,-0x1acf,
0xfab,0x1f43,-0x8cf,-0x854,0x1943,-0x10cf,-0x854,0x1943,-0x8cf,-0x1854,0x1943,
-0x10cf,-0x254,0x1143,-0x34cf,-0x254,0xb43,-0x34cf,0xfab,-0x6bc,-0x34cf,-0x254,
0x1143,-0x8cf,-0x254,0x143,0x1f30,-0x254,0x943,0x2f30,-0x854,-0x6bc,0x2f30,
-0x254,0x943,0x2f30,-0x1854,0x1943,-0x10cf,-0x254,0x1943,0x2f30,-0x1854,-0x6bc,
-0xcf,-0x54,0x1743,-0xcf,-0x54,0xb43,-0x22cf,-0x54,0x1f43,-0x22cf,-0x54,-0xebc,
-0xcf,0xfab,0xb43,-0x22cf,0xfab,0x1f43,-0x22cf,0xfab,-0xebc,-0xacf,-0x54,-0x10bc,
-0xacf,0xfab,-0x10bc,-0xacf,0xfab,-0x1ebc,-0x34cf,-0x54,-0x1ebc,-0x34cf,0xfab,
-0x1ebc,0x2f30,-0x254,0x1943,-0xcf,-0x54,0x15c3,-0xcf,-0x54,0xd5c,-0xcf,0x8e5,
0x15c3,-0xcf,0xb35,0x1355,-0xcf,0xb35,0xff2,-0xcf,0x8e5,0xd5c,0x130,-0x54,0xd5c,
0x130,-0x54,0x15c3,0x130,0x8e5,0xd5c,0x130,0xb35,0xff2,0x130,0xb35,0x1355,0x130,
0x8e5,0x15c3,-0x8cf,0xbcb,-0x1ebc,-0x8cf,-0x54,-0x1599,-0x8cf,0xbcb,-0x18de,
-0x8cf,0x8ed,-0x1599,-0xacf,0xbcb,-0x1ebc,-0xacf,-0x54,-0x1599,-0xacf,0xbcb,
-0x18de,-0xacf,0x8ed,-0x1599,0x1730,0x5e7,-0x1ebc,0x1730,-0x854,-0x1274,0x1730,
0x2b5,-0x1274,0x1730,0x5e7,-0x14a9,0x1930,-0x854,-0x1274,0x1930,0x5e7,-0x1ebc,
0x1930,0x2b5,-0x1274,0x1930,0x5e7,-0x14a9};
#define LEVELCEILING_TRIANGLE_COUNT 49
const S3L_Index levelCeilingTriangleIndices[LEVELCEILING_TRIANGLE_COUNT * 3] = {
32,20,30,75,72,73,34,63,95,88,71,70,93,33,45,98,30,96,94,33,92,91,33,94,91,100,
63,45,81,93,93,81,113,111,108,110,110,108,10,10,108,80,108,79,80,107,87,79,87,49,
79,47,49,48,51,50,54,43,44,50,50,44,52,59,52,44,59,53,52,60,59,44,56,60,55,60,44,
55,44,14,55,64,55,14,55,64,58,58,64,18,64,68,18,68,67,18,67,21,18,42,18,21,32,31,
20,75,74,72,34,33,63,88,89,71,93,92,33,98,97,30,91,63,33,108,107,79,87,48,49,47,
106,49,51,43,50,81,111,113,108,111,81,63,100,114,114,98,63};
#define LEVELCEILING_UV_COUNT 60
const S3L_Unit levelCeilingUVs[LEVELCEILING_UV_COUNT * 2] = {
0x1cc,-0xfd,0x15,0x2d9,0x1cc,0x2d9,0x1d3,-0x100,0x16,0x2e4,0x1d3,0x2e4,0x1,0x8d0,
-0x1f4,0x1f5,0x1,0x1f5,0x1d2,-0xf6,0x1a,0x2e0,0x1d2,0x2e0,0x1f6,0xcbb,-0x271,
0x8d0,0x1f6,0x8d0,-0x1f4,-0xbc0,0x1f6,-0x7d5,-0x1f4,-0x7d5,-0x3e9,0xcbb,-0x271,
0xcbb,-0x3e9,0x3eb,-0x5df,0x3eb,0x3ec,0x8d0,0x7d7,0xcbb,0x7d7,0x273,0x3ec,0x853,
0x469,0x273,0x274,0x468,0x274,0x65d,-0x7b,0x65d,-0x757,0x853,-0x757,0x65d,-0x271,
0x468,-0x561,0x0,-0x561,0x468,0x1,0x5e0,0x1f6,0x3eb,0x1f6,0x5e0,-0x1f4,0x3eb,
-0x1f4,-0x7d,0x3ec,0x1f5,0x7d7,-0x5e0,0x7d7,0x1f5,0x1f6,-0x5e0,0x1f6,-0x7d5,
-0x1f4,-0x7d5,-0x5df,-0x7d,-0x5df,-0xbc0,-0x1f4,-0x853,0x274,-0x853,0x5e1,-0xbc0,
0x7d7,-0x9cb,0x7d7,-0x65d,0x274,-0x65d,0x15,-0xfd,0x16,-0x100,0x1a,-0xf6,0x1f6,
-0xbc0,-0x271,0x0,-0x5df,-0xbc0};
#define LEVELCEILING_UV_INDEX_COUNT 49
const S3L_Index levelCeilingUVIndices[LEVELCEILING_UV_INDEX_COUNT * 3] = {
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,13,19,20,13,18,20,21,7,14,22,12,
12,22,23,24,25,26,26,25,27,27,25,28,25,29,28,30,31,29,31,32,29,33,32,34,35,36,37,
38,39,36,36,39,40,41,40,39,41,42,40,43,41,39,44,43,45,43,39,45,39,46,45,47,45,46,
45,47,48,48,47,49,47,50,49,50,51,49,51,52,49,53,49,52,0,54,1,3,55,4,6,13,7,9,56,
10,12,19,13,15,57,16,20,7,13,25,30,29,31,34,32,33,58,32,35,38,36,22,24,23,25,24,
22,7,21,59,59,15,7};
S3L_Model3D levelCeilingModel;
void levelCeilingModelInit()
{
S3L_initModel3D(
levelCeilingVertices,
LEVELCEILING_VERTEX_COUNT,
levelCeilingTriangleIndices,
LEVELCEILING_TRIANGLE_COUNT,
&levelCeilingModel);
}
#endif // guard

View file

@ -1,95 +0,0 @@
#ifndef LEVELFLOOR_MODEL_H
#define LEVELFLOOR_MODEL_H
#define LEVELFLOOR_VERTEX_COUNT 143
const S3L_Unit levelFloorVertices[LEVELFLOOR_VERTEX_COUNT * 3] = {
-0x10cf,-0x54,-0x6bc,-0x8cf,-0x54,-0xebc,-0x18cf,-0x54,-0x6bc,-0xcf,-0x54,
-0x1ebc,-0xcf,-0x54,-0xebc,-0x8cf,-0x54,0x143,-0xcf,-0x54,-0x6bc,-0x18cf,-0x54,
0x143,-0x12cf,-0x54,-0x8bc,0x730,-0x854,-0x1ebc,-0x12cf,0xfab,-0x8bc,0x730,
-0x854,-0xebc,-0x1acf,-0x54,0x1f43,-0x10cf,-0x54,0x943,0x130,0xfab,0x1943,-0x8cf,
-0x54,0x943,0x1730,-0x854,-0xebc,0x1930,-0x854,-0x8bc,0x2130,0xfab,-0x8bc,0x2130,
-0x854,-0x8bc,0x1730,-0x854,-0x6bc,0x1930,0xfab,-0x1ebc,0x130,-0x54,0x943,-0xcf,
-0x1854,-0xebc,-0xcf,-0x1854,-0x6bc,0xf30,-0x1854,-0xebc,-0x8cf,-0x1854,0x143,
0x130,-0x54,0x1943,-0x10cf,-0x1854,0x143,0xf30,-0x1854,-0x6bc,0x1f30,-0x854,
-0x6bc,0x1730,-0x1854,0x143,0x1f30,-0x1854,0x143,-0x24cf,-0x254,0xb43,-0x24cf,
-0x254,0x143,0x2f30,-0x854,-0x8bc,0x1730,-0x1854,-0x6bc,-0x1acf,-0x54,-0x8bc,
-0x1acf,-0x54,0x343,-0x12cf,-0x54,0xb43,-0x12cf,-0x54,0x1743,0x1f30,-0x54,0x943,
0x1930,0xfab,-0x8bc,-0x10cf,0xfab,0x943,0x130,0xfab,0x943,-0x24cf,0xfab,-0x6bc,
-0x24cf,-0x54,-0xebc,-0xcf,0xfab,0x1743,-0x12cf,0xfab,0x1743,-0x12cf,0xfab,0xb43,
-0x10cf,0xfab,-0x6bc,-0x18cf,0xfab,0x143,-0x8cf,0xfab,-0xebc,-0x8cf,0xfab,
-0x1ebc,-0x18cf,0xfab,-0x6bc,0x1f30,0xfab,0x943,0x1f30,0xfab,-0x6bc,0x2130,-0x54,
0x943,0x2130,0xfab,0x943,0x1730,0xfab,-0x1ebc,0x1730,0xfab,-0x6bc,0x2f30,-0x54,
0x943,0x2f30,-0x54,0x1943,-0x8cf,-0x254,0x943,0x2f30,0xfab,0x1943,0x2730,-0x854,
-0x1ebc,0x2f30,-0x854,-0x16bc,0x2730,0xfab,-0x1ebc,0x2f30,0xfab,-0x16bc,-0x18cf,
-0x1054,0x1143,-0x8cf,-0x1854,0x1143,-0x10cf,-0x1854,0x1143,0x1730,-0x1854,
0x1143,0x1f30,-0x1854,0x1143,0x1730,-0x854,0x1943,0x1f30,-0x854,0x1943,0x1730,
-0x1854,0x1943,0x1f30,-0x1854,0x1943,0x1f30,-0x1854,-0x6bc,-0x1acf,0xfab,0x343,
-0x1acf,0xfab,-0x8bc,-0x24cf,0xfab,-0xebc,-0x34cf,-0x54,-0xebc,-0x18cf,-0x1054,
0x143,-0x24cf,-0x1054,0x143,-0x34cf,-0x1054,0x143,-0x34cf,-0x1054,0x1143,-0x1acf,
0xfab,0x1f43,-0x8cf,-0x854,0x1943,-0x10cf,-0x854,0x1943,-0x8cf,-0x1854,0x1943,
-0x10cf,-0x254,0x1143,-0x34cf,-0x254,0xb43,-0x34cf,0xfab,-0x6bc,-0x34cf,-0x254,
0x1143,-0x8cf,-0x254,0x143,0x1f30,-0x254,0x943,0x2f30,-0x854,-0x6bc,0x2f30,
-0x254,0x943,0x2f30,-0x1854,0x1943,-0x10cf,-0x254,0x1943,0x2f30,-0x1854,-0x6bc,
-0xcf,-0x54,0x1743,-0xcf,-0x54,0xb43,-0x22cf,-0x54,0x1f43,-0x22cf,-0x54,-0xebc,
-0xcf,0xfab,0xb43,-0x22cf,0xfab,0x1f43,-0x22cf,0xfab,-0xebc,-0xacf,-0x54,-0x10bc,
-0xacf,0xfab,-0x10bc,-0xacf,0xfab,-0x1ebc,-0x34cf,-0x54,-0x1ebc,-0x34cf,0xfab,
-0x1ebc,0x2f30,-0x254,0x1943,-0xcf,-0x54,0x15c3,-0xcf,-0x54,0xd5c,-0xcf,0x8e5,
0x15c3,-0xcf,0xb35,0x1355,-0xcf,0xb35,0xff2,-0xcf,0x8e5,0xd5c,0x130,-0x54,0xd5c,
0x130,-0x54,0x15c3,0x130,0x8e5,0xd5c,0x130,0xb35,0xff2,0x130,0xb35,0x1355,0x130,
0x8e5,0x15c3,-0x8cf,0xbcb,-0x1ebc,-0x8cf,-0x54,-0x1599,-0x8cf,0xbcb,-0x18de,
-0x8cf,0x8ed,-0x1599,-0xacf,0xbcb,-0x1ebc,-0xacf,-0x54,-0x1599,-0xacf,0xbcb,
-0x18de,-0xacf,0x8ed,-0x1599,0x1730,0x5e7,-0x1ebc,0x1730,-0x854,-0x1274,0x1730,
0x2b5,-0x1274,0x1730,0x5e7,-0x14a9,0x1930,-0x854,-0x1274,0x1930,0x5e7,-0x1ebc,
0x1930,0x2b5,-0x1274,0x1930,0x5e7,-0x14a9};
#define LEVELFLOOR_TRIANGLE_COUNT 70
const S3L_Index levelFloorTriangleIndices[LEVELFLOOR_TRIANGLE_COUNT * 3] = {
6,0,1,4,6,1,13,5,15,4,1,128,13,0,5,3,11,4,23,29,24,2,0,7,122,121,41,62,57,61,70,
31,72,69,84,83,85,84,86,77,73,99,32,99,73,70,28,26,71,83,28,84,69,86,85,46,84,
115,102,40,57,62,41,72,90,70,73,31,32,78,101,32,61,19,35,38,40,12,104,38,12,105,
38,104,38,105,37,37,109,8,105,132,109,112,46,82,36,31,29,29,26,24,35,19,66,66,19,
65,46,112,105,116,122,115,6,5,0,3,4,128,13,7,0,3,9,11,16,11,136,11,9,136,23,25,
29,62,27,41,27,122,41,121,22,41,70,26,31,32,101,99,70,71,28,71,69,83,85,82,46,40,
39,116,39,103,116,116,115,40,72,76,90,73,72,31,61,57,19,38,39,40,37,105,109,3,
105,112,29,31,26,65,19,139,19,17,139,116,121,122,128,132,3,136,65,139,136,9,65,
105,3,132};
#define LEVELFLOOR_UV_COUNT 70
const S3L_Unit levelFloorUVs[LEVELFLOOR_UV_COUNT * 2] = {
0x192,0x2bb,-0x2b2,0x2bb,-0x90,0x4de,0x192,0x4de,-0x2b2,-0x189,-0x90,0x98,-0x90,
-0x189,-0x90,0x6b2,0x192,0x923,0x3b4,0x4de,0x192,0x4de,0x5d7,0x2bb,0x192,0x2bb,
-0x4d5,0x2bb,-0x4d5,0x98,0x21a,-0x4df,0x21a,-0x2a1,0xa1c,-0x189,0xe61,-0x5ce,
0xaa4,-0x189,0xe61,-0x189,-0x90,-0x3ac,0x7f9,0x98,0x7f9,-0x3ac,-0x4d5,-0x3ac,
-0x809,0x98,-0x4d5,0x98,-0xc4e,0x98,-0xc4e,-0x3ac,0xa1c,-0x5ce,0xa1c,-0x3ac,
0xe61,-0x5ce,0xa1c,0x98,-0x2b2,0x98,-0x90,0x98,-0x2b2,-0x3ac,-0x809,0x4de,0x192,
-0x4df,0x192,-0x545,-0x33b,-0x545,-0x90,-0x5ce,0xa1c,0x2bb,0xe61,0x2bb,0xaa4,
0x344,0xe61,0x344,-0x55e,0x10,-0x55e,-0x768,-0x780,-0x768,-0x780,0x4de,-0x55e,
0x344,-0x118,0x566,-0x33b,0x344,-0x118,0x6b2,-0xc4e,0x923,-0xc4e,0x4de,0x7f9,
0x2bb,0xe61,0x700,0xc3e,0x923,0x192,-0x2a1,0x3b4,0x923,0x7f9,0x4de,0x7f9,0x5db,
0x5d7,0x4de,0x21a,-0x5ce,0x21a,-0x189,-0x33b,-0x212,0x192,-0x212,0x7f9,-0x5ce,
0x882,0x5db,0x882,0x344};
#define LEVELFLOOR_UV_INDEX_COUNT 70
const S3L_Index levelFloorUVIndices[LEVELFLOOR_UV_INDEX_COUNT * 3] = {
0,1,2,3,0,2,4,5,6,3,2,7,4,1,5,8,9,3,10,11,12,13,1,14,15,16,17,18,19,20,21,22,23,
24,25,26,27,25,28,29,30,31,32,31,30,21,33,34,35,26,33,25,24,28,27,36,25,37,38,39,
19,18,17,23,40,21,30,22,32,41,42,32,20,43,44,45,39,46,47,45,46,48,45,47,45,48,49,
49,50,51,48,52,50,53,36,54,55,22,11,11,34,12,44,43,56,56,43,57,36,53,48,58,15,37,
0,5,1,8,3,7,4,14,1,8,59,9,60,9,61,9,59,61,10,62,11,18,63,17,63,15,17,16,64,17,21,
34,22,32,42,31,21,35,33,35,24,26,27,54,36,39,65,58,65,66,58,58,37,39,23,67,40,30,
23,22,20,19,43,45,65,39,49,48,50,8,48,53,11,22,34,57,43,68,43,69,68,58,16,15,7,
52,8,61,57,68,61,59,57,48,8,52};
S3L_Model3D levelFloorModel;
void levelFloorModelInit()
{
S3L_initModel3D(
levelFloorVertices,
LEVELFLOOR_VERTEX_COUNT,
levelFloorTriangleIndices,
LEVELFLOOR_TRIANGLE_COUNT,
&levelFloorModel);
}
#endif // guard

File diff suppressed because it is too large Load diff

View file

@ -1,149 +0,0 @@
#ifndef LEVELWALLS_MODEL_H
#define LEVELWALLS_MODEL_H
#define LEVELWALLS_VERTEX_COUNT 143
const S3L_Unit levelWallsVertices[LEVELWALLS_VERTEX_COUNT * 3] = {
-0x10cf,-0x54,-0x6bc,-0x8cf,-0x54,-0xebc,-0x18cf,-0x54,-0x6bc,-0xcf,-0x54,
-0x1ebc,-0xcf,-0x54,-0xebc,-0x8cf,-0x54,0x143,-0xcf,-0x54,-0x6bc,-0x18cf,-0x54,
0x143,-0x12cf,-0x54,-0x8bc,0x730,-0x854,-0x1ebc,-0x12cf,0xfab,-0x8bc,0x730,
-0x854,-0xebc,-0x1acf,-0x54,0x1f43,-0x10cf,-0x54,0x943,0x130,0xfab,0x1943,-0x8cf,
-0x54,0x943,0x1730,-0x854,-0xebc,0x1930,-0x854,-0x8bc,0x2130,0xfab,-0x8bc,0x2130,
-0x854,-0x8bc,0x1730,-0x854,-0x6bc,0x1930,0xfab,-0x1ebc,0x130,-0x54,0x943,-0xcf,
-0x1854,-0xebc,-0xcf,-0x1854,-0x6bc,0xf30,-0x1854,-0xebc,-0x8cf,-0x1854,0x143,
0x130,-0x54,0x1943,-0x10cf,-0x1854,0x143,0xf30,-0x1854,-0x6bc,0x1f30,-0x854,
-0x6bc,0x1730,-0x1854,0x143,0x1f30,-0x1854,0x143,-0x24cf,-0x254,0xb43,-0x24cf,
-0x254,0x143,0x2f30,-0x854,-0x8bc,0x1730,-0x1854,-0x6bc,-0x1acf,-0x54,-0x8bc,
-0x1acf,-0x54,0x343,-0x12cf,-0x54,0xb43,-0x12cf,-0x54,0x1743,0x1f30,-0x54,0x943,
0x1930,0xfab,-0x8bc,-0x10cf,0xfab,0x943,0x130,0xfab,0x943,-0x24cf,0xfab,-0x6bc,
-0x24cf,-0x54,-0xebc,-0xcf,0xfab,0x1743,-0x12cf,0xfab,0x1743,-0x12cf,0xfab,0xb43,
-0x10cf,0xfab,-0x6bc,-0x18cf,0xfab,0x143,-0x8cf,0xfab,-0xebc,-0x8cf,0xfab,
-0x1ebc,-0x18cf,0xfab,-0x6bc,0x1f30,0xfab,0x943,0x1f30,0xfab,-0x6bc,0x2130,-0x54,
0x943,0x2130,0xfab,0x943,0x1730,0xfab,-0x1ebc,0x1730,0xfab,-0x6bc,0x2f30,-0x54,
0x943,0x2f30,-0x54,0x1943,-0x8cf,-0x254,0x943,0x2f30,0xfab,0x1943,0x2730,-0x854,
-0x1ebc,0x2f30,-0x854,-0x16bc,0x2730,0xfab,-0x1ebc,0x2f30,0xfab,-0x16bc,-0x18cf,
-0x1054,0x1143,-0x8cf,-0x1854,0x1143,-0x10cf,-0x1854,0x1143,0x1730,-0x1854,
0x1143,0x1f30,-0x1854,0x1143,0x1730,-0x854,0x1943,0x1f30,-0x854,0x1943,0x1730,
-0x1854,0x1943,0x1f30,-0x1854,0x1943,0x1f30,-0x1854,-0x6bc,-0x1acf,0xfab,0x343,
-0x1acf,0xfab,-0x8bc,-0x24cf,0xfab,-0xebc,-0x34cf,-0x54,-0xebc,-0x18cf,-0x1054,
0x143,-0x24cf,-0x1054,0x143,-0x34cf,-0x1054,0x143,-0x34cf,-0x1054,0x1143,-0x1acf,
0xfab,0x1f43,-0x8cf,-0x854,0x1943,-0x10cf,-0x854,0x1943,-0x8cf,-0x1854,0x1943,
-0x10cf,-0x254,0x1143,-0x34cf,-0x254,0xb43,-0x34cf,0xfab,-0x6bc,-0x34cf,-0x254,
0x1143,-0x8cf,-0x254,0x143,0x1f30,-0x254,0x943,0x2f30,-0x854,-0x6bc,0x2f30,
-0x254,0x943,0x2f30,-0x1854,0x1943,-0x10cf,-0x254,0x1943,0x2f30,-0x1854,-0x6bc,
-0xcf,-0x54,0x1743,-0xcf,-0x54,0xb43,-0x22cf,-0x54,0x1f43,-0x22cf,-0x54,-0xebc,
-0xcf,0xfab,0xb43,-0x22cf,0xfab,0x1f43,-0x22cf,0xfab,-0xebc,-0xacf,-0x54,-0x10bc,
-0xacf,0xfab,-0x10bc,-0xacf,0xfab,-0x1ebc,-0x34cf,-0x54,-0x1ebc,-0x34cf,0xfab,
-0x1ebc,0x2f30,-0x254,0x1943,-0xcf,-0x54,0x15c3,-0xcf,-0x54,0xd5c,-0xcf,0x8e5,
0x15c3,-0xcf,0xb35,0x1355,-0xcf,0xb35,0xff2,-0xcf,0x8e5,0xd5c,0x130,-0x54,0xd5c,
0x130,-0x54,0x15c3,0x130,0x8e5,0xd5c,0x130,0xb35,0xff2,0x130,0xb35,0x1355,0x130,
0x8e5,0x15c3,-0x8cf,0xbcb,-0x1ebc,-0x8cf,-0x54,-0x1599,-0x8cf,0xbcb,-0x18de,
-0x8cf,0x8ed,-0x1599,-0xacf,0xbcb,-0x1ebc,-0xacf,-0x54,-0x1599,-0xacf,0xbcb,
-0x18de,-0xacf,0x8ed,-0x1599,0x1730,0x5e7,-0x1ebc,0x1730,-0x854,-0x1274,0x1730,
0x2b5,-0x1274,0x1730,0x5e7,-0x14a9,0x1930,-0x854,-0x1274,0x1930,0x5e7,-0x1ebc,
0x1930,0x2b5,-0x1274,0x1930,0x5e7,-0x14a9};
#define LEVELWALLS_TRIANGLE_COUNT 174
const S3L_Index levelWallsTriangleIndices[LEVELWALLS_TRIANGLE_COUNT * 3] = {
7,54,2,3,59,9,63,5,95,26,6,24,6,26,95,6,95,5,43,15,44,109,10,8,22,44,15,3,53,59,
29,16,20,29,20,36,31,36,20,41,96,30,60,137,138,22,96,41,124,125,14,13,51,7,82,93,
113,57,18,19,13,15,43,40,87,12,104,108,105,3,127,53,54,0,2,41,56,55,50,1,0,19,42,
17,56,20,60,27,64,14,8,80,37,110,134,133,61,68,64,65,68,66,35,66,68,140,21,67,35,
68,61,58,41,55,61,64,62,16,25,11,11,23,4,23,11,25,98,99,97,99,101,97,74,76,72,73,
77,75,30,78,32,80,38,37,12,107,104,46,108,81,69,71,91,81,45,34,34,45,33,34,84,46,
49,103,39,79,39,38,119,106,47,102,48,40,70,90,88,89,91,71,26,28,95,84,34,83,95,
83,34,28,83,95,94,92,86,91,94,69,112,82,113,34,46,81,86,69,94,86,92,85,52,129,
130,92,82,85,74,90,76,97,78,30,77,114,75,99,114,77,100,91,89,100,89,88,98,114,99,
22,15,63,74,100,88,124,120,119,125,119,118,126,118,117,122,117,115,123,116,120,
130,132,128,129,134,130,127,133,129,131,127,3,16,60,20,141,17,42,136,141,137,137,
142,138,138,140,135,7,51,54,63,15,5,109,110,10,23,24,6,6,4,23,29,25,16,60,16,137,
16,136,137,135,59,138,59,60,138,22,63,96,44,22,123,22,121,123,122,27,126,27,14,
126,44,123,124,125,126,14,44,124,14,13,43,51,57,58,18,40,48,87,104,107,108,54,50,
0,41,30,56,50,52,1,19,18,42,56,30,20,27,62,64,8,10,80,110,109,134,109,132,134,
131,111,133,111,110,133,65,67,68,9,59,135,67,65,140,58,57,41,80,79,38,12,87,107,
46,105,108,49,106,103,79,49,39,116,103,120,103,106,120,47,102,117,102,115,117,
119,120,106,47,117,118,118,119,47,102,47,48,128,1,130,1,52,130,52,53,129,53,127,
129,92,93,82,74,88,90,97,101,78,124,123,120,125,124,119,126,125,118,122,126,117,
123,121,116,130,134,132,129,133,134,127,131,133,21,140,142,141,139,17,42,21,142,
142,141,42,136,139,141,137,141,142,138,142,140,140,65,135,9,135,65,3,112,131,112,
113,131,131,113,111,75,114,74,74,114,100};
#define LEVELWALLS_UV_COUNT 214
const S3L_Unit levelWallsUVs[LEVELWALLS_UV_COUNT * 2] = {
-0x677,-0x3ef,-0x888,-0x811,-0x888,-0x3ef,-0xd9a,-0x3e8,-0x13b7,-0x7ff,-0xfa5,
-0x1de,-0x2791,-0x390,-0x299d,-0x415,-0x299d,-0x392,-0x29a3,0x20d,-0x2c82,-0x418,
-0x2c88,0x20a,-0x38b,-0x811,-0x17a,-0x3ef,0x11a,-0x811,0x144,-0x3f8,-0x1a7,
-0x81a,-0x1a7,-0x3f8,0x11a,-0x3ef,-0xb8e,-0x7fc,0x211,-0x16b,-0x14,0x36b,0x211,
0x36b,-0x62,-0x3ff,-0x270,-0x81a,-0x270,-0x3ff,-0x47e,-0x3ff,-0x72e,-0x3e0,
-0x72e,-0x359,-0x2fa,-0x1c6,-0xe0,-0x814,0x233,-0x4ac,0x2c7,-0x583,-0x2502,
-0x410,-0x1d56,-0x385,-0x1d55,-0x408,0x2d4,-0x6ea,0x3b4,-0x6ea,0x53c,-0x811,
-0x38b,-0x3ef,-0x677,-0x811,0x3be,-0x3e1,0x5ca,-0x7f5,-0x54,-0x7f7,0x94,-0x3f5,
-0x40d,-0x813,-0x40d,-0x1e6,-0xd24,-0x3f8,-0x1004,-0x812,-0x1008,-0x3fb,-0x1214,
-0x3fd,-0x1dd4,-0x821,-0x1dd8,-0x409,-0xb8e,-0x6ff,-0xa99,-0x3ef,-0x2fa,-0x814,
-0x72e,-0x814,-0xa99,-0x811,-0xd85,-0x3ef,-0x61c,-0x813,-0x61c,-0x1e6,-0xe0,
-0x1c6,-0x32ab,-0x3f7,-0x26ed,-0x807,-0x32a9,-0x80b,-0x3b8,-0x81a,-0x3b8,-0x3f8,
0x144,-0x81a,0x285,-0x65c,0x35d,-0x71a,-0x22da,-0x3f0,-0x1aaf,-0x802,-0x17cf,
-0x1e1,-0x1ab1,-0x1e3,-0x1e44,-0x1e4,-0x143b,-0x581,-0x143a,-0x7ff,-0x17cc,
-0x801,0x94,-0x813,0x118,-0x3f5,0x118,-0x813,-0x26ef,-0x3f2,-0x34b7,-0x208,
-0x32af,0x207,-0x30a7,-0x208,-0x2e9f,0x207,-0x2e9f,-0x410,0x2b89,-0x34e,0x2772,
0x24c,0x2f9d,-0x1c4,0x2f9b,0x24f,-0x272,-0x813,-0x272,-0x3f7,-0x64,-0x3f7,-0x474,
-0x3f2,-0x266,-0x3f2,-0x266,-0x80e,-0x266,-0x806,-0x25f,-0x3ea,-0x51,-0x3ed,
-0x6d2,-0x3f8,-0x1210,-0x814,-0x1e5b,-0x40a,-0x1e57,-0x821,0x130a,0x39,0x1514,
0x245,0x1516,-0x357,-0x2063,-0x823,-0x2274,-0x38b,-0x2502,-0x38d,-0x2277,0x9,
-0x9be,-0x81a,-0xe64,-0x3f8,-0x9be,-0x3f8,-0x6d2,-0x81a,-0xf9a,-0x6f3,-0xe64,
-0x81a,-0x117d,-0x81a,-0x889,-0x3f3,-0xd1f,-0x80f,-0x481,-0x3f7,-0x273,-0x3f7,
-0x273,-0x813,0x1720,-0x1ce,-0x2797,0x210,-0x2589,0x6,0xbe7,-0x35b,0xa60,-0x35b,
0xbe6,0x37,-0x56,-0x3e2,0x7d1,0x35,-0xd85,-0x811,-0x1023,-0x710,-0xf4a,-0x653,
0x2154,-0x1ca,0x1929,0x246,0x2152,0x24a,0x33b0,0x251,0x33b2,-0x1c3,0x235d,0x24a,
0x2774,-0x34f,0x235e,-0x1c9,0x1721,-0x356,0x192a,-0x1cd,-0x2791,-0x413,0x176,
0x15e,0x29d,0xb4,0x176,0xb4,0x57,0x15e,0x57,0xb4,-0xc5,0x15e,-0xc5,0xb4,-0x25e,
-0x3f1,-0x2e0,-0x64a,-0x2e0,-0x3f1,-0x25e,-0x64a,-0x1db,-0x3f1,-0x1db,-0x64a,
-0x159,-0x64a,-0x1db,-0x3ef,-0x159,-0x3ef,0xb9,0x203,-0x96,0x168,-0x96,0x203,
0x27e,0x203,0xb9,0x168,-0xb0b,-0x6fe,0x139,-0x1c6,-0x89c,-0x4bd,-0x139,-0x3eb,
-0xb6,-0x6ba,-0x139,-0x6ba,0x34a,0x15f,0x1f4,0xb0,0x1f4,0x15f,-0x181,0xb0,-0x181,
0x15f,-0x2e94,0x208,-0x2e8d,-0x41a,-0x14,-0x16b,0x233,-0x1c6,0x56d,-0x583,0x56d,
-0x814,0x229,-0x651,0x229,-0x3ef,0x455,-0x3ef,0x53c,-0x3ef,0x455,-0x651,0x285,
-0x3f8,0x4e1,-0x71a,0x4e1,-0x81a,-0x13b8,-0x581,-0xeef,-0x3f8,-0xeef,-0x65a,
-0x117d,-0x3f8,-0x111a,-0x65a,-0x111a,-0x3f8,-0x1079,-0x6f3,-0x885,-0x80b,-0xf4a,
-0x3ef,-0x11a7,-0x811,-0x11a7,-0x710,0x29d,0x15e,-0x25e,-0x64a,-0x25e,-0x3f1,
-0x1db,-0x64a,0x27e,0x168,-0xbc5,-0x813,-0xbc5,-0x58f,-0x92d,-0x58f,-0x89c,
-0x1e6,-0xb6,-0x3eb,0x34a,0xb0,-0xb0b,-0x7fb};
#define LEVELWALLS_UV_INDEX_COUNT 174
const S3L_Index levelWallsUVIndices[LEVELWALLS_UV_INDEX_COUNT * 3] = {
0,1,2,3,4,5,6,7,8,9,10,11,10,9,8,10,8,7,12,13,14,15,16,17,18,14,13,3,19,4,20,21,
22,23,24,25,26,25,24,27,28,29,30,31,32,33,34,35,36,37,38,39,40,0,41,42,43,44,45,
46,39,13,12,47,48,49,50,51,52,3,53,19,1,54,2,27,55,56,57,58,54,46,59,60,55,61,30,
62,63,64,17,65,66,67,68,69,70,71,63,72,71,73,74,73,71,75,76,77,74,71,70,78,79,80,
70,63,81,82,83,84,84,85,86,85,84,83,87,88,89,88,90,89,91,92,93,94,95,96,97,98,99,
65,100,66,49,101,50,102,51,103,104,105,106,103,107,108,108,107,109,108,110,102,
111,112,113,114,113,100,115,116,117,118,119,47,120,121,122,123,106,105,9,124,8,
110,108,125,8,125,108,124,125,8,126,127,128,106,126,104,129,41,43,108,102,103,
128,104,126,128,127,130,131,132,133,127,41,130,134,135,136,89,137,138,139,140,
141,88,140,139,142,106,123,142,123,143,87,140,88,33,144,6,134,142,143,145,146,
147,148,147,149,150,149,151,152,153,154,155,156,157,158,159,160,161,162,163,164,
165,161,166,53,3,167,30,61,168,60,59,169,170,171,172,173,174,174,175,176,0,40,1,
6,144,7,15,67,16,177,11,10,10,178,177,20,179,21,30,167,31,167,180,31,181,182,32,
182,30,32,33,6,34,14,18,183,18,184,183,185,186,187,186,38,187,14,183,36,37,187,
38,14,36,38,39,12,40,44,78,45,47,119,48,50,101,51,1,57,54,27,29,55,57,131,58,46,
45,59,55,29,61,62,81,63,17,16,65,67,15,68,15,188,68,189,190,69,190,67,69,72,77,
71,5,4,191,77,72,75,78,44,79,65,114,100,49,48,101,102,52,51,111,116,112,114,111,
113,192,112,193,112,116,193,117,194,195,194,196,195,115,193,116,117,195,197,197,
115,117,118,198,119,199,58,133,58,131,133,131,200,132,200,201,132,127,42,41,134,
143,135,89,90,137,145,202,146,148,145,147,150,148,149,152,203,153,155,204,156,
158,205,159,161,165,162,164,206,165,207,208,209,168,210,60,59,207,209,209,168,59,
169,211,170,172,212,173,174,173,175,75,72,191,5,191,72,3,129,166,129,43,166,166,
43,213,141,140,134,134,140,142};
S3L_Model3D levelWallsModel;
void levelWallsModelInit()
{
S3L_initModel3D(
levelWallsVertices,
LEVELWALLS_VERTEX_COUNT,
levelWallsTriangleIndices,
LEVELWALLS_TRIANGLE_COUNT,
&levelWallsModel);
}
#endif // guard

View file

@ -287,6 +287,8 @@ typedef struct
} S3L_Vec4;
static inline void S3L_initVec4(S3L_Vec4 *v);
static inline void S3L_setVec4(S3L_Vec4 *v, S3L_Unit x, S3L_Unit y,
S3L_Unit z, S3L_Unit w);
static inline void S3L_vec3Add(S3L_Vec4 *result, S3L_Vec4 added);
static inline void S3L_vec3Sub(S3L_Vec4 *result, S3L_Vec4 substracted);
S3L_Unit S3L_vec3Length(S3L_Vec4 v);
@ -871,6 +873,14 @@ void S3L_initVec4(S3L_Vec4 *v)
v->x = 0; v->y = 0; v->z = 0; v->w = S3L_FRACTIONS_PER_UNIT;
}
void S3L_setVec4(S3L_Vec4 *v, S3L_Unit x, S3L_Unit y, S3L_Unit z, S3L_Unit w)
{
v->x = x;
v->y = y;
v->z = z;
v->w = w;
}
void S3L_vec3Add(S3L_Vec4 *result, S3L_Vec4 added)
{
result->x += added.x;

View file

@ -8,7 +8,7 @@ features:
should be in a separate file?
- objtool: An option to parse material groups and generate an array of
per-triangle material indices.
per-triangle material indices. DONE
- PC == 2 (and possibly 1) could likely be accelerated by not using interpolate
functions, but rather FastLerStates for the values recomputed after each

View file

@ -13,6 +13,7 @@ def printHelp():
print(" -c compact format (off by default)")
print(" -t use direct instead of indexed UV coords (off by default)")
print(" -h include header guards (for model per file)")
print(" -m include a material array (per-triangle)")
print(" -nS use the name S for the model (defaut: \"model\")")
print(" -sX scale the model by X (default: 512)")
print(" -uY scale the U texture coord by Y (default: 512)")
@ -33,6 +34,7 @@ NAME = "model"
GUARDS = False
COMPACT = False
INDEXED_UVS = True
MATERIALS = False
for s in sys.argv:
if s == "-c":
@ -41,6 +43,8 @@ for s in sys.argv:
INDEXED_UVS = False
elif s == "-h":
GUARDS = True
elif s == "-m":
MATERIALS = True
elif s[:2] == "-s":
VERTEX_SCALE = int(s[2:])
elif s[:2] == "-u":
@ -58,6 +62,17 @@ vertices = []
uvs = []
triangles = []
triangleUVs = []
materials = []
materialNames = []
currentMatrial = 0
def getMaterialIndex(materialName):
try:
return materialNames.index(materialName)
except Exception:
materialNames.append(materialName)
return len(materialNames) - 1
# parse the file:
@ -88,6 +103,9 @@ for line in objFile:
triangles.append(t)
triangleUVs.append(u)
materials.append([currentMatrial])
elif line[:7] == "usemtl ":
currentMatrial = getMaterialIndex(line[7:])
# print the result:
@ -160,6 +178,9 @@ print(arrayString(NAME + "Vertices",vertices,3,[VERTEX_SCALE],5,False,"S3L_Unit"
print("#define " + NAME.upper() + "_TRIANGLE_COUNT " + str(len(triangles)))
print(arrayString(NAME + "TriangleIndices",triangles,3,[1],5,True,"S3L_Index",NAME.upper() + "_TRIANGLE_COUNT * 3"))
if MATERIALS:
print(arrayString(NAME + "Materials",materials,1,[1],5,True,"uint8_t",NAME.upper() + "_TRIANGLE_COUNT"))
if INDEXED_UVS:
print("#define " + NAME.upper() + "_UV_COUNT " + str(len(uvs)))
print(arrayString(NAME + "UVs",uvs,2,[U_SCALE,V_SCALE],5,False,"S3L_Unit",NAME.upper() + "_UV_COUNT * 2"))