Vector2 fscreen_dims;
Camera3D cam;
+Vector3 cam_reset_position;
Image barrow_image;
Texture barrow_texture;
Texture barrow_albedo;
Vector3 barrow_position;
// Dead center of the barrow, used for camera spawn etc
-Vector3 barrow_center;
+Vector3 map_center;
// Scale factor from image -> model
Vector3 barrow_scale_factor;
+Vector3 floor_scale_factor;
// Scaled dimensions of the barrow, barrow_scale_factor applied
-Vector3 barrow_size;
+Vector3 barrow_extent;
Vector3 barrow_rotation_axis;
float barrow_rotation;
Model floor_model;
Mesh floor_meshes[1U];
Vector3 floor_position;
-Vector3 floor_size;
+Vector3 floor_extent;
Vector3 floor_rotation_axis;
float floor_rotation;
Vector3 orb_directionality = {1.0f, 1.0f, 1.0f};
int map_visible = 0;
-int draw_barrow = 1;
+int draw_collision_mesh = 1;
typedef void(*renderfunc)();
typedef void(*controlfunc)();
BeginMode3D(cam);
BeginShaderMode(shader);
- if (draw_barrow)
+ DrawModelEx(floor_model, floor_position, floor_rotation_axis, floor_rotation, floor_extent, DARKGRAY);
+ DrawModelEx(barrow_model, barrow_position, barrow_rotation_axis, barrow_rotation, barrow_extent, DARKGRAY);
+ if (draw_collision_mesh)
{
- DrawModelEx(floor_model, floor_position, floor_rotation_axis, floor_rotation, floor_size, DARKGRAY);
- DrawModelEx(barrow_model, barrow_position, barrow_rotation_axis, barrow_rotation, barrow_size, DARKGRAY);
+ //DrawMesh(barrow_model.meshes[0], barrow_model.materials[0], barrow_mat);
}
for (int n = 0; n < room_count; n++)
{
Vector3 each = room_positions[n];
- DrawSphere(each, 0.25, RED);
+ DrawSphere(each, 1.0, RED);
}
+ DrawSphere(map_center, 1.0, BLUE);
+ DrawSphere(barrow_position, 1.0, GREEN);
+ DrawSphere(floor_position, 1.0, PURPLE);
for (int n = 0; n < spawn_spoke_count; n++)
{
DrawText(TextFormat(V3_FORMAT(player_collide_ray.position), V3_UNROLL(player_collide_ray.position), V3_UNROLL(player_collide_ray.direction)), 0, 128+(line_height*4), 16, GREEN);
DrawText(TextFormat(V3_FORMAT(room_positions[0]), V3_UNROLL(room_positions[0])), 0, 128+(line_height*5), 16, GREEN);
DrawText(TextFormat(V3_FORMAT(barrow_position), V3_UNROLL(barrow_position)), 0, 128+(line_height*6), 16, GREEN);
- DrawText(TextFormat(V3_FORMAT(barrow_size), V3_UNROLL(barrow_size)), 0, 128+(line_height*7), 16, GREEN);
+ DrawText(TextFormat(V3_FORMAT(floor_position), V3_UNROLL(floor_position)), 0, 128+(line_height*7), 16, GREEN);
+ DrawText(TextFormat(V3_FORMAT(barrow_size), V3_UNROLL(barrow_extent)), 0, 128+(line_height*8), 16, GREEN);
}
}
if (IsKeyReleased(KEY_N))
{
- draw_barrow = !draw_barrow;
+ draw_collision_mesh = !draw_collision_mesh;
}
if (IsKeyReleased(KEY_Z))
{
- cam.position = barrow_center;
+ cam.position = cam_reset_position;
}
if (IsKeyReleased(KEY_ONE))
player_collision = GetRayCollisionMesh(player_collide_ray, barrow_model.meshes[0U], barrow_mat);
player_rotation = new_player_rotation;
- if (player_collision.hit && player_collision.distance < 0.89f)
+ if (player_collision.hit && player_collision.distance < 1.30f)
{
player_velocity.x *= -1.05;
}
void wait_initialize_resources()
{
+ /* Floor resource setup. */
+ {
+ floor_image = LoadImage("./floor.png");
+ floor_albedo = LoadTexture("./floor_albedo.png");
+ while(!IsImageReady(floor_image)){}
+
+ floor_scale_factor = (Vector3){1.0f/8.0f, 8.0f, 1.0f/8.0f};
+ floor_extent = Vector3Multiply(
+ (Vector3){floor_albedo.width, 1.0f, floor_albedo.height},
+ floor_scale_factor);
+
+ floor_position = vec3_zero;
+ floor_rotation_axis = vec3_zero;
+ floor_rotation = 0.0f;
+
+ while(!IsTextureReady(floor_albedo)){}
+ floor_texture = LoadTextureFromImage(floor_image);
+ while(!IsTextureReady(floor_texture)){}
+
+ floor_meshes[0U] = GenMeshHeightmap(floor_image, vec3_unit);
+ floor_model = LoadModelFromMesh(floor_meshes[0]);
+ floor_model.materials[0].maps[MATERIAL_MAP_ALBEDO].texture = floor_albedo;
+ floor_model.materials[0].maps[MATERIAL_MAP_ROUGHNESS].texture = floor_albedo;
+ floor_model.materials[0].shader = shader;
+ while(!IsModelReady(floor_model)){}
+ }
+
/* Barrow resource setup. */
{
barrow_image = LoadImage("./barrow.png");
barrow_albedo = LoadTexture("./barrow_albedo.png");
- barrow_position = vec3_zero;
- barrow_position.y += 3.0f;
- barrow_scale_factor = (Vector3){1.0f/8.0f, 8.0f, 1.0f/8.0f};
- barrow_size = Vector3Multiply(
+ barrow_position = floor_position;
+ barrow_position.y += 2.0f;
+ barrow_scale_factor = (Vector3){1.0f/8.0f, 3.0f, 1.0f/8.0f};
+ barrow_extent = Vector3Multiply(
(Vector3){barrow_albedo.width, 1.0f, barrow_albedo.height},
barrow_scale_factor);
+
+ barrow_position.z += barrow_extent.z;
barrow_rotation_axis = (Vector3){1.0f, 0.0f, 0.0f};
barrow_rotation = 180.0f;
printf("barrow_position: {%f %f %f}\n", V3_UNROLL(barrow_position));
- printf("barrow_size: {%f %f %f}\n", V3_UNROLL(barrow_size));
+ printf("barrow_size: {%f %f %f}\n", V3_UNROLL(barrow_extent));
while(!IsImageReady(barrow_image)){}
while(!IsTextureReady(barrow_albedo)){}
barrow_model.materials[0].maps[MATERIAL_MAP_ROUGHNESS].texture = barrow_albedo;
barrow_model.materials[0].shader = shader;
- room_positions[0] = barrow_position;
- printf("sphere %f %f %f\n", V3_UNROLL(room_positions[0]));
- for (int n = 1; n < room_count; n++)
- {
- // Scale room positions down from gentime positions
- room_positions[n] = Vector3Multiply(room_positions[n], barrow_scale_factor);
- printf("sphere %f %f %f\n", V3_UNROLL(room_positions[n]));
- }
-
while(!IsModelReady(barrow_model)){}
}
- /* Floor resource setup. */
- {
- floor_image = LoadImage("./floor.png");
- floor_albedo = LoadTexture("./floor_albedo.png");
- while(!IsImageReady(floor_image)){}
-
- floor_size = barrow_size;
- floor_size.y = 3.0f;
-
- floor_position = barrow_position;
- barrow_position.z += barrow_size.z;
- barrow_position.y -= 0.5f;
- floor_position.y -= barrow_position.y;
-
- floor_rotation_axis = (Vector3){0.0f, 0.0f, floor_image.width};
- floor_rotation = 0.0f;
-
- while(!IsTextureReady(floor_albedo)){}
- floor_texture = LoadTextureFromImage(floor_image);
- while(!IsTextureReady(floor_texture)){}
-
- floor_meshes[0U] = GenMeshHeightmap(floor_image, vec3_unit);
- floor_model = LoadModelFromMesh(floor_meshes[0]);
- floor_model.materials[0].maps[MATERIAL_MAP_ALBEDO].texture = floor_albedo;
- floor_model.materials[0].maps[MATERIAL_MAP_ROUGHNESS].texture = floor_albedo;
- floor_model.materials[0].shader = shader;
- while(!IsModelReady(floor_model)){}
- }
-
/* Other resource setup. */
{
coffin_scale = (Vector3){1.5f, 1.5f, 1.5f};
hand_rotation = 0.0f;
}
+ printf("center room %f %f %f\n", V3_UNROLL(room_positions[0]));
+ for (int n = 0; n < room_count; n++)
+ {
+ // Scale room positions down from gentime positions
+ printf("room at %f %f %f\n", V3_UNROLL(room_positions[n]));
+ //room_positions[n].x -= barrow_image.width/2.0f;
+ room_positions[n].x -= 1.0f;
+ //room_positions[n].z -= barrow_image.height;
+ //room_positions[n] = Vector3Multiply(room_positions[n], barrow_scale_factor);
+ //room_positions[n] = Vector3Add(room_positions[n], barrow_size);
+ //room_positions[n] = Vector3Add(room_positions[n], map_center);
+ printf("room moved to %f %f %f\n", V3_UNROLL(room_positions[n]));
+ }
+
/* Setup Rays for visualizing spawn contact points */
spawn_spoke_count = room_count;
spawn_spoke_rays = malloc(sizeof(Ray) * spawn_spoke_count);
{
Ray* each = &spawn_spoke_rays[n];
each->position = room_positions[n+1];
- each->position = Vector3Add(each->position, barrow_position);
+ each->position = Vector3Add(each->position, floor_position);
each->direction = Vector3Subtract(each->position, cam.position);
printf("Initialized a ray at {%f %f %f} to {%f %f %f}\n",
V3_UNROLL(each->position), V3_UNROLL(each->direction));
/* Grab the full transformation matrix of the upper barrow for use in collision */
/* Apparently matrix work needs to be normalized. */
{
- Vector3 bt = (Vector3){0.0, -0.3, -1.0f};
- Vector3 bs = barrow_size;
+ // The Y adjustment seems to be the difference between 1 and the
+ // height of the ceiling, then scaled 1/10th?
+ Vector3 bt = (Vector3){0.0, -0.8, -1.0f};
+ Vector3 bs = barrow_extent;
Matrix mat_trans = MatrixTranslate(V3_UNROLL(bt));
Matrix mat_rot = MatrixRotate(barrow_rotation_axis, DEG2RAD * barrow_rotation);
Matrix mat_scale = MatrixScale(V3_UNROLL(bs));
/* Values and things to do that have to have to be done after Raylib is initialized. */
void initialize_renderer()
{
- barrow_center = barrow_size;
- barrow_center.x /= 2.0f;
- barrow_center.z /= 2.0f;
- barrow_center.y -= 6.5f;
+ cam_reset_position = map_center;
+ cam_reset_position.y = 1.0f;
+ map_center = floor_extent;
+ map_center.x /= 2.0f;
+ map_center.z /= 2.0f;
cam = (Camera3D){0};
- cam.position = barrow_center;
+ cam.position = cam_reset_position;
cam.target = cam.position;
cam.target.x += 3.0f;
cam.up = (Vector3){0.0f, 1.0f, 0.0f};
cam.fovy = 90.0f;
cam.projection = CAMERA_PERSPECTIVE;
+ /* eye in the sky */
+ //cam.position.y += 64;
+
/*
I know these are good at 60 fps. Per-second speed to move to FPS/independent movement.
*/