Jump to content
  • Advertisement
Sign in to follow this  

Getting the lowest positioned vertex

This topic is 4957 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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
'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

Where MatFromRender is the matrix used in Device.setTransform

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!