The Green Room

Thursday, August 6, 2009


This is my most ambitious project yet. It integrates UV Mapping with a 3D model that I created in Blender. Also I've integrated a 3D interactive page flip using the as3mod library. It works with most flash 3D engines.

I created the 3D mesh in Blender, UV Mapped the mesh, exported to a .DAE file, and imported the .DAE into papervision at run-time. It works really well although I had a lot of performance issues at first with triangles z-fighting. It is a common problem with the papervision rendering engine.
After reading through many forums, I finally figured out how to solve this problem and keep my cpu cylces low. I used separate viewport layers for each object that was having z-fighting issues.

here's an example

var obj_layer:ViewportLayer = viewport.getChildLayer(my_3D_Display_Object);
obj_layer.layerIndex = 1;

//tell the viewport to sort by z-indexing
viewport.containerSprite.sortMode = ViewportLayerSortMode.INDEX_SORT;

//I have an array of viewportLayers that I send to the rendering engine.
layers.push(obj_layer);


I was able to further tweak the performance by only removing things from the "layers" array that did not need updating once they've been rendered. For example...when you click on the book, the camera zooms in. Once it's stopped zooming in, it no longer needs to update the room mesh, just the book. So I remove the room's viewport layer from the layer array and viola...the rendering engine does not perform calculations on it until the user clicks the book's back button to return to the room view.

There are still a few z-index issues as well as camera rotation issues. The room does not spin, the camera spins around the room, I just constantly update the cameras degrees and run them through my formula, thus moving the camera in a circular motion around the 3D scene.


camera.x = 3800 * (Math.sin(degrees * (Math.PI/180)));
camera.y = 3800 * (Math.cos(degrees * (Math.PI/180)));
camera.rotationZ = (360-(degrees-180));
degrees += inertiaX;
if (!dragging) {
inertiaY *= .92;
inertiaX *= .92;
}

I also made the background design and the wallpaper myself in photoshop:)

0 comments:

Post a Comment