mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-11-23 20:59:58 +01:00
Update
This commit is contained in:
parent
49f963e47c
commit
42b558f486
10 changed files with 2435 additions and 59 deletions
|
@ -394,13 +394,16 @@ const S3L_Index cat1UVIndices[CAT1_UV_INDEX_COUNT * 3] = {
|
||||||
84, 89, 49 // 339
|
84, 89, 49 // 339
|
||||||
}; // cat1UVIndices
|
}; // cat1UVIndices
|
||||||
|
|
||||||
S3L_Model3D cat1Model =
|
S3L_Model3D cat1Model;
|
||||||
|
|
||||||
|
void cat1ModelInit()
|
||||||
{
|
{
|
||||||
.vertices = cat1Vertices,
|
S3L_initModel3D(
|
||||||
.vertexCount = CAT1_VERTEX_COUNT,
|
cat1Vertices,
|
||||||
.triangles = cat1TriangleIndices,
|
CAT1_VERTEX_COUNT,
|
||||||
.triangleCount = CAT1_TRIANGLE_COUNT,
|
cat1TriangleIndices,
|
||||||
.customTransformMatrix = 0
|
CAT1_TRIANGLE_COUNT,
|
||||||
};
|
&cat1Model);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
|
@ -394,13 +394,16 @@ const S3L_Index cat2UVIndices[CAT2_UV_INDEX_COUNT * 3] = {
|
||||||
83, 89, 48 // 339
|
83, 89, 48 // 339
|
||||||
}; // cat2UVIndices
|
}; // cat2UVIndices
|
||||||
|
|
||||||
S3L_Model3D cat2Model =
|
S3L_Model3D cat2Model;
|
||||||
|
|
||||||
|
void cat2ModelInit()
|
||||||
{
|
{
|
||||||
.vertices = cat2Vertices,
|
S3L_initModel3D(
|
||||||
.vertexCount = CAT2_VERTEX_COUNT,
|
cat2Vertices,
|
||||||
.triangles = cat2TriangleIndices,
|
CAT2_VERTEX_COUNT,
|
||||||
.triangleCount = CAT2_TRIANGLE_COUNT,
|
cat2TriangleIndices,
|
||||||
.customTransformMatrix = 0
|
CAT2_TRIANGLE_COUNT,
|
||||||
};
|
&cat2Model);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
|
@ -753,13 +753,16 @@ const S3L_Index chestUVIndices[CHEST_UV_INDEX_COUNT * 3] = {
|
||||||
47, 7, 32 // 693
|
47, 7, 32 // 693
|
||||||
}; // chestUVIndices
|
}; // chestUVIndices
|
||||||
|
|
||||||
S3L_Model3D chestModel =
|
S3L_Model3D chestModel;
|
||||||
|
|
||||||
|
void chestModelInit()
|
||||||
{
|
{
|
||||||
.vertices = chestVertices,
|
S3L_initModel3D(
|
||||||
.vertexCount = CHEST_VERTEX_COUNT,
|
chestVertices,
|
||||||
.triangles = chestTriangleIndices,
|
CHEST_VERTEX_COUNT,
|
||||||
.triangleCount = CHEST_TRIANGLE_COUNT,
|
chestTriangleIndices,
|
||||||
.customTransformMatrix = 0
|
CHEST_TRIANGLE_COUNT,
|
||||||
};
|
&chestModel);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
|
@ -945,13 +945,16 @@ const S3L_Index cityUVIndices[CITY_UV_INDEX_COUNT * 3] = {
|
||||||
372, 376, 373 // 588
|
372, 376, 373 // 588
|
||||||
}; // cityUVIndices
|
}; // cityUVIndices
|
||||||
|
|
||||||
S3L_Model3D cityModel =
|
S3L_Model3D cityModel;
|
||||||
|
|
||||||
|
void cityModelInit()
|
||||||
{
|
{
|
||||||
.vertices = cityVertices,
|
S3L_initModel3D(
|
||||||
.vertexCount = CITY_VERTEX_COUNT,
|
cityVertices,
|
||||||
.triangles = cityTriangleIndices,
|
CITY_VERTEX_COUNT,
|
||||||
.triangleCount = CITY_TRIANGLE_COUNT,
|
cityTriangleIndices,
|
||||||
.customTransformMatrix = 0
|
CITY_TRIANGLE_COUNT,
|
||||||
};
|
&cityModel);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
|
@ -717,13 +717,16 @@ const S3L_Index houseUVIndices[HOUSE_UV_INDEX_COUNT * 3] = {
|
||||||
159, 162, 160 // 597
|
159, 162, 160 // 597
|
||||||
}; // houseUVIndices
|
}; // houseUVIndices
|
||||||
|
|
||||||
S3L_Model3D houseModel =
|
S3L_Model3D houseModel;
|
||||||
|
|
||||||
|
void houseModelInit()
|
||||||
{
|
{
|
||||||
.vertices = houseVertices,
|
S3L_initModel3D(
|
||||||
.vertexCount = HOUSE_VERTEX_COUNT,
|
houseVertices,
|
||||||
.triangles = houseTriangleIndices,
|
HOUSE_VERTEX_COUNT,
|
||||||
.triangleCount = HOUSE_TRIANGLE_COUNT,
|
houseTriangleIndices,
|
||||||
.customTransformMatrix = 0
|
HOUSE_TRIANGLE_COUNT,
|
||||||
};
|
&houseModel);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include "grassNormalTexture.h"
|
#include "grassNormalTexture.h"
|
||||||
#include "sandTexture.h"
|
#include "sandTexture.h"
|
||||||
#include "sandNormalTexture.h"
|
#include "sandNormalTexture.h"
|
||||||
|
#include "treeModel.h"
|
||||||
|
#include "treeTexture.h"
|
||||||
|
|
||||||
uint8_t frameBuffer[S3L_RESOLUTION_X * S3L_RESOLUTION_Y * 3];
|
uint8_t frameBuffer[S3L_RESOLUTION_X * S3L_RESOLUTION_Y * 3];
|
||||||
|
|
||||||
|
@ -53,8 +55,9 @@ float interpolate(float a, float b, float t)
|
||||||
return a * (1.0 - t) + b * t;
|
return a * (1.0 - t) + b * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ISLAND_MODEL_INDEX 0
|
// 0, 1, 2 left for trees
|
||||||
#define WATER_MODEL_INDEX 1 // must be last, for transparency
|
#define ISLAND_MODEL_INDEX 3
|
||||||
|
#define WATER_MODEL_INDEX 4 // must be last, for transparency
|
||||||
#define MODELS_TOTAL (WATER_MODEL_INDEX + 1)
|
#define MODELS_TOTAL (WATER_MODEL_INDEX + 1)
|
||||||
|
|
||||||
#define GRID_TRIANGLES ((GRID_W - 1) * (GRID_H - 1) * 2)
|
#define GRID_TRIANGLES ((GRID_W - 1) * (GRID_H - 1) * 2)
|
||||||
|
@ -67,6 +70,8 @@ S3L_Unit waterNormals[GRID_W * GRID_H * 3];
|
||||||
|
|
||||||
S3L_Index gridTriangles[GRID_TRIANGLES * 3];
|
S3L_Index gridTriangles[GRID_TRIANGLES * 3];
|
||||||
|
|
||||||
|
S3L_Unit treeNormals[TREE_VERTEX_COUNT * 3];
|
||||||
|
|
||||||
S3L_Model3D models[MODELS_TOTAL];
|
S3L_Model3D models[MODELS_TOTAL];
|
||||||
S3L_Scene scene;
|
S3L_Scene scene;
|
||||||
|
|
||||||
|
@ -380,6 +385,16 @@ int main()
|
||||||
|
|
||||||
S3L_normalizeVec3(&toLightDirection);
|
S3L_normalizeVec3(&toLightDirection);
|
||||||
|
|
||||||
|
treeModelInit();
|
||||||
|
|
||||||
|
models[0] = treeModel;
|
||||||
|
models[1] = treeModel;
|
||||||
|
models[2] = treeModel;
|
||||||
|
|
||||||
|
S3L_setTransform3D(0,S3L_FRACTIONS_PER_UNIT * 2,0,0,0,0,S3L_FRACTIONS_PER_UNIT,S3L_FRACTIONS_PER_UNIT,S3L_FRACTIONS_PER_UNIT,&(models[0].transform));
|
||||||
|
S3L_setTransform3D(S3L_FRACTIONS_PER_UNIT,S3L_FRACTIONS_PER_UNIT * 2,0,0,0,0,S3L_FRACTIONS_PER_UNIT,S3L_FRACTIONS_PER_UNIT,S3L_FRACTIONS_PER_UNIT,&(models[1].transform));
|
||||||
|
S3L_setTransform3D(-S3L_FRACTIONS_PER_UNIT,S3L_FRACTIONS_PER_UNIT * 2,0,0,0,0,S3L_FRACTIONS_PER_UNIT,S3L_FRACTIONS_PER_UNIT,S3L_FRACTIONS_PER_UNIT,&(models[2].transform));
|
||||||
|
|
||||||
S3L_initModel3D(
|
S3L_initModel3D(
|
||||||
terrainVertices,
|
terrainVertices,
|
||||||
GRID_W * GRID_H,
|
GRID_W * GRID_H,
|
||||||
|
@ -388,6 +403,7 @@ int main()
|
||||||
&(models[ISLAND_MODEL_INDEX]));
|
&(models[ISLAND_MODEL_INDEX]));
|
||||||
|
|
||||||
S3L_computeModelNormals(models[0],terrainNormals,0);
|
S3L_computeModelNormals(models[0],terrainNormals,0);
|
||||||
|
S3L_computeModelNormals(treeModel,treeNormals,0);
|
||||||
|
|
||||||
S3L_initModel3D(
|
S3L_initModel3D(
|
||||||
waterVertices,
|
waterVertices,
|
||||||
|
@ -400,7 +416,7 @@ int main()
|
||||||
|
|
||||||
char fileName[] = "test00.ppm";
|
char fileName[] = "test00.ppm";
|
||||||
|
|
||||||
for (int i = 0; i < 50; ++i)
|
for (int i = 0; i < 5; ++i) // render the frames
|
||||||
{
|
{
|
||||||
animateWater();
|
animateWater();
|
||||||
|
|
||||||
|
|
|
@ -41,13 +41,16 @@ const S3L_Index plantUVIndices[PLANT_UV_INDEX_COUNT * 3] = {
|
||||||
3, 7, 4 // 9
|
3, 7, 4 // 9
|
||||||
}; // plantUVIndices
|
}; // plantUVIndices
|
||||||
|
|
||||||
S3L_Model3D plantModel =
|
S3L_Model3D plantModel;
|
||||||
|
|
||||||
|
void plantModelInit()
|
||||||
{
|
{
|
||||||
.vertices = plantVertices,
|
S3L_initModel3D(
|
||||||
.vertexCount = PLANT_VERTEX_COUNT,
|
plantVertices,
|
||||||
.triangles = plantTriangleIndices,
|
PLANT_VERTEX_COUNT,
|
||||||
.triangleCount = PLANT_TRIANGLE_COUNT,
|
plantTriangleIndices,
|
||||||
.customTransformMatrix = 0
|
PLANT_TRIANGLE_COUNT,
|
||||||
};
|
&plantModel);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
200
programs/treeModel.h
Normal file
200
programs/treeModel.h
Normal file
|
@ -0,0 +1,200 @@
|
||||||
|
#ifndef TREE_MODEL_H
|
||||||
|
#define TREE_MODEL_H
|
||||||
|
|
||||||
|
#define TREE_VERTEX_COUNT 29
|
||||||
|
const S3L_Unit treeVertices[TREE_VERTEX_COUNT * 3] = {
|
||||||
|
-405, 333, 436, // 0
|
||||||
|
-279, 391, -162, // 3
|
||||||
|
-210, 1196, -77, // 6
|
||||||
|
-182, 1351, 276, // 9
|
||||||
|
300, -235, 884, // 12
|
||||||
|
175, 458, 466, // 15
|
||||||
|
323, 456, -89, // 18
|
||||||
|
799, -149, -292, // 21
|
||||||
|
-377, -35, -757, // 24
|
||||||
|
-796, -197, 418, // 27
|
||||||
|
112, 1210, -203, // 30
|
||||||
|
329, 1710, -420, // 33
|
||||||
|
-444, 1833, -237, // 36
|
||||||
|
224, 1289, 169, // 39
|
||||||
|
-129, 2307, -1354, // 42
|
||||||
|
388, 1640, 328, // 45
|
||||||
|
-176, 1684, 369, // 48
|
||||||
|
1428, 1950, -138, // 51
|
||||||
|
-1254, 2185, 279, // 54
|
||||||
|
237, 1961, 1274, // 57
|
||||||
|
843, 2065, -1083, // 60
|
||||||
|
366, 3590, 1466, // 63
|
||||||
|
1533, 3256, -257, // 66
|
||||||
|
1256, 2031, 799, // 69
|
||||||
|
-745, 2083, 1179, // 72
|
||||||
|
-1320, 3489, 438, // 75
|
||||||
|
-1176, 2393, -744, // 78
|
||||||
|
-119, 3625, -1383, // 81
|
||||||
|
242, 4350, 183 // 84
|
||||||
|
}; // treeVertices
|
||||||
|
|
||||||
|
#define TREE_TRIANGLE_COUNT 52
|
||||||
|
const S3L_Index treeTriangleIndices[TREE_TRIANGLE_COUNT * 3] = {
|
||||||
|
0, 2, 3, // 0
|
||||||
|
5, 7, 4, // 3
|
||||||
|
6, 8, 7, // 6
|
||||||
|
1, 9, 8, // 9
|
||||||
|
4, 0, 5, // 12
|
||||||
|
10, 12, 2, // 15
|
||||||
|
5, 3, 13, // 18
|
||||||
|
1, 10, 2, // 21
|
||||||
|
6, 13, 10, // 24
|
||||||
|
12, 11, 14, // 27
|
||||||
|
13, 11, 10, // 30
|
||||||
|
3, 12, 16, // 33
|
||||||
|
13, 16, 15, // 36
|
||||||
|
11, 15, 17, // 39
|
||||||
|
16, 12, 18, // 42
|
||||||
|
16, 19, 15, // 45
|
||||||
|
17, 20, 11, // 48
|
||||||
|
21, 22, 23, // 51
|
||||||
|
19, 23, 15, // 54
|
||||||
|
21, 24, 25, // 57
|
||||||
|
16, 18, 24, // 60
|
||||||
|
25, 26, 27, // 63
|
||||||
|
12, 14, 26, // 66
|
||||||
|
22, 27, 20, // 69
|
||||||
|
27, 22, 28, // 72
|
||||||
|
22, 21, 28, // 75
|
||||||
|
25, 28, 21, // 78
|
||||||
|
27, 28, 25, // 81
|
||||||
|
20, 14, 11, // 84
|
||||||
|
27, 14, 20, // 87
|
||||||
|
26, 14, 27, // 90
|
||||||
|
23, 17, 15, // 93
|
||||||
|
22, 17, 23, // 96
|
||||||
|
20, 17, 22, // 99
|
||||||
|
16, 24, 19, // 102
|
||||||
|
21, 19, 24, // 105
|
||||||
|
23, 19, 21, // 108
|
||||||
|
12, 26, 18, // 111
|
||||||
|
25, 18, 26, // 114
|
||||||
|
24, 18, 25, // 117
|
||||||
|
0, 1, 2, // 120
|
||||||
|
5, 6, 7, // 123
|
||||||
|
6, 1, 8, // 126
|
||||||
|
1, 0, 9, // 129
|
||||||
|
4, 9, 0, // 132
|
||||||
|
10, 11, 12, // 135
|
||||||
|
5, 0, 3, // 138
|
||||||
|
1, 6, 10, // 141
|
||||||
|
6, 5, 13, // 144
|
||||||
|
13, 15, 11, // 147
|
||||||
|
3, 2, 12, // 150
|
||||||
|
13, 3, 16 // 153
|
||||||
|
}; // treeTriangleIndices
|
||||||
|
|
||||||
|
#define TREE_UV_COUNT 35
|
||||||
|
const S3L_Unit treeUVs[TREE_UV_COUNT * 2] = {
|
||||||
|
133, 397, // 0
|
||||||
|
228, 338, // 2
|
||||||
|
125, 335, // 4
|
||||||
|
489, 390, // 6
|
||||||
|
355, 489, // 8
|
||||||
|
493, 487, // 10
|
||||||
|
353, 401, // 12
|
||||||
|
234, 487, // 14
|
||||||
|
230, 399, // 16
|
||||||
|
132, 486, // 18
|
||||||
|
26, 491, // 20
|
||||||
|
26, 389, // 22
|
||||||
|
352, 333, // 24
|
||||||
|
221, 283, // 26
|
||||||
|
23, 327, // 28
|
||||||
|
488, 321, // 30
|
||||||
|
346, 287, // 32
|
||||||
|
260, 212, // 34
|
||||||
|
109, 271, // 36
|
||||||
|
22, 261, // 38
|
||||||
|
490, 270, // 40
|
||||||
|
385, 211, // 42
|
||||||
|
151, 206, // 44
|
||||||
|
17, 170, // 46
|
||||||
|
312, 209, // 48
|
||||||
|
491, 23, // 50
|
||||||
|
359, 85, // 52
|
||||||
|
430, 158, // 54
|
||||||
|
493, 193, // 56
|
||||||
|
23, 25, // 58
|
||||||
|
93, 172, // 60
|
||||||
|
141, 91, // 62
|
||||||
|
201, 199, // 64
|
||||||
|
256, 88, // 66
|
||||||
|
256, 17 // 68
|
||||||
|
}; // treeUVs
|
||||||
|
|
||||||
|
#define TREE_UV_INDEX_COUNT 52
|
||||||
|
const S3L_Index treeUVIndices[TREE_UV_INDEX_COUNT * 3] = {
|
||||||
|
0, 1, 2, // 0
|
||||||
|
3, 4, 5, // 3
|
||||||
|
6, 7, 4, // 6
|
||||||
|
8, 9, 7, // 9
|
||||||
|
10, 0, 11, // 12
|
||||||
|
12, 13, 1, // 15
|
||||||
|
11, 2, 14, // 18
|
||||||
|
8, 12, 1, // 21
|
||||||
|
6, 15, 12, // 24
|
||||||
|
13, 16, 17, // 27
|
||||||
|
15, 16, 12, // 30
|
||||||
|
2, 13, 18, // 33
|
||||||
|
14, 18, 19, // 36
|
||||||
|
16, 20, 21, // 39
|
||||||
|
18, 13, 22, // 42
|
||||||
|
18, 23, 19, // 45
|
||||||
|
21, 24, 16, // 48
|
||||||
|
25, 26, 27, // 51
|
||||||
|
28, 27, 20, // 54
|
||||||
|
29, 30, 31, // 57
|
||||||
|
18, 22, 30, // 60
|
||||||
|
31, 32, 33, // 63
|
||||||
|
13, 17, 32, // 66
|
||||||
|
26, 33, 24, // 69
|
||||||
|
33, 26, 34, // 72
|
||||||
|
26, 25, 34, // 75
|
||||||
|
31, 34, 29, // 78
|
||||||
|
33, 34, 31, // 81
|
||||||
|
24, 17, 16, // 84
|
||||||
|
33, 17, 24, // 87
|
||||||
|
32, 17, 33, // 90
|
||||||
|
27, 21, 20, // 93
|
||||||
|
26, 21, 27, // 96
|
||||||
|
24, 21, 26, // 99
|
||||||
|
18, 30, 23, // 102
|
||||||
|
29, 23, 30, // 105
|
||||||
|
27, 28, 25, // 108
|
||||||
|
13, 32, 22, // 111
|
||||||
|
31, 22, 32, // 114
|
||||||
|
30, 22, 31, // 117
|
||||||
|
0, 8, 1, // 120
|
||||||
|
3, 6, 4, // 123
|
||||||
|
6, 8, 7, // 126
|
||||||
|
8, 0, 9, // 129
|
||||||
|
10, 9, 0, // 132
|
||||||
|
12, 16, 13, // 135
|
||||||
|
11, 0, 2, // 138
|
||||||
|
8, 6, 12, // 141
|
||||||
|
6, 3, 15, // 144
|
||||||
|
15, 20, 16, // 147
|
||||||
|
2, 1, 13, // 150
|
||||||
|
14, 2, 18 // 153
|
||||||
|
}; // treeUVIndices
|
||||||
|
|
||||||
|
S3L_Model3D treeModel;
|
||||||
|
|
||||||
|
void treeModelInit()
|
||||||
|
{
|
||||||
|
S3L_initModel3D(
|
||||||
|
treeVertices,
|
||||||
|
TREE_VERTEX_COUNT,
|
||||||
|
treeTriangleIndices,
|
||||||
|
TREE_TRIANGLE_COUNT,
|
||||||
|
&treeModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // guard
|
2146
programs/treeTexture.h
Normal file
2146
programs/treeTexture.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -179,21 +179,17 @@ else:
|
||||||
print("#define " + NAME.upper() + "_DIRECT_UV_COUNT " + str(len(uvs2)))
|
print("#define " + NAME.upper() + "_DIRECT_UV_COUNT " + str(len(uvs2)))
|
||||||
print(arrayString(NAME + "DirectUVs",uvs2,6,[U_SCALE,V_SCALE],5,False,"S3L_Unit",NAME.upper() + "_DIRECT_UV_COUNT * 6"))
|
print(arrayString(NAME + "DirectUVs",uvs2,6,[U_SCALE,V_SCALE],5,False,"S3L_Unit",NAME.upper() + "_DIRECT_UV_COUNT * 6"))
|
||||||
|
|
||||||
print("S3L_Model3D " + NAME + "Model = ")
|
print("S3L_Model3D " + NAME + "Model;\n")
|
||||||
|
|
||||||
if COMPACT:
|
print("void " + NAME + "ModelInit()")
|
||||||
print("{.vertices=" +
|
print("{")
|
||||||
NAME + "Vertices,.vertexCount=" + str(len(vertices)) +
|
print(" S3L_initModel3D(")
|
||||||
",.triangles=" + NAME.upper() + "TriangleIndices,\n.triangleCount=" +
|
print(" " + NAME + "Vertices,")
|
||||||
str(len(triangles)) + ",.customTransformMatrix=0};");
|
print(" " + NAME.upper() + "_VERTEX_COUNT,")
|
||||||
else:
|
print(" " + NAME + "TriangleIndices,")
|
||||||
print("{")
|
print(" " + NAME.upper() + "_TRIANGLE_COUNT,")
|
||||||
print(" .vertices = " + NAME + "Vertices,")
|
print(" &" + NAME + "Model);")
|
||||||
print(" .vertexCount = " + NAME.upper() + "_VERTEX_COUNT,")
|
print("}")
|
||||||
print(" .triangles = " + NAME + "TriangleIndices,")
|
|
||||||
print(" .triangleCount = " + NAME.upper() + "_TRIANGLE_COUNT,")
|
|
||||||
print(" .customTransformMatrix = 0")
|
|
||||||
print("};")
|
|
||||||
|
|
||||||
if GUARDS:
|
if GUARDS:
|
||||||
print("\n#endif // guard")
|
print("\n#endif // guard")
|
||||||
|
|
Loading…
Reference in a new issue