Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Vertex manipulation

Author
Message
GCEclipse
22
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: United Kingdom
Posted: 9th Mar 2003 20:41
Hi,

I've submitted a set of wrapper functions for editing a model at vertex level.

Hope they help people.

Issues:

1.DOES NOT work in DB Classic

2.DOES NOT work in Patch 4.3

3.Definitely does work with 3.1

4.It uses a memblock 1 and a mesh one - if you have these elsewhere in a project you'll need to change the numbers of the memblock and the mesh in the functions.

5.They could be made faster in a few ways. For every function it creates the mesh from the object, memblock from the mesh then once it is finished it deletes the memblock. If it was set up to just make the memblock once - perhaps an initialise command? then it would increase the speed. I didn't do this optimisation because I wanted them all to be fairly standalone.

6. All co-ordinates are relative to the position of the object - bear that in mind when amending models. So if the model is positioned at 10,100,15 then you'd add 10 to the vertex X co-ordinate to get its absolute position in 3D space, you'd add 100 to the Y and 15 to the Z.

Any problems please tell me so I can improve on these. Any other functions you wish me to add, ditto.

Commands:

Vertices(ObjectNo)
Returns the number of vertices in the Object

VertexX(ObjNo,VertexNo)
VertexY(ObjNo,VertexNo)
VertexZ(ObjNo,VertexNo)
These 3 return the relative position of the vertex in X Y and Z planes. (Its relative to the centre of the object)

Position_Vertex(ObjNo,VertexNo,X#,Y#,Z#)
Positions the vertex relative to the objects centre.

Amend_Vertex_Normals(ObjNo,VertexNo,X#,Y#,Z#)
Amends the Normals of the Vertex. YOu can get some nice shading effects using this command.

Amend_Vertex_Diffuse(ObjNo,VertexNo,Colour)
Amends the diffuse color of the Vertex. Great for gradiant colour fx on the object.


Function Vertices(ObjNo)
`Returns number of Vertices
`Vars
MeshNo=100
make mesh from object MeshNo,ObjNo
NoVerts=0
`Make your meshes and memblocks
make memblock from mesh 1,MeshNo
`Calculate no of vertices
NoVerts=memblock dword(1,8)
`Tidy
delete memblock 1
endfunction NoVerts



Function VertexX(ObjNo,VertexNo)
`Returns X position of specified vertex
MeshNo=100
make mesh from object MeshNo,ObjNo
NoVerts=0
`Make Memblock
make memblock from mesh 1,MeshNo
`Calculate no of vertices
NoVerts=memblock dword(1,8)
If VertexNo
GCEclipse
22
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: United Kingdom
Posted: 9th Mar 2003 20:43
Ooops.



GCEclipse
22
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: United Kingdom
Posted: 22nd Mar 2003 15:09
From the amount of replies I've had I can see nobody really cares, but I thought I should mention that I've now tested this with the release candidate of patch 4 and it works ok.

dbellis
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 22nd Mar 2003 19:07
i dont see how you didnt get any posts were some one with a simerler item but by far less functionality got 8 this is a very usefull tool.

Damian

http://www.eclipsedevelopment.co.uk/
Succession The Betrayal Developer

Login to post a reply

Server time is: 2024-11-24 04:36:59
Your offset time is: 2024-11-24 04:36:59