here is the add mesh approach as in the link above, gives exactly the same shape above. but we need to attach the u/v in a different way for the sides. or we can use a modeling software to paint the sides after saving the mesh and exporting it to another format
Code: Select all
Enumeration
#LIGHT
#CAMERA
#mainwin
#Plane
#sphere
EndEnumeration
#cameraSpeed = 0.2
Define.f KeyX, KeyY, MouseX, MouseY
Global Dim MeshData.PB_MeshVertex(0)
Global Dim MeshDataInd.PB_MeshFace(0)
Define.f KeyX, KeyY
Declare CreateMatrix()
InitEngine3D()
InitMouse()
InitKeyboard()
InitSprite()
ExamineDesktops()
OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), "arrow keys+mouse: move/rotate camera.... X/Z rotate object", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0), DesktopHeight(0), 0, 0, 0)
Add3DArchive(".",#PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home+"Examples\3D\Data\Textures\",#PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home+"Examples\3D\Data\GUI",#PB_3DArchive_FileSystem)
Parse3DScripts()
CreateLight(0,RGB(255, 255, 95),-50,50,100)
;;============================================
OpenWindow3D(0,0,0,300,120,"Engine Stats")
TextGadget3D(0,2,0,300,30,"")
TextGadget3D(1,2,0,300,60,"")
ShowGUI(255,0)
;=============================================
CreateMaterial(0, LoadTexture(0, "White.jpg"))
DisableMaterialLighting(0, #True)
MaterialShadingMode(0, #PB_Material_Wireframe )
MaterialCullingMode(0, #PB_Material_NoCulling)
CreateCamera(#camera, 0, 0, 100, 100)
MoveCamera(#camera, 0, 0, 7, #PB_Absolute)
CameraFOV(#camera, 70)
CameraBackColor(#camera, RGB(255,200,200))
CameraLookAt(#camera,0,-5,0)
CreateLight(0, RGB(255,255,255), 40, 20, 0)
AmbientColor(RGB(200, 200, 200))
CreateMaterial(3, LoadTexture(3, "snow_1024.jpg"))
DisableMaterialLighting(3, #False)
SetMaterialColor(3, #PB_Material_AmbientColor, RGB(250, 255, 0))
SetMaterialColor(3, #PB_Material_SpecularColor, RGB(255, 255, 0))
CreateMaterial(1, LoadTexture(1, "ValetCoeur.jpg"))
MaterialCullingMode(1, #PB_Material_NoCulling)
DisableMaterialLighting(1, #False)
CreateMaterial(2, LoadTexture(2, "RustySteel.jpg"))
MaterialCullingMode(2, #PB_Material_NoCulling)
CreateMaterial(4, LoadTexture(4, "ground_diffuse.png"))
MaterialCullingMode(4, #PB_Material_NoCulling)
CreateMaterial(5, LoadTexture(5, "Geebee2.bmp"))
MaterialCullingMode(5, #PB_Material_NoCulling)
CreateMatrix()
WorldGravity(-9)
CreateSphere(#sphere, 0.2)
CreateEntity(#sphere, MeshID(#sphere), MaterialID(1))
EntityPhysicBody(#sphere, #PB_Entity_SphereBody, 1,3,0.2)
WorldShadows(#PB_Shadow_Additive)
Repeat
Event = WindowEvent()
If ExamineMouse()
MouseX = -MouseDeltaX()/20
MouseY = -MouseDeltaY()/20
EndIf
If ExamineKeyboard()
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
If KeyboardPushed(#PB_Key_Z)
DisableEntityBody(#sphere, #False)
ApplyEntityImpulse(#sphere, 0, 0, 0 )
RotateEntity(0,0,0,0.5, #PB_Relative)
ElseIf KeyboardPushed(#PB_Key_X)
DisableEntityBody(#sphere, #False)
ApplyEntityImpulse(#sphere, 0, 0, 0 )
RotateEntity(0,0,0,-0.5, #PB_Relative)
EndIf
If KeyboardPushed(#PB_Key_S)
SaveMesh(0, "Compound.mesh")
EndIf
EndIf
rot.f+0.6
RotateEntity(0, 0.0,0.5,0.0,#PB_Relative)
RotateCamera(#Camera, MouseY, MouseX, 0, #PB_Relative)
MoveCamera(#Camera, KeyX, 0, KeyY)
RenderWorld()
FlipBuffers()
;;==============================================
SetGadgetText3D(0,"FPS: "+StrF(Engine3DStatus(#PB_Engine3D_CurrentFPS )))
SetGadgetText3D(1,"Tris: "+StrF(Engine3DStatus(#PB_Engine3D_NbRenderedTriangles)))
;;================================================
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
End
Procedure CreateMatrix()
CreateMesh(0, #PB_Mesh_TriangleList, #PB_Mesh_Dynamic)
CreateCube(30,3)
count = 1
While count <=100
AddSubMesh(#PB_Mesh_TriangleList)
CopyMesh(30,31)
rot.f + 1
TransformMesh(31,0,count*3/100,0, 1,0.01,1,0,rot,0)
GetMeshData(31,0, MeshData(), #PB_Mesh_Vertex | #PB_Mesh_UVCoordinate | #PB_Mesh_Normal, 0, MeshVertexCount(31)-1)
GetMeshData(31,0, MeshDataInd(), #PB_Mesh_Face, 0, MeshIndexCount(31, 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
MeshVertexPosition(x,y,z)
MeshVertexNormal(1,1,1)
MeshVertexTextureCoordinate(MeshData(c)\u, MeshData(c)\v)
Next
ArrSizeInd = ArraySize(MeshDataInd())
For i=0 To ArrSizeInd Step 3
MeshFace(MeshDataInd(i)\Index, MeshDataInd(i+1)\Index,MeshDataInd(i+2)\Index)
Next
count+1
Wend
;NormalizeMesh(0)
FinishMesh(#True)
NormalizeMesh(0)
SetMeshMaterial(0, MaterialID(5))
CreateEntity(0, MeshID(0), MaterialID(5), 0,-5,0)
;EntityPhysicBody(0, #PB_Entity_BoxBody , 1, 0.2, 1)
EntityPhysicBody(0, #PB_Entity_StaticBody , 1, 0.2, 1)
EndProcedure