Sign in to follow this  
drb2k2

Getting the lowest positioned vertex

Recommended Posts

Hi all, I am trying to write a simple model program. When the user rotates a model I want the floor to touch the very bottom vertex. I have used Geometry bounding box to get the lowest, but this always returned the 'untransformed' vertex, i.e. without the rotation applied. I was perhaps thinking of using collision detection, but i'm not sure if this would just use the untranformed bounding box too. The model is also held in a vertex buffer so I can't use any .mesh methods on it. Speed isn't important because its not a game. If anyone has any pointers they would be much appreciated Cheers DRB2k2

Share this post


Link to post
Share on other sites
ok,
have managed to do it like this


Dim verts As CustomVertex.PositionNormalTextured() = CType(Me.VertexBuffer.Lock(0, 0), CustomVertex.PositionNormalTextured())
Dim i As Integer
min.X = 1.0E+18
min.Y = 1.0E+18
min.Z = 1.0E+18
max.X = -1.0E+18
max.Y = -1.0E+18
max.Z = -1.0E+18
Dim vec_Smallest As Vector3
For i = 0 To (Me.FacetCount * 3) - 1
vec_Smallest = verts(i).GetPosition
'transform it by the matrix
vec_Smallest.TransformCoordinate(Me.MatFromRender)
'now see if its smaller
If (vec_Smallest.X < min.X) Then
min.X = vec_Smallest.X
End If
If (vec_Smallest.Y < min.Y) Then
min.Y = vec_Smallest.Y
End If
If (vec_Smallest.Z < min.Z) Then
min.Z = vec_Smallest.Z
End If

If (vec_Smallest.X > max.X) Then
max.X = vec_Smallest.X
End If
If (vec_Smallest.Y > max.Y) Then
max.Y = vec_Smallest.Y
End If
If (vec_Smallest.Z > max.Z) Then
max.Z = vec_Smallest.Z
End If
Next
Me.VertexBuffer.Unlock()



Where MatFromRender is the matrix used in Device.setTransform

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this