aboutsummaryrefslogtreecommitdiffstats
path: root/src/world.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c58
1 files changed, 56 insertions, 2 deletions
diff --git a/src/world.c b/src/world.c
index fa676c8..19c2354 100644
--- a/src/world.c
+++ b/src/world.c
@@ -489,6 +489,19 @@ Vector3 utilityPoleIndexToPosition(int index, const World* world)
return position;
}
+// TODO: make the thing work
+void getUtilityPoleLinePositions(Vector3 position,
+ Vector3 output[UTILITY_LINE_COUNT])
+{
+ Vector3 positions[UTILITY_LINE_COUNT] = {
+ (Vector3){40.4336, -4.18579, 98.288},
+ (Vector3){40.4336, -4.18579, 82.729},
+ (Vector3){-40.4335, -4.18579, 98.288},
+ (Vector3){-40.4336, -4.18579, 82.729}
+ };
+}
+
+// TODO: UGGGGG HEADACHES. THIS IS SIMPLE BUT HEADACHES MAKE THINGS HARD.
Seed generateWorldUtilityPoles(World* world, const Assets* assets, Seed seed,
int start, int end)
{
@@ -496,6 +509,13 @@ Seed generateWorldUtilityPoles(World* world, const Assets* assets, Seed seed,
assets->shaders[INSTANCING_SHADER];
assets->models[UTILITY_POLE_MODEL].materials[0]
.maps[MATERIAL_MAP_DIFFUSE].color = BROWN;
+
+ Vector3 linePositions[UTILITY_LINE_COUNT] = {
+ (Vector3){40.4336, -4.18579, 98.288},
+ (Vector3){40.4336, -4.18579, 82.729},
+ (Vector3){-40.4335, -4.18579, 98.288},
+ (Vector3){-40.4336, -4.18579, 82.729}
+ };
for (int index = start; index < end; ++index)
{
@@ -513,8 +533,9 @@ Seed generateWorldUtilityPoles(World* world, const Assets* assets, Seed seed,
world);
Matrix lookat = MatrixLookAt(position, nextPosition,
(Vector3){0.0, 1.0, 0.0});
- // Hack for it to not effect position. Likely this isn't in a update look.
- lookat = QuaternionToMatrix(QuaternionFromMatrix(MatrixInvert(lookat)));
+ Quaternion rotation = QuaternionFromMatrix(MatrixInvert(lookat));
+ // Hack for it to not effect position. Luckily this isn't in a update look.
+ lookat = QuaternionToMatrix(rotation);
// Add pole to instancing data.
Matrix translation = MatrixTranslate(entity.position.x,
@@ -522,11 +543,43 @@ Seed generateWorldUtilityPoles(World* world, const Assets* assets, Seed seed,
entity.position.z);
Matrix matrix = MatrixMultiply(lookat, translation);
world->utilityPoleTransforms[index - start] = matrix;
+
+ // Get next position height for use of line creation.
+ nextPosition.y = getWorldHeightAtLocation(world, nextPosition.x,
+ nextPosition.z);
+
+ // Create lines.
+ UtilityPoleLines lines;
+
+ for (int lineIndex = 0; lineIndex < UTILITY_LINE_COUNT; ++lineIndex)
+ {
+ Vector3 linePosition = Vector3RotateByQuaternion(
+ linePositions[lineIndex], rotation);
+
+ lines[lineIndex].start = Vector3Add(entity.position, linePosition);
+ lines[lineIndex].end = Vector3Add(nextPosition, linePosition);
+ }
+
+ memcpy(&world->utilityPoleLines[index - start], &lines,
+ sizeof(UtilityPoleLines));
}
return seed;
}
+void drawUtilityPoleLines(const World* world)
+{
+ for (int index = 0; index < WORLD_UTILITY_POLE_COUNT; ++index)
+ {
+ for (int innerIndex = 0; innerIndex < UTILITY_LINE_COUNT; ++innerIndex)
+ {
+ DrawLine3D(world->utilityPoleLines[index][innerIndex].start,
+ world->utilityPoleLines[index][innerIndex].end,
+ BLACK);
+ }
+ }
+}
+
Seed generateWorldItems(World* world, Seed seed, int start, int end)
{
for (int index = start; index < end; ++index)
@@ -658,6 +711,7 @@ void updateWorld(World* world, Game* game)
game->assets.models[UTILITY_POLE_MODEL].materials[0],
world->utilityPoleTransforms,
WORLD_UTILITY_POLE_COUNT);
+ drawUtilityPoleLines(world);
// Draw BVH leafs.
#ifdef FT_DEBUG_MODE