Countvertices and Counttriangles don't work?
Blitz3D Forums/Blitz3D Programming/Countvertices and Counttriangles don't work?
| ||
| For some reason, however I code it, it always returns zero. |
| ||
| Maybe there are zero vertices/tris in the surface you are checking... Try this: function DebugMeshCounts(mesh) n_surfs = countsurfaces(mesh) debuglog "surfaces: "+n_surfs for s = 1 to n_surfs surf = getsurface(mesh,s) n_verts = countvertices(surf) n_tris = counttriangles(surf) debuglog "surface "+s+" verts: "+n_verts+" tris: "+n_tris t_verts = t_verts+n_verts t_tris = t_tris+n_tris next debuglog "total verts: "+t_verts debuglog "total tris: "+t_tris end function |
| ||
| Thanks. I just found a funny thing though which explains it all. I'm using AddMesh to add one to another, and it always seems to add the mesh to surface 2 of the destination mesh. I didn't even create surface 2. |
| ||
| If the mesh you are adding has different surface attributes to the target mesh Blitz will create new surfaces in the target mesh. |
| ||
| Mmmm... what attributes could they be? I haven't even done anything with the surface. I created a surface, then used AddMesh straight away. Maybe I need to PaintSurface the first surface? [edit] No, that doesn't work. Even if I don't create surface 1, using AddMesh results in 2 surfaces. |
| ||
| Are you saying you have a completely empty mesh and you add a mesh to this that has only one surface and you end up with two surfaces? (that would be weird). Or does the mesh you are adding to already have a surface? If it does and the two surfaces have been painted with the same brush then I would expect the surfaces to be merged, unless of course the vertex limit would be exceeded in which case I would expect a second surface to be created. If you have not painted both the surfaces though maybe they are being created with different attributes or some attributes are undefined. I have not tried that but it would not suprise me. |
| ||
Check out this example, it may clear things up, then again lol
Graphics3D 800,600
mesh=CreateMesh()
s1=CountSurfaces(mesh)
surf=CreateSurface(mesh)
s2=CountSurfaces(mesh)
cube=CreateCube()
AddMesh cube,mesh
s3=CountSurfaces(mesh)
sphere=CreateSphere()
brush=CreateBrush(255,0,0)
PaintMesh sphere,brush
AddMesh sphere,mesh
s4=CountSurfaces(mesh)
While Not KeyHit(1)
Text 0,0,"Surfcount of mesh "+s1+" because we haven't made any surfaces yet"
Text 0,10,"Surfcount after creating a surface "+s2+" we just created one surface"
Text 0,20,"Surfcount after addmeshing the cube "+s3+" the cube has the same brush properties as the empty surface"
Text 0,30,"Surfcount after addmeshing the sphere "+s4+" the sphere has different brush properties to the cube"
Flip
Wend
|
| ||
| That's what I thought. I've been using the same brush though so I don't know what's up. Also I am adding the mesh to a mesh with no surfaces, and still getting 2. I need to really take a good look at my code. |