REVIEWED: Camera redesign PR
This commit is contained in:
parent
73989a4981
commit
ea590c44a9
34 changed files with 321 additions and 268 deletions
|
@ -21,8 +21,6 @@
|
|||
|
||||
#include "raylib.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
|
@ -102,15 +100,11 @@ int main(void)
|
|||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadModelAnimations(anims, animsCount); // Unload model animations data
|
||||
UnloadModel(model); // Unload model
|
||||
|
||||
// Unload model animations data
|
||||
for (unsigned int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]);
|
||||
RL_FREE(anims);
|
||||
|
||||
UnloadModel(model); // Unload model
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -28,15 +28,15 @@ int main(void)
|
|||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 5.0f, 4.0f, 5.0f };
|
||||
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 45.0f;
|
||||
camera.projection = CAMERA_PERSPECTIVE;
|
||||
camera.position = (Vector3){ 5.0f, 4.0f, 5.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||
|
||||
Texture2D bill = LoadTexture("resources/billboard.png"); // Our billboard texture
|
||||
Vector3 billPositionStatic = { 0.0f, 2.0f, 0.0f }; // Position of billboard
|
||||
Vector3 billPositionRotating = { 1.0f, 2.0f, 1.0f };
|
||||
Texture2D bill = LoadTexture("resources/billboard.png"); // Our billboard texture
|
||||
Vector3 billPositionStatic = { 0.0f, 2.0f, 0.0f }; // Position of static billboard
|
||||
Vector3 billPositionRotating = { 1.0f, 2.0f, 1.0f }; // Position of rotating billboard
|
||||
|
||||
// Entire billboard texture, source is used to take a segment from a larger texture.
|
||||
Rectangle source = { 0.0f, 0.0f, (float)bill.width, (float)bill.height };
|
||||
|
@ -55,11 +55,13 @@ int main(void)
|
|||
float distanceRotating;
|
||||
float rotation = 0.0f;
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
@ -26,7 +26,12 @@ int main(void)
|
|||
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = { { 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 16.0f, 14.0f, 16.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||
|
||||
Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
|
||||
Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM)
|
||||
|
@ -36,18 +41,19 @@ int main(void)
|
|||
|
||||
// NOTE: By default each cube is mapped to one part of texture atlas
|
||||
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture
|
||||
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||
|
||||
Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
|
||||
|
||||
UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM
|
||||
|
||||
DisableCursor(); // Catch cursor
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
@ -28,7 +28,13 @@ int main(void)
|
|||
InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = { { 0.2f, 0.4f, 0.2f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 0.2f, 0.4f, 0.2f }; // Camera position
|
||||
camera.target = (Vector3){ 0.185f, 0.4f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
Image imMap = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
|
||||
Texture2D cubicmap = LoadTextureFromImage(imMap); // Convert image to texture to display (VRAM)
|
||||
|
@ -37,7 +43,7 @@ int main(void)
|
|||
|
||||
// NOTE: By default each cube is mapped to one part of texture atlas
|
||||
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture
|
||||
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||
|
||||
// Get map image data to be used for collision detection
|
||||
Color *mapPixels = LoadImageColors(imMap);
|
||||
|
@ -45,7 +51,8 @@ int main(void)
|
|||
|
||||
Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
|
||||
|
||||
DisableCursor(); // Catch cursor
|
||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -26,25 +26,31 @@ int main(void)
|
|||
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
|
||||
|
||||
// Define our custom camera to look into our 3d world
|
||||
Camera camera = { { 18.0f, 18.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 18.0f, 21.0f, 18.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||
|
||||
Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
|
||||
Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
|
||||
Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
|
||||
Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
|
||||
|
||||
Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 }); // Generate heightmap mesh (RAM and VRAM)
|
||||
Model model = LoadModelFromMesh(mesh); // Load model from generated mesh
|
||||
Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 }); // Generate heightmap mesh (RAM and VRAM)
|
||||
Model model = LoadModelFromMesh(mesh); // Load model from generated mesh
|
||||
|
||||
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||
Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Define model position
|
||||
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||
Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Define model position
|
||||
|
||||
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
|
||||
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
|
||||
|
||||
DisableCursor(); // Catch cursor
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
@ -59,7 +59,8 @@ int main(void)
|
|||
|
||||
bool selected = false; // Selected object flag
|
||||
|
||||
DisableCursor(); // Catch cursor
|
||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -34,11 +34,11 @@ int main(void)
|
|||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 5.0f, 5.0f, 5.0f }; // Camera position
|
||||
camera.position = (Vector3){ 5.0f, 5.0f, 5.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||
|
||||
// Load gltf model
|
||||
Model model = LoadModel("resources/models/gltf/robot.glb");
|
||||
|
@ -51,11 +51,13 @@ int main(void)
|
|||
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
@ -33,11 +33,12 @@ int main(void)
|
|||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 1.5f, 1.5f, 1.5f }; // Camera position
|
||||
camera.position = (Vector3){ 1.5f, 1.5f, 1.5f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 0.4f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
char modelFileName[128] = "resources/models/m3d/CesiumMan.m3d";
|
||||
|
@ -53,12 +54,13 @@ int main(void)
|
|||
int animFrameCounter = 0, animId = 0;
|
||||
ModelAnimation *anims = LoadModelAnimations(modelFileName, &animsCount); // Load skeletal animation data
|
||||
|
||||
DisableCursor(); // Catch cursor
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
@ -43,7 +43,7 @@ int main(void)
|
|||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||
|
||||
// Load MagicaVoxel files
|
||||
Model models[MAX_VOX_FILES] = { 0 };
|
||||
|
@ -69,7 +69,8 @@ int main(void)
|
|||
|
||||
int currentModel = 0;
|
||||
|
||||
DisableCursor(); // Catch cursor
|
||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -68,7 +68,8 @@ int main(void)
|
|||
|
||||
int currentModel = 0;
|
||||
|
||||
DisableCursor(); // Catch cursor
|
||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ int main(void)
|
|||
camera.target = (Vector3){ 0.0f, 8.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||
|
||||
Ray ray = { 0 }; // Picking ray
|
||||
|
||||
|
@ -64,7 +64,6 @@ int main(void)
|
|||
Vector3 sp = (Vector3){ -30.0f, 5.0f, 5.0f };
|
||||
float sr = 4.0f;
|
||||
|
||||
EnableCursor(); // Disable camera controls
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Main game loop
|
||||
|
|
|
@ -43,11 +43,11 @@ int main(void)
|
|||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 16.0f, 16.0f, 16.0f };
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 45.0f;
|
||||
camera.projection = CAMERA_PERSPECTIVE;
|
||||
camera.position = (Vector3){ 16.0f, 16.0f, 16.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||
|
||||
float rotationSpeed = 0.2f; // General system rotation speed
|
||||
|
||||
|
@ -56,7 +56,8 @@ int main(void)
|
|||
float moonRotation = 0.0f; // Rotation of moon around itself
|
||||
float moonOrbitRotation = 0.0f; // Rotation of moon around earth in degrees
|
||||
|
||||
DisableCursor(); // Catch cursor
|
||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -38,7 +38,12 @@ int main(void)
|
|||
InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = { { 1.0f, 1.0f, 1.0f }, { 4.0f, 1.0f, 4.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 1.0f, 1.0f, 1.0f }; // Camera position
|
||||
camera.target = (Vector3){ 4.0f, 1.0f, 4.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||
|
||||
// Load skybox model
|
||||
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
|
||||
|
@ -87,12 +92,13 @@ int main(void)
|
|||
UnloadImage(img);
|
||||
}
|
||||
|
||||
DisableCursor(); // Catch cursor
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
DisableCursor(); // Limit cursor to relative movement inside the window
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
@ -31,11 +31,11 @@ int main()
|
|||
|
||||
// Initialize the camera
|
||||
Camera3D camera = { 0 };
|
||||
camera.position = (Vector3){ 30.0f, 20.0f, 30.0f };
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 70.0f;
|
||||
camera.projection = CAMERA_PERSPECTIVE;
|
||||
camera.position = (Vector3){ 30.0f, 20.0f, 30.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 70.0f; // Camera field-of-view Y
|
||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||
|
||||
// Specify the amount of blocks in each direction
|
||||
const int numBlocks = 15;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue