Re: [c# .net 2005] problem with moving start of world
- From: "Robert Dunlop [MS MVP]" <rdunlop@xxxxxxxx>
- Date: Thu, 26 Jan 2006 13:50:09 -0800
"Piotrek Alchemik" <p.pietruszka@xxxxxxxxx> wrote in message
news:1138136286.948773.29550@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> i have small problem with creating my small project. I need to simulate
> some kind of arm. I am doing this by create few separate cubes, and
> trying to connect them in one point.
> I declare the cubes:
[clip]
> The problem i'm trying to solve is that when i rotate using yAngle, the
> first cube rotate exactly around the z line, which is created at the
> bottom of my first cube. The second one is located at the top of first
> one, but unfortunetly is rotating at the point, where started the first
> cube.
> Maybe can somebody help me solving my problems? Any idea how to move
> point 0,0,0 for second cube and force her to rotate around that point?
First, note that combining matrices through multiplication is not
commutative, unlike scalar multiplication. That is, the order by which you
multiply the matrices will effect the results. For example, rotation *
translation will produce a different result than translation * rotation -
it's the difference between moving an object then rotating it around its new
location, versus rotating an object around its original location then moving
it. Simply switching the order of the multiplication may take care of your
problem, though I'm not sure of the exact results you are looking for so it
may be more than that.
If you want to rotate around a specific point in space independent of the
final translation, then you need to translate the object so the center of
rotation is the origin, rotate it, translate it back to its origin, then
translate it to the desired location. An easy shortcut for this would be to
use the Matrix.AffineTransformation method, which lets you specify a
rotation center, a translation, a quaternion specifying the rotation, and a
scaling factor. If you look in the documentation for this function you'll
find the series of transformations I described above documented.
If you are going to be rendering a hierarchy of objects that are dependent
upon each other, you might want to check out the MatrixStack and Frame
classes as well.
--
Robert Dunlop
The X-Zone
http://www.directxzone.com/
Microsoft DirectX MVP
-------------
The opinions expressed in this message are my own personal views and do not
reflect the official views of the Microsoft Corporation.
The MVP program does not constitute employment or contractual obligation
with Microsoft.
.
- References:
- [c# .net 2005] problem with moving start of world
- From: Piotrek Alchemik
- [c# .net 2005] problem with moving start of world
- Prev by Date: Re: D3DCAPS9 for Skinned Meshes
- Next by Date: Re: powers of 2
- Previous by thread: [c# .net 2005] problem with moving start of world
- Next by thread: Mesh Intersect Confusion
- Index(es):
Relevant Pages
|