hugging models
Blitz3D Forums/Blitz3D Programming/hugging models
| ||
How do you determine if a vertex of facing up down left or right? is this possible? I am trying to drop a model onto a mesh terrain and have it deform to the countour of the terrain. Easy to do if you want to deform all points and flatten the model but I want to deform only the bottom of the model, and then sink the top of the model a bit to match the original thickness of the model and the countour of the mesh terrain. I want to drop crops and foilage onto my mesh terrain and I do not want to be limited to flat areas. Can anyone help? Thanks. |
| ||
Try getting the normals of the triangles. That might be what your after. |
| ||
I know at least 5 ppl here that could solve this in 20 minutes or less.. Any help would be greatly appreciated. Code would be very very appreciated, but gerneral how to go about it info would be much appreciated too. |
| ||
Damn... From reading the topic, I was expecting something entirely different... I do enjoy hugging models, on the odd occasion when I get the chance :) Andy |
| ||
Damn... From reading the topic, I was expecting something entirely different Tell me about it! |
| ||
LOL Generaly speaking, a vertex could be said to be facing a particular axis/direction if the absolute value of one of the elements x,y or z is greater than the rest. x#=VertexNX#(surface,vertindex) y#=VertexNY#(surface,vertindex) z#=VertexNZ#(surface,vertindex) ; check if x axis is dominant if (Abs(x) >= Abs(y)) and (Abs(x) >= Abs(z)) ; vertex is mostly facing X axis if x > 0 ; vertex if facing +X else ; vertex is facing -X end if else ... check if y is dominant..then Z "I want to drop crops and foilage onto my mesh terrain and I do not want to be limited to flat areas. Can anyone help?" If they're meshes/sprites, why not align them to the terrain using AlignToVector() ? Tom |
| ||
First let me apologize for my message title. LOL. Tom, align to vector wont really hug the surface of my mesh terrain properly, and it wont sink the top of the model down to match the countour and original width of the crop mesh. Unless I am missing somthing. Thanks |
| ||
If you can find any of Robs flex shadows, i believe that does it. It creates a mesh, and basically wraps it around the scenary. I think he creates a mesh, line picks straight down from each vertex on the mesh, and finds the height of nearest vertex, then sets the vertex height to that. |
| ||
Got it. I just modified the original flex code. Thanks to all that responded. This works with models that are square or rectangular. You will get undesired effects with complex models unless you modify the vertex check to include some instuction of mid range vertecis. Function UpdateFlex(flexmesh) w#=MeshHeight(flexmesh) xs#=EntityX(flexmesh):ys#=EntityY(flexmesh):zs#=EntityZ(flexmesh) ;move model To 0,0,0 PositionMesh flexmesh,0,0,0 ;here we just see wich vertices are below 0(top of model) and wich ;are above 0 (bottom of model) s=GetSurface(flexmesh,1) For i=0 To CountVertices(s)-1 vx#=VertexX(s,i) vy#=VertexY(s,i) vz#=VertexZ(s,i) TFormPoint vx,vy,vz,flexmesh,0 vy#=TFormedY() If vy#<0 Then sorter(i)=1 Else sorter(i)=2 Next ;put model in its original position again PositionMesh flexmesh,xs,ys,zs ;original flex code For i=0 To CountVertices(s)-1 vx#=VertexX(s,i) vy#=VertexY(s,i) vz#=VertexZ(s,i) TFormPoint vx,vy,vz,flexmesh,0 vx=TFormedX() : vy=TFormedY() : vz=TFormedZ() LinePick vx,vy,vz,vx,vy-9000,vz vy=PickedY()-.1 TFormPoint vx,vy,vz,0,flexmesh vx=TFormedX() : vy=TFormedY() : vz=TFormedZ() ;we put bottom vertices on ground If sorter(i)=1 Then VertexCoords s,i,vx,vy,vz Else ;and just sink the top vertices by original mesh height VertexCoords s,i,vx,vy+w#,vz EndIf Next ;since mesh is origin is 0,0,0 lets move it ; back up by half its height TranslateEntity flexmesh,0,(w#/1.25),0 End Function |