MP3D Engine Alpha 33
-
- Enthusiast
- Posts: 497
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: MP3D Engine Alpha 32
Hi Psychophanta,
This is very cool and thanks for these function!
I have "repaired" the "MP_PickCamera" function. Now it works with different "viewport". I don't have published the new lib, because i am working on a Threadsafe and unicode lib of mp3d. The informations about these libs find you in my mp3d forum. If i have solved all the problems i got with the unicode function, i will published 4 versions: normal, unicode, Threadsafe and unicode & Threadsafe for PB 5.31
Greetings Michael
This is very cool and thanks for these function!
I have "repaired" the "MP_PickCamera" function. Now it works with different "viewport". I don't have published the new lib, because i am working on a Threadsafe and unicode lib of mp3d. The informations about these libs find you in my mp3d forum. If i have solved all the problems i got with the unicode function, i will published 4 versions: normal, unicode, Threadsafe and unicode & Threadsafe for PB 5.31
Greetings 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:
About MP_KeyUp() function:
Thanks Mich,
By the way, you forgot this:
About MP_KeyUp() function:

By the way, you forgot this:
About MP_KeyUp() function:
Psychophanta wrote:What is the reason to be for a function which is just the inverse of another existing one?, I mean, if you already have 'MP_KeyDown(key)' the user should use 'Not MP_KeyDown(key)' and not another different function for it, what do you think?
Apart of it, there is not an equivalent function for 'KeyboardReleased(Key)', and there is often useful.
mpz wrote:Hello,
@Psychophanta, yes 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

-
- Enthusiast
- Posts: 497
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: MP3D Engine Alpha 32
Hi Psychophanta,
i have killed the command MP_KeyUp() now.
The function MP_KeyHit(key) is the same like KeyboardReleased(Key)'
Greetings Michael
i have killed the command MP_KeyUp() now.
The function MP_KeyHit(key) is the same like KeyboardReleased(Key)'
Greetings 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
Thanks for answer.
Another issue, related with physics 3D:
When a floor is under any physic entity all the behaviour is good, like in the "Domino Day" example, but when program rotate or move the floor, the pieces onto it does not move with floor, is this normal?
Example to show it:
Another issue, related with physics 3D:
When a floor is under any physic entity all the behaviour is good, like in the "Domino Day" example, but when program rotate or move the floor, the pieces onto it does not move with floor, is this normal?
Example to show it:
Code: Select all
MP_Graphics3DWindow(0, 0, 1024, 768, "",0)
light0 = MP_CreateLight(1)
MP_PositionEntity(light0, 0, 128, 0)
cam0 = MP_CreateCamera()
MP_CameraSetRange(cam0, 2, 2024)
MP_PositionEntity(cam0, -10, 22, -60)
MP_EntityLookAt(cam0, 0, 0, 0)
MP_PhysicInit()
tex0 = MP_CreateTextureColor(128, 128, RGBA(0, 255, 0, 0))
MP_MaterialEmissiveColor(tex0, 0, 122, 132, 132)
bodenplatte = MP_CreateRectangle(15, 1, 15)
MP_ScaleMesh( bodenplatte ,0.6,0.6,0.6)
MP_EntitySetTexture(bodenplatte, tex0)
MP_EntityPhysicBody(bodenplatte, 1, 0)
Mesh = MP_CreateRectangle(1.5,3,0.4);,0.1)
MP_EntityPhysicBody(Mesh, 2, 20)
MP_MaterialDiffuseColor(Mesh,255,Random(255),Random(255),Random(255))
MP_PositionEntity(Mesh,0,1.6,0)
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow
MP_Turnentity(bodenplatte,0,1,0,0)
MP_PhysicUpdate()
MP_RenderWorld()
MP_Flip()
Wend
MP_PhysicEnd()
Re: MP3D Engine Alpha 32
Psychophanta, this is normal , the same with PB Ogre. this is because MP_Turnentity() turn the floor geometrically and not physically, yes the geometrical functions have some physical effects but not fully implemented.
to affect the cube resting over a plane we should apply force to the plane, here is an example : the circular plane have a hinge and we apply small force to rotate it, a cube with small weight rest over the plane and it will rotate with it
Edit:increase the force from -0.02 to -0.1 and we will see the centrifugal force effect over the cube
line 36: MP_EntityAddImpulse(Mesh, -0.1, 0, 0 , 0, 0, 1.7)
now rotate the plane with MP_Turnentity and the cube will not rotate with it:
to affect the cube resting over a plane we should apply force to the plane, here is an example : the circular plane have a hinge and we apply small force to rotate it, a cube with small weight rest over the plane and it will rotate with it
Edit:increase the force from -0.02 to -0.1 and we will see the centrifugal force effect over the cube
line 36: MP_EntityAddImpulse(Mesh, -0.1, 0, 0 , 0, 0, 1.7)
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, "tests")
camera = MP_CreateCamera() ; Kamera erstellen
MP_PositionEntity(camera, 3, 2, -3 )
MP_EntityLookAt(camera,0,0,0)
light= MP_CreateLight(2) ; Es werde Licht
MP_PositionEntity(light, -10, 10, 0)
MP_AmbientSetLight (RGB(0,100,200))
Mesh = MP_CreateCylinder(10,0.2)
MP_RotateMesh(Mesh , 90 , 0, 0)
MP_EntitySetNormals (Mesh)
MP_MaterialDiffuseColor (Mesh,255,255,255,50)
MP_MaterialSpecularColor (Mesh, 255, 255 ,255, 155,5)
box = MP_CreateRectangle(0.2,0.2,0.2)
MP_PositionEntity(box, 0.5, 0.5, 0 )
MP_PhysicInit()
MP_EntityPhysicBody(Mesh , 5, 10)
MP_ConstraintCreateHinge (Mesh,0,1,0)
MP_EntityPhysicBody(box, 2, 0.1)
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
MP_EntityAddImpulse(Mesh, -0.02, 0, 0 , 0, 0, 1.7)
MP_PhysicUpdate()
MP_RenderWorld() ; Erstelle die Welt
MP_Flip () ; Stelle Sie dar
Wend
MP_PhysicEnd()
now rotate the plane with MP_Turnentity and the cube will not rotate with it:
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, "tests")
camera = MP_CreateCamera() ; Kamera erstellen
MP_PositionEntity(camera, 3, 2, -3 )
MP_EntityLookAt(camera,0,0,0)
light= MP_CreateLight(2) ; Es werde Licht
MP_PositionEntity(light, -10, 10, 0)
MP_AmbientSetLight (RGB(0,100,200))
Mesh = MP_CreateCylinder(10,0.2)
MP_RotateMesh(Mesh , 90 , 0, 0)
MP_EntitySetNormals (Mesh)
MP_MaterialDiffuseColor (Mesh,255,255,255,50)
MP_MaterialSpecularColor (Mesh, 255, 255 ,255, 155,5)
box = MP_CreateRectangle(0.2,0.2,0.2)
MP_PositionEntity(box, 0.5, 0.5, 0 )
MP_PhysicInit()
MP_EntityPhysicBody(Mesh , 5, 0)
;MP_ConstraintCreateHinge (Mesh,0,1,0)
MP_EntityPhysicBody(box, 2, 0.1)
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
;MP_EntityAddImpulse(Mesh, -0.02, 0, 0 , 0, 0, 1.7)
MP_Turnentity(Mesh,0,1,0,0)
MP_PhysicUpdate()
MP_RenderWorld() ; Erstelle die Welt
MP_Flip () ; Stelle Sie dar
Wend
MP_PhysicEnd()
Last edited by applePi on Fri May 22, 2015 12:30 pm, edited 1 time in total.
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Re: MP3D Engine Alpha 32
Thank you Apllepi, that is useful to me now. 

-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: MP3D Engine Alpha 32
You are creating a rod for your own back there mpz! Perhaps the 'highest level', Unicode and Threadsafe, is all that's needed? What do you think Psychophanta, ApplePi?i will published 4 versions: normal, unicode, Threadsafe and unicode & Threadsafe for PB 5.31
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: MP3D Engine Alpha 32
not sure what Michael wants to do IdeasVacuum , but surely there are users who ask for special versions at http://www.morty-productions.de/gamedev/ . of course the unicode version is a must.
i have added a remark to my example above (the first one)
i have added a remark to my example above (the first one)
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Re: MP3D Engine Alpha 32
At the moment personally don't need unicode nor thread , but anyway, it would be good.
-
- Enthusiast
- Posts: 497
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: MP3D Engine Alpha 32
Hi,
now it is possible for me to compile the lib in ASCII, unicode an Threadsafe mode. I think unicode is important for the future of this lib.
So it is easier to make a new working lib if the LTS cicle will end and a new PB version will come:
"So we decided to remove the ability to compile in ascii mode in the PB version that follows after the next LTS version"
http://www.purebasic.fr/english/viewtop ... 14&t=60214
P.S: I make my first steps in DX11 programming and test it to make a mp3d command compatible version of it. DX 11 shader are great...
Greetings Michael
now it is possible for me to compile the lib in ASCII, unicode an Threadsafe mode. I think unicode is important for the future of this lib.
So it is easier to make a new working lib if the LTS cicle will end and a new PB version will come:
"So we decided to remove the ability to compile in ascii mode in the PB version that follows after the next LTS version"
http://www.purebasic.fr/english/viewtop ... 14&t=60214
P.S: I make my first steps in DX11 programming and test it to make a mp3d command compatible version of it. DX 11 shader are great...
Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
Re: MP3D Engine Alpha 32
how to use the MP_GetMeshData with #PB_Mesh_Face ??
the following are using MP_GetMeshData with #PB_Mesh_Vertex
we check the sphere vertices\Y which are < 0 and and make them = 0 so i get a dome. its ground in reality was the sphere bottom .
but what is needed is to remove the sphere bottom to get a real half sphere
my partial code below show the dome
the following code depends on Michael example posted here: http://forums.purebasic.com/english/vie ... 55#p430641
what is needed is like this in PB Ogre, note we use Global Dim MeshDataInd.PB_MeshFace(0) here, and we rebuild the faces like this:
may be like this approximately in MP3D:
MP_AddTriangle(halfSphere, Indx(i)\Index, Indx(i+1)\Index,Indx(i+2)\Index)
the following are using MP_GetMeshData with #PB_Mesh_Vertex
we check the sphere vertices\Y which are < 0 and and make them = 0 so i get a dome. its ground in reality was the sphere bottom .
but what is needed is to remove the sphere bottom to get a real half sphere
my partial code below show the dome
the following code depends on Michael example posted here: http://forums.purebasic.com/english/vie ... 55#p430641
Code: Select all
Structure bgraCol
b.b
g.b
r.b
a.b
EndStructure
Structure MyVertex
x.f : y.f : z.f ; vertices coordinates
nx.f : ny.f : nz.f ; normal coordinates
Color.bgraCol ; color
u.f : v.f ; texture coordinates
; u1.f : v1.f ; texture coordinates 2
; u2.f : v2.f ; texture coordinates 2
EndStructure
MP_Graphics3D (640, 480, 0, 3)
SetWindowTitle(0, "..not complete Half Sphere .. ")
camera = MP_CreateCamera() ; Kamera erstellen
light0 = MP_CreateLight(1)
MP_PositionEntity(light0, 0, 128, 0)
cam0 = MP_CreateCamera()
MP_PositionEntity(cam0, 0, 3, -4)
MP_EntityLookAt(cam0, 0, 1, 0)
tex0 = MP_CreateTextureColor(128, 128, RGBA(0, 255, 0, 0))
MP_MaterialEmissiveColor(tex0, 0, 122, 132, 132)
tex1 = MP_CreateTextureColor(128, 128, RGBA(25, 255, 255, 0))
MP_MaterialEmissiveColor(tex1, 0, 122, 132, 132)
sphere = MP_CreateSphere(16)
MP_PositionEntity (sphere, 0, 1, 0)
vertexcount = MP_CountVertices(sphere)
vertexlenght = MP_GetMeshInfo (sphere, 64)
Dim Vert.MyVertex (vertexcount)
MP_GetMeshData(sphere, #PB_Mesh_Vertex,@Vert(),vertexlenght * vertexcount)
ground = MP_CreateRectangle(5, 0.5, 5)
MP_EntitySetTexture(ground, tex0)
For n = 0 To vertexcount-1
If Vert(n)\y < 0
Vert(n)\y = 0
EndIf
Next
MP_SetMeshData (sphere, #PB_Mesh_Vertex |#PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate , @Vert(), vertexcount)
mp_wireframe(1)
MP_EntitySetTexture(sphere, tex1)
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
MP_TurnEntity (sphere, 0, 0.4, 0)
MP_RenderWorld() ; Erstelle die Welt
MP_Flip () ; Stelle Sie dar
Wend
End
Code: Select all
For i=0 To ArrSizeInd Step 3
MeshFace(MeshDataInd(i)\Index, MeshDataInd(i+1)\Index,MeshDataInd(i+2)\Index)
Next
MP_AddTriangle(halfSphere, Indx(i)\Index, Indx(i+1)\Index,Indx(i+2)\Index)
Code: Select all
IncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb"
#CameraSpeed = 0.1
#Nb = 50 ; number of sphere Segments and Rings
#Radius = 4
#TempSphere = 30
Global Dim MeshData.PB_MeshVertex(0)
Global Dim MeshDataInd.PB_MeshFace(0)
Global flag=0
Declare HalfSphere()
Define.f KeyX, KeyY, MouseX, MouseY
InitEngine3D()
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Scripts",#PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Packs/desert.zip", #PB_3DArchive_Zip)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops()
OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), "press W for wireframe/ SolidFrame ,____ move by keyboard and mouse", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0), DesktopHeight(0)-10, 0, 0, 0)
;Materials
CreateMaterial(0, LoadTexture(0, "ground_diffuse.png"))
GetScriptMaterial(1, "SphereMap/SphereMappedRustySteel")
CreateMaterial(2, LoadTexture(2, "Dirt.jpg"))
GetScriptMaterial(3, "Scene/GroundBlend")
CreateMaterial(5, LoadTexture(5, "snow_1024.jpg"))
MaterialCullingMode(5, #PB_Material_NoCulling )
; Ground
CreatePlane(3, 200, 200, 5, 5, 5, 5)
CreateEntity(3,MeshID(3),MaterialID(5), 0, 0, 0)
EntityPhysicBody(3, #PB_Entity_BoxBody, 0, 1, 1)
; Camera
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 10, -10, #PB_Absolute)
CameraLookAt(0, 0,3,0)
CameraBackColor(0, RGB(224,225,241))
CreateLight(0, RGB(255, 255, 255), 200, 300, 0)
AmbientColor(RGB(255, 255, 255))
CreateMaterial(4, LoadTexture(4, "ValetCoeur.jpg"))
MaterialCullingMode(4, #PB_Material_NoCulling )
MaterialShadingMode(4, #PB_Material_Wireframe)
HalfSphere()
FinishMesh(1)
CreateEntity(7, MeshID(7), MaterialID(4), 0,3,0)
wireFrame = 0
Repeat
Screen3DEvents()
If ExamineMouse()
MouseX = -MouseDeltaX() * #CameraSpeed * 0.3
MouseY = -MouseDeltaY() * #CameraSpeed * 0.3
EndIf
If ExamineKeyboard()
If KeyboardReleased(#PB_Key_W)
If wireFrame
MaterialShadingMode(4, #PB_Material_Wireframe)
wireFrame ! 1
Else
MaterialShadingMode(4, #PB_Material_Solid)
wireFrame ! 1
EndIf
EndIf
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
MoveCamera (0, KeyX, 0, KeyY)
RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
RotateEntity(7, 0,0.2,0, #PB_Relative)
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
End
Procedure HalfSphere()
CreateMesh(7, #PB_Mesh_TriangleList, #PB_Mesh_Dynamic)
CreateSphere(#TempSphere,#Radius, #Nb, #Nb)
GetMeshData(#TempSphere,0, MeshData(), #PB_Mesh_Vertex | #PB_Mesh_Normal | #PB_Mesh_UVCoordinate , 0, MeshVertexCount(#TempSphere)-1)
GetMeshData(#TempSphere,0, MeshDataInd(), #PB_Mesh_Face, 0, MeshIndexCount(#TempSphere, 0)-1)
ArrSize = ArraySize(MeshData())
For c=0 To ArrSize
x.f = MeshData(c)\x
y.f = MeshData(c)\y
z.f = MeshData(c)\z
If y >= 0 ; to discard the sphere bottom in which the MeshData(c)\y < 0
MeshVertexPosition(x,y,z)
MeshVertexTextureCoordinate(MeshData(c)\u, MeshData(c)\v)
MeshVertexNormal(MeshData(c)\NormalX, MeshData(c)\NormalY, MeshData(c)\NormalZ)
EndIf
Next
ArrSizeInd = ArraySize(MeshDataInd())/2-((#Nb*6)+6) ; every square = 2 triangles = 6 vertexes
For i=0 To ArrSizeInd Step 3
MeshFace(MeshDataInd(i)\Index, MeshDataInd(i+1)\Index,MeshDataInd(i+2)\Index)
;Debug Str(MeshDataInd(i)\Index)+" "+Str(MeshDataInd(i+1)\Index)+" " +Str(MeshDataInd(i+2)\Index)
Next
EndProcedure
-
- Enthusiast
- Posts: 497
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: MP3D Engine Alpha 32
Hello to all,
@applePi, thanks for you good samples
how to use the MP_GetMeshData with #PB_Mesh_Face ??
the following are using MP_GetMeshData with #PB_Mesh_Vertex
Oh i have made this command, but i have not testet it. So i found some bugs and solved them.
I have made a new testlib for PB 5.22/5.24/5.31 (x86) to check these commands:
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip
MP_GetMeshData(sphere, #PB_Mesh_Face,@Tris(),Triscount*12)
and
MP_SetMeshData (sphere, #PB_Mesh_Face , @Tris(), Triscount)
if needed i can also make a command: MP_SubTriangle and MP_SubVertex too...
Greetings Michael
@applePi, thanks for you good samples

how to use the MP_GetMeshData with #PB_Mesh_Face ??
the following are using MP_GetMeshData with #PB_Mesh_Vertex
Oh i have made this command, but i have not testet it. So i found some bugs and solved them.
I have made a new testlib for PB 5.22/5.24/5.31 (x86) to check these commands:
http://www.flasharts.de/mpz/mp33_beta/d ... ibrary.zip
MP_GetMeshData(sphere, #PB_Mesh_Face,@Tris(),Triscount*12)
and
MP_SetMeshData (sphere, #PB_Mesh_Face , @Tris(), Triscount)
if needed i can also make a command: MP_SubTriangle and MP_SubVertex too...
Code: Select all
Structure bgraCol
b.b
g.b
r.b
a.b
EndStructure
Structure MyVertex_
x.f : y.f : z.f ; vertices coordinates
nx.f : ny.f : nz.f ; normal coordinates
Color.bgraCol ; color
u.f : v.f ; texture coordinates
; u1.f : v1.f ; texture coordinates 2
; u2.f : v2.f ; texture coordinates 2
EndStructure
Structure MyTris
v1.l : v2.l : v3.l ; vertices coordinates
EndStructure
MP_Graphics3D (640, 480, 0, 3)
SetWindowTitle(0, "..not complete Half Sphere .. ")
camera = MP_CreateCamera() ; Kamera erstellen
light0 = MP_CreateLight(1)
MP_PositionEntity(light0, 0, 128, 0)
cam0 = MP_CreateCamera()
MP_PositionEntity(cam0, 0, 3, -4)
MP_EntityLookAt(cam0, 0, 1, 0)
tex0 = MP_CreateTextureColor(128, 128, RGBA(0, 255, 0, 0))
MP_MaterialEmissiveColor(tex0, 0, 122, 132, 132)
tex1 = MP_CreateTextureColor(128, 128, RGBA(25, 255, 255, 0))
MP_MaterialEmissiveColor(tex1, 0, 122, 132, 132)
sphere = MP_CreateSphere(16)
MP_PositionEntity (sphere, 0, 1, 0)
vertexcount = MP_CountVertices(sphere)
vertexlenght = MP_GetMeshInfo (sphere, 64)
Triscount = MP_CountTriangles(sphere)
Dim Vert.MyVertex_ (vertexcount)
Dim Tris.MyTris (Triscount)
MP_GetMeshData(sphere, #PB_Mesh_Vertex,@Vert(),vertexlenght * vertexcount)
MP_GetMeshData(sphere, #PB_Mesh_Face,@Tris(),Triscount*12)
ground = MP_CreateRectangle(5, 0.5, 5)
MP_EntitySetTexture(ground, tex0)
; To look in the Tris
; For m = 0 To Triscount-1
; Debug "Tris = "+Str(m)
; Debug Tris(m)\v1
; Debug Tris(m)\v2
; Debug Tris(m)\v3
; Next
For n = 0 To vertexcount-1
If Vert(n)\y < 0
For m = 0 To Triscount-1
If Tris(m)\v1 = n : Tris(m)\v1 = 0 : Tris(m)\v2 = 0: Tris(m)\v3 = 0 : EndIf
If Tris(m)\v2 = n : Tris(m)\v1 = 0 : Tris(m)\v2 = 0: Tris(m)\v3 = 0 : EndIf
If Tris(m)\v3 = n : Tris(m)\v1 = 0 : Tris(m)\v2 = 0: Tris(m)\v3 = 0 : EndIf
Next
EndIf
Next
MP_SetMeshData (sphere, #PB_Mesh_Vertex |#PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate , @Vert(), vertexcount)
MP_SetMeshData (sphere, #PB_Mesh_Face , @Tris(), Triscount)
mp_wireframe(1)
MP_EntitySetTexture(sphere, tex1)
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
MP_TurnEntity (sphere, 0, 0.4, 0)
MP_RenderWorld() ; Erstelle die Welt
MP_Flip () ; Stelle Sie dar
Wend
End
Working on - MP3D Library - PB 5.73 version ready for download
Re: MP3D Engine Alpha 32
thats a great achievement Michael , and usable, i have only a few notes:
1- when we replace :
with:
it seems the objects destroyed, but if we keep the first one before the second one it will work (lines 47-48) but not the vice versa
2- when we give the half sphere physics type 5 (for dynamic concave geometry) then dropping a cube inside it will float as if the half sphere still have a ground, but it will go on if the half sphere have physics of type 1 (static)
3- it appears that the number of triangles stay the same before and after the operations.
4- i have made a copy of the sphere
it display the same behaviour
regarding the MP_SubTriangle and MP_SubVertex , every addition to the mesh functions will be great, i imagine it is may be like addSubMesh in PB ogre !! but not sure . but take your full time, we are not hurry
on the other hand : are there friction property for the joints in newton engine ??
such as: MP_ConstraintCreateHinge(sphere,0,1,0) and under a small force will rotate the sphere very rapidly unless we put some weight over it to make it rotate in regular speed.
thanks
1- when we replace :
Code: Select all
MP_GetMeshData(sphere, #PB_Mesh_Vertex,@Vert(),vertexlenght * vertexcount)
Code: Select all
MP_GetMeshData(sphere, #PB_Mesh_Vertex |#PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate,@Vert(),vertexlenght * vertexcount)
Code: Select all
Structure bgraCol
b.b
g.b
r.b
a.b
EndStructure
Structure MyVertex_
x.f : y.f : z.f ; vertices coordinates
nx.f : ny.f : nz.f ; normal coordinates
Color.bgraCol ; color
u.f : v.f ; texture coordinates
; u1.f : v1.f ; texture coordinates 2
; u2.f : v2.f ; texture coordinates 2
EndStructure
;#PB_Mesh_Vertex |#PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate
Structure MyTris
v1.l : v2.l : v3.l ; vertices coordinates
EndStructure
MP_Graphics3D (640, 480, 0, 3)
SetWindowTitle(0, "..not complete Half Sphere .. ")
camera = MP_CreateCamera() ; Kamera erstellen
light0 = MP_CreateLight(1)
MP_PositionEntity(light0, 0, 128, 0)
cam0 = MP_CreateCamera()
MP_PositionEntity(cam0, 0, 3, -3)
MP_EntityLookAt(cam0, 0, 1, 0)
tex0 = MP_CreateTextureColor(128, 128, RGBA(0, 255, 0, 0))
MP_MaterialEmissiveColor(tex0, 0, 122, 132, 132)
tex1 = MP_CreateTextureColor(128, 128, RGBA(25, 15, 255, 250))
MP_MaterialEmissiveColor(tex1, 0, 122, 132, 132)
sphere = MP_CreateSphere(16)
MP_PositionEntity (sphere, 0, 1, 0)
vertexcount = MP_CountVertices(sphere)
vertexlenght = MP_GetMeshInfo (sphere, 64)
Triscount = MP_CountTriangles(sphere)
Dim Vert.MyVertex_ (vertexcount)
Dim Tris.MyTris (Triscount)
MP_GetMeshData(sphere, #PB_Mesh_Vertex,@Vert(),vertexlenght * vertexcount)
;MP_GetMeshData(sphere, #PB_Mesh_Vertex |#PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate,@Vert(),vertexlenght * vertexcount)
MP_GetMeshData(sphere, #PB_Mesh_Face,@Tris(),Triscount*12)
ground = MP_CreateRectangle(5, 0.5, 5)
MP_EntitySetTexture(ground, tex0)
; To look in the Tris
; For m = 0 To Triscount-1
; Debug "Tris = "+Str(m)
; Debug Tris(m)\v1
; Debug Tris(m)\v2
; Debug Tris(m)\v3
; Next
For n = 0 To vertexcount-1
If Vert(n)\y < 0
For m = 0 To Triscount-1
If Tris(m)\v1 = n : Tris(m)\v1 = 0 : Tris(m)\v2 = 0: Tris(m)\v3 = 0 : EndIf
If Tris(m)\v2 = n : Tris(m)\v1 = 0 : Tris(m)\v2 = 0: Tris(m)\v3 = 0 : EndIf
If Tris(m)\v3 = n : Tris(m)\v1 = 0 : Tris(m)\v2 = 0: Tris(m)\v3 = 0 : EndIf
Next
EndIf
Next
MP_SetMeshData (sphere, #PB_Mesh_Vertex |#PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate , @Vert(), vertexcount)
MP_SetMeshData (sphere, #PB_Mesh_Face , @Tris(), Triscount)
MP_PositionEntity (sphere, 0, 1.5, 0)
MP_RotateEntity(sphere, 0,0,180)
texture = MP_LoadTexture(#PB_Compiler_Home + "Examples\3D\Data\Textures\MRAMOR6X6.jpg")
MP_EntitySetTexture(sphere, texture)
box = MP_CreateRectangle(0.2,0.2,0.2)
MP_EntitySetTexture(box, tex1)
MP_PositionEntity(box, 0.0, 2.0, 0 )
MP_PhysicInit()
MP_EntityPhysicBody(sphere , 5, 20)
MP_ConstraintCreateHinge(sphere,0,1,0)
MP_EntityPhysicBody(box, 2, 0.5)
MP_EntityPhysicBody(ground, 1, 1)
;mp_wireframe(1)
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
MP_EntityAddImpulse(sphere, -0.6, 0, 0 , 0, 0, 2.0)
;MP_TurnEntity (sphere, 0, 0.4, 0)
MP_PhysicUpdate()
MP_RenderWorld() ; Erstelle die Welt
MP_Flip () ; Stelle Sie dar
Wend
End
3- it appears that the number of triangles stay the same before and after the operations.
4- i have made a copy of the sphere
Code: Select all
For m = 0 To Triscount-1
MP_AddTriangle(testSphere,Tris(m)\v1,Tris(m)\v2,Tris(m)\v3)
Next
Code: Select all
Structure bgraCol
b.b
g.b
r.b
a.b
EndStructure
Structure MyVertex_
x.f : y.f : z.f ; vertices coordinates
nx.f : ny.f : nz.f ; normal coordinates
Color.bgraCol ; color
u.f : v.f ; texture coordinates
; u1.f : v1.f ; texture coordinates 2
; u2.f : v2.f ; texture coordinates 2
EndStructure
Structure MyTris
v1.l : v2.l : v3.l ; vertices coordinates
EndStructure
MP_Graphics3D (640, 480, 0, 3)
SetWindowTitle(0, "..not complete Half Sphere .. ")
camera = MP_CreateCamera() ; Kamera erstellen
light0 = MP_CreateLight(1)
MP_PositionEntity(light0, 0, 128, 0)
cam0 = MP_CreateCamera()
MP_PositionEntity(cam0, 0, 3, -3)
MP_EntityLookAt(cam0, 0, 1, 0)
tex0 = MP_CreateTextureColor(128, 128, RGBA(0, 255, 0, 0))
MP_MaterialEmissiveColor(tex0, 0, 122, 132, 132)
tex1 = MP_CreateTextureColor(128, 128, RGBA(25, 15, 255, 250))
MP_MaterialEmissiveColor(tex1, 0, 122, 132, 132)
sphere = MP_CreateSphere(16)
Triscount = MP_CountTriangles(sphere)
Debug "triangle counts before the operations over the sphere= "+ Str(Triscount)
MP_PositionEntity (sphere, 0, 1, 0)
vertexcount = MP_CountVertices(sphere)
vertexlenght = MP_GetMeshInfo (sphere, 64)
Triscount = MP_CountTriangles(sphere)
Dim Vert.MyVertex_ (vertexcount)
Dim Tris.MyTris (Triscount)
MP_GetMeshData(sphere, #PB_Mesh_Vertex,@Vert(),vertexlenght * vertexcount)
MP_GetMeshData(sphere, #PB_Mesh_Vertex |#PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate ,@Vert(),vertexlenght * vertexcount)
MP_GetMeshData(sphere, #PB_Mesh_Face,@Tris(),Triscount*12)
;ground = MP_CreateRectangle(5, 0.5, 5)
;MP_EntitySetTexture(ground, tex0)
testSphere = MP_CreateMesh()
; To look in the Tris
;For m = 0 To Triscount-1
; Debug "Tris = "+Str(m)
;Debug Tris(m)\v1
;Debug Tris(m)\v2
;Debug Tris(m)\v3
; Next
For n = 0 To vertexcount-1
MP_AddVertex(testSphere, Vert(n)\x,Vert(n)\y, Vert(n)\z, vert(n)\Color, Vert(n)\u, Vert(n)\v, vert(n)\nx, vert(n)\ny, vert(n)\nz)
;MP_AddVertex(testSphere, Vert(n)\x,Vert(n)\y, Vert(n)\z)
If Vert(n)\y < 0
For m = 0 To Triscount-1
If Tris(m)\v1 = n : Tris(m)\v1 = 0 : Tris(m)\v2 = 0: Tris(m)\v3 = 0 :EndIf
If Tris(m)\v2 = n : Tris(m)\v1 = 0 : Tris(m)\v2 = 0: Tris(m)\v3 = 0 :EndIf
If Tris(m)\v3 = n : Tris(m)\v1 = 0 : Tris(m)\v2 = 0: Tris(m)\v3 = 0 :EndIf
Next
EndIf
Next
For m = 0 To Triscount-1
MP_AddTriangle(testSphere,Tris(m)\v1,Tris(m)\v2,Tris(m)\v3)
Next
MP_PositionEntity (testSphere, 0, 0, 0)
MP_EntitySetTexture(testSphere, tex0)
MP_RotateEntity(testSphere, 0,0,180)
;Tr = MP_CountTriangles(testSphere)
;Debug Tr
MP_SetMeshData (sphere, #PB_Mesh_Vertex |#PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate , @Vert(), vertexcount)
MP_SetMeshData (sphere, #PB_Mesh_Face , @Tris(), Triscount)
MP_PositionEntity (sphere, 0, 2.0, 0)
MP_RotateEntity(sphere, 0,0,180)
MP_PositionEntity (testSphere, 0, 0.5, 0)
texture = MP_LoadTexture(#PB_Compiler_Home + "Examples\3D\Data\Textures\MRAMOR6X6.jpg")
MP_EntitySetTexture(sphere, texture)
MP_EntitySetTexture(testSphere, texture)
box = MP_CreateRectangle(0.2,0.2,0.2)
MP_EntitySetTexture(box, tex1)
MP_PositionEntity(box, 0.0, 2.0, 0 )
box2 = MP_CreateRectangle(0.2,0.2,0.2)
MP_EntitySetTexture(box2, tex0)
MP_PositionEntity(box2, 0.0, 1.0, 0 )
MP_PhysicInit()
MP_EntityPhysicBody(sphere , 5, 20)
MP_EntityPhysicBody(testSphere , 5, 20)
MP_ConstraintCreateHinge(sphere,0,1,0)
MP_ConstraintCreateHinge(testSphere,0,1,0)
MP_EntityPhysicBody(box, 2, 0.5)
MP_EntityPhysicBody(box2, 2, 0.5)
;MP_EntityPhysicBody(ground, 1, 1)
Triscount = MP_CountTriangles(sphere)
Debug "count after the operations = " +Str(Triscount)
Triscount = MP_CountTriangles(testSphere)
Debug "count of the copy at the screen bottom= "+Str(Triscount)
;mp_wireframe(1)
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
MP_EntityAddImpulse(Sphere, 0.6, 0, 0 , 0, 0, 2.0)
MP_EntityAddImpulse(testSphere, -0.6, 0, 0 , 0, 0, 2.0)
;MP_TurnEntity (sphere, 0, 0.4, 0)
MP_PhysicUpdate()
MP_RenderWorld() ; Erstelle die Welt
MP_Flip () ; Stelle Sie dar
Wend
End
on the other hand : are there friction property for the joints in newton engine ??
such as: MP_ConstraintCreateHinge(sphere,0,1,0) and under a small force will rotate the sphere very rapidly unless we put some weight over it to make it rotate in regular speed.
thanks
Re: MP3D Engine Alpha 32
Hi Michael, i have found that the floating cube over a hollow half sphere are not a special problem so no need to waste time for it, since the same phenomena happened with a hollow cup model with physics type 5, while when we give the model a physics type 1 the cube fall inside the cup and stay there. here is the cup2.x file
http://www.2shared.com/file/4IkCeNzW/cup2.html (click on the smaller download button and not the big one))
change physics type to 1 in line 79 to allow the cube to go inside the cup. the cup are downloaded from https://directxtk.codeplex.com/wikipage ... 0a%20model as obj file and converted it to dirctx (JT) x file using milkshape
as we know the physics type 5 works okay as demonstrated in the pendulum example, and in Gears demos, and now i am trying to simulate geneva drive device.
http://www.2shared.com/file/4IkCeNzW/cup2.html (click on the smaller download button and not the big one))
change physics type to 1 in line 79 to allow the cube to go inside the cup. the cup are downloaded from https://directxtk.codeplex.com/wikipage ... 0a%20model as obj file and converted it to dirctx (JT) x file using milkshape
Code: Select all
Structure bgraCol
b.b
g.b
r.b
a.b
EndStructure
Structure MyVertex_
x.f : y.f : z.f ; vertices coordinates
nx.f : ny.f : nz.f ; normal coordinates
Color.bgraCol ; color
u.f : v.f ; texture coordinates
; u1.f : v1.f ; texture coordinates 2
; u2.f : v2.f ; texture coordinates 2
EndStructure
;#PB_Mesh_Vertex |#PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate
Structure MyTris
v1.l : v2.l : v3.l ; vertices coordinates
EndStructure
MP_Graphics3D (640, 480, 0, 3)
SetWindowTitle(0, "..not complete Half Sphere .. ")
camera = MP_CreateCamera() ; Kamera erstellen
light0 = MP_CreateLight(1)
MP_PositionEntity(light0, 0, 128, 0)
cam0 = MP_CreateCamera()
MP_PositionEntity(cam0, 0, 3, -3)
MP_EntityLookAt(cam0, 0, 1, 0)
tex0 = MP_CreateTextureColor(128, 128, RGBA(0, 255, 0, 0))
MP_MaterialEmissiveColor(tex0, 0, 122, 132, 132)
tex1 = MP_CreateTextureColor(128, 128, RGBA(25, 15, 255, 250))
MP_MaterialEmissiveColor(tex1, 0, 122, 132, 132)
;sphere = MP_CreateSphere(16)
sphere = MP_LoadMesh("cup2.x")
MP_ResizeMesh(sphere,1.5,1.3,1.5)
MP_PositionEntity (sphere, 0, 1, 0)
vertexcount = MP_CountVertices(sphere)
vertexlenght = MP_GetMeshInfo (sphere, 64)
Triscount = MP_CountTriangles(sphere)
Dim Vert.MyVertex_ (vertexcount)
Dim Tris.MyTris (Triscount)
MP_GetMeshData(sphere, #PB_Mesh_Vertex,@Vert(),vertexlenght * vertexcount)
;MP_GetMeshData(sphere, #PB_Mesh_Vertex |#PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate,@Vert(),vertexlenght * vertexcount)
MP_GetMeshData(sphere, #PB_Mesh_Face,@Tris(),Triscount*12)
;ground = MP_CreateRectangle(5, 0.5, 5)
;MP_EntitySetTexture(ground, tex0)
; To look in the Tris
; For m = 0 To Triscount-1
; Debug "Tris = "+Str(m)
; Debug Tris(m)\v1
; Debug Tris(m)\v2
; Debug Tris(m)\v3
; Next
MP_PositionEntity (sphere, 0, 1.0, 0)
;MP_RotateEntity(sphere, 0,0,180)
texture = MP_LoadTexture(#PB_Compiler_Home + "Examples\3D\Data\Textures\MRAMOR6X6.jpg")
MP_EntitySetTexture(sphere, texture)
box = MP_CreateRectangle(0.3,0.3,0.3)
MP_EntitySetTexture(box, tex1)
MP_PositionEntity(box, 0.0, 2.0, 0 )
MP_PhysicInit()
MP_EntityPhysicBody(sphere , 5, 20)
;MP_ChangePhysicHull(sphere,1)
MP_ConstraintCreateHinge(sphere,0,1,0)
MP_EntityPhysicBody(box, 5, 0.1)
;MP_EntityPhysicBody(ground, 1, 1)
mp_wireframe(1)
While Not MP_KeyDown(#PB_Key_Escape) And Not WindowEvent() = #PB_Event_CloseWindow; Esc abfrage oder Windows Schliessen
MP_EntityAddImpulse(sphere, -0.6, 0, 0 , 0, 0, 2.0)
;MP_TurnEntity (sphere, 0, 0.4, 0)
MP_PhysicUpdate()
MP_RenderWorld() ; Erstelle die Welt
MP_Flip () ; Stelle Sie dar
Wend
End
-
- Enthusiast
- Posts: 497
- Joined: Sat Oct 11, 2008 9:07 pm
- Location: Germany, Berlin > member German forum
Re: MP3D Engine Alpha 32
Hi Applepi,
Thanks for the information. I could not found a bug in my program, but it makes only a hull and not this kind of special object. I will ask in the newton dynamics forum about this problem. I hope they can help ...
Question: Is it possible to make these kind of Physical object in PB -Ogre ? Or has Ogre only a hull version?
Greetings Michael
Thanks for the information. I could not found a bug in my program, but it makes only a hull and not this kind of special object. I will ask in the newton dynamics forum about this problem. I hope they can help ...
Question: Is it possible to make these kind of Physical object in PB -Ogre ? Or has Ogre only a hull version?
Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download