MP3D Engine Alpha 33
- 
				mpz
 - Enthusiast

 - Posts: 497
 - Joined: Sat Oct 11, 2008 9:07 pm
 - Location: Germany, Berlin > member German forum
 
Re: MP3D Engine Alpha 32
Hello,
first PB520 x86 lib ready for testing. You find them on the first page of this topic...
Grettings
Michael
			
			
									
									first PB520 x86 lib ready for testing. You find them on the first page of this topic...
Grettings
Michael
Working on - MP3D Library - PB 5.73 version ready for download
						- Psychophanta
 - Always Here

 - Posts: 5153
 - Joined: Wed Jun 11, 2003 9:33 pm
 - Location: Anare
 - Contact:
 
Re: MP3D Engine Alpha 32
Many thanks!
			
			
									
									
						Re: MP3D Engine Alpha 32
Hi Michael
thanks for updating, i have downloaded the file Install_MP3D_32_x86.exe , i have tried it on winxp, it still gives the error "PureBasic library missing: Misc"
regards
			
			
									
									
						thanks for updating, i have downloaded the file Install_MP3D_32_x86.exe , i have tried it on winxp, it still gives the error "PureBasic library missing: Misc"
regards
- 
				mpz
 - Enthusiast

 - Posts: 497
 - Joined: Sat Oct 11, 2008 9:07 pm
 - Location: Germany, Berlin > member German forum
 
Re: MP3D Engine Alpha 32
Hi,
@applepi, you must copy th elib manuelly, the installer Install_MP3D_32_x86.exe works with pb 5.11. With PB5.2 you need this installer an then you copy the file manually. In the future we need 2 installer
Testversion for PB5.20 beta, please copy into the PureBasic5.20\SubSystems\dx9\purelibraries\userlibraries\ folder
http://www.flasharts.de/mpz/PB520/x86/MP3D_Library
@Alexi, Xray... hm i think this could be done with a shader. I will look, it could be a have one for this
hm Instances , yes with the render routines or with the shader, perhaps i can make example for this too
                       
Greetings Michael
			
			
									
									@applepi, you must copy th elib manuelly, the installer Install_MP3D_32_x86.exe works with pb 5.11. With PB5.2 you need this installer an then you copy the file manually. In the future we need 2 installer
Testversion for PB5.20 beta, please copy into the PureBasic5.20\SubSystems\dx9\purelibraries\userlibraries\ folder
http://www.flasharts.de/mpz/PB520/x86/MP3D_Library
@Alexi, Xray... hm i think this could be done with a shader. I will look, it could be a have one for this
hm Instances , yes with the render routines or with the shader, perhaps i can make example for this too
Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
						- 
				mpz
 - Enthusiast

 - Posts: 497
 - Joined: Sat Oct 11, 2008 9:07 pm
 - Location: Germany, Berlin > member German forum
 
Re: MP3D Engine Alpha 32
Hi applePi,
here it comes:
http://www.flasharts.de/mpz/PB520/x86/MP3D_Library.zip
i have checked it with PB 5.20 and these lib works. I think it is a donwload problem too..
Greetings Michael
			
			
									
									here it comes:
http://www.flasharts.de/mpz/PB520/x86/MP3D_Library.zip
i have checked it with PB 5.20 and these lib works. I think it is a donwload problem too..
Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
						Re: MP3D Engine Alpha 32
Hi Michael
now it works. thank you
			
			
									
									
						now it works. thank you
Re: MP3D Engine Alpha 32
Hi Michael, in addition to the question about textures ...
Are you planning to work on display of objects with alpha? Because for me, they look like this:


			
			
									
									Are you planning to work on display of objects with alpha? Because for me, they look like this:


'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
						SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
- 
				mpz
 - Enthusiast

 - Posts: 497
 - Joined: Sat Oct 11, 2008 9:07 pm
 - Location: Germany, Berlin > member German forum
 
Re: MP3D Engine Alpha 32
Hi Andyly,
i am working on a feature to add a texture on a texture, but it is not so easy. To copy a texture to a texture is easy, but with alpha modus not. For now you can add a texure on another, but the textures can onyl be not big one. Can you send me two textures for testing please (one background and one to copy it on the background). Then i hav somthing for testing
I am working on a new terrain function too. If you can make a litte demo for me (one/two trees with the alpha problem and the background terrain) i can check the problem an find a solution for you...
Greetings Michael
			
			
									
									i am working on a feature to add a texture on a texture, but it is not so easy. To copy a texture to a texture is easy, but with alpha modus not. For now you can add a texure on another, but the textures can onyl be not big one. Can you send me two textures for testing please (one background and one to copy it on the background). Then i hav somthing for testing
I am working on a new terrain function too. If you can make a litte demo for me (one/two trees with the alpha problem and the background terrain) i can check the problem an find a solution for you...
Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
						Re: MP3D Engine Alpha 32
Michael, 2 files sent to you (to mail), as you asked, with examples.
			
			
									
									'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
						SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
- 
				mpz
 - Enthusiast

 - Posts: 497
 - Joined: Sat Oct 11, 2008 9:07 pm
 - Location: Germany, Berlin > member German forum
 
Re: MP3D Engine Alpha 32
Hi,
thanks this will helps very much...
Greetings Michael
			
			
									
									thanks this will helps very much...
Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
						Re: MP3D Engine Alpha 32
Hi mpz,it would be great if your functions sush as MP_Create3DText() support unicode.mpz wrote:Hi,
thanks this will helps very much...
Greetings Michael
poor English...
PureBasic & Delphi & VBA
						PureBasic & Delphi & VBA
Re: MP3D Engine Alpha 32
Michael, can we consider the example MP_Physic_Primitives.pb from C:\PureBasic\MP3D Demos\3DPhysik\ an example about concave geometry physics ?! because i have tried to compile the bullet-2.81-rev2613 engine and there is an example called
App_ConcaveDemo_vs2008_debug and it is almost do the same as your example, i attach the App_ConcaveDemo_vs2008_debug.exe it may need vc++2008 run time
http://www.mediafire.com/?a9ltd7l7a7oqle7
i have checked the file with https://www.virustotal.com and the results are Detection ratio 0 / 45
its output like this

the same as your example output http://www.flasharts.de/mpz/Physic.JPG
from your link http://www.purebasic.fr/english/viewtop ... 90#p414292
i am still don't know how to do Gears in bullet since my C++ are little
in fact my main purpose is to run Gears, i will do more experiments with your example to see how much it will go with concave concepts.
@leonhardt: i have used Google SketchUp 8 to make a model for chinese sentence (karate school) after translating it by google translator, but after i have installed the chinese fonts, it has this feature in Tools -> 3D Text
			
			
									
									
						App_ConcaveDemo_vs2008_debug and it is almost do the same as your example, i attach the App_ConcaveDemo_vs2008_debug.exe it may need vc++2008 run time
http://www.mediafire.com/?a9ltd7l7a7oqle7
i have checked the file with https://www.virustotal.com and the results are Detection ratio 0 / 45
its output like this

the same as your example output http://www.flasharts.de/mpz/Physic.JPG
from your link http://www.purebasic.fr/english/viewtop ... 90#p414292
i am still don't know how to do Gears in bullet since my C++ are little
in fact my main purpose is to run Gears, i will do more experiments with your example to see how much it will go with concave concepts.
@leonhardt: i have used Google SketchUp 8 to make a model for chinese sentence (karate school) after translating it by google translator, but after i have installed the chinese fonts, it has this feature in Tools -> 3D Text
- 
				mpz
 - Enthusiast

 - Posts: 497
 - Joined: Sat Oct 11, 2008 9:07 pm
 - Location: Germany, Berlin > member German forum
 
Re: MP3D Engine Alpha 32
Dear applePi,
i am sorry but i dont understand, how i can help you?!?
With mp3d it is possible to change the vertex coods of a mesh and this can actualized with the Physic engine. So it is possible to make a demo like your App_ConcaveDemo.
In the next mp3d version i have newton dynamics 3.1 included. This will be faster physics as the last version of mp3d. For now i have only 10% includet of the newton physic functions. Water and car Physic will be one of the next steps...
Greetings Michael
			
			
									
									i am sorry but i dont understand, how i can help you?!?
With mp3d it is possible to change the vertex coods of a mesh and this can actualized with the Physic engine. So it is possible to make a demo like your App_ConcaveDemo.
In the next mp3d version i have newton dynamics 3.1 included. This will be faster physics as the last version of mp3d. For now i have only 10% includet of the newton physic functions. Water and car Physic will be one of the next steps...
Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
						Re: MP3D Engine Alpha 32
Hi Michael
good news that you want to update to newton dynamics v3.1 and to add more functions
my wish if it is possible in newton dynamics to implement Gears, so the teeth of every one can go inside the other like the old clock, it is not possible to do this in bullet physics used in purebasic engine unless we choose its preperty as static and we want the gear to be dynamic. look here for the gear in ogre bullet, it is impossible to go inside between two tooths.

so since you are going to newton dynamics 3.1 in the future, if you can make the 2 Gears tangled and the second gear rotate by the effect of the first gear, then will be great. there is one thread in newton dynamics forum http://newtondynamics.com/forum/viewtop ... ars#p50537 in which someone was trying to simulate gears and he ask what collision hull should he use for this purpose? and someone replied him: You want a compound collider --> http://newtondynamics.com/wiki/index.ph ... s#Compound
so if you can implement that compound collider then may be we can make Gears
the following is a Gear 3D for MP3D based on a formula from matheworld http://mathworld.wolfram.com/GearCurve.html
it is useless in the context of my wish , i just want to celebrate your good news about newton 3.1 . use arrow keys and space to rotate.
save this texture to the same folder as the code
the same for purebasic ogre
			
			
									
									
						good news that you want to update to newton dynamics v3.1 and to add more functions
my wish if it is possible in newton dynamics to implement Gears, so the teeth of every one can go inside the other like the old clock, it is not possible to do this in bullet physics used in purebasic engine unless we choose its preperty as static and we want the gear to be dynamic. look here for the gear in ogre bullet, it is impossible to go inside between two tooths.

so since you are going to newton dynamics 3.1 in the future, if you can make the 2 Gears tangled and the second gear rotate by the effect of the first gear, then will be great. there is one thread in newton dynamics forum http://newtondynamics.com/forum/viewtop ... ars#p50537 in which someone was trying to simulate gears and he ask what collision hull should he use for this purpose? and someone replied him: You want a compound collider --> http://newtondynamics.com/wiki/index.ph ... s#Compound
so if you can implement that compound collider then may be we can make Gears
the following is a Gear 3D for MP3D based on a formula from matheworld http://mathworld.wolfram.com/GearCurve.html
it is useless in the context of my wish , i just want to celebrate your good news about newton 3.1 . use arrow keys and space to rotate.
save this texture to the same folder as the code
Code: Select all
#BUTTON = 6
 Quit.b = #False
rot.l=1 :stopFlag = 1 : wireFrame.b = 0
xs.f = 1:ys.f = 1:zs.f = 1
x.f: y.f :z.f: x0.f: y0.f=1 :z0.f
rotx.f:roty.f=0.5:rotz.f :rotx0.f: roty0.f: rotz0.f
up.f = 1.8: depth.f=0
ExamineDesktops()
MP_Graphics3D (DesktopWidth(0),DesktopHeight(0),0,2) ; Erstelle ein WindowsFenster #Window = 0
SetWindowTitle(0, "PgUp PgD scale mesh..Arrows for rotation, space: stop/rotate,  QA far/near, key_pad R/L/U/D") 
MP_DrawText (1,1,"press W _wireFrame, D _ delete triangles")
ButtonGadget(#BUTTON, 0, DesktopHeight(0)-60, 60, 30, "rotate/stop") 
MP_Viewport(0,0,DesktopWidth(0),DesktopHeight(0)-60)
light=MP_CreateLight(1) 
MP_PositionEntity (light,-6,0,0)
MP_EntityLookAt(light,0,0,3)
MP_LightSetColor(light,RGB(255,255,255))
InitKeyboard()
camera=MP_CreateCamera() ; Kamera erstellen
MP_PositionCamera(camera, 0, 0.5, -10)
Mesh = MP_CreateMesh() ; Erzeuge leeres Mesh
SetActiveGadget(#BUTTON)
;WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
x.f: y.f :z.f : u.f:  r.f
i.l: j.l
 u.f=0 :txu.f : txv.f
;;;;;;;
x.f: y.f :z.f :  u.f=0 :txu.f : txv.f
rMajor.f = 2 : rMinor.f = 0.5
      majorRadius.f = 2: minorRadius.f = 1.5: numMajor.l = 50: numMinor.l = 25
      majorStep.f   = 2 * #PI / (numMajor+0);
      minorStep.f   = 2 * #PI / (numMinor+0)
      i.l: j.l
      x.f: y.f :z.f :r.f :t.f
      a.f=1:b.f=10: 
 For i = 0 To numMajor
        t.f = i * majorStep;
        
        For j = 0 To numMinor
          r = 1+1/b*TanH(b*Sin(12*t))
          u.f = j * minorStep;
          x = r*Cos(t) * (majorRadius + minorRadius * Cos(u))
          y = r*Sin(t) * (majorRadius + minorRadius * Cos(u))
          z.f = minorRadius * Sin(u)
          tt+1
          
          MP_AddVertex (Mesh, x, y,z,0,txu,txv) 
          txv = txv + 1/numMinor ; texture coordinates
          
        Next
        txv = 0
        txu = txu + 1/numMajor ;texture coordinates
      Next
     
     v.l=0      
;;;;;ppppppppppppppppppppppppppppppppppppppppppppppppppppppp      
 For i = 0 To numMajor
      For j = 0 To numMinor-1
          MP_AddTriangle(Mesh,v,v+1,v + numMinor+1)
          MP_AddTriangle(Mesh,v + numMinor+1,v + numMinor+2,v+1 )
          If i=numMajor-1 And j=numMinor-1 ;bypass the last triangle
          
          EndIf 
          v + 1 
         
     Next
     
   Next 
   ;ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
   
   ;last vertex to connect:
   lastV = (numMinor+1)*(numMajor+1)-1-(numMinor+1)
   s = lastv - numMinor
   For v = 0 To numMinor
          MP_AddTriangle(Mesh,s,s+1, v)
          MP_AddTriangle(Mesh,v,v+1,s+1 )
          If i=numMajor-1 And j=numMinor-1 ;bypass the last triangle
            ;numMinor-1
          EndIf 
         s+1
                    
   Next
   
     
  MP_EntitySetNormals(Mesh) 
;WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
Texture = MP_LoadTexture("Rusty_Steel.jpg")
MP_EntitySetTexture (Mesh, Texture )
MP_MaterialEmissiveColor (Texture,0,255,255,255)
MP_PositionEntity (Mesh,0,0.1,3) ; Position des Meshs
h.f=0:up.f=0.1:depth.f=3
x=90: y=0: z=0 :indx = 126
Repeat
  Event = WindowEvent()
  If Event = #PB_Event_Gadget
    Select EventGadget()
      Case #BUTTON
        If rot = 0
          rot = 1
          rotx= rotx0:roty=roty0:rotz=rotz0 ; restore rotation status
          stopFlag = 1
          
        Else
          rot = 0
          rotx0= rotx:roty0=roty:rotz0=rotz ;back up rotation status
          rotx=0:roty=0:rotz=0
          stopFlag = 0
          
        EndIf
                    
    EndSelect
  EndIf 
  If stopFlag=1
    x + rotx
    y + roty
    z + rotz
  EndIf
  MP_DrawText (1,1,"press W _wireFrame, D _ delete triangles")  
  MP_DrawText (1,15,"keyPad keys: up.down.left.right")
  MP_RotateEntity(Mesh, x, y, z)
  MP_RenderWorld() ; Erstelle die Welt
  MP_Flip ()
 
  If MP_KeyDown(#PB_Key_Up)  ; rotate left
    rotx=1:roty=0:rotz=0
    rotx0 = rotx: roty0 = roty :rotz0 = rotz
    x + rotx
    y + roty
    z + rotz
    stopFlag=0
    rot = 0
  ElseIf MP_KeyDown(#PB_Key_Down) ; rotate right
    rotx=-1:roty=0:rotz=0
    rotx0 = rotx: roty0 = roty :rotz0 = rotz
    x + rotx
    y + roty
    z + rotz
    stopFlag=0
    rot = 0
  ElseIf MP_KeyDown(#PB_Key_Right)   ; rotate up
    rotx=0:roty=1:rotz=0
    rotx0 = rotx: roty0 = roty :rotz0 = rotz
    x + rotx
    y + roty
    z + rotz
    stopFlag=0
    rot = 0
  ElseIf MP_KeyDown(#PB_Key_Left) ; rotate down
    rotx=0:roty=-1:rotz=0 
    rotx0 = rotx: roty0 = roty :rotz0 = rotz
    x + rotx
    y + roty
    z + rotz
    stopFlag=0
    rot = 0
  EndIf 
  
  If MP_KeyDown(#PB_Key_PageUp) ; scale up model
    xs.f + 0.01:ys.f + 0.01:zs.f + 0.01
    MP_ScaleEntity(Mesh,xs,ys,zs)
    
  ElseIf MP_KeyDown(#PB_Key_PageDown) ; scale down model
    xs -0.01:ys -0.01:zs- 0.01
    If xs<0 :xs=0:ys=0:zs=0:EndIf
    MP_ScaleEntity(Mesh,xs,ys,zs)
    
  EndIf
  If MP_KeyDown(#PB_Key_Pad8) ; up move
    up + 0.01
    MP_PositionEntity(Mesh,h,up,depth)
   ElseIf MP_KeyDown(#PB_Key_Pad2) ; down move
    up - 0.01
    MP_PositionEntity(Mesh,h,up,depth)
  ElseIf MP_KeyDown(#PB_Key_Pad6)
    h + 0.01
    MP_PositionEntity(Mesh,h,up,depth)
    ElseIf MP_KeyDown(#PB_Key_Pad4)
    h - 0.01
    MP_PositionEntity(Mesh,h,up,depth)
    
    ElseIf MP_KeyDown(#PB_Key_Q) ; forward move
    depth - 0.01
    MP_PositionEntity(Mesh,h,up,depth)
    ElseIf MP_KeyDown(#PB_Key_A) ; inward move
    depth + 0.01
    MP_PositionEntity(Mesh,h,up,depth)
    ElseIf MP_KeyHit(#PB_Key_W) ; display wire frame for the material
      If wireFrame=0
      MP_Wireframe (1) 
      wireFrame ! 1
         ElseIf wireFrame=1
           MP_Wireframe (0)
           wireFrame ! 1 
      EndIf
    ElseIf MP_KeyDown(#PB_Key_D) 
      MP_FreeTriangle(Mesh, 1)
       ;indx -1: MP_FreeVertex(Mesh ,indx)
        
  EndIf
   If MP_KeyDown(#PB_Key_Escape)
      Quit = #True
    EndIf
    
    
Until Quit = #True Or Event = #PB_Event_CloseWindowCode: Select all
Enumeration
   #MESH
   #LIGHT
   #CAMERA_ONE
   #BUTTON
   #mainwin
 EndEnumeration
Quit.b = #False
rot.l=1 :stopFlag = 1
xs.f = 0.3:ys.f = 0.3:zs.f = 0.3
x.f: y.f :z.f: x0.f: y0.f=1 :z0.f
rotx.f:roty.f=0.5:rotz.f :rotx0.f: roty0.f: rotz0.f
up.f = 1.8: depth.f=0: wireFrame.b=0
ExamineDesktops()
If OpenWindow(#mainwin, 0, 0, DesktopWidth(0), DesktopHeight(0), "PgUp PgD scale mesh..Arrows for rotation, space: stop/rotate,  QA far/near, key_pad R/L/U/D", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ButtonGadget(#BUTTON, 0, DesktopHeight(0)-60, 60, 30, "rotate/stop") 
;Initialize environment
InitEngine3D()
InitSprite()
OpenWindowedScreen(WindowID(#mainwin), 0, 0, DesktopWidth(0), DesktopHeight(0)-60, 0, 0, 0)
InitKeyboard()
SetFrameRate(60)
Add3DArchive("/", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/Sources\Data", #PB_3DArchive_FileSystem)
CreateLight(0,RGB(255,255,255),-100,40,30)
AmbientColor(RGB(100,100,100))
CreateCamera(#CAMERA_ONE, 0, 0, 400, 400)
MoveCamera(#CAMERA_ONE, 0, 4, 15)
CameraLookAt(#CAMERA_ONE, 0, 2, 0)
EndIf
SetActiveGadget(#BUTTON)
CreateMaterial(0, LoadTexture(0, "RustySteel.jpg"))
;MaterialShadingMode(0, #PB_Material_Wireframe)
MaterialCullingMode(0, #PB_Material_NoCulling)
DisableMaterialLighting(0, #True)
CreateMesh(1, #PB_Mesh_TriangleList , #PB_Mesh_Static )
SetMeshMaterial(1, MaterialID(0))
     x.f: y.f :z.f :  u.f=0 :txu.f : txv.f
rMajor.f = 2 : rMinor.f = 0.5
      majorRadius.f = 2: minorRadius.f = 1.5: numMajor.l = 50: numMinor.l = 25
      majorStep.f   = 2 * #PI / (numMajor+0);
      minorStep.f   = 2 * #PI / (numMinor+0)
      i.l: j.l
      x.f: y.f :z.f :r.f :t.f
      a.f=1:b.f=10: 
      
      For i = 0 To numMajor
        t.f = i * majorStep;
        
        For j = 0 To numMinor
          r = 1+1/b*TanH(b*Sin(12*t))
          u.f = j * minorStep;
          x = r*Cos(t) * (majorRadius + minorRadius * Cos(u))
          y = r*Sin(t) * (majorRadius + minorRadius * Cos(u))
          z.f = minorRadius * Sin(u)
          tt+1
          MeshVertexPosition(x, y, z);
          MeshVertexTextureCoordinate(txu, txv)
          MeshVertexNormal(x, y, z)
          txv = txv + 1/numMinor ; texture coordinates
          
        Next
        txv = 0
        txu = txu + 1/numMajor ;texture coordinates
      Next
     
     v.l=0
     For i = 0 To numMajor
      For j = 0 To numMinor-1
          MeshFace(v,v+1,v + numMinor+1)
          MeshFace(v + numMinor+1,v + numMinor+2,v+1 )
          If i=numMajor-1 And j=numMinor-1 ;bypass the last triangle
          
          EndIf 
          v + 1 
         
     Next
     
   Next 
   
   ;last vertex to connect:
   lastV = (numMinor+1)*(numMajor+1)-1-(numMinor+1)
   s = lastv - numMinor
   For v = 0 To numMinor
          MeshFace(s,s+1, v)
          MeshFace(v,v+1,s+1 )
          If i=numMajor-1 And j=numMinor-1 ;bypass the last triangle
            ;numMinor-1
          EndIf 
         s+1
                    
   Next
   
   
    NormalizeMesh(1)
    FinishMesh(#True)
    CreateEntity(1, MeshID(1), MaterialID(0))  
    ScaleEntity(1,1.5, 1.5, 1.5)
  ;Main loop
  MoveEntity(1,0,up,depth,#PB_Absolute) 
  x = 180: y=0: z=0 : h.f
  EntityPhysicBody(1, #PB_Entity_ConvexHullBody   , 1.0)
  WorldGravity(0)
  ;WorldDebug(#PB_World_DebugBody)
Repeat
  Event = WindowEvent()
  If Event = #PB_Event_Gadget
    Select EventGadget()
      Case #BUTTON
        If rot = 0
          rot = 1
          rotx= rotx0:roty=roty0:rotz=rotz0 ; restore rotation status
          stopFlag = 1
          
        Else
          rot = 0
          rotx0= rotx:roty0=roty:rotz0=rotz ;back up rotation status
          rotx=0:roty=0:rotz=0
          stopFlag = 0
          
        EndIf
                    
    EndSelect
  EndIf 
  If stopFlag=1
    x + rotx
    y + roty
    z + rotz
  EndIf
  
   RotateEntity(1, x, y, z)
   
   RenderWorld()
   FlipBuffers()
  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Up)  ; rotate left
    rotx=1:roty=0:rotz=0
    rotx0 = rotx: roty0 = roty :rotz0 = rotz
    x + rotx
    y + roty
    z + rotz
    stopFlag=0
    rot = 0
  ElseIf KeyboardPushed(#PB_Key_Down) ; rotate right
    rotx=-1:roty=0:rotz=0
    rotx0 = rotx: roty0 = roty :rotz0 = rotz
    x + rotx
    y + roty
    z + rotz
    stopFlag=0
    rot = 0
  ElseIf KeyboardPushed(#PB_Key_Right)   ; rotate up
    rotx=0:roty=1:rotz=0
    rotx0 = rotx: roty0 = roty :rotz0 = rotz
    x + rotx
    y + roty
    z + rotz
    stopFlag=0
    rot = 0
  ElseIf KeyboardPushed(#PB_Key_Left) ; rotate down
    rotx=0:roty=-1:rotz=0 
    rotx0 = rotx: roty0 = roty :rotz0 = rotz
    x + rotx
    y + roty
    z + rotz
    stopFlag=0
    rot = 0
  EndIf 
  
  If KeyboardPushed(#PB_Key_PageUp) ; scale up model
    xs.f = 1.1:ys.f = 1.1:zs.f = 1.1
    ScaleEntity(1,xs,ys,zs)
    
  ElseIf KeyboardPushed(#PB_Key_PageDown) ; scale down model
    xs = 0.9:ys = 0.9:zs= 0.9
    ScaleEntity(1,xs,ys,zs)
    
  EndIf
  If KeyboardPushed(#PB_Key_Pad8) ; up move
    up + 0.1
    MoveEntity(1,h,up,depth,#PB_Absolute)
   ElseIf KeyboardPushed(#PB_Key_Pad2) ; down move
    up - 0.1
    MoveEntity(1,h,up,depth,#PB_Absolute)
  ElseIf KeyboardPushed(#PB_Key_Pad6)
    h + 0.1
    MoveEntity(1,h,up,depth,#PB_Absolute)
    ElseIf KeyboardPushed(#PB_Key_Pad4)
    h - 0.1
    MoveEntity(1,h,up,depth,#PB_Absolute)
    
    ElseIf KeyboardPushed(#PB_Key_Q) ; forward move
    depth - 0.1
    MoveEntity(1,h,up,depth,#PB_Absolute)
    ElseIf KeyboardPushed(#PB_Key_A) ; inward move
    depth + 0.1
    MoveEntity(1,h,up,depth,#PB_Absolute)
    ElseIf KeyboardReleased(#PB_Key_W) ; display wire frame for the material
      If wireFrame=0
      MaterialShadingMode(0, #PB_Material_Wireframe)
      wireFrame ! 1
         ElseIf wireFrame=1
           MaterialShadingMode(0, #PB_Material_Solid)
           wireFrame ! 1
      EndIf
  EndIf
   If KeyboardPushed(#PB_Key_Escape)
      Quit = #True
    EndIf
    
    
Until Quit = #True Or Event = #PB_Event_CloseWindow

