thats a great achievement Michael , and usable, i have only a few notes:
1- when we replace :
Code: Select all
MP_GetMeshData(sphere, #PB_Mesh_Vertex,@Vert(),vertexlenght * vertexcount)
with:
Code: Select all
MP_GetMeshData(sphere, #PB_Mesh_Vertex |#PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate,@Vert(),vertexlenght * vertexcount)
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
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
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
Code: Select all
For m = 0 To Triscount-1
MP_AddTriangle(testSphere,Tris(m)\v1,Tris(m)\v2,Tris(m)\v3)
Next
it display the same behaviour
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
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