Collision radius and registration points

Blitz3D Forums/Blitz3D Programming/Collision radius and registration points

martonic(Posted 2004) [#1]
Hi! I am familiar with 2-d graphics in which buttons etc. have a "registration point" that can be used to lay out a rectangle for mouse click reactions (for example). Do 3-d meshes, such as character meshes, also have a registration point? If so, A) is there an easy way to tell where that is and B) is it typically at the feet, head or middle of a character mesh? If character meshes have a registration point, is that then used as the center point of their "EntityRadius" elipsoid? If not, where is the center of that ellipsoid? Thanks for any input on these fundamental questions.


big10p(Posted 2004) [#2]
By "registration point" I'm guessing you mean 'origin'. Yes, 3D meshes do have origins. In fact, all point(vertex) coordinates in the mesh are relative to this origin. For most meshes the origin is usually smack-bang in the centre but it can actually be set to *anywhere* in 3D space.

If you position a mesh with PositionEntity, the point in 3D space you specify is where the mesh is placed, with it's origin at that point. And, yes, EntityRadius etc. are also set at the origin.


martonic(Posted 2004) [#3]
Thanks for your answer which, like all good answers, raises further questions.

In the "create mesh" example (Blitz3d Help) they create an empty mesh and add 6 vertices and 8 triangles, after which it is used as a graphical element.

They never explicitly created an origin for it. Is there a "default origin" or if not, what does EntityRadius etc. consider to be the "effective origin" of such constructs?

You say an origin can be set to anywhere in 3-d space. How can I set or change an object's origin?

BTW I don't assume I'm entitled to answers! But if it interests you, I'd like to hear your thoughts. Thanks.


Bot Builder(Posted 2004) [#4]
Yes. The default origin is xyz position 0,0,0 with a pitch/yaw/roll of 0,0,0.

You can move an obects origin with the following:
Function MoveOrigin(obj,x#,y#,z#)
 MoveEntity obj,x,y,z
 MoveMesh obj,-x,-y,-z
End Function


this works because Movemesh moves the vertices without moving the origin and moveentity moves both.


martonic(Posted 2004) [#5]
Thank you.


martonic(Posted 2004) [#6]
I tried it but the function "MoveMesh" does not seem to be supported in Blitz3d. But we can do this instead:

Function MoveOrigin(obj,x#,y#,z#)
save_x# = EntityX(obj,1)
save_y# = EntityY(obj,1)
save_z# = EntityZ(obj,1)

PositionEntity obj,0,0,0,1
PositionMesh obj,-x,-y,-z
PositionEntity(obj,save_x+x,save_y+y,save_z+z,1)
End Function

Thanks for pointing me in the right direction.

-Marty


ZombieWoof(Posted 2004) [#7]
I've got a mesh with the origin far offset from them mesh -- is there a quick and dirty way to get the origin back to mesh center without walking all the verts to determine the real mesh extents ?? MeshWidth, MeshHeight, and MeshDepth appear to include the origin in the space they describe. (or have I missed something ?)


REDi(Posted 2004) [#8]
@ZombieWoof
You could use this to center the origin
FitMesh MeshID,-(MeshWidth(MeshID)/2.0),-(MeshHeight(MeshID)/2.0),-(MeshDepth(MeshID)/2.0),MeshWidth(MeshID),MeshHeight(MeshID),MeshDepth(MeshID)


Hope that helps.


Beaker(Posted 2004) [#9]
I presume he meant PositionMesh() instead of MoveMesh().


martonic(Posted 2004) [#10]
Using the function "MoveOrigin" in my post, just above, you can try this:

1) PositionEntity(object,0,0,0,1)
2) MoveOrigin (object, -MeshWidth(object), -MeshHeight(object), -MeshDepth(object))
3) PositionEntity(object) as desired.

This should move the origin to a point on the bounding box for the object.

-Marty


ZombieWoof(Posted 2004) [#11]
@papa: tried that -- didnt seem to work