CodeBase - Weld Vertices
Return to the CodeBase listing
Category: Basic 3D
Version: 1.1
Information
Uploaded: 22nd Jun 2007 00:07
Modified: 28th Jun 2007 07:49
Author: Visigoth
Summary
This function will take a DBPro primitive, and probably any other object you want, as long as they are static, no animations, and weld the vertices. Creates a before an after .x file of the mesh so you can see the difference. Just delete the save mesh lines if you don't want the files. EDITED: Improved weld time, added stretch UV coordinates.
Full Description
The function basically takes an object, converts it into mesh data,copies all the vertex data into an array, then searches through the vertexdata looking for duplicate vertices. It marks any duplicates, then copies the unigue ones into their own placeholders in the array. Then, it gets the index values for the original vertices, and compares the vertices at those locations with the unique ones. Any matches get pointed to the unique vertices. Then, it deletes the unnecessary vertex indexes, and writes the unique ones to the remaining vertex indexes. Then, it writes the indice indexex to the vertexdata. It then converts the mesh back to an object, and then uses built in DBPro command Set Object Normals to calculate the normals. Works great so far on all the primitives, except the sphere, which has a very prominent seam, but this is some weird lighting effect, or problem with the normals creation. Great if you want to make your own primitives, like matrixes (that's why I wrote it). Have fun! <br /> EDIT:<br /> params are now weld_vertices (object ID,UV flag)<br /> object ID is the object number of the object to weld<br /> UV flag is either no UV mapping 0<br /> Stretch UV mapping 1<br /> I found two loops that were real slow, so I improved that, should go quite a bit faster with larger meshes. I also added a planar type UV mapping. You can't really tile a map on an object with welded verts, so I had to do this to stretch the map across the object. Great for large plains or matrix type objects. Use a flag of 1 in the second parameter.
Comments
No comments yet.