Hi,
@applePi -> how to save the points coordinates easily
MP_SavePrimitives (Entity, File.s)
and
MP_LoadPrimitives (File.s)
or
*memory = MP_GetMemPrimitives(Entity)
size = MP_SizeMemPrimitives(Entity)
openfile...
WriteData(0, *memory , size )
closefile
@Gnom -> car physics example for mp3d
i use newton dynamic 3.11, if you find a demo i can make an example. i had no time fro searching...
@Mythros -> kinect
i have no kinetic device, i think the price is 100 Euro. If you have some data file i can have a look on it to make a 3d mesh from these
@applePi -> i get 2D and not 3D shape
little error, you read only 2 parameter not three -> use -> vx(k) = ValF(StringField(a$, k+1, " "))
greetings Michael
Code: Select all
#Mode = 7 ; #Mode = 1 or #Mode = 7
Structure PointVertex
x.f
y.f
z.f
CompilerIf #Mode = 7
Size.f ;--- Only if Mode = 7
CompilerEndIf
Color.l;d3dcolor
EndStructure
Global mAngle.f = Cos(-0.005)
Global pAngle.f = Sin(0.005)
; code for MP3D
Declare DrawMatrix()
Declare isolate()
Global angle.f
Global xres=640, yres=480
MP_Graphics3D (xres,yres,0,3)
SetWindowTitle(0, "press up/down to move camera ")
camera=MP_CreateCamera()
light=MP_CreateLight(2)
MP_LightSetColor (light, RGB(255,255,255))
MP_PositionEntity(light, 0, 10, 20)
MP_EntityLookAt(light,0,0,0)
Global size = 16642
Global Entity= MP_CreatePrimitives (size, #Mode)
Define.f red, green, blue
Quit.b = #False
;==============================================================
MP_ScaleEntity(Entity, 1.5, 1.5, 1.5)
;MP_MeshSetBlendColor(Entity, $FFFFFFFF)
;MP_MeshSetAlpha(Entity,3)
;MP_MeshAlphaSort(Entity);
DrawMatrix()
MP_PrimitivesBlendingMode(Entity, 5,2)
MP_PositionCamera(camera, 0, 0, 700)
MP_CameraLookAt(camera,0,0,0)
MP_PositionEntity(light, 0 , 0, 10)
MP_EntityLookAt(light,0,0,0)
;MP_VSync(0)
xx.f=0 :zz.f=0
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
If MP_KeyDown(#PB_Key_Up)
zz.f + 20
ElseIf MP_KeyDown(#PB_Key_Down)
zz.f - 20
EndIf
MP_PositionEntity(Entity, xx, 0, zz)
MP_TurnEntity(Entity,0,1,0)
;isolate(); call the routine for rotating only the green points
MP_DrawText (1,1,"FPS = "+Str(MP_FPS()))
MP_RenderWorld()
MP_Flip ()
Wend
Procedure DrawMatrix()
ReadFile(0, "data.txt")
Dim vx.f(3)
x.f:y.f:z.f
*Memory = MP_GetMemPrimitives(Entity)
For i=0 To size ;size 16641
*myvertex.PointVertex = *Memory + i * SizeOf(PointVertex)
a$ = ReadString(0)
For k=1 To 3
vx(k) = ValF(StringField(a$, k+1, " "))
Next
r=0:g=255:b=0
*myvertex\x = vx(2)/64
*myvertex\y = -vx(1)/64
*myvertex\z = vx(3)/64
*myvertex\color = MP_ARGB(200,r,g,(vx(2)+800)/10)
Next
MP_CloseMemPrimitives(Entity)
CloseFile(0)
EndProcedure
Procedure isolate() ; rotate green core
angle.f = 0.05
*Memory = MP_GetMemPrimitives(Entity)
*myvertex.PointVertex = *Memory
For i=0 To size
;If *myvertex\Color & $FF00
x.f = *myvertex\x
z.f = *myvertex\z
*myvertex\x = mAngle* x - pAngle* z
*myvertex\z = mAngle* z + pAngle* x
CompilerIf #Mode = 7
*myvertex\Size = 2.5 ;--- Only if Mode = 7
CompilerEndIf
;EndIf
*myvertex + SizeOf(PointVertex)
Next
MP_CloseMemPrimitives(Entity)
EndProcedure