-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEx6.exw
103 lines (65 loc) · 2.04 KB
/
Ex6.exw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
include std/machine.e
include std/convert.e
include flags.e
include Euraylib.ew
atom width = 800
atom height = 450
InitWindow(width,height,"3D Stuff")
constant Vector3_X = 0,
Vector3_Y = 4,
Vector3_Z = 8,
SIZEOF_VECTOR3 = 12,
$
constant Camera3D_Position = 0,
Camera3D_Target = 12,
Camera3D_Up = 24,
Camera3D_Fovy = 36,
Camera3D_Type = 40,
SIZEOF_CAMERA3D = 44,
$
atom cam = allocate_data(SIZEOF_CAMERA3D)
mem_set(cam,0,SIZEOF_CAMERA3D)
procedure poke_float(atom p,atom f)
poke(p,atom_to_float32(f))
end procedure
atom blue = bytes_to_int({0,0,255,255})
atom white = bytes_to_int({255,255,255,255})
SetTargetFPS(60)
public procedure SetCameraPosition(atom cam,atom x,atom y,atom z)
poke_float(cam + Camera3D_Position + Vector3_X,x)
poke_float(cam + Camera3D_Position + Vector3_Y,y)
poke_float(cam + Camera3D_Position + Vector3_Z,z)
end procedure
public procedure SetCameraTarget(atom cam,atom x,atom y,atom z)
poke_float(cam + Camera3D_Target + Vector3_X,x)
poke_float(cam + Camera3D_Target + Vector3_Y,y)
poke_float(cam + Camera3D_Target + Vector3_Z,z)
end procedure
public procedure SetCameraUp(atom cam,atom x,atom y,atom z)
poke_float(cam + Camera3D_Up + Vector3_X,x)
poke_float(cam + Camera3D_Up + Vector3_Y,y)
poke_float(cam + Camera3D_Up + Vector3_Z,z)
end procedure
public procedure SetCameraFOVY(atom cam,atom fovy)
poke_float(cam + Camera3D_Fovy,fovy)
end procedure
public procedure SetCameraType(atom cam,integer xtype)
poke4(cam + Camera3D_Type,xtype)
end procedure
SetCameraPosition(cam,0,10.0,10.0)
SetCameraTarget(cam,0,0,0)
SetCameraUp(cam,0,1,0)
SetCameraFOVY(cam,45.0)
SetCameraType(cam,CAMERA_PERSPECTIVE)
while not WindowShouldClose() do
BeginDrawing()
ClearBackground(white)
BeginMode3D(0,10.0,10.0,0,0,0,0,1,0,45.0,CAMERA_PERSPECTIVE)
DrawCube(-4.0,0.0,2.0,2.0,5.0,2.0,blue)
--DrawGrid(10,1.0)
EndMode3D()
DrawFPS(1,1)
EndDrawing()
end while
CloseWindow()
90.40