adjust examples
This commit is contained in:
parent
22be6c3b61
commit
35e225a85e
|
|
@ -50,9 +50,6 @@ int main(void)
|
||||||
colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
|
colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Catch cursor
|
|
||||||
DisableCursor();
|
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ int main(void)
|
||||||
|
|
||||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
SetCameraMode(&camera, CAMERA_FREE); // Set a free camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@ int main(void)
|
||||||
|
|
||||||
RayCollision collision = { 0 };
|
RayCollision collision = { 0 };
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
SetCameraMode(&camera, CAMERA_FREE); // Set a free camera mode
|
||||||
|
EnableCursor(); // Disable camera controls
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -50,7 +51,14 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
UpdateCamera(&camera);
|
if (IsCursorHidden()) UpdateCamera(&camera); // Update camera
|
||||||
|
|
||||||
|
// Toggle camera controls
|
||||||
|
if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT))
|
||||||
|
{
|
||||||
|
if (IsCursorHidden()) EnableCursor();
|
||||||
|
else DisableCursor();
|
||||||
|
}
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||||
{
|
{
|
||||||
|
|
@ -93,10 +101,12 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY);
|
DrawText("Try clicking on the box with your mouse!", 240, 10, 20, DARKGRAY);
|
||||||
|
|
||||||
if (collision.hit) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, (int)(screenHeight * 0.1f), 30, GREEN);
|
if (collision.hit) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, (int)(screenHeight * 0.1f), 30, GREEN);
|
||||||
|
|
||||||
|
DrawText("Right click mouse to toggle camera controls", 10, 430, 10, GRAY);
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ int main(void)
|
||||||
|
|
||||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set first person camera mode
|
SetCameraMode(&camera, CAMERA_FIRST_PERSON); // Set first person camera mode
|
||||||
|
|
||||||
SetTargetFPS(90); // Set our game to run at 90 frames-per-second
|
SetTargetFPS(90); // Set our game to run at 90 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ int main(void)
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - core world screen");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = { 0 };
|
Camera camera = { 0 };
|
||||||
|
|
@ -36,7 +36,7 @@ int main(void)
|
||||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||||
Vector2 cubeScreenPosition = { 0.0f, 0.0f };
|
Vector2 cubeScreenPosition = { 0.0f, 0.0f };
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
SetCameraMode(&camera, CAMERA_FREE); // Set a free camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ int main(void)
|
||||||
ModelAnimation *anims = LoadModelAnimations("resources/models/iqm/guyanim.iqm", &animsCount);
|
ModelAnimation *anims = LoadModelAnimations("resources/models/iqm/guyanim.iqm", &animsCount);
|
||||||
int animFrameCounter = 0;
|
int animFrameCounter = 0;
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
|
SetCameraMode(&camera, CAMERA_FREE); // Set free camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ int main(void)
|
||||||
Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard
|
Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard
|
||||||
Vector3 billPosition = { 0.0f, 2.0f, 0.0f }; // Position where draw billboard
|
Vector3 billPosition = { 0.0f, 2.0f, 0.0f }; // Position where draw billboard
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
SetCameraMode(&camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ int main(void)
|
||||||
|
|
||||||
UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM
|
UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
SetCameraMode(&camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ int main(void)
|
||||||
|
|
||||||
Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
|
Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set camera mode
|
SetCameraMode(&camera, CAMERA_FIRST_PERSON); // Set camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ int main(void)
|
||||||
|
|
||||||
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
|
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
SetCameraMode(&camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ int main(void)
|
||||||
// NOTE: bounds are calculated from the original size of the model,
|
// NOTE: bounds are calculated from the original size of the model,
|
||||||
// if model is scaled on drawing, bounds must be also scaled
|
// if model is scaled on drawing, bounds must be also scaled
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
SetCameraMode(&camera, CAMERA_FREE); // Set a free camera mode
|
||||||
|
|
||||||
bool selected = false; // Selected object flag
|
bool selected = false; // Selected object flag
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ int main(void)
|
||||||
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
|
SetCameraMode(&camera, CAMERA_FREE); // Set free camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ int main(void)
|
||||||
|
|
||||||
int currentModel = 0;
|
int currentModel = 0;
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set a orbital camera mode
|
SetCameraMode(&camera, CAMERA_ORBITAL); // Set a orbital camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ int main(void)
|
||||||
|
|
||||||
int currentModel = 0;
|
int currentModel = 0;
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set a orbital camera mode
|
SetCameraMode(&camera, CAMERA_ORBITAL); // Set a orbital camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,8 @@ int main(void)
|
||||||
Vector3 sp = (Vector3){ -30.0f, 5.0f, 5.0f };
|
Vector3 sp = (Vector3){ -30.0f, 5.0f, 5.0f };
|
||||||
float sr = 4.0f;
|
float sr = 4.0f;
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
SetCameraMode(&camera, CAMERA_FREE); // Set a free camera mode
|
||||||
|
EnableCursor(); // Disable camera controls
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -73,7 +74,14 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
UpdateCamera(&camera);
|
if (IsCursorHidden()) UpdateCamera(&camera); // Update camera
|
||||||
|
|
||||||
|
// Toggle camera controls
|
||||||
|
if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT))
|
||||||
|
{
|
||||||
|
if (IsCursorHidden()) EnableCursor();
|
||||||
|
else DisableCursor();
|
||||||
|
}
|
||||||
|
|
||||||
// Display information about closest hit
|
// Display information about closest hit
|
||||||
RayCollision collision = { 0 };
|
RayCollision collision = { 0 };
|
||||||
|
|
@ -219,7 +227,7 @@ int main(void)
|
||||||
DrawText(TextFormat("Barycenter: %3.2f %3.2f %3.2f", bary.x, bary.y, bary.z), 10, ypos + 45, 10, BLACK);
|
DrawText(TextFormat("Barycenter: %3.2f %3.2f %3.2f", bary.x, bary.y, bary.z), 10, ypos + 45, 10, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawText("Use Mouse to Move Camera", 10, 430, 10, GRAY);
|
DrawText("Right click mouse to toggle camera controls", 10, 430, 10, GRAY);
|
||||||
|
|
||||||
DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ int main(void)
|
||||||
camera.fovy = 45.0f;
|
camera.fovy = 45.0f;
|
||||||
camera.projection = CAMERA_PERSPECTIVE;
|
camera.projection = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE);
|
SetCameraMode(&camera, CAMERA_FREE);
|
||||||
|
|
||||||
float rotationSpeed = 0.2f; // General system rotation speed
|
float rotationSpeed = 0.2f; // General system rotation speed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ int main(void)
|
||||||
UnloadImage(img);
|
UnloadImage(img);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set a first person camera mode
|
SetCameraMode(&camera, CAMERA_FIRST_PERSON); // Set a first person camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ int main(void)
|
||||||
lights[2] = CreateLight(LIGHT_POINT, (Vector3){ -2, 1, 2 }, Vector3Zero(), GREEN, shader);
|
lights[2] = CreateLight(LIGHT_POINT, (Vector3){ -2, 1, 2 }, Vector3Zero(), GREEN, shader);
|
||||||
lights[3] = CreateLight(LIGHT_POINT, (Vector3){ 2, 1, -2 }, Vector3Zero(), BLUE, shader);
|
lights[3] = CreateLight(LIGHT_POINT, (Vector3){ 2, 1, -2 }, Vector3Zero(), BLUE, shader);
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
SetCameraMode(&camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ int main(void)
|
||||||
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
|
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
|
||||||
|
|
||||||
// Setup orbital camera
|
// Setup orbital camera
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
SetCameraMode(&camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ int main(void)
|
||||||
// Using just 1 point lights
|
// Using just 1 point lights
|
||||||
CreateLight(LIGHT_POINT, (Vector3){ 0, 2, 6 }, Vector3Zero(), WHITE, shader);
|
CreateLight(LIGHT_POINT, (Vector3){ 0, 2, 6 }, Vector3Zero(), WHITE, shader);
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
SetCameraMode(&camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ int main(void)
|
||||||
matDefault.maps[MATERIAL_MAP_DIFFUSE].color = BLUE;
|
matDefault.maps[MATERIAL_MAP_DIFFUSE].color = BLUE;
|
||||||
|
|
||||||
// Set an orbital camera mode
|
// Set an orbital camera mode
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL);
|
SetCameraMode(&camera, CAMERA_ORBITAL);
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ int main(void)
|
||||||
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set an orbital camera mode
|
SetCameraMode(&camera, CAMERA_FREE); // Set an orbital camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ int main(void)
|
||||||
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
|
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
|
||||||
|
|
||||||
// Setup orbital camera
|
// Setup orbital camera
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
SetCameraMode(&camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ int main(void)
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
camera.fovy = 65.0f; // Camera field-of-view Y
|
camera.fovy = 65.0f; // Camera field-of-view Y
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set camera mode
|
SetCameraMode(&camera, CAMERA_FREE); // Set camera mode
|
||||||
|
|
||||||
// Load raymarching shader
|
// Load raymarching shader
|
||||||
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
|
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user