Moving an object from one position and orientation to another without
hitting any obstacles is a very hard problem.  Google for "piano mover's
problem" and you can find a ton of research into algorithms for
analyzing problems like that.  We don't actually try to solve that in
real time in Source - we apply a bunch of constraints to make motion
planning problems tractable.  So it's hard for me to give you more
specific suggestions on that because I think it's not really a good
choice to try and solve that problem without introducing some
constraints or cheats.

As far as rotating around a point that isn't the center of the object -
that's really simple.  You can build the transform you want and then
apply it directly or separate it into a linear part (translation,
velocity, force) and an angular part (rotation, angular velocity,
torque) and apply those parts.  An intuitive way to explain how to build
such a transformation is to compute the vector that moves the center of
mass to the desired rotation center, then compute the matrix that
performs only the rotational part (like rotate 90 degrees around the x
axis).  So to get the combined transform you'd apply the translation
vector, then apply the rotation, then apply the negative translation
vector but rotated by the rotation.  Hopefully that makes sense.

In practice we don't usually do this as a combined transformation in
physics - we just set target positions/orientations and solve for the
velocities that move the object linearly and angularly to those targets
- treating those parts as independent problems.  This means that the
path will diverge from the curved path you'd expect to take, but we
generally take steps over small enough periods of time to not care about
that error.  That's how shadow controllers work, for example.

Jay




-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Nick
Sent: Wednesday, February 06, 2008 9:46 PM
To: [email protected]
Subject: Re: [hlcoders] snapping objects to a specific position

I also wondered how to do this. Jay, if you could please look at my
diagram and try to explain exactly how to do this???

http://img231.imageshack.us/img231/2334/howtofn1.jpg

Could you give a code example? It would help out a ton, I have looked
through the sdk for months and cannot find any clue on how to do such
a thing.

On Feb 6, 2008 12:35 PM, Jay Stelly <[EMAIL PROTECTED]> wrote:
> If you have one vector pointing in a direction (like say the X-axis of
> an object) and another that points where you'd like the first vector
to
> be pointing after applying the torque, then
ComputeRotSpeedToAlignAxes()
> will calculate an angular velocity (this is mass/inertia independent)
> that rotates the first axis in the direction of the second axis taking
> into account the current rotational velocity of the object.
>
> So I think you have the right idea when you say they are normal that
> show the desired and current alignment.  "testAxis" is the current
> alignment, "alignAxis" is the desired alignment in your case.  It
> doesn't matter what space you use as long as you know that the current
> and desired axes as well as the output angular velocity are in that
> space.  Also, this function has a pretty specific purpose so it may
not
> be tuned exactly for your situation; it doesn't take time into account
> for example.  Shadow controllers have a better concept of hitting a
> target position/orientation while obeying some physical constraints.
> Maybe that is a better tool for what you are trying to do.
>
> When you ask how to change the rotation axis of a physics object you
> aren't asking a very precise question.  Applying a torque to the
object
> will most likely change the rotation axis of the object.  The center
of
> mass is the point around which all applied torques rotate, but there
are
> infinitely many rotation axes passing through that point.
>
> Jay
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of
coderdude
> > Sent: Wednesday, February 06, 2008 8:31 AM
> > To: [email protected]
> > Subject: [hlcoders] snapping objects to a specific position
> >
>
> > How do I calculate the torque needed to move an object to
> > it's goal position? How to change the rotation axis of a phys
> > object? will PhysSetMassCenterOverride() do the job? I want
> > the object to point a specific direction, but fail on extreme
> > conditions (obstacle), I looked at
> > ComputeRotSpeedToAlignAxes() but I don't know the parameters.
> > Are they normals which show the desired, then current
> > alignment? Or maybe the other way around? Local or world space?
> >
> > Dam, it's hard to use APIs when you don't know what they do :/
> >
> > _______________________________________________
> > To unsubscribe, edit your list preferences, or view the list
> > archives, please visit:
> > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >
> >
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to