My first Blender model- Acorn
This commit is contained in:
39
main.c
39
main.c
@@ -6,7 +6,7 @@
|
||||
#include "stdlib.h"
|
||||
#include "stdint.h"
|
||||
#include "rlgl.h"
|
||||
#include <float.h> // for FLT_MAX
|
||||
#include "float.h"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Defines and Macros
|
||||
@@ -183,6 +183,11 @@ int main(void)
|
||||
float wall_pitch = 0.0f; // rotate around X
|
||||
float wall_roll = 0.0f; // rotate around Z
|
||||
|
||||
Model acorn = LoadModel("resources/3d_models/my_models/my_acorn.glb");
|
||||
Vector3 acorn_position = { 0.0f, 0.0f, 0.0f };
|
||||
float acorn_yaw = 0.0f; // rotate around Y
|
||||
float acorn_pitch = 0.0f; // rotate around X
|
||||
float acorn_roll = 0.0f; // rotate around Z
|
||||
|
||||
// Load a 2D image as texture for the billboard
|
||||
//Billboards always point toward the active camera.
|
||||
@@ -277,6 +282,7 @@ int main(void)
|
||||
|
||||
//Apply shader to wall
|
||||
ApplyFogShaderToModel(&wall, fog);
|
||||
ApplyFogShaderToModel(&acorn, fog);
|
||||
|
||||
// Defaults for opaque geometry (no alpha cut)
|
||||
float cutoffOpaque = 0.0f;
|
||||
@@ -293,7 +299,7 @@ int main(void)
|
||||
float spotAngleDeg = 35.0f; //cone angle
|
||||
float spotCos = cosf(DEG2RAD * (spotAngleDeg * 0.5f));
|
||||
float spotSoft = 0.10f;
|
||||
float lightRange = 100.0f;
|
||||
float lightRange = 150.0f;//100.0f;
|
||||
float lightFade = 1.0f;
|
||||
float intensity = 0.25f; // try 0.7–1.5 to taste
|
||||
float beamSpread = 0.05f; // try 0.15–0.35; higher = less “laser” at distance
|
||||
@@ -371,14 +377,14 @@ int main(void)
|
||||
UpdateBody(&g, g.player.lookRotation.x, sideway, forward, IsKeyDown(KEY_SPACE), crouching);
|
||||
|
||||
// Build wall collider (scale must match your DrawModelEx scale)
|
||||
BoundingBox wallBox = MakeModelWorldAABB(wall, wall_position, (Vector3){5,5,5}, wall_yaw);
|
||||
BoundingBox acornBox = MakeModelWorldAABB(acorn, acorn_position, (Vector3){0.25,0.25,0.25}, acorn_yaw);
|
||||
|
||||
// Collide player vs wall (XZ slide)
|
||||
ResolveAgainstBoxXZ(&g, wallBox);
|
||||
ResolveAgainstBoxXZ(&g, acornBox);
|
||||
|
||||
|
||||
// put near your update logic
|
||||
float B = 123;
|
||||
float B = 122;
|
||||
float T = 1.0f; // wall half-thickness
|
||||
float H = 4.0f; // wall height
|
||||
|
||||
@@ -431,17 +437,17 @@ int main(void)
|
||||
|
||||
|
||||
// wall editor
|
||||
if (IsKeyDown(KEY_RIGHT) && IsKeyDown(KEY_LEFT_SHIFT)) wall_position.x += 0.5f;
|
||||
else if (IsKeyPressed(KEY_RIGHT)) wall_position.x += 0.5f;
|
||||
if (IsKeyDown(KEY_RIGHT) && IsKeyDown(KEY_LEFT_SHIFT)) acorn_position.x += 0.5f;
|
||||
else if (IsKeyPressed(KEY_RIGHT)) acorn_position.x += 0.5f;
|
||||
|
||||
if (IsKeyDown(KEY_LEFT) && IsKeyDown(KEY_LEFT_SHIFT)) wall_position.x -= 0.5f;
|
||||
else if (IsKeyPressed(KEY_LEFT)) wall_position.x -= 0.5f;
|
||||
if (IsKeyDown(KEY_LEFT) && IsKeyDown(KEY_LEFT_SHIFT)) acorn_position.x -= 0.5f;
|
||||
else if (IsKeyPressed(KEY_LEFT)) acorn_position.x -= 0.5f;
|
||||
|
||||
if (IsKeyDown(KEY_UP) && IsKeyDown(KEY_LEFT_SHIFT)) wall_position.z += 0.5f;
|
||||
else if (IsKeyPressed(KEY_UP)) wall_position.z += 0.5f;
|
||||
if (IsKeyDown(KEY_UP) && IsKeyDown(KEY_LEFT_SHIFT)) acorn_position.z += 0.5f;
|
||||
else if (IsKeyPressed(KEY_UP)) acorn_position.z += 0.5f;
|
||||
|
||||
if (IsKeyDown(KEY_DOWN) && IsKeyDown(KEY_LEFT_SHIFT)) wall_position.z -= 0.5f;
|
||||
else if (IsKeyPressed(KEY_DOWN)) wall_position.z -= 0.5f;
|
||||
if (IsKeyDown(KEY_DOWN) && IsKeyDown(KEY_LEFT_SHIFT)) acorn_position.z -= 0.5f;
|
||||
else if (IsKeyPressed(KEY_DOWN)) acorn_position.z -= 0.5f;
|
||||
|
||||
|
||||
|
||||
@@ -509,11 +515,11 @@ int main(void)
|
||||
BeginShaderMode(fog);
|
||||
|
||||
//DrawModel(wall, wall_position, 5.0, WHITE);
|
||||
DrawModelEx(wall, wall_position, (Vector3){0,1,0}, wall_yaw, (Vector3){5,5,5}, WHITE);
|
||||
DrawModelEx(acorn, acorn_position, (Vector3){0,1,0}, wall_yaw, (Vector3){0.25,0.25,0.25}, WHITE);
|
||||
RenderTrees(&g, tree, treepos, treeSize);
|
||||
//DrawBillboard(g.player.camera, sign, bbPos, bbSize, WHITE); //zombie
|
||||
|
||||
DrawPerimeter(wall, 123.0f, 1.5f);
|
||||
DrawPerimeter(wall, 122.0f, 1.5f);
|
||||
|
||||
EndShaderMode();
|
||||
|
||||
@@ -554,6 +560,7 @@ int main(void)
|
||||
UnloadTexture(tree); // frees tree texture
|
||||
UnloadTexture(sign);
|
||||
UnloadModel(wall);
|
||||
UnloadModel(acorn);
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -810,7 +817,7 @@ static inline void DrawTreeBillboardStable(Camera cam, Texture2D tex, Vector3 gr
|
||||
|
||||
static void RenderTrees(Master* g, Texture2D tree, Vector3 baseTreePos, float treeSize)
|
||||
{
|
||||
const int floorExtent = FLOOR_EXTENT;
|
||||
const int floorExtent = FLOOR_EXTENT - 3;
|
||||
const float tileSize = TILE_SIZE;
|
||||
|
||||
// Placement knobs
|
||||
|
||||
Reference in New Issue
Block a user