Several Vertex Manipulation Functions by Preston C3rd Jan 2004 20:13
|
---|
Summary Manipulate your objects vertices with these functions! Description This code was programmed by Preston "NWC_Omega" Chaderton. Special Thanks To TheDarthster for assisting me in the creation of this library and explaining to me what format the make memblock from mesh command uses. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Rem Vertice Editing Function Library Rem By Preston "NWC_Omega" Chaderton Rem Special Thanks To TheDarthster For Helping Me Through The Creation of This Library RemStart This library will give you direct access to your objects vertex data. It does this by making a mesh, then memblock from the mesh, then editing the mesh data in the Memblock. The Library Contains the Following Functions PositionVertex(Object Number,Vertex Number,X Position,Y Position,Z Position) -Positions Vertex at Specified Coordinate SetVertexNormals(Object Number,Vertex Number,X Normal,Y Normal,Z Normal) -Sets the Vertices Current Normals SetVertexUV(Object Number,Vertex Number,U Coordinate,Y Coordinate) -Sets the Vertices Current UV Texture Coordinates VertexPositionX(Object Number,Vertex Number) -Returns the Vertices X Position VertexPositionY(Object Number,Vertex Number) -Returns the Vertices Y Position VertexPositionZ(Object Number,Vertex Number) -Returns the Vertices Z Position VertexNormalX(Object Number,Vertex Number) -Returns the Vertices X Normal VertexNormalY(Object Number,Vertex Number) -Returns the Vertices Y Normal VertexNormalZ(Object Number,Vertex Number) -Returns the Vertices Z Normal VertexU(Object Number,Vertex Number) -Returns the Vertices Current U Texture Coordinate VertexV(Object Number,Vertex Number) -Returns the Vertices Current V Texture Coordinate RemEnd `********************************************** ` Library Setup! `Please Copy and Paste this Following Code Into ` The Top of Your Program. `********************************************** cls rgb(255,255,255) get image 15000,0,0,1,1 `********************************************** ` Please Do Not Use Image Number 15000 ` Please Do Not Use Mesh Number 10 ` Please Do Not Use Memblock Number 10 `********************************************** `************************************************ `Documentation `************************************************ RemStart Memblock Mesh Format (338): Make a Memblock of the right size (3 vertices, 36 bytes of data each) make memblock 1,(polys*3*36)+12 Write FVF Header write memblock dword 1,0,338 Write FVF Size write memblock dword 1,4,36 Number of Vertices write memblock dword 1,8,polys*3 Vertice Positions write memblock float 1,12,x1# write memblock float 1,16,y1# write memblock float 1,20,z1# Normals write memblock float 1,24,0 write memblock float 1,28,0 write memblock float 1,32,-1.00 Colors write memblock dword 1,36,rgb(255,0,0) UV Coordinates write memblock float 1,40,0.00 write memblock float 1,44,0.00 Memblock Mesh Format (274): Make a Memblock of the right size (3 vertices, 32 bytes of data each) make memblock 1,(polys*3*36)+12 Write FVF Header write memblock dword 1,0,274 Write FVF Size write memblock dword 1,4,32 Number of Vertices write memblock dword 1,8,polys*3 Vertice Positions write memblock float 1,12,x1# write memblock float 1,16,y1# write memblock float 1,20,z1# Normals write memblock float 1,24,0 write memblock float 1,28,0 write memblock float 1,32,-1.00 UV Coordinates write memblock float 1,36,0.00 write memblock float 1,40,0.00 The make memblock from mesh command creates memblock meshes in the 274 format. Please remember this. RemEnd `********************************************* `Functions `********************************************* Function PositionVertex(object,vertex,x#,y#,z#) make mesh from object 10,object make memblock from mesh 10,10 write memblock float 10,12+((32*vertex)-32),x# write memblock float 10,(12+((32*vertex))-32)+4,y# write memblock float 10,(12+((32*vertex))-32)+8,z# delete mesh 10 delete object object make mesh from memblock 10,10 make object object,10,15000 delete mesh 10 delete memblock 10 endfunction Function SetVertexNormals(object,vertex,x#,y#,z#) make mesh from object 10,object make memblock from mesh 10,10 write memblock float 10,24+((32*vertex)-32),x# write memblock float 10,(24+((32*vertex))-32)+4,y# write memblock float 10,(24+((32*vertex))-32)+8,z# delete mesh 10 delete object object make mesh from memblock 10,10 make object object,10,15000 delete mesh 10 delete memblock 10 endfunction Function SetVertexUV(object,vertex,u#,v#) make mesh from object 10,object make memblock from mesh 10,10 write memblock float 10,12+((32*vertex)-32),u# write memblock float 10,(12+((32*vertex))-32)+4,v# delete mesh 10 delete object object make mesh from memblock 10,10 make object object,10,15000 delete mesh 10 delete memblock 10 endfunction Function VertexPositionX(object,vertex) make mesh from object 10,object make memblock from mesh 10,10 xpos=memblock float(10,12+((32*vertex)-32)) delete mesh 10 delete memblock 10 endfunction xpos Function VertexPositionY(object,vertex) make mesh from object 10,object make memblock from mesh 10,10 ypos=memblock float(10,16+((32*vertex)-32)) delete mesh 10 delete memblock 10 endfunction ypos Function VertexPositionZ(object,vertex) make mesh from object 10,object make memblock from mesh 10,10 zpos=memblock float(10,20+((32*vertex)-32)) delete mesh 10 delete memblock 10 endfunction zpos Function VertexNormalX(object,vertex) make mesh from object 10,object make memblock from mesh 10,10 xpos=memblock float(10,24+((32*vertex)-32)) delete mesh 10 delete memblock 10 endfunction xpos Function VertexNormalY(object,vertex) make mesh from object 10,object make memblock from mesh 10,10 ypos=memblock float(10,28+((32*vertex)-32)) delete mesh 10 delete memblock 10 endfunction ypos Function VertexNormalZ(object,vertex) make mesh from object 10,object make memblock from mesh 10,10 zpos=memblock float(10,32+((32*vertex)-32)) delete mesh 10 delete memblock 10 endfunction zpos Function VertexU(object,vertex) make mesh from object 10,object make memblock from mesh 10,10 upos=memblock float(10,36+((32*vertex)-32)) delete mesh 10 delete memblock 10 endfunction upos Function VertexV(object,vertex) make mesh from object 10,object make memblock from mesh 10,10 vpos=memblock float(10,40+((32*vertex)-32)) delete mesh 10 delete memblock 10 endfunction vpos |