Page 61 of 71

Re: MP3D Engine Alpha 32

Posted: Sun Dec 20, 2015 1:40 am
by mpz
Hello to all,

here comes a little update now with Threadsafe for PB 5.40 x86 and x64

MP3D Installer - V.0.52, works with PB 5.24 < 5.30 and 5.40 LTS
http://www.flasharts.de/mpz/mp33_beta/M ... taller.exe

Greetings Michael

Re: MP3D Engine Alpha 32

Posted: Tue Dec 22, 2015 2:06 pm
by applePi
Hi Michael
thanks for the new version. i want to suggest a rotational torque functions, like this:
NewtonBodySetTorque, NewtonBodyAddTorque and the related functions
http://newtondynamics.com/wiki/index.ph ... ySetTorque
http://newtondynamics.com/wiki/index.ph ... eAndTorque

the usual pulse force does not work correctly when we want to rotate a flying object such as a UFO, or a top (toy). look this example in PB ogre which show the case even it does not work correctly, i am still investigating)
we have here ApplyEntityTorque(), and ApplyEntityTorqueImpulse(). you may have more functions in newton engine. the torque is like rotating top toy by hand. look the attached example, as you can see the top toy (cone shape) does not stop, while in your engine i think we can add several physical material properties...etc to stop the top.

Code: Select all

Define.f KeyX, KeyY


#plane = 500
#cube = 0
#cone = 1
#camera = 0

Define.f KeyX, KeyY, MouseX, MouseY

ExamineDesktops()
OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), " torque ....press 'Z' to give rotational torque to the cone", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
;Initialize environment
  InitEngine3D()
  InitSprite()
OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0), DesktopHeight(0), 0, 0, 0)


  InitKeyboard()
  InitMouse()
SetFrameRate(60)


Add3DArchive(".", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Models", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts",#PB_3DArchive_FileSystem)

Parse3DScripts()
    
    
            
    CreateCamera(#camera, 0, 0, 100, 100)
    MoveCamera(#camera, 0, 1, 30, #PB_Absolute)
    ;CameraFOV(#camera, 70)
 
    CameraLookAt(#camera,0,-15,0)
        
    CreateLight(0,RGB(255,255,255),-100,40,30)
    AmbientColor(RGB(200,200,200))
    
    CreateMaterial(1, LoadTexture(1, "MRAMOR6X6.jpg"))
    MaterialCullingMode(1, #PB_Material_NoCulling)

    CreateMaterial(2, LoadTexture(2, "RustySteel.jpg"))
    MaterialCullingMode(2, #PB_Material_NoCulling)
    
    CreateMaterial(4, LoadTexture(4, "ground_diffuse.png"))
    MaterialCullingMode(4, #PB_Material_NoCulling)
        
    CreatePlane(#plane, 200, 200, 5, 5, 2, 2) ; the ground
    CreateEntity(#plane, MeshID(#plane), MaterialID(4), 0,-25,0)
    CreateEntityBody(#plane, #PB_Entity_PlaneBody, 1, 0.2, 4)
    
CreateCone(#cone, 5, 5)
CreateEntity(#cone, MeshID(#cone), MaterialID(1), 0,6,0)
RotateEntity(#cone, 177,0,0)

CreateEntityBody(#cone, #PB_Entity_ConeBody, 1, 0.6,2)

;WorldDebug(#PB_World_DebugBody) ;
ApplyEntityTorque(#cone, 0, 2000, 0)
For i=0 To 200
  
  ApplyEntityTorqueImpulse(#cone, 0, 1, 0)

Next

Repeat
      Event = WindowEvent()
        
      If ExamineMouse()
        MouseX = -MouseDeltaX()/20 
        MouseY = -MouseDeltaY()/20
      EndIf
      
          
      If ExamineKeyboard()
         
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -1
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = 1
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -1
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = 1
        Else
          KeyY = 0
        EndIf
        
        If KeyboardReleased(#PB_Key_Space)
          stone = CreateCube(#PB_Any , 0.5)
          stone = CreateEntity(#PB_Any, MeshID(stone),MaterialID(2))
          ScaleEntity(stone,4,2,4)
          MoveEntity(stone, 0,40, 0)
          CreateEntityBody(stone,#PB_Entity_BoxBody,3)
      
        EndIf
        
        If KeyboardPushed(#PB_Key_Z)
          
          ApplyEntityTorque(#cone, 0, 200, 0)

        EndIf
        
  
       EndIf
       
        
      RotateCamera(#Camera, MouseY, MouseX, 0, #PB_Relative)
      MoveCamera(#Camera, KeyX, 0, KeyY)
      
             
      StopDrawing()
      
      RenderWorld()
  
      FlipBuffers()
      
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  
    End
    
    

Re: MP3D Engine Alpha 32

Posted: Tue Dec 22, 2015 7:23 pm
by mpz
Hi applePi,

in my engine i use the command "NewtonBodySetOmega" Instead of NewtonBodyAddTorque. I have made a little demos file from them

http://newtondynamics.com/wiki/index.ph ... dySetOmega

MP_EntitySetOmega(Entity, xOmega.f , yOmega.f ,zOmega.f)

MP_EntityGetOmega (Entity , *vVector.D3DXVECTOR3)

to change something. To make a friction for turns is possible if you need...

Greetings Michael

Code: Select all

;////////////////////////////////////////////////////////////////
;//
;// Project Title: MP 3D Engine Beispielprogramme
;// Dateiname: MP_Torque.pb
;// Erstellt am: 22.12.2015
;// Update am  : 
;// Author: Michael Paulwitz
;// 
;// Info: 
;// Physic with Torque Meshs
;// Physik mit drehung 
;//
;//
;////////////////////////////////////////////////////////////////


Structure vecf
  x.f
  y.f
  z.f
EndStructure  

Structure matrix
  m.f[16]
EndStructure  

MP_Graphics3DWindow(0, 0, 800, 600, "MP3D Demo with Torque, Space to reset", 0)

light0 = MP_CreateLight(1)
MP_PositionEntity(light0, 0, 128, 0)
MP_EntityLookAt(light0, 0, 0, 0)
cam0 = MP_CreateCamera()
MP_CameraSetRange(cam0, 2, 2024)
MP_PositionEntity(cam0, -32, 64, -152)
MP_EntityLookAt(cam0, 0, 0, 0)
MP_PhysicInit()

If CreateImage(0, 255, 255)
  MP_CreateImageColored(0, 0, RGB(100,155,255), RGB(0,255,255), RGB(0,0,255), RGB(0,0,255))     
EndIf

tex0 = MP_ImageToTexture( 0 )

;################ Bodenplatte ################
bodenplatte = MP_CreateRectangle(256, 1, 256) ; Bodenplatte kann natürlich auch ein x-beliebiges Mesh sein
MP_ScaleMesh( bodenplatte ,0.6,0.6,0.6)
;MP_RotateEntity (bodenplatte, -20, 0, 0)

MP_EntitySetTexture(bodenplatte, tex0)
MP_EntityPhysicBody(bodenplatte, 1, 0)
;#############################################

NewList TempMesh()

For m = 0 To 7
  
    AddElement(TempMesh())
    TempMesh() = MP_CreatePyramid(3,4,3)
    
    MP_ScaleMesh (TempMesh(),3,3,3)
    MP_RotateEntity (TempMesh(), 180, 0, 0)
    
    MP_MaterialDiffuseColor(TempMesh(),255,Random(255),Random(255),Random(255)) 
    
    MP_EntityPhysicBody(TempMesh(), 4, 1)
    
    NewMaterial = MP_CreatePhysicMaterial() 
    MP_SetPhysicMaterialProperties(NewMaterial,0,m/14,m/14)
    MP_SetPhysicMaterialtoMesh (TempMesh(), NewMaterial)
    
    MP_EntitySetOmega(TempMesh(), 0 , 100 ,0)
    
    MP_PositionEntity(TempMesh(), (m-4) * 14, 15 + (m*2) ,0)
  
Next 
  

While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow

   
   If MP_KeyDown(#PB_Key_Space)=1
      FirstElement(TempMesh()) 
      
      For m = 0 To 7
          MP_EntityResetPhysic(TempMesh())
          MP_RotateEntity (TempMesh(), 180, 0, 0)
          MP_EntitySetOmega(TempMesh(), 0 , 100 ,0)
          MP_PositionEntity(TempMesh(), (m-4) * 14, 15 + (m*2) ,0)
          NextElement(TempMesh()) 

      Next 

   EndIf
   
   MP_EntityGetOmega(TempMesh(),Omega.vecf)
   MP_DrawText (1,1,"FPS = "+Str(MP_FPS())+" / GetOmega = "+StrF(Omega\y))
   
  MP_PhysicUpdate()  
  
  
  
  MP_RenderWorld()
  
  MP_Flip()  
Wend

MP_PhysicEnd()

Re: MP3D Engine Alpha 32

Posted: Wed Dec 23, 2015 7:59 am
by applePi
Thank you Michael, this is very interesting as it is almost like the real world tops toys, the MP_EntitySetOmega is very usefull.
i have played with your example using the cones which are tiled initially 4 degrees from vertical positions and it is also amusing

Code: Select all

AddElement(TempMesh())
;TempMesh() = MP_CreatePyramid(3,4,3)
TempMesh() = MP_CreateCone(16,12)
MP_ScaleMesh (TempMesh(),6,6,1)
;MP_ScaleMesh (TempMesh(),3,3,3)
MP_RotateEntity (TempMesh(), 266, 0, 0)
in the real world i like the throwing tops made from wood :
Image

Re: MP3D Engine Alpha 32

Posted: Fri Dec 25, 2015 1:10 pm
by Psychophanta
Nice, pity i didn't get MP3D when i developed this document:
https://www.youtube.com/watch?v=vU_vMz_1-rE

About omega and torque i must say it is useful to me.
I did this somedays ago to implement some other stuff to it to explain via video some behaviour about inertial fields....

Code: Select all

;Peonza Conica (21 Agosto 2015)
;/ inits
Define .f
ExamineDesktops()
Global bitplanes.a=DesktopDepth(0),RX.u=DesktopWidth(0)*2/3,RY.u=DesktopHeight(0)*0.6:MP_Graphics3DWindow(0,0,RX,RY,"Peonza conica",#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SystemMenu):MP_VSync(1):MP_SetAntialiasing(4)
; Global bitplanes.a=DesktopDepth(0),RX.u=DesktopWidth(0),RY.u=DesktopHeight(0):MP_Graphics3D(RX,RY,bitplanes,0):MP_VSync(1):MP_SetAntialiasing(4):SetWindowTitle(0,"Peonza conica")
Global ShowCursor.b=0,CursorX=RX/2,CursorY=RY/2,showgui.b=1,mdx,mdy
Global font.i=MP_LoadFont("Tahoma",20,1,0)
Structure D3DMATRIX
  _11.f : _12.f : _13.f : _14.f
  _21.f : _22.f : _23.f : _24.f
  _31.f : _32.f : _33.f : _34.f
  _41.f : _42.f : _43.f : _44.f
EndStructure
Structure D3DXVECTOR3
  x.f
  y.f
  z.f
EndStructure
Structure Vector3D Extends D3DXVECTOR3
  m.f;<-length(modulo)
EndStructure
MP_PhysicInit()
;\
Global.i camara,pivotcam,light,chapa,piv,stone,stone2,fondo,fondotexture,bola,disco,mastileje,pivot
;/ Luz
light.i=MP_CreateLight(1)
MP_LightSetColor(light,$FFFFFF)
MP_PositionEntity(light,4,4,0)
MP_CreateSkyBox("..\media\skyboxsun5deg","jpg",100)
;\
Procedure.i Matriz4x4xMatriz4x4(*a.D3DMATRIX,*b.D3DMATRIX,*prod.D3DMATRIX); producto
  *prod\_11=*a\_11**b\_11+*a\_12**b\_21+*a\_13**b\_31+*a\_14**b\_41:*prod\_12=*a\_11**b\_12+*a\_12**b\_22+*a\_13**b\_32+*a\_14**b\_42:*prod\_13=*a\_11**b\_13+*a\_12**b\_23+*a\_13**b\_33+*a\_14**b\_43:*prod\_14=*a\_11**b\_14+*a\_12**b\_24+*a\_13**b\_34+*a\_14**b\_44
  *prod\_21=*a\_21**b\_11+*a\_22**b\_21+*a\_23**b\_31+*a\_24**b\_41:*prod\_22=*a\_21**b\_12+*a\_22**b\_22+*a\_23**b\_32+*a\_24**b\_42:*prod\_23=*a\_21**b\_13+*a\_22**b\_23+*a\_23**b\_33+*a\_24**b\_43:*prod\_24=*a\_21**b\_14+*a\_22**b\_24+*a\_23**b\_34+*a\_24**b\_44
  *prod\_31=*a\_31**b\_11+*a\_32**b\_21+*a\_33**b\_31+*a\_34**b\_41:*prod\_32=*a\_31**b\_12+*a\_32**b\_22+*a\_33**b\_32+*a\_34**b\_42:*prod\_33=*a\_31**b\_13+*a\_32**b\_23+*a\_33**b\_33+*a\_34**b\_43:*prod\_34=*a\_31**b\_14+*a\_32**b\_24+*a\_33**b\_34+*a\_34**b\_44
  *prod\_41=*a\_41**b\_11+*a\_42**b\_21+*a\_43**b\_31+*a\_44**b\_41:*prod\_42=*a\_41**b\_12+*a\_42**b\_22+*a\_43**b\_32+*a\_44**b\_42:*prod\_43=*a\_41**b\_13+*a\_42**b\_23+*a\_43**b\_33+*a\_44**b\_43:*prod\_44=*a\_41**b\_14+*a\_42**b\_24+*a\_43**b\_34+*a\_44**b\_44
  ProcedureReturn *prod
EndProcedure
Procedure.i flecha(px.f=0,py.f=0,pz.f=0,x.f=1,y.f=0,z.f=0,color.l=$EE3333,lados.a=8)
  Protected mod.f=Sqr(x*x+y*y+z*z),cil.i=MP_CreateCylinder(lados,mod),cono.i=MP_CreateCone(lados,mod/8):ciltexture=MP_CreateTextureColor(8,8,color)
  MP_ResizeMesh(cil,mod/80,mod/80,mod)
  MP_TranslateMesh(cil,0,0,mod/2)
  MP_RotateMesh(cono,180,0,180)
  MP_ResizeMesh(cono,mod/20,mod/20,mod/10)
  MP_TranslateMesh(cono,0,0,mod)
  MP_AddMesh(cono,cil):MP_FreeEntity(cono)
;   MP_EntityLookAt(cil,x+0.000001,y,z,0,0)
  MP_PositionEntity(cil,px,py,pz)
  MP_EntitySetTexture(cil,ciltexture,0,0)
  ProcedureReturn cil
EndProcedure
Procedure.i BaseSistemaCoordenadas(px.f=0,py.f=0,pz.f=0,colorx.l=$EEAA88,colory.l=$22AADD,colorz.l=$AADDAA,lados.a=8)
  Protected vx.i=flecha(px,py,pz,1,0,0,colorx,lados)
  Protected vy.i=flecha(px,py,pz,0,1,0,colory,lados)
  Protected vz.i=flecha(px,py,pz,0,0,1,colorz,lados)
  MP_AddMesh(vx.i,vy.i);:MP_FreeEntity(vx.i)
  MP_AddMesh(vz.i,vy.i);:MP_FreeEntity(vz.i)
  ProcedureReturn vy.i
EndProcedure
; baseglobal.i=BaseSistemaCoordenadas(-1.5,1,0)
flecha.i=flecha()
MP_ScaleMesh(flecha,4,4,1)
MP_HideEntity(flecha,1)
;
camara=MP_CreateCamera():pivotcam.i=MP_CreateMesh():MP_EntitySetParent(camara,pivotcam,0):MP_PositionEntity(camara,0,0,-3):MP_TurnEntity(pivotcam,18,0,0,0)
;
fondo=MP_CreateRectangle(20,0,20)
MP_PositionEntity(fondo,0,-1,0)
fondotexture=MP_LoadTexture("..\media\wood-floor2.jpg",0,0)
MP_EntitySetTexture(fondo,fondotexture,0,0)
MP_EntityPhysicBody(fondo,1,0)
;
mastileje=MP_CreateCylinder(8,2)
MP_RotateMesh(mastileje,90,0,0)
MP_ScaleMesh(mastileje,0.05,0.5,0.05)
MP_PositionEntity(mastileje,0,-0.5,0)
MP_EntityPhysicBody(mastileje,1,0)
bola=MP_CreateSphere(4):MP_MaterialEmissiveColor(bola,$bb,$8E,$AA,$FB):MP_ResizeMesh(bola,0.1,0.1,0.1)
#verticesdisco=6
disco=MP_CreateCylinder(#verticesdisco,0.01)
MP_RotateMesh(disco,90,-90,0)
MP_MeshSetAlpha(disco,2)
; discocolor.l=$99AAAABB:discoTexture.i=MP_CreateTextureColor(8,8,discocolor):MP_EntitySetTexture(disco,discoTexture,0,0)
MP_MaterialDiffuseColor(disco,$55,$1E,$FA,$EB):MP_MaterialEmissiveColor(disco,$99,$AE,$BA,$6B)
MP_EntityPhysicBody(disco,3,1)
;
MP_ConstraintCreateBall(disco,0,1,0,1,0,0,0,0,mastileje)
;Bisagras:
Dim bisagra.i(#verticesdisco-1):Dim pesa.i(#verticesdisco-1):Dim hilo.i(#verticesdisco-1):rad=1
For t.a=0 To #verticesdisco-1
  posx=rad*Cos(#PI*(t/#verticesdisco*2-1))
  posz=rad*Sin(#PI*(t/#verticesdisco*2-1))
  bisagra(t)=MP_CreateSphere(4):MP_ResizeMesh(bisagra(t),0.02,0.02,0.02)
  pesa(t)=MP_CreateSphere(12):MP_ResizeMesh(pesa(t),0.08,0.08,0.08)
  hilo(t)=MP_CreateCylinder(6,1):MP_RotateMesh(hilo(t),-90,0,0):MP_ResizeMesh(hilo(t),0.005,0.3,0.005):MP_TranslateMesh(hilo(t),0,0.15,0):MP_MaterialEmissiveColor(hilo(t),$99,$BB,$56,$89)
  MP_TranslateMesh(bisagra(t),posx,0,posz)
  MP_PositionEntity(pesa(t),posx,-0.3,posz)
  MP_EntitySetParent(hilo(t),pesa(t),0)
  MP_AddMesh(bisagra(t),disco):MP_FreeEntity(bisagra(t))
Next
For t.a=0 To #verticesdisco-1
  MP_EntityPhysicBody(pesa(t),3,0.1)
  MP_ConstraintCreateBall(pesa(t),0,0,1,0,0,0,0.3,0,disco)
Next
MP_MouseInWindow()
MP_UseCursor(0)
pesa.a=0
While MP_KeyDown(#PB_Key_Escape)=0 And WindowEvent()<>#PB_Event_CloseWindow
  mdx=MP_MouseDeltaX()/200:mdy=MP_MouseDeltaY()/200:mdw=MP_MouseDeltaWheel()/400
  If MP_KeyHit(#PB_Key_Space)
  ElseIf MP_KeyHit(#PB_Key_W)
    wf.b!1
    MP_Wireframe(wf.b)
  ElseIf MP_KeyDown(#PB_Key_Left)
    ;  MP_EntitySetOmega(disco,0,1,0)
    MP_EntityAddImpulse(disco,0,0,1,-10,0,0)
    MP_EntityAddImpulse(disco,0,0,-1,10,0,0)
  ElseIf MP_KeyDown(#PB_Key_Right)
    ;  MP_EntitySetOmega(disco,0,-1,0)
    MP_EntityAddImpulse(disco,0,0,-1,-10,0,0)
    MP_EntityAddImpulse(disco,0,0,1,10,0,0)
  ElseIf MP_KeyHit(#PB_Key_Up)
  ElseIf MP_KeyHit(#PB_Key_Down)
  ElseIf MP_KeyHit(#PB_Key_End)
    MP_HideEntity(flecha,1)
  ElseIf MP_KeyHit(#PB_Key_F5)
  ElseIf MP_MouseButtonDown(1)
;     picked.i=MP_PickCamera(camara,WindowMouseX(0),WindowMouseY(0))
;     If picked
;       MP_PositionEntity(pivotcam,MP_EntityGetX(picked,0),MP_EntityGetY(picked,0),MP_EntityGetZ(picked,0))
;     EndIf
    MP_MoveEntity(pivotcam,mdx,-mdy,0)
  Else
    MP_TurnEntity(pivotcam,mdy*60,mdx*60,0,0)
    If mdw
      MP_EntitySetZ(camara,MP_EntityGetZ(camara)+mdw); <- MP_MoveEntity(cam,0,0,mdw)
    EndIf
    If MP_KeyDown(#PB_Key_Left)
      MP_MoveEntity(pivotcam,-0.1,0,0)
    ElseIf MP_KeyDown(#PB_Key_Right)
      MP_MoveEntity(pivotcam,0.1,0,0)
    ElseIf MP_KeyDown(#PB_Key_Up)
      MP_MoveEntity(pivotcam,0,0.1,0)
    ElseIf MP_KeyDown(#PB_Key_Down)
      MP_MoveEntity(pivotcam,0,-0.1,0)
    EndIf
  EndIf
  MP_PhysicUpdate()
  MP_RenderWorld()
  MP_Flip():Delay(8)
Wend
MP_PhysicEnd()

Re: MP3D Engine Alpha 32

Posted: Fri Dec 25, 2015 5:56 pm
by applePi
now i know why Psychophanta have commented the line 115 MP_EntitySetOmega(disco,0,1,0)
because if he rotated the table with the Right key then suddenly we press left key:

Code: Select all

ElseIf MP_KeyDown(#PB_Key_Left)
    MP_EntitySetOmega(disco,0,1,0)
the table will instantaneously reverse the rotation and begins to rotate in a fixed speed. this is like the behavior of a digital motor used in printers, and not like the analogue motors . while when we use:

Code: Select all

ElseIf MP_KeyDown(#PB_Key_Left)
      MP_EntityAddImpulse(disco,0,0,1,-10,0,0)
it will slow speed gradually and then rotated in reverse.
so i think: my suggestions about torque functions above http://purebasic.fr/english/viewtopic.p ... 00#p478716 is still valid. the MP_EntityAddImpulse does not work for powering free objects (ie does not have joints) like tops toys and UFO etc. if Michael have implemented it someday in the next year will be great. however MP_EntitySetOmega is very useful also.

Re: MP3D Engine Alpha 32

Posted: Mon Dec 28, 2015 1:11 pm
by Psychophanta
Yes, @applePi, that's it.
Omega is angular speed, and Torque is external force to perform increment (or decrement) of angular speed.
A variation of omega is the consequence of a Torque.
If no command for torque , then we have to use add 2 impulses at the same distance of axis and in the opposit direction.

Re: MP3D Engine Alpha 32

Posted: Sun Jan 10, 2016 1:31 pm
by hippy
Hello All,

mpz this is awesome, thank you, the ThreadSafe latest versions seem to work great with PB 5.40 LTS.


I have a question though.... is there something similar to isSprite and isTexture?

I have a problem when the DX device is lost and restored, this code can crash unless Iknow if it still is valid, because RenderWorld() fails when the sprite or maybe texture is not valid.

Code: Select all


Static tex
Static spr

  If newImg    
             If tex 
               MP_FreeTexture(tex)
               tex = 0
             EndIf   
                 
             tex = MP_ImageToTexture(WSession\img_num)  
             If tex 
               MP_SpriteSetTexture(spr, tex)           
             EndIf

           ;-- If device is lost here somewhere I think, this now crashes RenderWorld()

           If spr
              MP_DrawSprite( spr, x, y  )                            
            EndIf
    Endif


I can make it work if I free the sprite and texture every loop, but it is slower? Is there a better way?

Code: Select all

Static tex
Static spr

  If newImg     
             If tex 
               MP_FreeTexture(tex)
               tex = 0
             EndIf 
             If spr 
               MP_FreeSprite(spr)
               spr = 0
             EndIf  
                              
             tex = MP_ImageToTexture(WSession\img_num)  
             spr = MP_SpriteFromTexture(tex)           
           EndIf

           ;-- If device is lost here I think, this now crashes RenderWorld()

           If spr
              MP_DrawSprite( spr, x, y  )                            
            EndIf
    Endif

Many thanks :)

Cheers,
Hippy

Re: MP3D Engine Alpha 32

Posted: Mon Jan 11, 2016 2:46 pm
by Joubarbe
I've installed MP3D with the latest installer, 64bits, and it gave me some error on some demos. Besides, in each example, I have a "POLINK:fatal error: File not found : D3D9.LIB". Did the installer did something wrong or is it me ... ? The dx9 folder is in the subsystems directory as it should.

(running PB 5.41)

Re: MP3D Engine Alpha 32

Posted: Mon Jan 11, 2016 3:29 pm
by leonhardt
Joubarbe wrote:I've installed MP3D with the latest installer, 64bits, and it gave me some error on some demos. Besides, in each example, I have a "POLINK:fatal error: File not found : D3D9.LIB". Did the installer did something wrong or is it me ... ? The dx9 folder is in the subsystems directory as it should.

(running PB 5.41)
use the right version of mp3d and pb,check the dx9 subsystem of project option,should be ok。

Re: MP3D Engine Alpha 32

Posted: Mon Jan 11, 2016 4:49 pm
by Joubarbe
Well I have no problem when using the x86 version, but the x64 doesn't work for me.

Re: MP3D Engine Alpha 32

Posted: Tue Jan 12, 2016 12:24 am
by mpz
Dear Joubarbe,

in the MP3D_Installer.exe you must activate the Funktion "DX9 Librarys". These function installes the dx9 libs include the

C:\Program Files\PureBasic 5.41 x64\PureLibraries\Windows\Libraries\d3d9.lib

library.

Here for manually installation ...

http://www.flasharts.de/mpz/d3dx9.lib

Greetings Michael

Re: MP3D Engine Alpha 32

Posted: Tue Jan 12, 2016 2:34 pm
by Joubarbe
Then I'm afraid there's a problem in your installer, somewhere else.

The only option that is not checked by default is the threadsafe one, so in the three installations that I've attempted, I've always kept the default setting (not being interested by multi thread).

Again, it's working fine with the x86 version. And ultimately, it's fine that way, but still, it should work with the x64 as well if I read you correctly.

(putting manually the d3dx9.lib inside the PB windows libraries folder doesn't help)

Re: MP3D Engine Alpha 32

Posted: Tue Jan 12, 2016 5:00 pm
by applePi
Hi Michael, Joubarbe is right, i have installed purebasic 5.41_x64 on win7 x64, then running the MP3D_Installer, choosing only the important items since i copy the demos from x86 version.
it say installed successfuly, yes it installed the "MP3D_Library" file but not dx9, nor any of the
dinput8.lib
d3dx9.lib
dxguid.lib
...
i have copied these dx files from x86 but does not work, there is many polink error, i have installed the directX 9 from
http://download.microsoft.com/download/ ... redist.exe and no luck
and then dx9 nov. 2007 from http://filehippo.com/download_directx/3345/
also there is polink errors
i suggest 2 installers one for x86 and one for x64, like the purebasic distribution

Re: MP3D Engine Alpha 32

Posted: Tue Jan 12, 2016 11:17 pm
by Psychophanta
There seems not to free 2DPhysics bodies nor statics entities:
Please test it in the examples of the native package.

Example:

Code: Select all

BallBody=MP_2DPhysicBodyCircle(wX/2,5 , 31, Ball, 10)
MP_FreeEntity(BallBody); <- does not free anything