Vertex/Vertices Movment..
Blitz3D Forums/Blitz3D Programming/Vertex/Vertices Movment..
| ||
hi.. i've been trying to find here and on blitzcoder some explanations or exampels on how to get a vertex or a group of vertecies from an mesh and then manipulate it.. ie. move it around but found none.. can anyone point me to some examples ? tnx |
| ||
hi, i am no b3d pro but i see that your post has been on the forum for several days without recieveing any answer, so here am i. the philosphy of what you want to do is the following : . a mesh is a collection of surfaces (one or more) . a surface is a collection of vertices (one or more) (. triangles are made of (3) vertices) so if you want to manipulate vertices, you have to go from the bigger structure to the smaller, that is from the mesh to the vertex : . mesh=loadmesh() or createmesh() or any mesh . surface=getsurface(mesh, index of the surface) . vertex-coord-X=vertexx(surface, index of the vertex) . idem for Y and Z coordinates then change those X Y and Z values as you wish : . vertexcoords surface,index of vertex,X,Y,Z you will have to adapt the XYZ values of every vertex you want to change ... but if you change the XYZ coords of a vertex that is part of several triangles, all the triangles will deform. hoping to be of some help orion one . |
| ||
orion one, I have a problem that sounds up your street- I would like to get a heart mesh to beat realistically ie. atria then ventricles. I would also like to simulate things like af, brady & tachy, vt, st elevation/depression etc. Is this possible? would it be possible to use the signal from a 12 lead ecg to drive the mesh? I am developing educational software for the cardiac catheterisation labs. Cheers Shawnus |
| ||
try this:Graphics3D 1024,768,32 SetBuffer BackBuffer() WireFrame True camera=CreateCamera() PositionEntity camera,0,10,-10 ship=LoadMesh("models\fighter.3ds") ScaleMesh ship,0.03,0.03,0.03 PointEntity camera,ship light=CreateLight() angle#=0 alpha#=1.0 Type vertex Field s ; surface Field index Field x# Field y# Field z# End Type Global maxx#,maxy#,maxz#,minx#,miny#,minz# Global rangex#,rangey#,rangez# GetModel(ship) rangex=maxx-minx rangey=maxy-miny rangez=maxz-minz UpdateNormals ship While Not KeyDown(1) RenderWorld Text 0,0,"Press C to cloak" TurnEntity ship,0,0.1,0 If KeyHit( 46 )=True cloak=1-cloak If cloak=1 And MilliSecs()>timer angle=angle+12 timer=MilliSecs()+20 alpha=alpha*0.95 If alpha<0.0009 Then alpha=1.0:cloak=False setalpha(ship,alpha) vc=0 For v.vertex=Each vertex vc=vc+1 perx#=((maxx-v\x)+minx)*48.0 pery#=((maxy-v\y)+miny)*48.0 perz#=((maxz-v\z)+minz)*48.0 VertexCoords v\s,v\index,v\x+(Sin(angle+perx)/4.0),v\y+(Cos(angle+pery)/4.0),v\z+(Cos(angle+perz)/4.0) Next UpdateNormals ship EndIf Flip Wend End Function setalpha(ship,alpha#) cc=CountChildren(ship) If cc=0 EntityAlpha ship,alpha Else For count=0 To cc-1 gc=GetChild(ship,count) setalpha(gc,alpha) Next EndIf End Function Function GetModel(ship) For sur=1 To CountSurfaces(ship) ; get all the surfaces surface=GetSurface(ship,sur) ; get the vertices for each surface For vertex=0 To CountVertices(surface)-1 v.vertex=New vertex v\s=surface v\index=vertex v\x=VertexX(surface,vertex) v\y=VertexY(surface,vertex) v\z=VertexZ(surface,vertex) ; get the limits of the model If v\x>maxx# Then maxx=v\x If v\x<minx# Then minx=v\x If v\y>maxy# Then maxy=v\y If v\y<miny# Then miny=v\y If v\z>maxz# Then maxz=v\z If v\z<minz# Then minz=v\z Next Next End Function You may have to adjust the scale of whatever model you decide to punch into this |
| ||
thanks _skully- i will try it shawnus |
| ||
_skully sorry for the wait for my reply- it works wonderfully. thanks. shawnus |