This tip shows Primitives can not be Added like Meshes (unremark commented code lines to see it):
Code: Select all
ExamineDesktops()
Global bitplanes.b=DesktopDepth(0),RX.u=DesktopWidth(0)/2,RY.u=DesktopHeight(0)/2
MP_Graphics3D(RX,RY,0,1):MP_VSync(1)
SetWindowTitle(0,"Orbitar")
Procedure.f MP_EntityDistance(c,o)
Protected vx.f=MP_EntityGetX(o)-MP_EntityGetX(c),vy.f=MP_EntityGetY(o)-MP_EntityGetY(c),vz.f=MP_EntityGetZ(o)-MP_EntityGetZ(c)
ProcedureReturn Sqr(vx*vx+vy*vy+vz*vz)
EndProcedure
light=MP_CreateLight(2)
MP_LightSetColor(light,RGB(119,118,50))
MP_PositionEntity(light,-6,10,-5)
MP_AmbientSetLight(RGB(0,100,120))
d.f=0.5:color.l=$AA3E77BB
mesh=MP_CreatePrimitives(10,3)
MP_SetPrimitives(mesh,0,-d,d,-d,$AA3E77BB)
MP_SetPrimitives(mesh,1,-d,-d,-d,$AA3E77BB)
MP_SetPrimitives(mesh,2,d,-d,-d,$AA3E77BB)
MP_SetPrimitives(mesh,3,d,d,-d,$AA3E77BB)
MP_SetPrimitives(mesh,4,-d,d,-d,$AA3E77BB)
MP_SetPrimitives(mesh,5,-d,d,d,$AA3E77BB)
MP_SetPrimitives(mesh,6,-d,-d,d,$AA3E77BB)
MP_SetPrimitives(mesh,7,d,-d,d,$AA3E77BB)
MP_SetPrimitives(mesh,8,d,d,d,$AA3E77BB)
MP_SetPrimitives(mesh,9,-d,d,d,$AA3E77BB)
mesh2=MP_CreatePrimitives(2,2):MP_SetPrimitives(mesh2,0,-d,-d,-d,$AA3E77BB):MP_SetPrimitives(mesh2,1,-d,-d,d,$AA3E77BB)
mesh3=MP_CreatePrimitives(2,2):MP_SetPrimitives(mesh3,0,d,-d,-d,$AA3E77BB):MP_SetPrimitives(mesh3,1,d,-d,d,$AA3E77BB)
mesh4=MP_CreatePrimitives(2,2):MP_SetPrimitives(mesh4,0,d,d,-d,$AA3E77BB):MP_SetPrimitives(mesh4,1,d,d,d,$AA3E77BB)
; MP_AddMesh(mesh4,mesh)
; MP_AddMesh(mesh3,mesh)
; MP_AddMesh(mesh2,mesh)
; MP_FreeEntity(mesh4)
; MP_FreeEntity(mesh3)
; MP_FreeEntity(mesh2)
camera=MP_CreateCamera()
MP_PositionEntity(camera,0,2,-5)
Procedure Orbitar(c,dx.d,dy.d,dz.d,o,r.d)
;Funcion para orbitar una entidad '*c' alrededor de otra '*o' siendo 'dx' y 'dy' los incrementos de las coordenadas sobre la superficie de una esfera de orbitación de radio 'r'. 'dz' es el incremento del radio 'r'.
;Function to make a 3D entity '*c' to orbitate around another 3D entity '*o' being 'dx' y 'dy' the increments of the coords over the orbitation sphere surface with radius 'r'. 'dz' is the increment of the radius 'r'.
MP_MoveEntity(c,dx,dy,0)
MP_PointEntity(c,o)
MP_MoveEntity(c,0,0,Sqr(dx*dx+dy*dy+r*r)-r+dz)
EndProcedure
m.f=MP_EntityDistance(camera,mesh)
MP_UseCursor(0):MP_MouseInWindow()
Repeat
mdw.f=MP_MouseDeltaWheel()/400
m-mdw
Orbitar(camera,m*-MP_MouseDeltaX()/200,m*MP_MouseDeltaY()/200,mdw,mesh,m)
MP_RenderWorld()
MP_Flip()
Until MP_KeyHit(#PB_Key_Escape)