|
1 | | -#!/usr/bin/env python3 |
2 | 1 | """ |
3 | 2 |
|
4 | 3 | Example converted to Python from: |
|
8 | 7 |
|
9 | 8 |
|
10 | 9 | """ |
11 | | -# |
12 | | -#<<<<<<< HEAD |
13 | | -#<<<<<<< HEAD |
14 | | -#<<<<<<< HEAD |
15 | | -from raylib import rl, ffi |
16 | | -#======= |
17 | | -#from raylib.dynamic import raylib as rl, ffi |
18 | | -#>>>>>>> ffe4403 (complete fog example) |
19 | | -#======= |
20 | | -#from raylib.static import rl, ffi |
21 | | -#>>>>>>> 10b63b9 (added shaders_texture_waves.py) |
22 | | -#======= |
23 | | -#from raylib.static import rl, ffi |
24 | | -#>>>>>>> 1775ffc4b093c881ee44a8027b4143add066d738 |
| 10 | + |
| 11 | +import raylib as rl |
| 12 | + |
25 | 13 | from raylib.colors import * |
26 | 14 | import math |
27 | 15 |
|
|
31 | 19 | rl.SetConfigFlags(rl.FLAG_MSAA_4X_HINT | rl.FLAG_WINDOW_RESIZABLE) |
32 | 20 | rl.InitWindow(1280, 768, b'Fog Test') |
33 | 21 |
|
34 | | -camera = ffi.new('struct Camera3D *', [ |
| 22 | +camera = rl.ffi.new('struct Camera3D *', [ |
35 | 23 | [6, 2, 6], |
36 | 24 | [0, .5, 0], |
37 | 25 | [0, 1, 0], |
|
45 | 33 |
|
46 | 34 | texture = rl.LoadTexture(b'resources/test.png') |
47 | 35 |
|
48 | | -model.materials[0].maps[rl.MAP_DIFFUSE].texture = texture |
49 | | -model2.materials[0].maps[rl.MAP_DIFFUSE].texture = texture |
50 | | -model3.materials[0].maps[rl.MAP_DIFFUSE].texture = texture |
| 36 | +model.materials[0].maps[rl.MATERIAL_MAP_ALBEDO].texture = texture |
| 37 | +model2.materials[0].maps[rl.MATERIAL_MAP_ALBEDO].texture = texture |
| 38 | +model3.materials[0].maps[rl.MATERIAL_MAP_ALBEDO].texture = texture |
51 | 39 |
|
52 | 40 | light = Light(LIGHT_POINT, [ 0, 4, 0 ], Vector3Zero(), WHITE) |
53 | 41 | lightSystem = LightSystem([ 0.2, 0.2, 0.2, 1.0 ], light) |
54 | | -# |
55 | | -#<<<<<<< HEAD |
56 | | -#<<<<<<< HEAD |
57 | | -fog_color = ffi.new('float[]', [0.2,0.2,1.0,1.0]) |
| 42 | + |
| 43 | +fog_color = rl.ffi.new('float[]', [0.2,0.2,1.0,1.0]) |
58 | 44 | fogC = rl.GetShaderLocation(lightSystem.shader, b'fogColor') |
59 | | -rl.SetShaderValue(lightSystem.shader, fogC, fog_color, rl.UNIFORM_VEC4); |
60 | | -#======= |
61 | | -#fog_color = [0.2, 0.2, 1.0, 1.0] |
62 | | -#>>>>>>> ffe4403 (complete fog example) |
63 | | -#======= |
64 | | -#fog_color = ffi.new('float[]', [0.2,0.2,1.0,1.0]) |
| 45 | +rl.SetShaderValue(lightSystem.shader, fogC, fog_color, rl.SHADER_UNIFORM_VEC4); |
| 46 | + |
65 | 47 | fogC = rl.GetShaderLocation(lightSystem.shader, b'fogColor') |
66 | | -rl.SetShaderValue(lightSystem.shader, fogC, fog_color, rl.UNIFORM_VEC4); |
67 | | -#>>>>>>> 1775ffc4b093c881ee44a8027b4143add066d738 |
| 48 | +rl.SetShaderValue(lightSystem.shader, fogC, fog_color, rl.SHADER_UNIFORM_VEC4); |
| 49 | + |
68 | 50 | fogD = rl.GetShaderLocation(lightSystem.shader, b'FogDensity') |
69 | 51 | fogDensity = 0.12 |
70 | 52 |
|
|
84 | 66 | lightSystem.update(camera.position) |
85 | 67 |
|
86 | 68 |
|
87 | | - model.transform = ffi.cast("Matrix *",MatrixMultiply(model.transform, MatrixRotateX(-0.025)))[0] |
88 | | - model.transform = ffi.cast("Matrix *",MatrixMultiply(model.transform, MatrixRotateZ(0.012)))[0] |
| 69 | + model.transform = rl.ffi.cast("Matrix *",MatrixMultiply(model.transform, MatrixRotateX(-0.025)))[0] |
| 70 | + model.transform = rl.ffi.cast("Matrix *",MatrixMultiply(model.transform, MatrixRotateZ(0.012)))[0] |
89 | 71 |
|
90 | 72 | if rl.IsKeyDown(rl.KEY_UP): |
91 | 73 | fogDensity = min(fogDensity + 0.001, 1) |
92 | 74 |
|
93 | 75 | if rl.IsKeyDown(rl.KEY_DOWN): |
94 | 76 | fogDensity = max(fogDensity - 0.001, 0) |
95 | 77 |
|
96 | | - rl.SetShaderValue(lightSystem.shader, fogD, ffi.new('float[]', [fogDensity]), rl.UNIFORM_FLOAT) |
| 78 | + rl.SetShaderValue(lightSystem.shader, fogD, rl.ffi.new('float[]', [fogDensity]), rl.SHADER_UNIFORM_FLOAT) |
97 | 79 |
|
98 | 80 | rl.BeginDrawing() |
99 | 81 |
|
100 | 82 | rl.ClearBackground([int(255 * i) for i in fog_color]) |
101 | | -#<<<<<<< HEAD |
102 | | -#<<<<<<< HEAD |
103 | | -# if rl.IsKeyDown(rl.KEY_SPACE): |
104 | | -# rl.ClearBackground(BLACK) |
105 | | -#======= |
106 | | -#>>>>>>> ffe4403 (complete fog example) |
107 | | -#======= |
| 83 | + |
108 | 84 | if rl.IsKeyDown(rl.KEY_SPACE): |
109 | 85 | rl.ClearBackground(BLACK) |
110 | | -#>>>>>>> 1775ffc4b093c881ee44a8027b4143add066d738 |
| 86 | + |
111 | 87 |
|
112 | 88 | rl.BeginMode3D(camera[0]) |
113 | 89 | rl.DrawModel(model, [0] * 3, 1, WHITE) |
|
118 | 94 | rl.DrawModel(model, [i, 0, 2], 1, WHITE) |
119 | 95 |
|
120 | 96 |
|
121 | | - rl.DrawGizmo([1000, 1000, 1000]) |
| 97 | + #Raylib removed this function |
| 98 | + #rl.DrawGizmo([1000, 1000, 1000]) |
122 | 99 |
|
123 | 100 | rl.EndMode3D() |
124 | 101 |
|
|
0 commit comments