Sorry mini, but the only i must know, in the example, is the mesh has more than 7 indexes. I don't need at all to know the total amount of indexes of the mesh; if it has more than 7, it should work, as i can understand.
So, there seems the issue is related to another things.
Ok, I post the complete tip to show. Look at the lin 97, if you uncomment it, then the error comes.
Code: Select all
;/ inits
If InitEngine3D(#PB_Engine3D_NoLog,#PB_Compiler_Home+"Compilers\Engine3d.dll")=0
MessageRequester("Error","The 3D Engine can't be initialized",0):End
EndIf
AntialiasingMode(#PB_AntialiasingMode_x4)
InitSprite():InitKeyboard():InitMouse()
OpenWindow(0,0,0,800,600,"cuerpo TID",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,800,600,1,0,0,#PB_Screen_WaitSynchronization)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
#luz=0
#camara=0
#pivotcamara=0
#pivot=1
#textura=0
#material=0
#malla=0
;\
Structure Vector3D
x.f:y.f:z.f:m.f
EndStructure
Macro ProductoEscalar(a,b)
(a#\x*b#\x+a#\y*b#\y+a#\z*b#\z)
EndMacro
Macro getmodulo(v)
(Sqr#ProductoEscalar(v#,v#))
EndMacro
Macro ProductoVectorial(in1,in2,out,in1x=x,in1y=y,in1z=z,in2x=x,in2y=y,in2z=z,outx=x,outy=y,outz=z); <- Calculates the vectorial product of two 3D vectors. Just modify this procedure to get the vectorial product for 4D, 5D, 6D or any dimension you need.
out#\outx#=in1#\in1y#*in2#\in2z#-in1#\in1z#*in2#\in2y#
out#\outy#=in1#\in1z#*in2#\in2x#-in1#\in1x#*in2#\in2z#
out#\outz#=in1#\in1x#*in2#\in2y#-in1#\in1y#*in2#\in2x#
EndMacro
Procedure.b MouseButtonEdgeDetection(mbutton.b)
Static mb.b:Protected i.b=1<<mbutton
If MouseButton(mbutton);<-if current key status is PUSHED
If mb&i=0:mb|i:ProcedureReturn 1:EndIf;<-if previous key status was NOT PUSHED, then assign previous state to current one, and EXIT.
ElseIf mb&i;<-else (if previous key status was PUSHED and current key status is NOT PUSHED):
mb!i:ProcedureReturn -1;<-set previous key status to NOT PUSHED.
EndIf
ProcedureReturn 0
EndProcedure
Macro PonerVertice(posx,posy,posz,texcoordu,texcoordv,color)
MeshVertex(posx#,posy#,posz#,texcoordu#,texcoordv#,color#)
; MeshVertexPosition(posx#,posy#,posz#)
; MeshVertexTextureCoordinate(texcoordu#,texcoordv#)
; MeshVertexColor(color#)
EndMacro
Macro RND(v1,v2,ndecimales=3); maximo 'ndecimales' = 9
;genera un número aleatorio entre los valores v1 y v2
;NOTE: usar con variables de punto flotante para que esta macro funcione correctamente
(Random(1E#ndecimales#)*(v2#-v1#)/1E#ndecimales#+v1#)
EndMacro
CreateLight(#luz,$EEEEEE,4,4,2,#PB_Light_Point):SetLightColor(#luz,#PB_Light_DiffuseColor,$EEEEEE):MoveLight(#luz,4,4,2,#PB_Absolute)
CreateCamera(#camara,0,0,100,100):CreateNode(#pivotcamara,0,0,0):AttachNodeObject(#pivotcamara,CameraID(#camara)):CameraRange(#camara,0.1,1000):CameraBackColor(#camara,$181911)
MoveCamera(#camara,0,0,45,#PB_Absolute)
CreateMaterial(#material,0,$33E7FF):DisableMaterialLighting(#material,1)
eje.Vector3D
ele.Vector3D
ene.Vector3D
#nvertices=60000
Dim vertices.MeshVertex(#nvertices)
Macro todovertice(rotax=RND(-1,1,6),rotay=RND(-1,1,6),rotaz=RND(-1,1,6))
vertices(0)\x=RND(-0.2,0.2,6):vertices(0)\y=RND(-0.2,0.2,6):vertices(0)\z=RND(-0.2,0.2,6)
MeshVertexPosition(vertices(0)\x,vertices(0)\y,vertices(0)\z):MeshVertexColor($43D4E2):MeshIndex(0)
ele\x=vertices(0)\x-0:ele\y=vertices(0)\y-0:ele\z=vertices(0)\z-0
For t.u=1 To #nvertices
eje\x=rotax#:eje\y=rotay#:eje\z=rotaz#
ProductoVectorial(ele,eje,ene):ene\m=getmodulo(ene)
long.f=RND(0.1,1,6)
ene\x*long/ene\m:ene\y*long/ene\m:ene\z*long/ene\m
vertices(t)\x=vertices(t-1)\x+ene\x:vertices(t)\y=vertices(t-1)\y+ene\y:vertices(t)\z=vertices(t-1)\z+ene\z
MeshVertexPosition(vertices(t)\x,vertices(t)\y,vertices(t)\z):MeshVertexColor($43D4E2):MeshIndex(t)
ele\x=vertices(t)\x-vertices(t-1)\x:ele\y=vertices(t)\y-vertices(t-1)\y:ele\z=vertices(t)\z-vertices(t-1)\z
Next
EndMacro
CreateMesh(#malla,#PB_Mesh_LineStrip,#PB_Mesh_Static)
todovertice(0,0)
FinishMesh(0)
SetMeshMaterial(#malla,MaterialID(#material))
CreateNode(#pivot):AttachNodeObject(#pivot,MeshID(#malla))
Repeat:Repeat:evento.i=WindowEvent():Until evento=#PB_Event_None
ExamineMouse():ExamineKeyboard()
CursorX.f=WindowMouseX(0):CursorY.f=WindowMouseY(0):mdx.f=MouseDeltaX()/200:mdy.f=MouseDeltaY()/200:mdz.f=MouseWheel()/2
If mdx Or mdy Or mdz
If MouseButton(#PB_MouseButton_Right)
MoveCamera(#camara,mdx,-mdy,0,#PB_Local)
Else
RotateNode(#pivotcamara,-mdy*6,-mdx*6,0,#PB_Relative)
MoveCamera(#camara,0,0,-mdz,#PB_Relative)
EndIf
EndIf
If KeyboardReleased(#PB_Key_Up)
UpdateMesh(#malla,0)
todovertice(0,0)
FinishMesh(0)
NormalizeMesh(#malla,0)
UpdateMeshBoundingBox(#malla)
;GetMeshData(#malla,0,vertices.MeshVertex(),#PB_Mesh_Vertex,0,7); <- error
ElseIf MouseButtonEdgeDetection(#PB_MouseButton_Left)=1
SetMeshData(#malla,0,vertices.MeshVertex(),#PB_Mesh_Vertex,0,7)
NormalizeMesh(#malla,0)
UpdateMeshBoundingBox(#malla)
ElseIf KeyboardReleased(#PB_Key_Right):anchuradelinea.a+1:glLineWidth_(anchuradelinea)
ElseIf KeyboardReleased(#PB_Key_Left):anchuradelinea.a-1:glLineWidth_(anchuradelinea)
EndIf
TimeSinceLastFrame.i=RenderWorld(50)
FlipBuffers()
StartDrawing(WindowOutput(0))
DrawText(1,1,"vertices: "+Str(MeshVertexCount(#malla,0)))
StopDrawing()
Delay(13)
Until KeyboardPushed(#PB_Key_Escape)