Page 1 of 1

SetMeshData : create mesh from scratch ?

Posted: Tue Aug 13, 2013 8:27 pm
by eddy
Hi,

Is it possible to create mesh from scratch with SetMeshData(...) function ?

Code: Select all

mesh=CreateMesh(#PB_Any)
FinishMesh(1)
SetMeshData(mesh, ....) ; face
SetMeshData(mesh, ....)  ; vertex

Re: SetMeshData : create mesh from scratch ?

Posted: Tue Aug 13, 2013 8:39 pm
by Comtois
no you can't.

Re: SetMeshData : create mesh from scratch ?

Posted: Tue Aug 13, 2013 8:58 pm
by IdeasVacuum
You can make a mesh from scratch, if you pre-calculate the vertex points.
In the code below, I have the points that describe a mesh saved as strings(x,y,z) in a linked list:

Code: Select all

D.s = Chr(44) ;comma

If CreateMesh(#MeshSTL, #PB_Mesh_TriangleList, #PB_Mesh_Static)

     SetMeshMaterial(#MeshSTL, MaterialID(#MatlSTL))

     FirstElement(sgListPts())

     Repeat

          MeshVertexPosition(ValD(StringField(sgListPts(),1,D)),ValD(StringField(sgListPts(),2,D)),ValD(StringField(sgListPts(),3,D)))
                 NextElement(sgListPts())

          MeshVertexPosition(ValD(StringField(sgListPts(),1,D)),ValD(StringField(sgListPts(),2,D)),ValD(StringField(sgListPts(),3,D)))
                 NextElement(sgListPts())

          MeshVertexPosition(ValD(StringField(sgListPts(),1,D)),ValD(StringField(sgListPts(),2,D)),ValD(StringField(sgListPts(),3,D)))
                 NextElement(sgListPts())

                    MeshFace(i, i + 1, i + 2)

                    i = i + 3

     Until i > ListSize(sgListPts())

    FinishMesh(#True)
EndIf

Re: SetMeshData : create mesh from scratch ?

Posted: Tue Aug 13, 2013 9:04 pm
by eddy
I found an old version of this function.
I thought it would be faster to create mesh with an array of vertices.
but, well, that's not possible.

Re: SetMeshData : create mesh from scratch ?

Posted: Tue Aug 13, 2013 10:14 pm
by IdeasVacuum
...using code similar to mine in a Procedure, it is possible.