Beispiel #1
0
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()
Beispiel #2
0
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.
"""
Beispiel #3
0
                         rl.GetScreenHeight() / 2, 0), 64)))
    for i in range(125)
]
while not rl.WindowShouldClose():
    if (rl.GetScreenWidth(), rl.GetScreenHeight()) != dims:
        canvas = rl.LoadRenderTexture(rl.GetScreenWidth(),
                                      rl.GetScreenHeight())
        rl.SetTextureWrap(canvas.texture, rl.WRAP_MIRROR_REPEAT)
        ini = False
        dims = rl.GetScreenWidth(), rl.GetScreenHeight()

    rl.BeginDrawing()

    rl.BeginTextureMode(canvas)
    if not ini:
        rl.ClearBackground([200, 200, 0, 255] if BEES else WHITE)
        if BEES:
            rl.DrawRectangle(0, 0, dims[0], dims[1] // 2, (0, 200, 255, 255))
            rl.DrawCircle(dims[0] - 72, 72, 32, [255, 200, 0, 255])
        else:
            ini = True

    for part in parts:
        part.process()

    rl.EndTextureMode()

    tex = canvas.texture
    rl.DrawTexturePro(tex, [0.0, 0.0, tex.width, -tex.height],
                      [0, 0, tex.width, tex.height], [0, 0], 0.0, WHITE)
Beispiel #4
0
    # Set here to "snap" and don't to enable "floating" back into position
    if not drag:
        rl.SetWindowPosition(int(window_pos.x), int(window_pos.y))

    if drag:
        window_pos += mouse_pos - offset
        drag = not rl.IsMouseButtonReleased(rl.MOUSE_LEFT_BUTTON)
        rl.SetWindowPosition(int(window_pos.x), int(window_pos.y))

        if not drag:
            window_vel = (mouse_pos - offset) * glm.vec2(1, 0.6) * 0.8
            if any(glm.isnan(window_vel)):
                window_vel = glm.vec2()

    rl.BeginDrawing()
    rl.ClearBackground([0] * 4)

    rl.BeginTextureMode(target)
    rl.ClearBackground([0] * 4)
    rl.DrawRectangle(0, 0, width, height, [0] * 4)

    rl.DrawTextureEx(
        awd,
        tween.getPointOnLine(*start1, *end1, tween.easeInOutQuad(elapsed)),
        0,
        32,
        [255, 200, 0, trans]  # Yellow
    )

    rl.DrawTextureEx(
        awd,
Beispiel #5
0
    if rl.IsKeyDown(rl.KEY_UP):
        fogDensity = min(fogDensity + 0.001, 1)

    if rl.IsKeyDown(rl.KEY_DOWN):
        fogDensity = max(fogDensity - 0.001, 0)

    rl.SetShaderValue(shader, fogD, ffi.new('float[]', [fogDensity]),
                      rl.UNIFORM_FLOAT)

    rl.SetShaderValue(shader, shader.locs[rl.LOC_VECTOR_VIEW],
                      ffi.new('float[]', [camera.position.x]), rl.UNIFORM_VEC3)

    rl.BeginDrawing()

    rl.ClearBackground([int(255 * i) for i in fog_color])

    rl.BeginMode3D(camera[0])
    rl.DrawModel(model, [0] * 3, 1, WHITE)
    rl.DrawModel(model2, [-2.6, 0, 0], 1, WHITE)
    rl.DrawModel(model3, [2.6, 0, 0], 1, WHITE)

    for i in range(-20, 20, 2):
        rl.DrawModel(model, [i, 0, 2], 1, WHITE)

    rl.DrawGizmo([1000, 1000, 1000])

    rl.EndMode3D()

    rl.DrawFPS(10, 10)
    rl.DrawText(f'Up/Down to change fog density: {fogDensity}'.encode('utf-8'),
Beispiel #6
0
    files = []
    if rl.IsFileDropped():
        file_count = ffi.new('int *')
        files = rl.GetDroppedFiles(file_count)
        files = [ffi.string(files[i]).decode() for i in range(file_count[0])]
        rl.ClearDroppedFiles()
    return files


while not rl.WindowShouldClose():
    for file in get_dropped_files():
        h = Haishoku.loadHaishoku(file)
        colors = {str(blob): blob[1] for blob in h.palette}

    rl.BeginDrawing()
    rl.ClearBackground(WHITE)

    x, y = 0, 0
    for name, color in colors.items():
        r, g, b = color
        rl.DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, (r, g, b, 255))
        x += TILE_SIZE
        if x > WIDTH:
            x = 0
            y += TILE_SIZE

    rl.EndDrawing()

    if rl.IsKeyPressed(rl.KEY_E):
        rl.TakeScreenshot(b'pallet.png')
Beispiel #7
0
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()