Papervision Pivot Points

I am back working with Papervision 3D, which is fun. I won’t go into too much detail on the project itself, but I needed to make 3D packaging that opens up and flattens out when a button on it is pressed. This means I will need to be pivoting planes again. The pivot point by default is in the center of the shape and I need it to pivot from the edges, but there is no built-in function to change its location.

With the DDA Power Pyramid, I overcame this hurdle by making the sides twice as tall as they needed to be and using a transparent image as the texture that only took up the top half. This way the pivot point was still in the middle, but it appeared to be at the base of the side.

With this project there are more sides to move and transparent images wouldn’t resolve the issue as easily. Luckily, Laurence steered me toward a tutorial that specifically faced this issue. Apparently, the solution lies in making objects to hold the objects.

For example, say you have a shape that is in a meta object called A. You will need to make another meta object and add A to it. So maybe… B.addChild(A);. Now to reposition the pivot, we must move the A object’s coordinates and then move the B object’s coordinates to make up for the change in A. So if we move A’s X position 100 to the right, we must move B’s X position 100 to the left. When you then render the scene the shape will be in the exact same place, but when you rotate B, the new pivot of the shape held deep inside will be 100 pixels to the side.

This is a useful method and can save some headaches that may have been faced using transparent images. Try it out on your own Papervision project and pivot away to your hearts content.