Сообщение от Le Thaw
Подскажите как работает эта функция MP_3Dto2D
Судя по всему, преобразовывает 3D координаты в 2D.
Сообщение от Le Thaw
Что это *pV.D3DXVector3?
Указатель на структуру.
В справке написано.
pV.D3DXVector3 = Adresse of a 2d Point (x.f/y.f/z.f)
То есть структура имеет вид. PureBasic | 1
2
3
4
5
| Structure D3DXVector3
x.f
y.f
z.f
EndStructure |
|
Примеры в которых есть функция MP_3Dto2D().
PureBasic | 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
| ;////////////////////////////////////////////////////////////////
;//
;// Project Title: MP 3D Engine Beispielprogramme
;// Dateiname: MP_04_Static_Level.pb
;// Erstellt am: 15.5.2011
;// Update am :
;// Author: Michael Paulwitz
;//
;// Info:
;// Physic with different Meshs
;// Physik mit unterschiedlichen Meshs
;//
;//
;////////////////////////////////////////////////////////////////
Structure Liste
Mesh.i
Tyoe.i
EndStructure
Structure vecf
x.f
y.f
z.f
EndStructure
Structure matrix
m.f[16]
EndStructure
Global NewList MyList.Liste()
Global NewMaterial
Procedure Newmesh ()
For n = 0 To 19
AddElement(MyList())
Ergebnis = Random(9)
If Ergebnis = 0
MyList()\Mesh = MP_CreateRetangle(5, 5, 5)
MP_EntityPhysicBody(MyList()\Mesh, 2, 10)
ElseIf Ergebnis = 1
MyList()\Mesh = MP_CreateRetangle(7, 3, 5)
MP_EntityPhysicBody(MyList()\Mesh, 2, 10)
ElseIf Ergebnis = 2
MyList()\Mesh = MP_CreateSphere(20)
MP_ScaleMesh(MyList()\Mesh, 2.5,2.5,2.5)
MP_EntityPhysicBody(MyList()\Mesh, 3, 10)
MP_SetPhysicMaterialtoMesh (MyList()\Mesh, NewMaterial)
ElseIf Ergebnis = 3
MyList()\Mesh = MP_CreateSphere(20)
MP_ScaleMesh(MyList()\Mesh, 4,2.5,2.5)
MP_EntityPhysicBody(MyList()\Mesh, 3, 10)
MP_SetPhysicMaterialtoMesh (MyList()\Mesh, NewMaterial)
ElseIf Ergebnis = 4
MyList()\Mesh = MP_CreateTorus(2, 5, 12)
MP_EntityPhysicBody(MyList()\Mesh, 4, 10)
ElseIf Ergebnis = 5
MyList()\Mesh = MP_CreatePyramid(5, 5, 5)
MP_EntityPhysicBody(MyList()\Mesh, 4, 10)
ElseIf Ergebnis = 6
MyList()\Mesh = MP_CreateTeapot()
MP_ScaleMesh(MyList()\Mesh, 3,3,3)
MP_EntityPhysicBody(MyList()\Mesh, 4, 10)
ElseIf Ergebnis = 7
MyList()\Mesh = MP_Create3DText("Times","MP3D",10)
MP_EntityPhysicBody(MyList()\Mesh, 4, 10)
ElseIf Ergebnis = 8
MyList()\Mesh = MP_CreateCone(10,5)
MP_ScaleMesh(MyList()\Mesh, 2.5,2.5,2.5)
MP_EntityPhysicBody(MyList()\Mesh, 4, 10)
ElseIf Ergebnis = 9
MyList()\Mesh = MP_CreateCylinder(15,5)
MP_ScaleMesh(MyList()\Mesh, 2.5,2.5,2.5)
MP_EntityPhysicBody(MyList()\Mesh, 4, 10)
EndIf
MP_EntitySetColor(MyList()\Mesh,MP_ARGB(255,Random(255),Random(255),Random(255)))
MP_PositionEntity(MyList()\Mesh, 0, 40 + n*10,0)
Next n
EndProcedure
MP_Graphics3DWindow(0, 0, 1024, 768, "MP3D Physik Demo, Mouse to hit and move, Space to delete Meshs",0)
; MP_VSync(0)
light0 = MP_CreateLight(1)
MP_PositionEntity(light0, 0, 128, 0)
cam0 = MP_CreateCamera()
MP_CameraSetRange(cam0, 2, 2024)
MP_PositionCamera(cam0, -32, 64, -152)
MP_CameraLookAt(cam0, 0, 0, 0)
MP_PhysicInit()
NewMaterial = MP_CreatePhysicMaterial()
MP_SetPhysicMaterialProperties(NewMaterial,1,0,0)
tex0 = MP_CreateTextureColor(128, 128, RGBA(0, 255, 0, 0))
tex0 = MP_LoadTexture("detail3.bmp")
MP_MaterialEmissiveColor(tex0, 0, 122, 132, 132)
;################ Bodenplatte ################
bodenplatte = MP_LoadMesh("Scene2.x"); Bodenplatte kann natьrlich auch ein x-beliebiges Mesh sein
MP_ScaleMesh( bodenplatte ,0.6,0.6,0.6)
MP_EntitySetTexture(bodenplatte, tex0)
;MP_RotateEntity (bodenplatte,0,0,16)
MP_EntityPhysicBody(bodenplatte, 1, 0)
Newmesh ()
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
If MP_MouseButtonDown(0) ; Linke Maustaste gedrьckt?
If Mouseon = 0
Meshfound = MP_PickCamera (cam0,WindowMouseX(0),WindowMouseY(0))
If Meshfound <> bodenplatte
Mouseon = 1
MP_3Dto2D(MP_EntityGetX(Meshfound),MP_EntityGetY(Meshfound),MP_EntityGetZ(Meshfound), @pointPosit.vecf );= box\m[12], box\m[13], box\m[14])
KeyZ.f = pointPosit\z
MP_EntitySetPhysic(Meshfound,0)
EndIf
Else
MP_2Dto3D(WindowMouseX(0),WindowMouseY(0),KeyZ, @pointPosit )
If Meshfound
*Mesh.Matrix = MP_EntityGetMatrix (Meshfound)
*Mesh\m[12] = pointPosit\x
; If pointPosit\y <7
; pointPosit\y = 7
; EndIf
*Mesh\m[13] = pointPosit\y
*Mesh\m[14] = pointPosit\z
MP_3Dto2D(pointPosit\x,pointPosit\y,pointPosit\z, @pointPosit.vecf );= box\m[12], box\m[13], box\m[14])
MP_Circle (pointPosit\x, pointPosit\y, 30, MP_ARGB(0,255,0,0))
MP_DrawText (100,40,"Mesh "+Str(Meshfound)+" found")
EndIf
EndIf
Else
MP_EntitySetPhysic(Meshfound,1)
Mouseon = 0
EndIf
If MP_KeyDown(#PB_Key_Space)=1
ForEach MyList()
MP_FreeEntity(MyList()\Mesh)
DeleteElement(MyList())
Next
Newmesh ()
EndIf
MP_PhysicUpdate()
MP_RenderWorld()
MP_Flip()
Wend
MP_PhysicEnd() |
|
PureBasic | 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
| ;////////////////////////////////////////////////////////////////
;//
;// Project Title: MP 3D Engine Beispielprogramme
;// Dateiname: MP_Physic_CatchMove.pb
;// Erstellt am: 15.5.2011
;// Update am :
;// Author: Michael Paulwitz
;//
;// Info:
;// Catch Objekt and Moveit
;// Objekt nehmen und bewegen
;//
;//
;////////////////////////////////////////////////////////////////
Structure vecf
x.f
y.f
z.f
EndStructure
Structure matrix
m.f[16]
EndStructure
MP_Graphics3DWindow(0, 0, 800, 600, "MP3D Handle Demo, catch and move with mouse and Mousewheel w/s", 0)
light0 = MP_CreateLight(1)
MP_PositionEntity(light0, 0, 128, 0)
cam0 = MP_CreateCamera()
MP_CameraSetRange(cam0, 2, 2024)
MP_PositionCamera(cam0, -32, 64, -152)
MP_CameraLookAt(cam0, 0, 0, 0)
MP_PhysicInit()
tex0 = MP_LoadTexture("detail3.bmp")
tex1 = MP_LoadTexture("crate01.jpg")
;################ Bodenplatte ################
bodenplatte = MP_CreateRetangle(256, 1, 256) ; Bodenplatte kann natьrlich auch ein x-beliebiges Mesh sein
MP_ScaleMesh( bodenplatte ,0.6,0.6,0.6)
MP_EntitySetTexture(bodenplatte, tex0)
MP_EntityPhysicBody(bodenplatte, 1, 0)
;#############################################
Mesh = MP_CreateRetangle(5, 5, 5)
MP_EntitySetTexture(Mesh , tex1)
MP_EntityPhysicBody(Mesh , 2, 10)
MP_PositionEntity(Mesh, 0, 20,0)
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
If MP_MouseButtonDown(0) ; Linke Maustaste gedrьckt?
If Mouseon = 0
Meshfound = MP_PickCamera (cam0,WindowMouseX(0),WindowMouseY(0))
Mouseon = 1
MP_3Dto2D(MP_EntityGetX(Meshfound),MP_EntityGetY(Meshfound),MP_EntityGetZ(Meshfound), @pointPosit.vecf );= box\m[12], box\m[13], box\m[14])
KeyZ.f = pointPosit\z
MP_EntitySetPhysic(Meshfound,0)
Else
MP_2Dto3D(WindowMouseX(0),WindowMouseY(0),KeyZ, @pointPosit )
If Meshfound
*Mesh.Matrix = MP_EntityGetMatrix (Meshfound)
*Mesh\m[12] = pointPosit\x
If pointPosit\y <7
pointPosit\y = 7
EndIf
*Mesh\m[13] = pointPosit\y
*Mesh\m[14] = pointPosit\z
MP_3Dto2D(pointPosit\x,pointPosit\y,pointPosit\z, @pointPosit.vecf );= box\m[12], box\m[13], box\m[14])
MP_Circle (pointPosit\x, pointPosit\y, 30, MP_ARGB(0,255,0,0))
MP_DrawText (100,40,"Mesh "+Str(Meshfound)+" found")
EndIf
EndIf
Else
MP_EntitySetPhysic(Meshfound,1)
Mouseon = 0
EndIf
If MP_MouseDeltaWheel() > 0
KeyZ.f +0.0003
ElseIf MP_MouseDeltaWheel() <0
KeyZ.f - 0.0003
EndIf
If MP_EntityGetY(Mesh) < -60
MP_EntitySetY(Mesh,60)
MP_EntitySetX(Mesh,0)
MP_EntitySetZ(Mesh,0)
EndIf
MP_PhysicUpdate()
MP_RenderWorld()
MP_Flip()
Wend
MP_PhysicEnd() |
|
PureBasic | 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
| ;////////////////////////////////////////////////////////////////
;//
;// Project Title: MP 3D Engine Beispielprogramme
;// Dateiname: MP_Physic_Wall1.pb
;// Erstellt am: 15.5.2011
;// Update am :
;// Author: Michael Paulwitz
;//
;// Info:
;// Physic with some cube Meshs
;// Physik mit einigen Wьrfeln
;//
;//
;////////////////////////////////////////////////////////////////
Structure vecf
x.f
y.f
z.f
EndStructure
Structure matrix
m.f[16]
EndStructure
MP_Graphics3DWindow(0, 0, 800, 600, "MP3D Wall1 Demo, catch and move the cubes, Space to reset", 0)
light0 = MP_CreateLight(1)
MP_PositionEntity(light0, 0, 128, 0)
cam0 = MP_CreateCamera()
MP_CameraSetRange(cam0, 2, 2024)
MP_PositionCamera(cam0, -32, 64, -152)
MP_CameraLookAt(cam0, 0, 0, 0)
MP_PhysicInit()
tex0 = MP_LoadTexture("detail3.bmp")
tex1 = MP_LoadTexture("crate01.jpg")
;################ Bodenplatte ################
bodenplatte = MP_CreateRetangle(256, 1, 256) ; Bodenplatte kann natьrlich auch ein x-beliebiges Mesh sein
MP_ScaleMesh( bodenplatte ,0.6,0.6,0.6)
MP_EntitySetTexture(bodenplatte, tex0)
MP_EntityPhysicBody(bodenplatte, 1, 0)
;#############################################
NewList TempMesh()
For m = 0 To 7
For n = 0 To 7
AddElement(TempMesh())
TempMesh() = MP_CreateRetangle(5, 5, 5)
MP_EntitySetTexture(TempMesh() , tex1)
MP_EntityPhysicBody(TempMesh(), 2, 10)
MP_PositionEntity(TempMesh(), (m-4) * 6, n * 5.2 + 5 ,0)
Next
Next
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
If MP_MouseButtonDown(0) ; Linke Maustaste gedrьckt?
If Mouseon = 0
Meshfound = MP_PickCamera (cam0,WindowMouseX(0),WindowMouseY(0))
Mouseon = 1
MP_3Dto2D(MP_EntityGetX(Meshfound),MP_EntityGetY(Meshfound),MP_EntityGetZ(Meshfound), @pointPosit.vecf );= box\m[12], box\m[13], box\m[14])
KeyZ.f = pointPosit\z
MP_EntitySetPhysic(Meshfound,0)
Else
MP_2Dto3D(WindowMouseX(0),WindowMouseY(0),KeyZ, @pointPosit )
If Meshfound
*Mesh.Matrix = MP_EntityGetMatrix (Meshfound)
*Mesh\m[12] = pointPosit\x
If pointPosit\y <7
pointPosit\y = 7
EndIf
*Mesh\m[13] = pointPosit\y
*Mesh\m[14] = pointPosit\z
MP_3Dto2D(pointPosit\x,pointPosit\y,pointPosit\z, @pointPosit.vecf );= box\m[12], box\m[13], box\m[14])
MP_Circle (pointPosit\x, pointPosit\y, 30, MP_ARGB(0,255,0,0))
MP_EntitySetPhysicMatrix (Meshfound, *Mesh)
MP_DrawText (100,40,"Mesh "+Str(Meshfound)+" found")
EndIf
EndIf
Else
MP_EntitySetPhysic(Meshfound,1)
Mouseon = 0
EndIf
If MP_MouseDeltaWheel() > 0
KeyZ.f +0.0003
ElseIf MP_MouseDeltaWheel() <0
KeyZ.f - 0.0003
EndIf
If MP_KeyDown(#PB_Key_Space)=1
FirstElement(TempMesh())
For m = 0 To 7
For n = 0 To 7
MP_EntityResetPhysic(TempMesh())
MP_PositionEntity(TempMesh(), (m-4) * 6, n * 5.2 + 5 ,0)
NextElement(TempMesh())
Next
Next
EndIf
MP_DrawText (1,1,"FPS = "+Str(MP_FPS()))
MP_PhysicUpdate()
MP_RenderWorld()
MP_Flip()
Wend
MP_PhysicEnd() |
|
1
|