Pivot Point centering

Blitz3D Forums/Blitz3D Programming/Pivot Point centering

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

The only other thing i think you mean, which i'm now getting, is actually getting the centre location of the mesh in the first place, which did trip me up when doing the cannon game, because you can't use the entityX commands etc.

What i did was find the centre point of the mesh as it was, so:

I looped through each vertex in the mesh, and had six different functions, but three should do you:

find_middle_x()
find_middle_y()
find_middle_z()

function find_middle_x(mesh)

   c = countvertices(mesh,surface) ; you'll need to select the correct surface
   least_x# = 999999
   most_x# = -999999
   for loop = 1 to c
      
      if vertexX(mesh,surface) < least_x then
         least_x = vertexX(mesh,surface)
      end if
      if vertexX(mesh,surface) > most_X then
         most_x = vertexX(mesh,surface)
      end if
   next

   average = least_x + ((most_x - least_x)/2)

   return average

end function


Something like that. Note, the above might not work, as i can't test it, but it give you the basic idea. That way you have your centre point. From that, use the centring code i gave in the above posts, then positionentity your mesh at the co-ords you received from your middle functions. That should sort your out.

Sorry it took so long to catch on!