diff options
author | nathan <nathansmith@disroot.org> | 2025-08-06 12:43:37 +0000 |
---|---|---|
committer | nathan <nathansmith@disroot.org> | 2025-08-06 12:43:37 +0000 |
commit | 94ca30b13bffe1f02313b7fd32b2320e5c490fa5 (patch) | |
tree | 5019ec84a0c39fd2e38a11d03672e2ccdef6020d | |
parent | c5989ca9bcc1758f4d772d20b8bd4ae7762bc75e (diff) | |
download | FindThings-94ca30b13bffe1f02313b7fd32b2320e5c490fa5.tar.gz FindThings-94ca30b13bffe1f02313b7fd32b2320e5c490fa5.tar.bz2 FindThings-94ca30b13bffe1f02313b7fd32b2320e5c490fa5.zip |
UGGGGG
-rw-r--r-- | assets/images/bush.png (renamed from assets/bush.png) | bin | 12123 -> 12123 bytes | |||
-rw-r--r-- | assets/images/flower.png (renamed from assets/flower.png) | bin | 2561 -> 2561 bytes | |||
-rw-r--r-- | assets/images/mint.png (renamed from assets/mint.png) | bin | 2581 -> 2581 bytes | |||
-rw-r--r-- | assets/images/nickel.png (renamed from assets/nickel.png) | bin | 2372 -> 2372 bytes | |||
-rw-r--r-- | assets/images/skybox.png (renamed from assets/skybox.png) | bin | 11307 -> 11307 bytes | |||
-rw-r--r-- | assets/images/tree.png (renamed from assets/tree.png) | bin | 55810 -> 55810 bytes | |||
-rw-r--r-- | assets/models/UtilityPole.mtl | 2 | ||||
-rw-r--r-- | assets/models/UtilityPole.obj | 71 | ||||
-rw-r--r-- | src/assets.c | 20 | ||||
-rw-r--r-- | src/assets.h | 8 | ||||
-rw-r--r-- | src/entity.c | 8 | ||||
-rw-r--r-- | src/world.c | 8 | ||||
-rw-r--r-- | src/world.h | 6 |
13 files changed, 116 insertions, 7 deletions
diff --git a/assets/bush.png b/assets/images/bush.png Binary files differindex 2d46b4c..2d46b4c 100644 --- a/assets/bush.png +++ b/assets/images/bush.png diff --git a/assets/flower.png b/assets/images/flower.png Binary files differindex 09685a6..09685a6 100644 --- a/assets/flower.png +++ b/assets/images/flower.png diff --git a/assets/mint.png b/assets/images/mint.png Binary files differindex 013c13f..013c13f 100644 --- a/assets/mint.png +++ b/assets/images/mint.png diff --git a/assets/nickel.png b/assets/images/nickel.png Binary files differindex bdb5dc8..bdb5dc8 100644 --- a/assets/nickel.png +++ b/assets/images/nickel.png diff --git a/assets/skybox.png b/assets/images/skybox.png Binary files differindex 6bc64c2..6bc64c2 100644 --- a/assets/skybox.png +++ b/assets/images/skybox.png diff --git a/assets/tree.png b/assets/images/tree.png Binary files differindex 30d3fa9..30d3fa9 100644 --- a/assets/tree.png +++ b/assets/images/tree.png diff --git a/assets/models/UtilityPole.mtl b/assets/models/UtilityPole.mtl new file mode 100644 index 0000000..7ec6792 --- /dev/null +++ b/assets/models/UtilityPole.mtl @@ -0,0 +1,2 @@ +# Blender 4.4.3 MTL File: 'None' +# www.blender.org diff --git a/assets/models/UtilityPole.obj b/assets/models/UtilityPole.obj new file mode 100644 index 0000000..83cf6ae --- /dev/null +++ b/assets/models/UtilityPole.obj @@ -0,0 +1,71 @@ +# Blender 4.4.3 +# www.blender.org +mtllib UtilityPole.mtl +o UtilityPole +v 0.000000 -20.000000 -1.000000 +v 0.000000 20.000000 -1.000000 +v 0.866025 -20.000000 -0.500000 +v 0.866025 20.000000 -0.500000 +v 0.866025 -20.000000 0.500000 +v 0.866025 20.000000 0.500000 +v 0.000000 -20.000000 1.000000 +v 0.000000 20.000000 1.000000 +v -0.866025 -20.000000 0.500000 +v -0.866025 20.000000 0.500000 +v -0.866025 -20.000000 -0.500000 +v -0.866025 20.000000 -0.500000 +vn 0.5000 -0.0000 -0.8660 +vn 1.0000 -0.0000 -0.0000 +vn 0.5000 -0.0000 0.8660 +vn -0.5000 -0.0000 0.8660 +vn -0.0000 1.0000 -0.0000 +vn -1.0000 -0.0000 -0.0000 +vn -0.5000 -0.0000 -0.8660 +vn -0.0000 -1.0000 -0.0000 +vt 1.000000 1.000000 +vt 0.833333 0.500000 +vt 1.000000 0.500000 +vt 0.833333 1.000000 +vt 0.666667 0.500000 +vt 0.666667 1.000000 +vt 0.500000 0.500000 +vt 0.500000 1.000000 +vt 0.333333 0.500000 +vt 0.250000 0.490000 +vt 0.042154 0.130000 +vt 0.457846 0.130000 +vt 0.333333 1.000000 +vt 0.166667 0.500000 +vt 0.166667 1.000000 +vt -0.000000 0.500000 +vt 0.957846 0.370000 +vt 0.750000 0.010000 +vt 0.542154 0.370000 +vt 0.457846 0.370000 +vt 0.042154 0.370000 +vt 0.250000 0.010000 +vt -0.000000 1.000000 +vt 0.750000 0.490000 +vt 0.957846 0.130000 +vt 0.542154 0.130000 +s 0 +f 2/1/1 3/2/1 1/3/1 +f 4/4/2 5/5/2 3/2/2 +f 6/6/3 7/7/3 5/5/3 +f 8/8/4 9/9/4 7/7/4 +f 2/10/5 10/11/5 6/12/5 +f 10/13/6 11/14/6 9/9/6 +f 12/15/7 1/16/7 11/14/7 +f 3/17/8 7/18/8 11/19/8 +f 2/1/1 4/4/1 3/2/1 +f 4/4/2 6/6/2 5/5/2 +f 6/6/3 8/8/3 7/7/3 +f 8/8/4 10/13/4 9/9/4 +f 6/12/5 4/20/5 2/10/5 +f 2/10/5 12/21/5 10/11/5 +f 10/11/5 8/22/5 6/12/5 +f 10/13/6 12/15/6 11/14/6 +f 12/15/7 2/23/7 1/16/7 +f 11/19/8 1/24/8 3/17/8 +f 3/17/8 5/25/8 7/18/8 +f 7/18/8 9/26/8 11/19/8 diff --git a/src/assets.c b/src/assets.c index 2ceff83..09388b8 100644 --- a/src/assets.c +++ b/src/assets.c @@ -16,20 +16,24 @@ const char shaderAssetNames[SHADER_ASSET_COUNT][FT_NAMEMAX] = { "skybox" }; +const char modelAssetPaths[MODEL_ASSET_COUNT][FT_NAMEMAX] = { + "UtilityPole.obj" +}; + void initAssets(Assets* assets) { // Textures. for (int index = 0; index < TEXTURE_ASSET_COUNT; ++index) { assets->textures[index] = LoadTexture( - TextFormat("assets/%s", textureAssetPaths[index])); + TextFormat("assets/images/%s", textureAssetPaths[index])); } // Images; for (int index = 0; index < IMAGE_ASSET_COUNT; ++index) { assets->images[index] = LoadImage( - TextFormat("assets/%s", imageAssetPaths[index])); + TextFormat("assets/images/%s", imageAssetPaths[index])); } // Shaders. @@ -41,6 +45,13 @@ void initAssets(Assets* assets) TextFormat("assets/shaders/glsl%i/%s.fs", GLSL_VERSION, shaderAssetNames[index])); } + + // Models. + for (int index = 0; index < MODEL_ASSET_COUNT; ++index) + { + assets->models[index] = LoadModel( + TextFormat("assets/models/%s", modelAssetPaths[index])); + } } void closeAssets(Assets* assets) @@ -59,4 +70,9 @@ void closeAssets(Assets* assets) { UnloadShader(assets->shaders[index]); } + + for (int index = 0; index < MODEL_ASSET_COUNT; ++index) + { + UnloadModel(assets->models[index]); + } } diff --git a/src/assets.h b/src/assets.h index 743926c..2457115 100644 --- a/src/assets.h +++ b/src/assets.h @@ -6,10 +6,12 @@ #define TEXTURE_ASSET_COUNT 5 #define IMAGE_ASSET_COUNT 1 #define SHADER_ASSET_COUNT 1 +#define MODEL_ASSET_COUNT 1 extern const char textureAssetPaths[TEXTURE_ASSET_COUNT][FT_NAMEMAX]; extern const char imageAssetPaths[IMAGE_ASSET_COUNT][FT_NAMEMAX]; extern const char shaderAssetNames[SHADER_ASSET_COUNT][FT_NAMEMAX]; +extern const char modelAssetPaths[MODEL_ASSET_COUNT][FT_NAMEMAX]; typedef int8_t AssetId; @@ -32,10 +34,16 @@ enum { SKYBOX_SHADER }; +// Model asset ids. +enum { + UTILITY_POLE_MODEL +}; + typedef struct { Texture textures[TEXTURE_ASSET_COUNT]; Image images[IMAGE_ASSET_COUNT]; Shader shaders[SHADER_ASSET_COUNT]; + Model models[MODEL_ASSET_COUNT]; } Assets; void initAssets(Assets* assets); diff --git a/src/entity.c b/src/entity.c index f9f7989..c63acf4 100644 --- a/src/entity.c +++ b/src/entity.c @@ -91,10 +91,10 @@ void updateEntity(Entity* entity, Game* game) (Vector2){POND_SIZE * 2.5, POND_SIZE * 2.5}, BLUE); break; case UTILITY_POLE: - DrawCylinder(Vector3Subtract(entity->position, - (Vector3){0.0, UTILITY_POLE_HEIGHT}), - UTILITY_POLE_RADIUS, UTILITY_POLE_RADIUS, - UTILITY_POLE_HEIGHT * 2.0, 6, BROWN); + /* DrawCylinder(Vector3Subtract(entity->position, */ + /* (Vector3){0.0, UTILITY_POLE_HEIGHT}), */ + /* UTILITY_POLE_RADIUS, UTILITY_POLE_RADIUS, */ + /* UTILITY_POLE_HEIGHT * 2.0, 6, BROWN); */ break; default: break; diff --git a/src/world.c b/src/world.c index 1d0aa10..828aaa3 100644 --- a/src/world.c +++ b/src/world.c @@ -482,6 +482,9 @@ Seed generateWorldUtilityPoles(World* world, Seed seed, int start, int end) Entity entity = createEntity(UTILITY_POLE, Vector3Zero()); seed = putEntityInRandomPlace(world, seed, &entity); world->entities[index] = entity; + + world->utilityPoleTransforms[index - start] = MatrixTranslate( + entity.position.x, entity.position.y, entity.position.z); } return seed; @@ -614,6 +617,11 @@ void updateWorld(World* world, Game* game) updateEntity(&world->entities[index], game); } + DrawMeshInstanced(game->assets.models[UTILITY_POLE_MODEL].meshes[0], + game->assets.models[UTILITY_POLE_MODEL].materials[0], + world->utilityPoleTransforms, + WORLD_UTILITY_POLE_COUNT); + // Draw BVH leafs. #ifdef FT_DEBUG_MODE if (IsKeyPressed(KEY_RIGHT)) diff --git a/src/world.h b/src/world.h index 1d7dd72..fc84ca3 100644 --- a/src/world.h +++ b/src/world.h @@ -52,9 +52,13 @@ struct World { Vector3 size; Texture heightmapTexture; Model heightmap; + Entity entities[WORLD_ENTITY_MAX]; - BVHNode bvh; WorldUID places[WORLD_PLACE_COUNT]; + BVHNode bvh; + + // Transforms for mesh instancing. + Matrix utilityPoleTransforms[WORLD_UTILITY_POLE_COUNT]; int bvhDebugSelect; }; |