def camera_test(): rl.SetTraceLogLevel(rl.LOG_ERROR) rl.SetConfigFlags(rl.FLAG_WINDOW_RESIZABLE) rl.InitWindow(512, 256, b'Test') rl.SetTargetFPS(60) rl.DisableCursor() flycam = CameraFly() while not rl.WindowShouldClose(): flycam.update() cam = flycam.get_camera() rl.BeginDrawing() rl.ClearBackground((0, 200, 255, 255)) rl.BeginMode3D(cam[0]) # NOTE(pebaz): For whatever reason, this can solve a percentage of artifacts rl.DrawGizmo([100000000, 100000000, 100000000]) rl.DrawGrid(32, 1) rl.EndMode3D() rl.EndDrawing() rl.CloseWindow()
camera = ffi.new( "struct Camera3D *", [[18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0]) image = rl.LoadImage(b"examples/models/resources/heightmap.png") texture = rl.LoadTextureFromImage(image) mesh = rl.GenMeshHeightmap(image, [16, 8, 16]) model = rl.LoadModelFromMesh(mesh) print( model.materials ) # SHOULD BE A pointer to a 'struct Material' but some is NULL pointer to 'Material' ? model.materials.maps[rl.MAP_DIFFUSE].texture = texture rl.UnloadImage(image) rl.SetCameraMode(camera[0], rl.CAMERA_ORBITAL) while not rl.WindowShouldClose(): rl.UpdateCamera(camera) rl.BeginDrawing() rl.ClearBackground(RAYWHITE) rl.BeginMode3D(camera[0]) rl.DrawModel(model, (-8.0, 0.0, -8.0), 1.0, RED) rl.DrawGrid(20, 1.0) rl.EndMode3D() rl.DrawText(b"This mesh should be textured", 190, 200, 20, VIOLET) rl.EndDrawing() rl.CloseWindow() """ Previously this failed to work in the same place the ctypes binding fails, accessing materials of a model. I though it was because Python can't dynamically tell the difference between a pointer and an array. """
skybox.materials[0].maps[rl.MAP_CUBEMAP].texture = rl.GenTextureCubemap( shdrCubemap, texHDR, 512, rl.UNCOMPRESSED_R32G32B32) rl.UnloadTexture(texHDR) rl.UnloadShader(shdrCubemap) rl.SetCameraMode(camera[0], rl.CAMERA_FIRST_PERSON) rl.SetTargetFPS(60) while not rl.WindowShouldClose(): rl.UpdateCamera(camera) rl.BeginDrawing() rl.ClearBackground(RAYWHITE) rl.BeginMode3D(camera[0]) rl.DrawModel(skybox, [0, 0, 0], 1.0, WHITE) rl.DrawGrid(10, 1.0) for x in range(10): for y in range(10): rl.DrawCube([x * 2, 0, y * 2], 1, 1, 1, MAROON) rl.DrawCubeWires([x * 2, 0, y * 2], 1, 1, 1, RED) rl.EndMode3D() rl.DrawFPS(10, 10) rl.EndDrawing() rl.CloseWindow() rl.UnloadShader(skybox.materials[0].shader) rl.UnloadTexture(skybox.materials[0].maps[rl.MAP_CUBEMAP].texture) rl.UnloadModel(skybox)
from raylib.dynamic import raylib as rl, ffi from raylib.colors import * from camera import CameraFly rl.SetTraceLogLevel(rl.LOG_ERROR) rl.SetConfigFlags(rl.FLAG_WINDOW_RESIZABLE) rl.InitWindow(512, 256, b'Test') rl.SetTargetFPS(60) rl.DisableCursor() flycam = CameraFly() while not rl.WindowShouldClose(): flycam.update() cam = flycam.get_camera() rl.BeginDrawing() rl.ClearBackground((0, 200, 255, 255)) rl.BeginMode3D(cam[0]) # NOTE(pebaz): For whatever reason, this can solve a percentage of artifacts rl.DrawGizmo([100000000, 100000000, 100000000]) rl.DrawGrid(32, 1) rl.EndMode3D() rl.EndDrawing() rl.CloseWindow()