Topic: Can't AddVertex (BB3D Irrlicht)
hello together,
my problem is i want create a triangle like you can see in the following code. But i get an error every time in the surface.bmx. What should i do????
SuperStrict
Import irrlicht.b3d
ib3d_Graphics3D(800, 600, 32, 0, True, True, EDT_DIRECT3D8)
Global cam:CAMERA = ib3d_CreateCamera()
ib3d_PositionEntity(cam, 0, 0, -10)
Global light1:LIGHT = ib3d_CreateLight()
ib3d_PositionEntity(light1, 0, 0, 0)
'SMeshBuffer()
Global cube:MESH = ib3d_CreateMesh()
Global surf:SURFACE = ib3d_CreateSurface(cube, SF_NORMAL)
Global v1:Int = ib3d_AddVertex(surf, 0,0 , 0)
Global v2:Int = ib3d_AddVertex(surf, 1, -1, 0)
Global v3:Int = ib3d_AddVertex(surf, -1, -1, 0)
ib3d_AddTriangle(surf, v1, v2, v3)
ib3d_UpdateNormals(cube)
While Not ib3d_KeyDown(KEY_ESCAPE)
ib3d_UpdateWorld
ib3d_RenderWorld
WEnd
Surface.bmx
The error show that something in this wrong in this Method:
' TODO: dont think this is working right. need to examine source of addTestSceneNode().
Method addVertex:Int(x:Float,y:Float,z:Float,nx:Float=0,ny:Float=0,nz:Float=0,u:Float=0,v:Float=0)
If Not _mbuf Or Not _mbuf.isValid() Then RuntimeError "Surface meshbuffer is invalid"
Rem
Local vert:S3DVertex=S3DVertexDefault.createFromVals(x,y,z,nx,ny,nz,SColor.createFromVals(255,255,255,255),u,v)
Local vert_array:S3DVertex[1] = vert
'DebugLog("before: "+_mbuf.getVertices().size())
_mbuf.getVertices().push_back(vert)
'DebugLog("after: "+_mbuf.getVertices().size())
EndRem
RuntimeError "Not Implemented"
Return _mbuf.getVertexCount()-1
EndMethod