Tiago's Weblog Code & Technology Aficionado – Come for the Flash, stay for more!

Papervision3d – Registration point workaround

I've been working with Papervision for a few weeks now, as I got 2 assignments where I had to use pv3d to enter the next dimension, after a fairly long learning curve I'm quite up the basics and ready to work on it, one of the downsides of the current version was the issue of not being able to move the registration point, also called pivot point or Anchor Point.

The workaround which I've worked with is pretty simple and it doesn't afford a lot of work, the downside is that you really need to develop a visual feeling for 3d space, which is not simple if you never worked with 3d packages like 3ds max or Maya

Let's have a look at how Papervision objects are built, in this example I'm going to take a simple primitive like a plane, have a look at the graphic below to understand how a plane is built.

pv3d_01.jpg

So as you see the registration point of the plane has been created exactly in the middle of it, which is actually ok, but what if you want to rotate the plane on it's left edge? That won't work.. So the solution is just to place the object (in our case the plane) inside of a displayObject3d and reposition the plane inside the displayobject3d.

pv3d_02.jpg

As you have seen on the graphic above, we insert our plane inside the displayObject3d (marked black) and we are now able to rotate the "plane" (marked red) from it's left edge. Let's have a look at the code.

1
2
3
4
firstContainer = new DisplayObject3D(); 
primitive1.x = 505;
firstContainer .addChild(primitive1);
scene.addChild(firstContainer);

First we create our DisplayObject called firstContainer, we position the primitive (in our case the plane) at the x coordinate 505, then we add the primitive1 to our firstContainer and last but not least you add the container to the scene.

From now on instead of rotating primitive1 we only rotate the whole firstContainer and the primitive will follow it as it's embedded in it.

Comments (6) Trackbacks (0)
  1. This is great. Very simple, but something I somehow overlooked. Thanks!

  2. Much appreciated. Thanks man.

  3. I was struggling for a while trying to properly position my planes. Then I thought “Hey maybe the registration point…”, then found your article and it confirmed that registration points are in the centre of the planes. Thanks very much!

  4. First hit on google, and it was exactly what I needed.

    Thanks!

Trackbacks are disabled.