MP3D Engine Alpha 33
-
- Enthusiast
- Posts: 494
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: MP3D Engine Alpha 32
Hi applePi,
the comands "MP_Box Box Kollison", MP_EntityCollTri and MP_3DCollisionCube2Cube are the first test of me to create a own collision test. The functions dont work with newton.
I am working on some new newton functions to make a car better working...
Greetings
Michael
the comands "MP_Box Box Kollison", MP_EntityCollTri and MP_3DCollisionCube2Cube are the first test of me to create a own collision test. The functions dont work with newton.
I am working on some new newton functions to make a car better working...
Greetings
Michael
Working on - MP3D Library - PB 5.73 version ready for download
- Psychophanta
- Addict
- Posts: 4996
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Lípetsk, Russian Federation
- Contact:
Re: MP3D Engine Alpha 32
Thanks Michael.
Please needed also for the Physics engine the Corkscrew joint and a command to destroy (free) joints.
Please needed also for the Physics engine the Corkscrew joint and a command to destroy (free) joints.
http://www.zeitgeistmovie.com
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
-
- Enthusiast
- Posts: 494
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: MP3D Engine Alpha 32
Hi to all,
@Psychophanta
i have integrated 4 new joint comands to "destroy" the joints:
MP_ConstraintDestroyBall (Entity) ; Destroy a Ball and Socket joint functions
MP_ConstraintDestroyHinge (Entity) ; Destroy a Hinge joint functions
MP_ConstraintDestroySlider (Entity) ; Destroy a Slider joint functions
MP_ConstraintDestroyUpVector (Entity) ; Destroy a UpVector joint functions
I am search for a Corkscrew joint newton demo. If i find them i can integrate it in mp3d
Here comes the testing lib ( i have actualized x86/x64 for PB524 and PB540 too):
32 Bit MP3D_lib for PureBasic\SubSystems\dx9\purelibraries\userlibraries\
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip
Greetings
Michael
@Psychophanta
i have integrated 4 new joint comands to "destroy" the joints:
MP_ConstraintDestroyBall (Entity) ; Destroy a Ball and Socket joint functions
MP_ConstraintDestroyHinge (Entity) ; Destroy a Hinge joint functions
MP_ConstraintDestroySlider (Entity) ; Destroy a Slider joint functions
MP_ConstraintDestroyUpVector (Entity) ; Destroy a UpVector joint functions
I am search for a Corkscrew joint newton demo. If i find them i can integrate it in mp3d
Here comes the testing lib ( i have actualized x86/x64 for PB524 and PB540 too):
32 Bit MP3D_lib for PureBasic\SubSystems\dx9\purelibraries\userlibraries\
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip
Greetings
Michael
Code: Select all
;////////////////////////////////////////////////////////////////
;//
;// Project Title: MP 3D Engine Beispielprogramme
;// Dateiname: MP_DestroyUpVector.pb
;// Erstellt am: 25.3.2016
;// Update am :
;// Author: Michael Paulwitz
;//
;// Info:
;// Physic with UpVector Meshs
;// Physik mit UpVector
;//
;//
;////////////////////////////////////////////////////////////////
MP_Graphics3DWindow(0, 0, 800, 600, "MP3D Demo with Upvector, Space to destroy Upvector", 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, -18, 30, -80)
MP_EntityLookAt(cam0, 0, 0, 0)
MP_PhysicInit()
If CreateImage(0, 255, 255)
MP_CreateImageColored(0, 0, RGB(100,155,255), RGB(110,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_EntitySetTexture(bodenplatte, tex0)
MP_EntityPhysicBody(bodenplatte, 1, 0)
;#############################################
Mesh = MP_CreateCone(16,12)
MP_ScaleMesh (Mesh,6,6,1)
MP_RotateEntity (Mesh, 260, 0, 0)
MP_MaterialDiffuseColor(Mesh,255,Random(255),Random(255),Random(255))
MP_EntityPhysicBody(Mesh, 4, 1)
MP_EntitySetOmega(Mesh, 0 , 20 ,0)
MP_PositionEntity(Mesh, 0, 10,0)
MP_ConstraintCreateUpVector (Mesh,0,1,0) ; Mesh is Upvectored
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
If MP_KeyDown(#PB_Key_Space)
MP_ConstraintDestroyUpVector (Mesh) ; del Upvector
EndIf
MP_PhysicUpdate()
MP_RenderWorld()
MP_Flip()
Wend
MP_PhysicEnd()
Working on - MP3D Library - PB 5.73 version ready for download
- Psychophanta
- Addict
- Posts: 4996
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Lípetsk, Russian Federation
- Contact:
Re: MP3D Engine Alpha 32
Good one, Michael,
however, what if we create more than one constraint of the same type for the same mesh?, How to "destroy" it?
(By the way, no new version available in the link you wrote, the linked file is from february. Is there a new one?)
however, what if we create more than one constraint of the same type for the same mesh?, How to "destroy" it?
(By the way, no new version available in the link you wrote, the linked file is from february. Is there a new one?)
http://www.zeitgeistmovie.com
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
Re: MP3D Engine Alpha 32
drawing points in real time, such as we want to register events in the sky and to feed its xyz positions to the computer and to plot that position besides the other positions in real time.
in MP3D i create MP_CreatePrimitives (60000, 7) mode 7 for big points
but plot only 11 points, then after that when we press 'space' we plot another points to join the other points to simulate the real time plotting. really Michael have made big achievements in making his graphics Lib easy to use.
in MP3D i create MP_CreatePrimitives (60000, 7) mode 7 for big points
but plot only 11 points, then after that when we press 'space' we plot another points to join the other points to simulate the real time plotting. really Michael have made big achievements in making his graphics Lib easy to use.
Code: Select all
#Mode = 7 ; #Mode = 1 or #Mode = 7 ; 7 for big points
Structure PointVertex
x.f
y.f
z.f
CompilerIf #Mode = 7
Size.f ;--- Only if Mode = 7
CompilerEndIf
Color.l;d3dcolor
EndStructure
; code for MP3D
Declare DrawMatrix()
ExamineDesktops()
MP_Graphics3D (DesktopWidth(0),DesktopHeight(0),0,3) ; Erstelle ein WindowsFenster #Window = 0
MP_Viewport(0,0,DesktopWidth(0),DesktopHeight(0)-5)
SetWindowTitle(0, "press up/down to move camera, A/Z to move up.down ")
camera=MP_CreateCamera()
light=MP_CreateLight(2)
MP_LightSetColor (light, RGB(255,255,255))
Global size = 60000
Global vertexcount = 11
Global Entity= MP_CreatePrimitives (size, #Mode)
Define.f red, green, blue
Quit.b = #False : Global PointSize.f=5
;==============================================================
DrawMatrix()
MP_PrimitivesBlendingMode(Entity, 5,2)
MP_PositionEntity(camera, 0, 0, 700)
MP_EntityLookAt(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 : camY=0
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
If MP_KeyDown(#PB_Key_Up)
zz.f + 0.3
ElseIf MP_KeyDown(#PB_Key_Down)
zz.f - 0.3
EndIf
If MP_KeyDown(#PB_Key_A)
camY+1
MP_PositionEntity(camera, 0, camY, 700)
ElseIf MP_KeyDown(#PB_Key_Z)
camY-1
MP_PositionEntity(camera, 0, camY, 700)
ElseIf MP_KeyHit(#PB_Key_R)
MP_ScaleEntity(Entity, 1, 0.2, 1)
EndIf
If MP_KeyDown(#PB_Key_Space)
*Memory = MP_GetMemPrimitives(Entity)
*myvertex.PointVertex = *Memory + vertexcount * SizeOf(PointVertex)
x = Random(200)-100:y = Random(200)-100:z = Random(200)-100
*myvertex\x = x
*myvertex\y = y
*myvertex\z = z
CompilerIf #Mode = 7
*myvertex\Size = PointSize ;--- Only if Mode = 7
CompilerEndIf
*myvertex\color = MP_ARGB(200,Random(255,50),Random(255,50),Random(255,50))
vertexcount+1
If vertexcount = size: End:EndIf
*myvertex + SizeOf(PointVertex)
MP_CloseMemPrimitives(Entity)
EndIf
MP_PositionEntity(Entity, xx, 0, zz)
MP_TurnEntity(Entity,0,0.1,0)
SetWindowTitle(0, "vertex count = "+Str(vertexcount)+ "...."+"FPS = "+Str(MP_FPS())+" press Space to add more points")
;MP_DrawText (1,1,"FPS = "+Str(MP_FPS()))
MP_RenderWorld()
MP_Flip ()
Wend
MP_CloseMemPrimitives(Entity)
Procedure DrawMatrix()
*Memory = MP_GetMemPrimitives(Entity)
For i=0 To 10
x = Random(200)-100:y = Random(200)-100:z = Random(200)-100
*myvertex.PointVertex = *Memory + i * SizeOf(PointVertex)
r=0:g=255:b=0
*myvertex\x = x
*myvertex\y = y
*myvertex\z = z
CompilerIf #Mode = 7
*myvertex\Size = PointSize ;--- Only if Mode = 7
CompilerEndIf
*myvertex\color = MP_ARGB(200,r,g,b)
Next
MP_CloseMemPrimitives(Entity)
EndProcedure
- Psychophanta
- Addict
- Posts: 4996
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Lípetsk, Russian Federation
- Contact:
Re: MP3D Engine Alpha 32
mpz wrote: i have integrated 4 new joint comands to "destroy" the joints:
MP_ConstraintDestroyBall (Entity) ; Destroy a Ball and Socket joint functions
MP_ConstraintDestroyHinge (Entity) ; Destroy a Hinge joint functions
MP_ConstraintDestroySlider (Entity) ; Destroy a Slider joint functions
MP_ConstraintDestroyUpVector (Entity) ; Destroy a UpVector joint functions
I am search for a Corkscrew joint newton demo. If i find them i can integrate it in mp3d
Here comes the testing lib ( i have actualized x86/x64 for PB524 and PB540 too):
32 Bit MP3D_lib for PureBasic\SubSystems\dx9\purelibraries\userlibraries\
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip
Greetings
Michael
Dear Michael;Psychophanta wrote:no new version available in the link you wrote, the linked file is from february. Is there a new one?
Still can not free constraint, can you upload the newest library?
Thanks!
http://www.zeitgeistmovie.com
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
-
- Enthusiast
- Posts: 494
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: MP3D Engine Alpha 32
Hello Psychophanta,
oh yes, i will check this in the evening and upgrade all libs.
Greetings Michael
oh yes, i will check this in the evening and upgrade all libs.
Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
-
- Enthusiast
- Posts: 494
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: MP3D Engine Alpha 32
Hello Psychophanta,
i have checked this and have actualized all libs. Now the commands are integrated...
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip
Greetings Michael
i have checked this and have actualized all libs. Now the commands are integrated...
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip
Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
- Psychophanta
- Addict
- Posts: 4996
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Lípetsk, Russian Federation
- Contact:
Re: MP3D Engine Alpha 32
Thanks Michael.
Don't forget we are waiting for new advances.
Don't forget we are waiting for new advances.
http://www.zeitgeistmovie.com
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
- Psychophanta
- Addict
- Posts: 4996
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Lípetsk, Russian Federation
- Contact:
Re: MP3D Engine Alpha 32
Here a useful tip:
2 different ways to turn an entity over XY axes relative to camera view (eye).
1)
2)
Code to test them:
(USE: Key_LeftControl to move camera point of view, so you can see the global axises from different points in space. Key_LeftShift to run the method '1)'. No key to run the method '2)'. Key_RightShift to turn the piece over global axises.)
Feel free to translate code to other 3D layouts.
2 different ways to turn an entity over XY axes relative to camera view (eye).
1)
Code: Select all
Procedure.i Turn_Body_by_Angle_adding(*fi.Vector3D,Body.i,*matriz.D3DMATRIX=0,vx.f=0,vy.f=0,vz.f=0)
;Rotar un entity un ángulo dado *fi.Vector3D:
Protected rot1.D3DMATRIX,rot.D3DMATRIX,cos.f,sin.f,coss.f,ang.Vector3D
*fi\m=getmodulo(*fi)
If *fi\m
If *matriz=0
*matriz=MP_EntityGetMatrix(Body)
EndIf
*matriz\_41+vx:*matriz\_42+vy:*matriz\_43+vz
CopyMemory(*matriz,@rot,SizeOf(D3DMATRIX))
CopyMemory(*fi,@ang,SizeOf(Vector3D))
cos=Cos(ang\m):sin=Sin(ang\m):coss=1-cos
ang\x/ang\m:ang\y/ang\m:ang\z/ang\m
rot1\_11=cos+ang\x*ang\x*coss:rot1\_12=ang\x*ang\y*coss-ang\z*sin:rot1\_13=ang\x*ang\z*coss+ang\y*sin
rot1\_21=ang\y*ang\x*coss+ang\z*sin:rot1\_22=cos+ang\y*ang\y*coss:rot1\_23=ang\y*ang\z*coss-ang\x*sin
rot1\_31=ang\z*ang\x*coss-ang\y*sin:rot1\_32=ang\z*ang\y*coss+ang\x*sin:rot1\_33=cos+ang\z*ang\z*coss
MP_EntitySetMatrix(Body,Matriz3x3xMatriz3x3(*matriz,@rot1,@rot))
ProcedureReturn @rot
EndIf
ProcedureReturn 0
EndProcedure
Code: Select all
Procedure.i MatrizRotacionaldeunAngulodadoalrededordeunejedefinidoporunvectorunidad(*u.Vector3D,Body.i,ANG.f,*matriz.D3DMATRIX=0,vx.f=0,vy.f=0,vz.f=0)
Protected rot.D3DMATRIX,rot1.D3DMATRIX
If ANG
If *matriz=0
*matriz=MP_EntityGetMatrix(Body)
EndIf
*matriz\_41+vx:*matriz\_42+vy:*matriz\_43+vz
;Matriz de Rotación de un ángulo dado 'ANG' alrededor de un eje dado definido por el vector unidad (*u\x,*u\y,*u\z)
rot1\_11=Cos(ANG)+*u\x**u\x*(1-Cos(ANG)):rot1\_12=*u\x**u\y*(1-Cos(ANG))-*u\z*Sin(ANG):rot1\_13=*u\x**u\z*(1-Cos(ANG))+*u\y*Sin(ANG)
rot1\_21=*u\y**u\x*(1-Cos(ANG))+*u\z*Sin(ANG):rot1\_22=Cos(ANG)+*u\y**u\y*(1-Cos(ANG)):rot1\_23=*u\y**u\z*(1-Cos(ANG))-*u\x*Sin(ANG)
rot1\_31=*u\z**u\x*(1-Cos(ANG))-*u\y*Sin(ANG):rot1\_32=*u\z**u\y*(1-Cos(ANG))+*u\x*Sin(ANG):rot1\_33=Cos(ANG)+*u\z**u\z*(1-Cos(ANG))
CopyMemory(*matriz,@rot,SizeOf(D3DMATRIX))
MP_EntitySetMatrix(Body,Matriz3x3xMatriz3x3(*matriz,@rot1,@rot))
ProcedureReturn @rot
EndIf
ProcedureReturn 0
EndProcedure
(USE: Key_LeftControl to move camera point of view, so you can see the global axises from different points in space. Key_LeftShift to run the method '1)'. No key to run the method '2)'. Key_RightShift to turn the piece over global axises.)
Code: Select all
; Rota una entidad sobre su centro geométrico (rotación intrínseca si ese centro corresponde con su centro de masas). Diciembre 2014
Define .f
MP_Graphics3D(640,480,0,3)
SetWindowTitle(0,"TurnEntity over relative to eye axis")
maincam.i=MP_CreateCamera()
pivotcam.i=MP_CreateMesh():MP_EntitySetParent(maincam,pivotcam,0):MP_PositionEntity(maincam,0,0,-4)
light.i=MP_CreateLight(1)
If CreateImage(0,255,255)
Font.i=LoadFont(#PB_Any,"Arial",138)
StartDrawing(ImageOutput(0))
Box(0, 0, 128, 128,RGB(255,0,0))
Box(128, 0, 128, 128,RGB(0,255,0))
Box(0, 128, 128, 128,RGB(0,0,255))
Box(128, 128, 128, 128,RGB(255,255,0))
DrawingFont(FontID(Font))
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(73,35,"5",RGB(0,0,0))
StopDrawing()
EndIf
Object0.i=MP_CreateSkySphere(20)
; Object0.i=MP_CreateSphere(20)
; Object0.i=MP_CreateCube()
MP_EntitySetTexture(Object0,MP_ImageToTexture(0),0,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
Macro ProductoEscalar(a,b,ax=x,ay=y,az=z,bx=x,by=y,bz=z)
(a#\ax#*b#\bx#+a#\ay#*b#\by#+a#\az#*b#\bz#)
EndMacro
Macro getmodulo(v,vx=x,vy=y,vz=z)
(Sqr#ProductoEscalar(v#,v#,vx#,vy#,vz#,vx#,vy#,vz#))
EndMacro
Procedure.i Matriz3x3xMatriz3x3(*a.D3DMATRIX,*b.D3DMATRIX,*prod.D3DMATRIX); producto
*prod\_11=*a\_11**b\_11+*a\_12**b\_21+*a\_13**b\_31:*prod\_12=*a\_11**b\_12+*a\_12**b\_22+*a\_13**b\_32:*prod\_13=*a\_11**b\_13+*a\_12**b\_23+*a\_13**b\_33
*prod\_21=*a\_21**b\_11+*a\_22**b\_21+*a\_23**b\_31:*prod\_22=*a\_21**b\_12+*a\_22**b\_22+*a\_23**b\_32:*prod\_23=*a\_21**b\_13+*a\_22**b\_23+*a\_23**b\_33
*prod\_31=*a\_31**b\_11+*a\_32**b\_21+*a\_33**b\_31:*prod\_32=*a\_31**b\_12+*a\_32**b\_22+*a\_33**b\_32:*prod\_33=*a\_31**b\_13+*a\_32**b\_23+*a\_33**b\_33
ProcedureReturn *prod
EndProcedure
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=$AA66AA,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.i=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,size.f=1,colorx.l=$EEAA88,colory.l=$22AADD,colorz.l=$AADDAA,lados.a=8)
Protected vx.i=flecha(px,py,pz,size,0,0,colorx,lados)
Protected vy.i=flecha(px,py,pz,0,size,0,colory,lados)
Protected vz.i=flecha(px,py,pz,0,0,size,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
Procedure.i Turn_Body_by_Angle_adding(*fi.Vector3D,Body.i,*matriz.D3DMATRIX=0,vx.f=0,vy.f=0,vz.f=0)
;Rotar un entity un ángulo dado *fi.Vector3D:
Protected rot1.D3DMATRIX,rot.D3DMATRIX,cos.f,sin.f,coss.f,ang.Vector3D
*fi\m=getmodulo(*fi)
If *fi\m
If *matriz=0
*matriz=MP_EntityGetMatrix(Body)
EndIf
*matriz\_41+vx:*matriz\_42+vy:*matriz\_43+vz
CopyMemory(*matriz,@rot,SizeOf(D3DMATRIX))
CopyMemory(*fi,@ang,SizeOf(Vector3D))
cos=Cos(ang\m):sin=Sin(ang\m):coss=1-cos
ang\x/ang\m:ang\y/ang\m:ang\z/ang\m
rot1\_11=cos+ang\x*ang\x*coss:rot1\_12=ang\x*ang\y*coss-ang\z*sin:rot1\_13=ang\x*ang\z*coss+ang\y*sin
rot1\_21=ang\y*ang\x*coss+ang\z*sin:rot1\_22=cos+ang\y*ang\y*coss:rot1\_23=ang\y*ang\z*coss-ang\x*sin
rot1\_31=ang\z*ang\x*coss-ang\y*sin:rot1\_32=ang\z*ang\y*coss+ang\x*sin:rot1\_33=cos+ang\z*ang\z*coss
MP_EntitySetMatrix(Body,Matriz3x3xMatriz3x3(*matriz,@rot1,@rot))
ProcedureReturn @rot
EndIf
ProcedureReturn 0
EndProcedure
Procedure.i MatrizRotacionaldeunAngulodadoalrededordeunejedefinidoporunvectorunidad(*u.Vector3D,Body.i,ANG.f,*matriz.D3DMATRIX=0,vx.f=0,vy.f=0,vz.f=0)
Protected rot.D3DMATRIX,rot1.D3DMATRIX
If ANG
If *matriz=0
*matriz=MP_EntityGetMatrix(Body)
EndIf
*matriz\_41+vx:*matriz\_42+vy:*matriz\_43+vz
;Matriz de Rotación de un ángulo dado 'ANG' alrededor de un eje dado definido por el vector unidad (*u\x,*u\y,*u\z)
rot1\_11=Cos(ANG)+*u\x**u\x*(1-Cos(ANG)):rot1\_12=*u\x**u\y*(1-Cos(ANG))-*u\z*Sin(ANG):rot1\_13=*u\x**u\z*(1-Cos(ANG))+*u\y*Sin(ANG)
rot1\_21=*u\y**u\x*(1-Cos(ANG))+*u\z*Sin(ANG):rot1\_22=Cos(ANG)+*u\y**u\y*(1-Cos(ANG)):rot1\_23=*u\y**u\z*(1-Cos(ANG))-*u\x*Sin(ANG)
rot1\_31=*u\z**u\x*(1-Cos(ANG))-*u\y*Sin(ANG):rot1\_32=*u\z**u\y*(1-Cos(ANG))+*u\x*Sin(ANG):rot1\_33=Cos(ANG)+*u\z**u\z*(1-Cos(ANG))
CopyMemory(*matriz,@rot,SizeOf(D3DMATRIX))
MP_EntitySetMatrix(Body,Matriz3x3xMatriz3x3(*matriz,@rot1,@rot))
ProcedureReturn @rot
EndIf
ProcedureReturn 0
EndProcedure
baseglobal.i=BaseSistemaCoordenadas(-1.5,1,0,1)
*rot.D3DMATRIX=MP_EntityGetMatrix(pivotcam)
rot.D3DMATRIX
rot1.D3DMATRIX
rotx.D3DMATRIX
roty.D3DMATRIX
; MP_RotateEntity(Object0,Random(360),Random(360),Random(360),0)
MP_MouseInWindow()
MP_UseCursor(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_KeyDown(#PB_Key_LeftControl); <- mover el punto de vista
MP_TurnEntity(pivotcam,mdy*60,mdx*60,0,0)
If mdw
MP_EntitySetZ(maincam,MP_EntityGetZ(maincam)+mdw); <- MP_MoveEntity(cam,0,0,mdw)
EndIf
*rot=MP_EntityGetMatrix(pivotcam)
ElseIf MP_KeyDown(#PB_Key_RightShift); <- rotar el objeto sobre eje 'x' global y sobre eje 'y' global
;Para rotar la entidad alrededor del eje, en el plano XY del mundo, que define el desplazamiento del raton
;matriz de rotación sobre eje x del mundo:
rotx\_11=1:rotx\_12=0:rotx\_13=0:rotx\_14=0
rotx\_21=0:rotx\_22=Cos(-mdy):rotx\_23=Sin(-mdy):rotx\_24=0
rotx\_31=0:rotx\_32=-Sin(-mdy):rotx\_33=Cos(-mdy):rotx\_34=0
rotx\_41=0:rotx\_42=0:rotx\_43=0:rotx\_44=1
;matriz de rotación sobre eje y del mundo:
roty\_11=Cos(mdx):roty\_12=0:roty\_13=Sin(mdx):roty\_14=0
roty\_21=0:roty\_22=1:roty\_23=0:roty\_24=0
roty\_31=-Sin(mdx):roty\_32=0:roty\_33=Cos(mdx):roty\_34=0
roty\_41=0:roty\_42=0:roty\_43=0:roty\_44=1
;obtener matriz de rotación sobre eje, en el plano XY del mundo, que define el desplazamiento del raton:
Matriz4x4xMatriz4x4(@rotx,@roty,@rot1); o lo que es lo mismo: Matriz4x4xMatriz4x4(@roty,@rotx,@rot1)
MP_EntitySetMatrix(Object0,Matriz4x4xMatriz4x4(MP_EntityGetMatrix(Object0),@rot1,@rot))
Else; <- rotar el objeto sobre eje 'x' y 'y' relativo al ojo.
;Para rotar la entidad alrededor del eje, en el plano XY del ojo, que define el desplazamiento del raton.
;El tema está en que el raton se mueve en 2 dimensiones, es decir en el plano, entonces de la entrada del raton obtenemos:
;1. de su desplazamiento vertical un vector en dirección X, cuya amplitud y sentido nos indica el ángulo a rotar alrededor de ese eje X
;2. de su desplazamiento horizontal un vector en dirección Y, cuya amplitud y sentido nos indica el ángulo a rotar alrededor de ese eje Y
;Tenemos pues un vector definido por el movimiento del ratón.
;El ojo se puede mover en el espacio del mundo y apuntar la vista hacia cualquier parte,
;por lo que el plano frontal del ojo puede variar y no coincidir con el plano XY del mundo.
;Entonces el vector que obtenemos del movimiento del ratón ha de estar contenido en el plano frontal del ojo.
;Hay que disponer el vector (mdx,mdy,mdz) sobre el plano XY de la base de coordenadas del pivotcam (plano frontal del ojo), no del mundo.
;Para ello, el vector (0,mdx,0) hay que ponerlo sobre el eje Y del plano frontal de ojo
;y el vector (mdy,0,0) hay que ponerlo sobre el eje X del plano frontal de ojo:
;Tenemos en *rot la dirección del eje X, a través del vector X-> del plano frontal del ojo ( *rot\_11,*rot\_12,*rot\_13 )
;y la dirección del eje Y, a través del vector Y-> del plano frontal del ojo ( *rot\_21,*rot\_22,*rot\_23 )
;Por tanto procedemos a obtener ambos vectores unidad:
;el colineal al eje de abscisas en el plano frontal del ojo y el colineal al eje de ordenadas en este plano:
THETA.d=Sqr(mdx*mdx+mdy*mdy)
If THETA>0
ux_m.d=Sqr(*rot\_11**rot\_11+*rot\_12**rot\_12+*rot\_13**rot\_13)
If ux_m>0
;los cosenos directores de un vector cualquiera son las coordenadas escalares de ese mismo vector con módulo unidad, es decir,
;son las proyecciones de ese vector unitario sobre cada uno de los ejes principales
ux_x.d=*rot\_11/ux_m:ux_y.d=*rot\_12/ux_m:ux_z.d=*rot\_13/ux_m; <- son los cosenos directores
;ahora multiplicando este vector unitario, por el modulo de (mdy,0,0) obtenemos ya la componente X pero en el plano frontal del ojo:
ux_x*mdy:ux_y*mdy:ux_z*mdy
EndIf
;Hacemos lo mismo para obtener la componente Y del movimiento del ratón pero en el plano frontal del ojo
uy_m.d=Sqr(*rot\_21**rot\_21+*rot\_22**rot\_22+*rot\_23**rot\_23)
If uy_m>0
;los cosenos directores de un vector cualquiera son las coordenadas escalares de ese mismo vector con módulo unidad, es decir,
;son las proyecciones de ese vector unitario sobre cada uno de los ejes principales
uy_x.d=*rot\_21/uy_m:uy_y.d=*rot\_22/uy_m:uy_z.d=*rot\_23/uy_m; <- son los cosenos directores.
;ahora multiplicando este vector unitario, por el modulo de (0,mdx,0) obtenemos ya la componente X pero en el plano frontal del ojo:
uy_x*mdx:uy_y*mdx:uy_z*mdx
EndIf
;Para obtener el vector que define la recta alrededor de la cual ha de rotar el objeto, basta con sumar esas 2 componentes obtenidas,
;y dado que ambas componentes están contenidas en el plano frontal del ojo, la suma de ambas también lo estará:
u.Vector3D
u\x=ux_x.d+uy_x.d:u\y=ux_y.d+uy_y.d:u\z=ux_z.d+uy_z.d
If MP_KeyDown(#PB_Key_LeftShift)
Turn_Body_by_Angle_adding(@u.Vector3D,Object0.i); <- METODO 1
Else ; METODO 2:
;el módulo del vector original en el plano XY del mundo (THETA) es el mismo al vector rotado al plano XY frontal del ojo, así que: Sqr(u\x*u\x+u\y*u\y+u\z*u\z) = THETA
;Convertimos este vector en unitario:
u\x/THETA:u\y/THETA:u\z/THETA
MatrizRotacionaldeunAngulodadoalrededordeunejedefinidoporunvectorunidad(@u.Vector3D,Object0.i,THETA)
EndIf
EndIf
EndIf
MP_RenderWorld()
MP_Flip():Delay(8)
Wend
http://www.zeitgeistmovie.com
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
Re: MP3D Engine Alpha 32
I've no idea what is going on; but when I install the best I can get is for it to run for about 15 seconds and then it just crashes, any idea how I can get better information on how to inform you better on what is going on;
Tried on;
5.40 (64/32 Bit)
5.41 (64Bit - I would have tried the 32Bit version, but I lost my PureBasic archive for 5.41 (32bit) and it's not in the museum to re-download it only 5.40 is available)
5.42 (64/32 Bit)
Windows 10
Tried on;
5.40 (64/32 Bit)
5.41 (64Bit - I would have tried the 32Bit version, but I lost my PureBasic archive for 5.41 (32bit) and it's not in the museum to re-download it only 5.40 is available)
5.42 (64/32 Bit)
Windows 10
- Psychophanta
- Addict
- Posts: 4996
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Lípetsk, Russian Federation
- Contact:
Re: MP3D Engine Alpha 32
The package works fine in PB5.42 32bit, so I guess the problem is Win10. Please try on 8.1, 7, XP.
If you are having problems please bump it one more time and I post the good complete package.
By the way @Michael:
The current package of MP3D does not work in PB5.50!
If you are having problems please bump it one more time and I post the good complete package.
By the way @Michael:
The current package of MP3D does not work in PB5.50!
http://www.zeitgeistmovie.com
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
- Psychophanta
- Addict
- Posts: 4996
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Lípetsk, Russian Federation
- Contact:
Re: MP3D Engine Alpha 32
besides of it, there seems a problem with MP_CalcPitchYawRoll() function. This tip should do an entity orientation which makes it to remain in the current orientation, i.e., no change.Psychophanta wrote:By the way @Michael:
The current package of MP3D does not work in PB5.50!
But it doesn't work:
Code: Select all
MP_CalcPitchYawRoll(MP_EntityGetMatrix(Object0),@pointer.D3DXVECTOR3)
MP_RotateEntity(Object0,pointer\x,pointer\y,pointer\z)
Code: Select all
MP_RotateEntity(Object0,MP_EntityGetPitch(Object0,0),MP_EntityGetYaw(Object0,0),MP_EntityGetRoll(Object0,0))
-
- Enthusiast
- Posts: 494
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: MP3D Engine Alpha 32
Hi to all,
i dont had much time in the latest month but i will use more time in the next time for my baby mp3d. i hav different ideas and will talk about them in the next time...
I have actualised the lib to 5.50 see the first page. I am sorry i see some problems and will solve them end of august after my holliday. But most of the demos programs are working well.
Thanks Psychophanta i will look on you information soon, but in the morning im must fly to my holiday. I check this after them...
Greetings and have fun
Michael
i dont had much time in the latest month but i will use more time in the next time for my baby mp3d. i hav different ideas and will talk about them in the next time...
I have actualised the lib to 5.50 see the first page. I am sorry i see some problems and will solve them end of august after my holliday. But most of the demos programs are working well.
Thanks Psychophanta i will look on you information soon, but in the morning im must fly to my holiday. I check this after them...
Greetings and have fun
Michael
Working on - MP3D Library - PB 5.73 version ready for download
-
- User
- Posts: 59
- Joined: Mon Dec 24, 2012 9:07 am
- Location: Germany, Munich
Re: MP3D Engine Alpha 32
Hello Michael,
function MP_SoundSetEffect not working!
Do you planing add 3d sound functions or MP_SoundGetPan / MP_SoundGetVolume?
Danke für ihre bibliothek!
function MP_SoundSetEffect not working!
Do you planing add 3d sound functions or MP_SoundGetPan / MP_SoundGetVolume?
Danke für ihre bibliothek!
Sory my bad english