finding y on mesh
Blitz3D Forums/Blitz3D Programming/finding y on mesh
| ||
ok you all know how the terrain y command works. well im making mesh for terrrain instead for obvios reason and I cnanot figure out how I find the y of the mesh. So that I can have a model start above the mesh at all times you know a y+20 or something. any ways any help is much appreciated. Paul T. Silva |
| ||
Make the mesh pickable and use a linepick straight down. Position the mesh at the pickedx(),pickedy() etc.. coordinates. Alternatively just use blitz inbuilt collisions and position then mesh at collisionx(), y, z etc... |
| ||
Use a line pick and then get the y value from pickedy() linepick entityX(myobject),entityY(myobject),entityZ(myobject),entityX(myobject),entityY(myobject)-5000,entityZ(myobject) pickedY() should now hold the Y position edit: oops,... got beat to it. Forgot to mention the mesh needs to be pick-able |
| ||
ok never messed with line pick but ill give it a try =) |
| ||
is there a example somewhere on using line pick? as i cant find one with the docs for this im not 100% getting it |
| ||
You can also calculate the position of any point on the terrain quite easily if the vertices are equally spaced in the x/z directions (ie it is made up of squares/rectangles all the same size in the x/z direction). Much faster than using a line pick. Download this file and look for the .bb file "MeshTerrain.bb" that contains a method for calculating the height of the ground at any point in my mesh terrain: http://home.swiftdsl.com.au/~gezeder/lloyd/GBS_Code.zip (You may also need to include the globals.bb file if you wish to test this out..) |
| ||
There's also a function in the code arcs that calculates the Y of a point on a triangle, given the X,Z coords of the point. |
| ||
ok im a hair confuse heres what i put LinePick EntityX(mterra),EntityY(mterra),EntityZ(mterra),EntityX(p\ent),EntityY(p\ent)-5000,EntityZ(p\ent) i get the error that entity does not exist. which I dont understand because those are valid names to the entity. did i puntuate the line incoreectly? |