x file terrain.
hello.
I have a helicopter flying on the terrain.
y coordinate determines the height of the helicopter from the terrain. terrain and helicopter is .x files. To give a tweak to terrain a bumper had been inserted. a part of code at the below.
myquestion is how can I detect height of the terrain at specific point. because ofthe bumpy terrain y coordinate must change as long as the helicopter flies.I need to get y coordinate of helicopter according to terrain. thanks
' Tweak the terrain vertices to add some bumpy terrain
IfNot (terrainMeshIsNothing)Then' Set FVF to VertexFVFterrainMesh.SetFVF(Device, MeshVertex.Format)
' Get access to the mesh verticesDim pVBAs VertexBuffer =NothingDim verticesAs MeshVertex() =NothingDim numVerticesAsInteger = terrainMesh.SysMemMesh.NumberVerticespVB = terrainMesh.SysMemMesh.VertexBuffer
vertices =
CType(pVB.Lock(0,GetType(MeshVertex), 0, numVertices), MeshVertex())Dim iAsIntegerFor i = 0 To numVertices - 1Dim v00 As New Vector3(vertices(i).p.X + 0.0F, 0.0F, vertices(i).p.Z + 0.0F) Dim v10 As New Vector3(vertices(i).p.X + 0.1F, 0.0F, vertices(i).p.Z + 0.0F)Dim v01 As New Vector3(vertices(i).p.X + 0.0F, 0.0F, vertices(i).p.Z + 0.1F)v00.Y = HeightField(1 * v00.X, 1 * v00.Z)v10.Y = HeightField(1 * v10.X, 1 * v10.Z) v01.Y = HeightField(1 * v01.X, 1 * v01.Z)Dim n As Vector3 = Vector3.Cross(Vector3.Subtract(v01, v00), Vector3.Subtract(v10, v00))n.Normalize()vertices(i).p.Y = v00.Yvertices(i).n.X = n.Xvertices(i).n.Y = n.Yvertices(i).n.Z = n.Zvertices(i).tu *= 10vertices(i).tv *= 10Next i
