Hi Psychophanta
how this happened ? i have tried to replicate the error but can't.
the test below is adapted from Meshmanual2.pb
here we draw 4 vertices which have automatically vertex indices 0,1,2,3 . after that we connect every 3 vertices with
MeshIndex(0): MeshIndex(1): MeshIndex(2)
MeshIndex(0): MeshIndex(2): MeshIndex(3)
to make 2 triangles (instead of using MeshFace() function)
even we have 4 vertices but the number of indices is 6 as can be seen
if there is a bug it should be that if we replace MeshIndex(3) with MeshIndex(100) it does not throw an error but instead it does not draw the second triangle without giving an error that there is no vertex 100
Code: Select all
#CameraSpeed = 1
#scale = 3
IncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/fonts", #PB_3DArchive_FileSystem)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
;- Material
CreateMaterial(0, LoadTexture(0, "White.jpg"))
DisableMaterialLighting(0, #True)
MaterialCullingMode(0, #PB_Material_NoCulling )
MaterialShadingMode(0, #PB_Material_Wireframe)
;- Mesh Plane (using MeshIndex)
CreateMesh(0, #PB_Mesh_TriangleList, #PB_Mesh_Static)
MeshVertexPosition(-10, -10, 0) ; vertex index 0
MeshVertexPosition(-10, 10, 0) ; vertex index 1
MeshVertexPosition( 10, 10, 0) ; vertex index 2
MeshVertexPosition( 10, -10, 0) ; vertex index 3
; Define usage of vertices by referring To the indexes
MeshIndex(0): MeshIndex(1): MeshIndex(2)
MeshIndex(0): MeshIndex(2): MeshIndex(3)
FinishMesh(#True)
plane2= CreateEntity(#PB_Any, MeshID(0), MaterialID(0))
SetMeshMaterial(0, MaterialID(0))
;-Camera
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 0, 100, #PB_Absolute)
CameraFOV(0, 40)
CameraBackColor(0, RGB(0, 0, 40))
;-Light
CreateLight(0, RGB(255,255,255), -10, 60, 10)
AmbientColor(RGB(90, 90, 90))
Debug Str(MeshVertexCount(0))
Debug MeshIndexCount(0)
Repeat
Screen3DEvents()
ExamineKeyboard()
RotateEntity(Plane2, 0.3, -0.3, -0.3, #PB_Relative)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
End