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 VertexFVF

terrainMesh.SetFVF(Device, MeshVertex.Format)

' Get access to the mesh vertices

Dim pVBAs VertexBuffer =Nothing

Dim verticesAs MeshVertex() =Nothing

Dim numVerticesAsInteger = terrainMesh.SysMemMesh.NumberVertices

pVB = terrainMesh.SysMemMesh.VertexBuffer

vertices =CType(pVB.Lock(0,GetType(MeshVertex), 0, numVertices), MeshVertex())

Dim iAsInteger

For i = 0 To numVertices - 1

Dim 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.Y

vertices(i).n.X = n.X

vertices(i).n.Y = n.Y

vertices(i).n.Z = n.Z

vertices(i).tu *= 10

vertices(i).tv *= 10

Next i

[4277 byte] By [mech3] at [2007-12-25]
# 1
Evaluate your hight field at the helicopter's projected x and z world-space position...
WessamBahnassi at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...