Showing posts with label Papervision. Show all posts
Showing posts with label Papervision. Show all posts

2008-09-08

Papervision 3D hand cursor

viewport:Viewport3D's property buttonMode is what control if a hand cursor should show on ALL or NON 3D objects. If buttonMode=true the hand cursor will show whether or not the materials are interactive, or if you are listening for InteractiveScene3DEvents.

So if you need hand cursor to show all time, set viewport.buttonMode=true; and if you do not want a hand cursor anytime, set viewport.buttonMode=false;

If you need to show a hand cursor on specific target objects, you should set viewport.buttonMode=false; and then have each target object to set listeners. In those callback functions you must use CursorManager.setCursor(id:Class) | CursorManager.remove...

2008-08-31

Papervision 3D Framerate

Let us share some constructive hands-on tips or trix on how to increase framerates. There's a lot of design issues from modeling 3D-objects to bind them to value-/business objects (classes). However, you should also take the rendering principals of the Flashplayer and your 3D-API in consideration! The gems in this topics may be, in no particular order, under clever headlines, so feel free to contribute by comments.

1) Override Flex default framerate of 24 by setting the desired framerate Application property in *.mxml (haven't got it to work from CSS). Try framerate 60, and hope that the Flashplayer may reach the fps of 40 once in a while.

2) Ask your self when and why you need to run onEnterFrame()! Even for a design built with constant movement in mind, it is a good strategy to provide for situations where a 3D world is allowed to freeze for a couple of seconds. If you can make it freeze without the user notice it - good for you. You will need that time to load additional assets or resources.

IMPORTANT!!! Try NOT to use onEnterFrame() at all in your 3D viewport rendering engine! Try the Timer intervall instead. And above all - try NOT to use two or more onEnterFrame()-callbacks in parallell, that will probably sink you application framerate below 10 fps.

In PV3D all DisplayObject3D have a pointer to the scene or context they belong to. Therefor you may choose to use the Scene object as the eventdispatcher for such events as PLAY and STOP to control when to stop or run the onEnterFrame.

3) If you know, or if the 3D object or face itself know that it should be invisible - set its visibility to false. In that way the the culling process does not even need to calculate.

4) Z-depth and culling calculus are process intensive. One finding I had was with a cube, or rather six individual planes, with no awareness of eachother, in a group forming a cubelike shape. I wanted to keep the cube in constant movement of a Perlin noiced sine function in each degree of freedom (DOF). The cube was rotated with in a slow wobbeling motion showing the same three faces to the camera, two sides and the rooftop. I found that the framerate decreased when one face - the rooftop - had it's normal almost perpendicular to the camera. The more the rooftop pointed it's normal direction towards the camera the framerate increased.

Thus, a large surface with a tiny projection to the view plane is more computationally heavy than when the same side projects more of its surface to the view plane! By rotating the default angle of my cube slightly, the culling did not kick in, and I increased the framerate by two times.

5) Over all for FlashPlayer rendering, check how Bitmap Cache Policy can be used in your project..

2008-08-30

3D General

Let's talk about how to optimize 3D for Flex. Keep it low poly, and simple texturing to allow more cpu and framerate. You will need the power for animation in both 3D viewport and 2D. There are several 3D API's and their offsprings for Flex/Flash developers out there. I tried Sandy, but got stucked with Papervision - in the summer of 2008 the branch GreatWhite Effects. Whether they are called GreatWhite, Away3D or anything else I believe in general that it really doesn't matter which one you choose. You should try them all, but you can't be an expert on all of them, and you should choose the one targeted to solve your specific problems or design needs.

3D on the web is not to be compared to modern 3D technology for film effects, computer games, or game consols! The open source community mentioned aboved are doing a tremendous job putting effort into making the API's both stable and effectfull, but as long as it is all about software rendering we must consider following when starting a new project:

a) From a technical point of view, keep it simple shading, low poly, and light-weight texturing!
b) From a design point of view - are you sure 3D is going to add to user experience at all?

These are two mayor considerations when first meeting your client. You don't want to end up with a disapointed client stating that you did not live up to their expectations!

... to be continued