MP3D Engine Alpha 33

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 32

Post by Psychophanta »

A question: Are not Primitives the same as Meshes?
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)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 32

Post by mpz »

Hello,

@Psychophanta

the command "MP_PickCamera" works fine in a normal Render loop. If you use them in a CameraViewPort mode you must make two different camera loops and the command works fine, see example. I will have a look on it, perhaps i can find a solution to make it in your example working too.

Code: Select all

WindowWidth=640:WindowHeigh=480
MP_Graphics3D(WindowWidth,WindowHeigh,0,2)
ViewPortX=300:ViewPortY=60:ViewPortWidth=100:ViewPortHeigh=400
light=MP_CreateLight(1)
m=MP_CreateCube()
MP_EntitySetZ(m,8)
cam=MP_CreateCamera()
ViewPortA = MP_CameraViewPort(cam,ViewPortX,ViewPortY,ViewPortWidth,ViewPortHeigh,$008B340A)
MP_CameraSetPerspective(cam,45,ViewPortWidth/ViewPortHeigh)

ViewPortX2=400:ViewPortY2=80:ViewPortWidth2=200:ViewPortHeigh2=300
cam2=MP_CreateCamera()
ViewPortB = MP_CameraViewPort(cam2,ViewPortX2,ViewPortY2,ViewPortWidth2,ViewPortHeigh2,$00346B0A)
MP_CameraSetPerspective(cam2,45,ViewPortWidth2/ViewPortHeigh2)
m2=MP_CreateCube()
MP_EntitySetZ(m2,-1000)
MP_PositionEntity(cam2,0,0,-995)
MP_PointEntity(cam2,m2)

While WindowEvent()<>#PB_Event_CloseWindow
  
  MP_RenderBegin(cam,ViewPortA) ;
  picked=MP_PickCamera(cam,WindowMouseX(0),WindowMouseY(0)); <---- MP_PickCamera() does not work correctly here !!
  MP_DrawText(300,60,Hex(picked)+" found")
  If picked   
     MP_Wireframe (1) 
     MP_RenderMesh (picked)
   EndIf
   MP_Wireframe (0)
   MP_RenderText ()
   MP_RenderMesh()
   MP_RenderEnd() 
  
  
  MP_RenderBegin(cam2,ViewPortB) ;
  picked2=MP_PickCamera(cam2,WindowMouseX(0),WindowMouseY(0))
  MP_DrawText(400,80,Hex(picked2)+" found")
  If picked2   
     MP_Wireframe (1) 
     MP_RenderMesh (picked2)
  EndIf
  MP_Wireframe (0)
  MP_RenderText ()
  MP_RenderMesh()
  MP_RenderEnd() 
  
  MP_TurnEntity(m,-0.1,0.3,-0.23)
  MP_TurnEntity(m2,0.3,-0.23,-0.1)
  MP_Flip()  
  
Wend
* Meshs and Primitives are in MP3d different =

I make Mesh with this command:
http://msdn.microsoft.com/de-de/library ... 85%29.aspx
vantage, load and save as Direct x mesh but It is made only of triangles with different textures or colour vertex

I make primitives with this command:
http://msdn.microsoft.com/de-de/library ... 85%29.aspx
vantage, You can show different geometric types on screen (points, lines, triangles), but you can't mix different types in one primitives and can't load and save it as directx Mesh, Physic funktion not possible for now too

Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 32

Post by Psychophanta »

Thank you again Michael.
I would suggest add something like your last tip to the Examples in MP3D package.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 32

Post by mpz »

Hello,

@applePi, i have integrated only 10% of the newtondynamics funtions. If you need more commands, tell me and i will integrate them...
http://newtondynamics.com/forum/newton.php


@Psychophanta

i forget to tell you the Funktion KeyboardReleased(Key) has in MP3D the Name MP_KeyHit(key)

Now the command "MP_PickCamera" works fine in normal Render loop and in CameraViewport Modus too.

i have made a new lib for testing

Automatic Installer (use mp3d_library only)
http://www.flasharts.de/mpz/mp33_beta/M ... taller.exe


Manually installation for PB5.22 < 5.31 (x86)
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip

Manually installation for PB5.11 > 4.60 (x86)
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip

Code: Select all

WindowWidth=640:WindowHeigh=480
MP_Graphics3D(WindowWidth,WindowHeigh,0,2)
ViewPortX=300:ViewPortY=60:ViewPortWidth=100:ViewPortHeigh=400
light=MP_CreateLight(1)
m=MP_CreateCube()
MP_EntitySetZ(m,8)
cam=MP_CreateCamera()
MP_CameraViewPort(cam,ViewPortX,ViewPortY,ViewPortWidth,ViewPortHeigh,$008B340A)
MP_CameraSetPerspective(cam,45,ViewPortWidth/ViewPortHeigh)

ViewPortX2=400:ViewPortY2=80:ViewPortWidth2=200:ViewPortHeigh2=300
cam2=MP_CreateCamera()
MP_CameraViewPort(cam2,ViewPortX2,ViewPortY2,ViewPortWidth2,ViewPortHeigh2,$00346B0A)
MP_CameraSetPerspective(cam2,45,ViewPortWidth2/ViewPortHeigh2)
m2=MP_CreateCube()
MP_EntitySetZ(m2,-1000)
MP_PositionEntity(cam2,0,0,-995)
MP_PointEntity(cam2,m2)

MP_AmbientSetLight (RGB(120,34,123)) ; purple backgroundcolor

While WindowEvent()<>#PB_Event_CloseWindow
  picked=MP_PickCamera(cam,WindowMouseX(0),WindowMouseY(0))
  MP_DrawText(100,40,"Mesh "+Hex(picked)+" found")
  picked2=MP_PickCamera(cam2,WindowMouseX(0),WindowMouseY(0))
  MP_DrawText(100,70,"Mesh2 "+Hex(picked2)+" found")
  MP_TurnEntity(m,-0.1,0.3,-0.23)
  MP_TurnEntity(m2,0.3,-0.23,-0.1)
  MP_RenderWorld()
  MP_Flip()
Wend
Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 32

Post by Psychophanta »

Several points:
1) Please take a close look : because MP_KeyHit(key) does not return true when key is released, but when is just hitted-on.

2) I have noticed that 2D stuff is a bit slow in your lib in comparison with Ogre or Blitz3D for example. May be my VGA problem?

3) Nice and thanks for the new lib with Pick stuff improved (even i already fixed my program for it :? ).
But, please take care when dealing with sacrify speed. :D
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 32

Post by applePi »

Hi Michael
i am trying to make my "pendulum with escapement" demo to run again http://purebasic.fr/english/viewtopic.p ... 10#p428893 since i have buyed specially at that time a real pendulum with escapement to look at its working closely before designing this toy program,
but it does not run with the new library since there are some functions changes.
MP_ChangeMeshCoord(Entity,*Matrix.D3DXMATRIX) :
how to add the *Matrix.D3DXMATRIX
may be also other things
in concise how to edit this examples to work again, also could we add tick tack tick tack sound ??
i will look at the newtondynamics .
here is the example again for your convenience:
note that i have edited it in july 19 2014 to be compatible with july 19 library version

Code: Select all

ExamineDesktops()
Global bitplanes.b=DesktopDepth(0),RX.w=DesktopWidth(0),RY.w=DesktopHeight(0),s_bg.i
MP_Graphics3D(RX,RY,0,1);MP_VSync(0)
SetWindowTitle(0, "MP3D Physik Pendulum & Escapement demo, press Space , Z for more testing ") 

camera = MP_CreateCamera()    ; Kamera erstellen

MP_PositionEntity(camera, 0, 0, -5 )
MP_EntityLookAt(camera,0,0,0)

light= MP_CreateLight(0)    ; Es werde Licht

MP_AmbientSetLight (RGB(0,100,200))

;construction of a gear with 18 teeth
ang=40 ; the angle wanted for every tooth of the gear
Mesh = MP_CreateCylinder(10,0.2)
For i=1 To 18
angle.f+20
x.f = Cos(Radian(angle)) * 1: z.f = Sin(Radian(angle)) * 1
Mesh2 = MP_CreateRectangle (0.5,0.05,0.2)
MP_PositionEntity (Mesh2,x,z,0)
ang+20
MP_RotateEntity(Mesh2 , 0 , 0, ang)
MP_ChangeMeshCoord(Mesh2)
MP_AddMesh(Mesh2 , Mesh ) : MP_FreeEntity(Mesh2)
Next

MP_EntitySetNormals (Mesh)
MP_MaterialDiffuseColor (Mesh,255,255,255,50)
MP_MaterialSpecularColor (Mesh, 255, 255 ,255, 155,5)
;MP_MeshSetAlpha(Mesh, 1)

escape = MP_CreateRectangle (1.5,0.05,0.2) ;the rod above the gear teeth
MP_PositionEntity (escape, 0, 0, 0)
escape2 = MP_CreateRectangle (0.5,0.05,0.2) ; the right small piece attached to the rod
MP_PositionEntity (escape2, 0.7, -0.1, 0)
MP_RotateEntity(escape2 , 0 , 0, 90)
MP_ChangeMeshCoord(escape2)
MP_AddMesh(escape2 , escape ) : MP_FreeEntity(escape2)

escape2 = MP_CreateRectangle (0.5,0.05,0.2) ; the left small piece attached to the rod
MP_PositionEntity (escape2, -0.7, -0.1, 0)
MP_RotateEntity(escape2 , 0 , 0, -100)
MP_ChangeMeshCoord(escape2)
MP_AddMesh(escape2 , escape ) : MP_FreeEntity(escape2)

; pendulum
Mesh7 = MP_CreateRectangle (0.05,2.5,0.05)
MP_PositionEntity (Mesh7, 0, -1.3, -0.3)
MP_ChangeMeshCoord(Mesh7)
MP_AddMesh(Mesh7 , escape ) :MP_FreeEntity(Mesh7)

sphere = MP_CreateSphere(10)
MP_ResizeMesh(sphere,0.5,0.5,0.3)
MP_PositionEntity (sphere, 0, -2.3,  -0.5)
;MP_ChangeMeshCoord(sphere)
;MP_AddMesh(sphere , escape ) :MP_FreeEntity(sphere)

; repositioning of the rod and its 2 attached pieces above the gear teeth
MP_PositionEntity (escape, 0, 1.35, 0) ; repositioning of the rod and its 2 attached pieces above the gear teeth

MP_EntitySetNormals (escape)
MP_MaterialDiffuseColor (escape,255,33,255,50)
MP_MaterialSpecularColor (escape, 255, 255 ,255, 155,5)

MP_PhysicInit()
MP_ChangeMeshCoord(sphere)
;MP_EntityPhysicBody(sphere , 5, 1)
MP_AddMesh(sphere , escape ) :MP_FreeEntity(sphere)

MP_EntityPhysicBody(escape , 5, 2)
;MP_ConstraintCreateHinge(Entity, PinX.f, PinY.f, PinZ.f [, Pivotx.f, Pivoty.f, Pivotz.f [, MasterEntity]]); create a Hinge joint functions 
MP_ConstraintCreateHinge (escape,0,0,1)

MP_EntityPhysicBody(Mesh , 5, 10)
MP_ConstraintCreateHinge (Mesh,0,0,1)
;MP_EntitySetWind(Mesh, 1.0 , 1.0 ,0)


While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
        
    MP_EntityAddImpulse(Mesh, 0, -0.5, 0 , -1.7,0, 0)
    
   If MP_KeyHit(#PB_Key_Space)
          MP_EntityAddImpulse(escape, -1, 0, 0 , 1,0, 0)
          MP_EntityAddImpulse(Mesh, 0, -0.1, 0 , -1.7,0, 0)
        ElseIf MP_KeyHit(#PB_Key_Z) 
          MP_PositionEntity (escape, 0, 2.5, 0)
          
   EndIf
    
    MP_PhysicUpdate()
    
    MP_RenderWorld() ; Erstelle die Welt
    MP_Flip () ; Stelle Sie dar
    
Wend
  
MP_PhysicEnd()
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 32

Post by mpz »

Hi,

@Psychophanta,

1) new command MP_KeyRelease(#PB_Key) integrated, new lib created for download ready now (see answer before to load lib)
2) "2D stuff is a bit slow in your lib in comparison with Ogre or Blitz3D for example",
Please make testcode for ogre or blitz3d. i will see what i can do

@applePi, you dont need the MP_ChangeMeshCoord for these anymore. I have changed you code to work and have remarked them....
61) rename function: MP_PositionMesh(Entity,x.f,y.f,z.f) -> new name MP_TranslateMesh(Entity,x.f,y.f,z.f)
62) new function added: MP_RotateMesh(Entity, pitch.f, yaw.f, roll.f) -> The function MP_RotateMesh rotate the vertice of a mesh

Code: Select all

ExamineDesktops()
Global bitplanes.b=DesktopDepth(0),RX.w=DesktopWidth(0),RY.w=DesktopHeight(0),s_bg.i
MP_Graphics3D(RX,RY,0,1);MP_VSync(0)
SetWindowTitle(0, "MP3D Physik Pendulum & Escapement demo, press Space , Z for more testing ")

camera = MP_CreateCamera()    ; Kamera erstellen

MP_PositionEntity(camera, 0, 0, -5 )
MP_EntityLookAt(camera,0,0,0)

light= MP_CreateLight(0)    ; Es werde Licht

MP_AmbientSetLight (RGB(0,100,200))

;construction of a gear with 18 teeth
ang=40 ; the angle wanted for every tooth of the gear
Mesh = MP_CreateCylinder(10,0.2)
For i=1 To 18
angle.f+20
x.f = Cos(Radian(angle)) * 1: z.f = Sin(Radian(angle)) * 1
Mesh2 = MP_CreateRectangle (0.5,0.05,0.2)
;MP_PositionEntity (Mesh2,x,z,0)
;ang+20
;MP_RotateEntity(Mesh2 , 0 , 0, ang)
;MP_ChangeMeshCoord(Mesh2)

ang+20
MP_RotateMesh(Mesh2 , 0 , 0, ang)
MP_TranslateMesh(Mesh2,x,z,0)


MP_AddMesh(Mesh2 , Mesh ) : MP_FreeEntity(Mesh2)
Next

MP_EntitySetNormals (Mesh)
MP_MaterialDiffuseColor (Mesh,255,255,255,50)
MP_MaterialSpecularColor (Mesh, 255, 255 ,255, 155,5)
;MP_MeshSetAlpha(Mesh, 1)

escape = MP_CreateRectangle (1.5,0.05,0.2) ;the rod above the gear teeth
MP_PositionEntity (escape, 0, 0, 0)
escape2 = MP_CreateRectangle (0.5,0.05,0.2) ; the right small piece attached to the rod
;MP_PositionEntity (escape2, 0.7, -0.1, 0)
;MP_RotateEntity(escape2 , 0 , 0, 90)
;MP_ChangeMeshCoord(escape2)
MP_RotateMesh(escape2 , 0 , 0, 90)
MP_TranslateMesh(escape2, 0.7, -0.1, 0)

MP_AddMesh(escape2 , escape ) : MP_FreeEntity(escape2)

escape2 = MP_CreateRectangle (0.5,0.05,0.2) ; the left small piece attached to the rod
;MP_PositionEntity (escape2, -0.7, -0.1, 0)
;MP_RotateEntity(escape2 , 0 , 0, -100)
;MP_ChangeMeshCoord(escape2)
MP_RotateMesh(escape2 , 0 , 0, -100)
MP_TranslateMesh(escape2, -0.7, -0.1, 0)

MP_AddMesh(escape2 , escape ) : MP_FreeEntity(escape2)

; pendulum
Mesh7 = MP_CreateRectangle (0.05,2.5,0.05)
;MP_PositionEntity (Mesh7, 0, -1.3, -0.3)
;MP_ChangeMeshCoord(Mesh7)
MP_TranslateMesh(Mesh7, 0, -1.3, -0.3)

MP_AddMesh(Mesh7 , escape ) :MP_FreeEntity(Mesh7)

sphere = MP_CreateSphere(10)
MP_ResizeMesh(sphere,0.5,0.5,0.3)
;MP_PositionEntity (sphere, 0, -2.3,  -0.5)
;MP_ChangeMeshCoord(sphere)
MP_TranslateMesh(sphere, 0, -2.3,  -0.5)



; repositioning of the rod and its 2 attached pieces above the gear teeth
MP_PositionEntity (escape, 0, 1.35, 0) ; repositioning of the rod and its 2 attached pieces above the gear teeth

MP_EntitySetNormals (escape)
MP_MaterialDiffuseColor (escape,255,33,255,50)
MP_MaterialSpecularColor (escape, 255, 255 ,255, 155,5)

MP_PhysicInit()
;MP_EntityPhysicBody(sphere , 5, 1)
MP_AddMesh(sphere , escape ) :MP_FreeEntity(sphere)

MP_EntityPhysicBody(escape , 5, 2)
;MP_ConstraintCreateHinge(Entity, PinX.f, PinY.f, PinZ.f [, Pivotx.f, Pivoty.f, Pivotz.f [, MasterEntity]]); create a Hinge joint functions
MP_ConstraintCreateHinge (escape,0,0,1)

MP_EntityPhysicBody(Mesh , 5, 10)
MP_ConstraintCreateHinge (Mesh,0,0,1)
;MP_EntitySetWind(Mesh, 1.0 , 1.0 ,0)


While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
       
    MP_EntityAddImpulse(Mesh, 0, -0.5, 0 , -1.7,0, 0)
   
   If MP_KeyHit(#PB_Key_Space)
          MP_EntityAddImpulse(escape, -1, 0, 0 , 1,0, 0)
          MP_EntityAddImpulse(Mesh, 0, -0.1, 0 , -1.7,0, 0)
        ElseIf MP_KeyHit(#PB_Key_Z)
          MP_PositionEntity (escape, 0, 2.5, 0)
         
   EndIf
   
    MP_PhysicUpdate()
   
    MP_RenderWorld() ; Erstelle die Welt
    MP_Flip () ; Stelle Sie dar
   
Wend
 
MP_PhysicEnd()
 
Greetinsg Michael
Working on - MP3D Library - PB 5.73 version ready for download
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 32

Post by applePi »

Hi Michael
** adding spring joint will be great, this is something like :
Image
when we press the blue cube by a weight or a force it will go down, and when we release the force it will return up, the red cube can be static or sitting on the ground. it is possible can be done with the available joints. may be with a slider joint like this: http://www.purebasic.fr/english/viewtop ... 25#p429540
you may find these links usefull:
http://newtondynamics.com/forum/viewtop ... ngs#p53877
http://www.newtondynamics.com/forum/vie ... =10&t=6760
http://www.ogre3d.org/addonforums/viewtopic.php?t=8625

** can you correct this small code: http://www.purebasic.fr/english/viewtop ... 10#p429359
the joint should be able to rotate and to move, such as this picture
http://postimg.org/image/y2tlz4drl/
but it does not now. even it show the effect but the hinge does not rotate nor move.

Code: Select all

;// Project Title: MP 3D Engine Beispielprogramme
 ;// Dateiname: MP_Physik_ConstraintCreatHinge.pb
 ;// Erstellt am: 11.8.2011
 ;// Update am  : 
 ;// Author: Michael Paulwitz
 ;// 
 ;// Info: 
 ;// Physic with Hinge
 ;// Physik mit Rad
 ;//
 ;//
 ;////////////////////////////////////////////////////////////////
 ;MP_Physik_ConstraintCreatHinge tutorial
 ExamineDesktops()
 Global bitplanes.b=DesktopDepth(0),RX.w=DesktopWidth(0),RY.w=DesktopHeight(0),s_bg.i
 MP_Graphics3D(RX,RY,0,1);MP_VSync(0)
 SetWindowTitle(0, "Press left/Right move pivot _ Up/Down rotate pivot _ space drop stone") 
 Declare HingePosition(disp.f)
 Declare dropStone()
 
 camera = MP_CreateCamera()    ; Kamera erstellen
 MP_PositionEntity(camera, 0, 5, -5 )
 MP_EntityLookAt(camera,0,0,0)

 light= MP_CreateLight(2)    ; Es werde Licht
 MP_LightSetColor(light, RGB(255,128,50))
 MP_PositionEntity(light, -6 , 10, -5)
   
 MP_AmbientSetLight (RGB(0,100,200))
 Global.f hingX=0,hingY=0,hingZ=0, disp.f
 Global piv = MP_CreateCylinder(10,1)
 Global.f length = 6, angle = 0, rot = 5, dirX = 1, dirZ = 1
 Global stone
 MP_ResizeMesh(piv,0.4,0.4,0.4)
 Global Mesh = MP_CreateRectangle (length,0.05,0.5)
 MP_PositionEntity (Mesh,0,0,0)
 MP_PositionEntity (piv,hingX,hingY,hingZ) ; the pivot position
 HingePosition(0)
 
 While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
   If MP_KeyHit(#PB_Key_Right)
     disp.f = 0.5 ; disp :the displacement og the Hinge to the right
     rot = 0 ; we don't want to change the pivot angle when we move pivot left or right
     HingePosition(disp)
    
   ElseIf MP_KeyHit(#PB_Key_Left)
     disp = -0.5 ; disp :the displacement of the Hinge to the left
     rot = 0 
     HingePosition(disp)
   EndIf  
      
   If MP_KeyHit(#PB_Key_Up)
     rot = 5 ; the increment of angle
     disp = 0
     HingePosition(disp)
     ElseIf MP_KeyHit(#PB_Key_Down) 
       rot = -5  ;the decrement of angle
       disp = 0
       HingePosition(disp)
   EndIf  
     
   If MP_KeyHit(#PB_Key_Space)
     dropStone()
   
   EndIf
    
     MP_Drawtext(10,20,"Length of rect="+StrF(length,2)+" /   Hinge relative X Position = "+StrF(HingX,2) + "   Y = 0  " + "  Z = 0")
     MP_Drawtext(10,40,"Angle= "+StrF(angle,2))
     MP_PhysicUpdate()
     MP_RenderWorld() ; Erstelle die Welt
     MP_Flip () ; Stelle Sie dar
     
 Wend
   
 MP_PhysicEnd()
 

 Procedure HingePosition(disp.f )
     hingX + disp
     MP_FreeEntity(Mesh): MP_FreeEntity(piv)
     piv = MP_CreateCylinder(10,1)
     MP_ResizeMesh(piv,0.4,0.4,0.4)
     MP_RotateEntity(piv , 0 , angle, 0)
     angle + rot     
     Mesh = MP_CreateRectangle (length,0.05,0.5)
     MP_PositionEntity (Mesh,0,0,0)
     MP_PositionEntity (piv,hingX,hingY,hingZ) ; the pivot position relative to the Mesh
     ;MP_ChangeMeshCoord(piv)
     MP_AddMesh(piv , Mesh ) : MP_FreeEntity(piv)
     MP_PhysicInit()
     MP_EntityPhysicBody(Mesh , 4, 10)
     
     ;http://www.mathwarehouse.com/vectors/images/main/how-To-solve.gif
     dirX = 1*Sin(Radian(angle)) ; the X component of the pivot vector
     dirZ = 1*Cos(Radian(angle)) ; the Z component of the pivot vector
     
     MP_ConstraintCreateHinge (Mesh,dirX,0,dirZ,hingX,hingY,hingZ)
     
     MP_EntitySetNormals (Mesh)
     MP_MaterialDiffuseColor (Mesh,255,255,128,50)
     MP_MaterialSpecularColor (Mesh, 255, 255 ,255, 155,5)
   EndProcedure
   
   Procedure dropStone()
   stone = MP_CreateRectangle(1,1,1)
   MP_EntityPhysicBody(stone, 2, 1)
   ;MP_EntitySetGravity(stone, 0 , -1 ,0)
   MP_PositionEntity (stone,-2.5,1,0)  
   stone2 = MP_CreateRectangle(1,1,1)
   MP_EntityPhysicBody(stone2, 2, 1)
   ;MP_EntitySetGravity(stone2, 0 , -1 ,0)
   MP_PositionEntity (stone2,1,1,0)  
    
   EndProcedure
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 32

Post by Psychophanta »

applePi wrote: ** can you correct this small code: http://www.purebasic.fr/english/viewtop ... 10#p429359
the joint should be able to rotate and to move, such as this picture
http://postimg.org/image/y2tlz4drl/
but it does not now. even it show the effect but the hinge does not rotate nor move.

Code: Select all

;// Project Title: MP 3D Engine Beispielprogramme
 ;// Dateiname: MP_Physik_ConstraintCreatHinge.pb
 ;// Erstellt am: 11.8.2011
 ;// Update am  : 
 ;// Author: Michael Paulwitz
 ;// 
 ;// Info: 
 ;// Physic with Hinge
 ;// Physik mit Rad
 ;//
 ;//
 ;////////////////////////////////////////////////////////////////
 ;MP_Physik_ConstraintCreatHinge tutorial
 ExamineDesktops()
 Global bitplanes.b=DesktopDepth(0),RX.w=DesktopWidth(0),RY.w=DesktopHeight(0),s_bg.i
 MP_Graphics3D(RX,RY,0,1);MP_VSync(0)
 SetWindowTitle(0, "Press left/Right move pivot _ Up/Down rotate pivot _ space drop stone") 
 Declare HingePosition(disp.f)
 Declare dropStone()
 
 camera = MP_CreateCamera()    ; Kamera erstellen
 MP_PositionEntity(camera, 0, 5, -5 )
 MP_EntityLookAt(camera,0,0,0)

 light= MP_CreateLight(2)    ; Es werde Licht
 MP_LightSetColor(light, RGB(255,128,50))
 MP_PositionEntity(light, -6 , 10, -5)
   
 MP_AmbientSetLight (RGB(0,100,200))
 Global.f hingX=0,hingY=0,hingZ=0, disp.f
 Global piv = MP_CreateCylinder(10,1)
 Global.f length = 6, angle = 0, rot = 5, dirX = 1, dirZ = 1
 Global stone
 MP_ResizeMesh(piv,0.4,0.4,0.4)
 Global Mesh = MP_CreateRectangle (length,0.05,0.5)
 MP_PositionEntity (Mesh,0,0,0)
 MP_PositionEntity (piv,hingX,hingY,hingZ) ; the pivot position
 HingePosition(0)
 
 While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
   If MP_KeyHit(#PB_Key_Right)
     disp.f = 0.5 ; disp :the displacement og the Hinge to the right
     rot = 0 ; we don't want to change the pivot angle when we move pivot left or right
     HingePosition(disp)
    
   ElseIf MP_KeyHit(#PB_Key_Left)
     disp = -0.5 ; disp :the displacement of the Hinge to the left
     rot = 0 
     HingePosition(disp)
   EndIf  
      
   If MP_KeyHit(#PB_Key_Up)
     rot = 5 ; the increment of angle
     disp = 0
     HingePosition(disp)
     ElseIf MP_KeyHit(#PB_Key_Down) 
       rot = -5  ;the decrement of angle
       disp = 0
       HingePosition(disp)
   EndIf  
     
   If MP_KeyHit(#PB_Key_Space)
     dropStone()
   
   EndIf
    
     MP_Drawtext(10,20,"Length of rect="+StrF(length,2)+" /   Hinge relative X Position = "+StrF(HingX,2) + "   Y = 0  " + "  Z = 0")
     MP_Drawtext(10,40,"Angle= "+StrF(angle,2))
     MP_PhysicUpdate()
     MP_RenderWorld() ; Erstelle die Welt
     MP_Flip () ; Stelle Sie dar
     
 Wend
   
 MP_PhysicEnd()
 

 Procedure HingePosition(disp.f )
     hingX + disp
     MP_FreeEntity(Mesh): MP_FreeEntity(piv)
     piv = MP_CreateCylinder(10,1)
     MP_ResizeMesh(piv,0.4,0.4,0.4)
     MP_RotateEntity(piv , 0 , angle, 0)
     angle + rot     
     Mesh = MP_CreateRectangle (length,0.05,0.5)
     MP_PositionEntity (Mesh,0,0,0)
     MP_PositionEntity (piv,hingX,hingY,hingZ) ; the pivot position relative to the Mesh
     ;MP_ChangeMeshCoord(piv)
     MP_AddMesh(piv , Mesh ) : MP_FreeEntity(piv)
     MP_PhysicInit()
     MP_EntityPhysicBody(Mesh , 4, 10)
     
     ;http://www.mathwarehouse.com/vectors/images/main/how-To-solve.gif
     dirX = 1*Sin(Radian(angle)) ; the X component of the pivot vector
     dirZ = 1*Cos(Radian(angle)) ; the Z component of the pivot vector
     
     MP_ConstraintCreateHinge (Mesh,dirX,0,dirZ,hingX,hingY,hingZ)
     
     MP_EntitySetNormals (Mesh)
     MP_MaterialDiffuseColor (Mesh,255,255,128,50)
     MP_MaterialSpecularColor (Mesh, 255, 255 ,255, 155,5)
   EndProcedure
   
   Procedure dropStone()
   stone = MP_CreateRectangle(1,1,1)
   MP_EntityPhysicBody(stone, 2, 1)
   ;MP_EntitySetGravity(stone, 0 , -1 ,0)
   MP_PositionEntity (stone,-2.5,1,0)  
   stone2 = MP_CreateRectangle(1,1,1)
   MP_EntityPhysicBody(stone2, 2, 1)
   ;MP_EntitySetGravity(stone2, 0 , -1 ,0)
   MP_PositionEntity (stone2,1,1,0)  
    
   EndProcedure
Please allow me to correct it:
Just replace line 83 by:

Code: Select all

MP_RotateMesh(piv,0,angle,0)
and line 87 by:

Code: Select all

MP_TranslateMesh(piv,hingX,hingY,hingZ) ; the pivot position relative to the Mesh
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: MP3D Engine Alpha 32

Post by applePi »

thank you Psychophanta, yes now it works .
i am confused easily from changing the functions
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 32

Post by Psychophanta »

mpz wrote:the command MP_KeyUp double. i will kill them. I will have a look on 'KeyboardReleased(Key)' and can make a new command with this function
... new command MP_KeyRelease(#PB_Key) integrated.
Thank you again, this increase the consistence.
Please add in your 'to-do' list this one:
MP_MouseButtonRelease()
No hurry!
:wink:

At the moment i solve it with:

Code: Select all

Procedure.b MouseButtonEdgeDetection(mbutton.b)
  Static mb.b:Protected i.b=1<<mbutton
  If MP_MouseButtonDown(mbutton);<-if current key status is PUSHED
    If mb&i=0:mb|i:ProcedureReturn 1:EndIf;<-if previous key status was NOT PUSHED, then assign previous state to current one, and EXIT.
  ElseIf mb&i;<-else (if previous key status was PUSHED and current key status is NOT PUSHED):
    mb!i:ProcedureReturn -1;<-set previous key status to NOT PUSHED.
  EndIf
  ProcedureReturn 0
EndProcedure
Which returns '1' on hit, '0' while holded or up, and '-1' on release.


Apart i have share here 2 functional functions: one to create a plane grid mesh and another to create a rectangular poliedro mesh arists. Both using primitives:

Code: Select all

;The orbitation way is made with mouse moving the camera onto an imaginary spherical surface where the center is the given entity:
;Moving mouse in 'x' (horizontally) makes the camera to move over parallels onto that spherical surface.
;Moving mouse in 'y' (vertically) makes the camera to move over meridianes onto that spherical surface.
;With the mouse wheel can be modified the radius lenght of the imaginary sphere, i.e., the distance between the camera and the given entity.
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
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
light=MP_CreateLight(2)
MP_LightSetColor(light,RGB(119,118,50))
MP_PositionEntity(light,-6,10,-5)
MP_AmbientSetLight(RGB(0,100,120))
;/ Suelo:
Procedure.i CreateGridPrimitives(sizex.f=1.0,sizey.f=1.0,m.l=10,n.l=10,color.l=$AA3E77BB)
  Protected grid.i,sm.b=1-(m<<1!1)&2,sn.b=(n<<1!1)&2-1,l.l=2*(m+n+1)
  If m=1 And n=1
    grid=MP_CreatePrimitives(l-1,3)
    MP_SetPrimitives(grid,0,-sizex/2,sizey/2,0,color)
    MP_SetPrimitives(grid,1,-sizex/2,-sizey/2,0,color)
    MP_SetPrimitives(grid,2,sizex/2,-sizey/2,0,color)
    MP_SetPrimitives(grid,3,sizex/2,sizey/2,0,color)
    MP_SetPrimitives(grid,4,-sizex/2,sizey/2,0,color); <- cerrar secuencia
  Else
    grid=MP_CreatePrimitives(l+1,3)
    For t.l=0 To 2*m+1
      v.b=1-(t<<1!t)&2
      MP_SetPrimitives(grid,t,sizex*(Int(t/2)-m/2),sizey*n/2*v,0,color)
    Next
    If m&1
      For t.l=1 To l-2*m-2
        v.b=1-(t<<1!t)&2
        MP_SetPrimitives(grid,t+2*m+1,sizex*m/2*v,sizey*(n/2-Int(t/2)),0,color)
      Next
    Else
      For t.l=1 To l-2*m-2
        v.b=1-(t<<1!t)&2
        MP_SetPrimitives(grid,t+2*m+1,sizex*m/2*v,sizey*(Int(t/2)-n/2),0,color)
      Next
    EndIf
    MP_SetPrimitives(grid,l,sizex*m/2*sn,sizey*n/2*sm,0,color); <- cerrar secuencia
  EndIf
  ProcedureReturn grid
EndProcedure
;\
;/ celda
Procedure.i CreateCellPrimitives(sizex.f=1.0,sizey.f=1.0,sizez.f=1.0,color.l=$AA3E77BB)
  Protected dx.f=sizex/2,dy.f=sizey/2,dz.f=sizez/2,celda.i=MP_CreatePrimitives(16,3)
  MP_SetPrimitives(celda,0,-dx,dy,-dz,color)
  MP_SetPrimitives(celda,1,-dx,-dy,-dz,color)
  MP_SetPrimitives(celda,2,dx,-dy,-dz,color)
  MP_SetPrimitives(celda,3,dx,dy,-dz,color)
  MP_SetPrimitives(celda,4,-dx,dy,-dz,color)
  MP_SetPrimitives(celda,5,-dx,dy,dz,color)
  MP_SetPrimitives(celda,6,-dx,-dy,dz,color)
  MP_SetPrimitives(celda,7,dx,-dy,dz,color)
  MP_SetPrimitives(celda,8,dx,dy,dz,color)
  MP_SetPrimitives(celda,9,-dx,dy,dz,color)
  MP_SetPrimitives(celda,10,dx,dy,dz,color)
  MP_SetPrimitives(celda,11,dx,dy,-dz,color)
  MP_SetPrimitives(celda,12,dx,-dy,-dz,color)
  MP_SetPrimitives(celda,13,dx,-dy,dz,color)
  MP_SetPrimitives(celda,14,-dx,-dy,dz,color)
  MP_SetPrimitives(celda,15,-dx,-dy,-dz,color)
  ProcedureReturn celda
EndProcedure
;\
turnx.f=(Random(1E5)-5E4)/5E4:turny.f=(Random(1E5)-5E4)/5E4:turnz.f=(Random(1E5)-5E4)/5E4
celda.i=CreateCellPrimitives((Random(1E5)+1)/5E4,(Random(1E5)+1)/5E4,(Random(1E5)+1)/5E4,$AABE777B)
camera=MP_CreateCamera()
MP_PositionEntity(camera,0,2,-5)
MP_PointEntity(camera,celda)
m.f=MP_EntityDistance(camera,celda)
MP_UseCursor(0):MP_MouseInWindow()
Repeat
  If MP_KeyDown(#PB_Key_LeftControl)
    mdw.f=MP_MouseDeltaWheel()/400
    m-mdw
    Orbitar(camera,m*-MP_MouseDeltaX()/200,m*MP_MouseDeltaY()/200,mdw,celda,m)
  ElseIf MP_ElapsedMicroseconds()%$100<5
    turnx.f=(Random(1E5)-5E4)/5E4:turny.f=(Random(1E5)-5E4)/5E4:turnz.f=(Random(1E5)-5E4)/5E4
    If suelo:MP_FreeEntity(suelo):suelo=0:celda.i=CreateCellPrimitives((Random(1E5)+1)/5E4,(Random(1E5)+1)/5E4,(Random(1E5)+1)/5E4,$AABE777B)
    ElseIf celda:MP_FreeEntity(celda):celda=0:Suelo.i=CreateGridPrimitives((Random(1E5)+1)/5E4,(Random(1E5)+1)/5E4,Random(60)+1,Random(60)+1,$AB44C5A7)
    EndIf
  Else
    If suelo:MP_TurnEntity(suelo,turnx,turny,turnz,0)
    Else:MP_TurnEntity(celda,turnx,turny,turnz,0)
    EndIf
  EndIf
  MP_RenderWorld()
  MP_Flip()
  Delay(10)
Until MP_KeyHit(#PB_Key_Escape)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 32

Post by mpz »

Hello to all,

@applePi, adding spring joint. I have tested some code examples but have not a solution for these function.My joints doesnt spring :( . I hope i will find a solution in the next time

@Psychophanta, thanks for your good help and a nice example.
I have only a little changing for your code. If you use in Purtbasic a windows it is important to use a WindowEvent() call. Without them the event buffer is overrunning and the program crashes
Please change line 103 to

Code: Select all

    Until MP_KeyHit(#PB_Key_Escape) Or WindowEvent() = #PB_Event_CloseWindow 
or

Code: Select all

    WindowEvent()
    Until MP_KeyHit(#PB_Key_Escape)

i will include a command MP_MouseButtonRelease() in the next version too

Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 32

Post by Psychophanta »

Thanks for the latests improvements.
mpz wrote:...it is important to use a WindowEvent() call. Without them the event buffer is overrunning and the program crashes
Ok. Is there the same requirement if use a full screen with 'MP_Graphics3D(RX,RY,bitplanes,0)' ?
By the way, if you can, please post a simple tip with the command 'MP_FullScreenMode(Var)' to toggle between full screen mode and window mode.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: MP3D Engine Alpha 32

Post by Psychophanta »

Hi again.
I think i found another issue when changin ViewPort of a camera. Even freeing the camera, camera still exists and the new created camera with another viewport does not work properly while picking:

Code: Select all

    WindowWidth=640:WindowHeigh=480
    MP_Graphics3D(WindowWidth,WindowHeigh,0,2)
    ViewPortX=300:ViewPortY=60:ViewPortWidth=100:ViewPortHeigh=400
    light=MP_CreateLight(1)
    m=MP_CreateCube()
    MP_EntitySetZ(m,8)
    cam=MP_CreateCamera()
    MP_CameraViewPort(cam,ViewPortX,ViewPortY,ViewPortWidth,ViewPortHeigh,$008B340A)
    MP_CameraSetPerspective(cam,45,ViewPortWidth/ViewPortHeigh)

    ViewPortX2=400:ViewPortY2=80:ViewPortWidth2=200:ViewPortHeigh2=300
    cam2=MP_CreateCamera()
    MP_CameraViewPort(cam2,ViewPortX2,ViewPortY2,ViewPortWidth2,ViewPortHeigh2,$00346B0A)
    MP_CameraSetPerspective(cam2,45,ViewPortWidth2/ViewPortHeigh2)
    m2=MP_CreateCube()
    MP_EntitySetZ(m2,-1000)
    MP_PositionEntity(cam2,0,0,-995)
    MP_PointEntity(cam2,m2)

    MP_AmbientSetLight(RGB(120,34,123)) ; purple backgroundcolor
    
    MP_CameraSetPerspective(cam2,45,ViewPortWidth2/ViewPortHeigh2)
    While WindowEvent()<>#PB_Event_CloseWindow
      picked=MP_PickCamera(cam,WindowMouseX(0),WindowMouseY(0))
      MP_DrawText(100,40,"Mesh "+Hex(picked)+" found")
      picked2=MP_PickCamera(cam2,WindowMouseX(0),WindowMouseY(0))
      If MP_KeyHit(#PB_Key_C)
        MP_FreeEntity(cam2)
        cam2=MP_CreateCamera()
        ViewPortX2=4:ViewPortY2=8:ViewPortWidth2=300:ViewPortHeigh2=200
        MP_CameraViewPort(cam2,ViewPortX2,ViewPortY2,ViewPortWidth2,ViewPortHeigh2,$00346B0A)
        MP_CameraSetPerspective(cam2,45,ViewPortWidth2/ViewPortHeigh2)
      EndIf
      MP_DrawText(100,70,"Mesh2 "+Hex(picked2)+" found")
      MP_TurnEntity(m,-0.1,0.3,-0.23)
      MP_TurnEntity(m2,0.3,-0.23,-0.1)
      MP_RenderWorld()
      MP_Flip()
    Wend
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D Engine Alpha 32

Post by mpz »

A happy new Year to all...

@Psychophanta,

1) new command MP_ MP_MouseButtonRelease(Button) integrated, new lib created for download ready now (see answer before to load lib)

2) Now your last demo works fine now. I had forgotten to delete the Viewports of a camera if you delete a camera. Please check it

Code: Select all


; must integrade in a while wend loop of a mp3d demo
      If MP_MouseButtonRelease(0)
        Debug "Left Mouse on"
      EndIf  
      
      If MP_MouseButtonHit(0)
        Debug "Left Mouse off"
      EndIf  
      
      If MP_KeyHit(#PB_Key_A)
        Debug "Key A on"
      EndIf
      
      If MP_KeyRelease(#PB_Key_A)
        Debug "Key A off"
      EndIf


Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
Post Reply