Tuesday, May 13, 2008

Camera and Transform Matrices in Papervision3D

I've had some troubles to fully understand the matrices system in Papervision3D: between the view matrix, the transform, the camera eye, etc, etc...
But I think I've got it now. All you need to know in order to make transformations between world and camera coordinate systems is this formula:

o.view = camera.eye * o.transform

In other words, any DisplayObject3D o has a transform matrix that represents its transformation in the world coordinate system. It also has a view matrix that represents its transformation in the camera coordinate system. The camera's eye matrix allows to pass from the world to the camera coordinate system. In papervision3D:

o.view.calculateMultiply(camera.eye, o.transform);

will compute your object's updated view matrix. In the other direction:


o.transform.calculateMultiply( invEye, o.view);

will update the object's transform according to its view matrix. Note that invEye is the inverse of camera.eye.

One last piece of advice: I've noticed that modifying a view matrix alone doesn't change anything. If you modify the view, you need to update the transform according to the second formula.

Wednesday, April 16, 2008

How to display text in papervision

I've been looking for a tutorial to display a simple text field within papervision without much success. I finally tumbled on this blog post where it was quite well explained. The example however might be a little long to demonstrate my sole purpose: how to display text in papervision.

So I've decided to put here an even simpler example to make things crystal clear:


// create your text field and set its content.
var t:TextField = new TextField();
t.text = "Hello world!";
// create a BitmapData of your wished width and height
var bitmap:BitmapData = new BitmapData(100,100);
// Fill bmp with the content of your TextField.
//It's as if you took a picture of t.

bitmap.draw(t);
// Create a material with the resulting BitmapData and you can use it on any DisplayObject3D!
var material:BitmapMaterial = new BitmapMaterial(bitmap);
material.smooth = true;
material.doubleSided = true;
var p:Plane = new Plane(material,100,100);
scene.addChild(p);


First observation is that it seems impossible to directly embed a UIComponent within papervision *sigh*. Whatever the UIComponent (Button, TextField, etc), it has to be put somehow in a texture and applied on a DisplayObject3D such as a Plane.

Or at least, I have no knowledge of another way to do it. Does anybody know better? My worry is that it may slow down the frame rate to display text in a texture rather than directly as what it really is: good old plain text.

Tuesday, April 15, 2008

Underground parking lot + empty bottles = Mario theme song

I just discovered this video which I confess, made me laugh a lot. That's crazy how some people have nothing better to do than aligning empty bottles, but the result is so funny that you can't really blame them, can you?


http://view.break.com/487616 - Watch more free videos