I dwelt on Papervision3D as part of a project and I wanted to test its integration in a project MXML. Unfortunately, I realized that most tutorials on the subject if not all, speak of creating a project in ActionScript 3. So I create classes for the integration of an object papervision3D as MXML tag, allowing for easy inclusion of a 3D scene in a Flex project. I propose you a small example showing the use of these classes within a project MXML.
Example available here with the sources. The explanations are in the following article ... I am inspired by this tutorial on creating a scene and its generic initialization to create a new class PV3DScene.
I added 4 main things:
- Extending the Canvas class instead of Sprite in AS3 projects
- The option of not rendering to calculate each frame with the variable needRender and adding a method invalidateScene (which saves a lot of CPU in the case of a static scene!)
- The scaling of the scene depending on the size of the canvas
- The creation of objects in the scene using the method as add3DObject and remove3DObject and adding a childrenObjects Array
I then create a class PV3DObject to manage the interactivity type models imported from Collada autres.Le result is the ability to define 3D objects like this:
public class FxCube extends PV3DObject (
public var faceWidth: Number = 500;
public var quality: Number = 20;FxCube public function () (
super ();
)override protected function createChildren (): void (
var ml: MaterialsList = new MaterialsList;
var mat: BitmapFileMaterial = new BitmapFileMaterial ( 'fx.jpg');
ml.addMaterial (mat, 'all');
addChild (new Cube (ml, faceWidth, faceWidth, faceWidth, quality));)
)
And additions to the 3D component in an MXML component in this way:
<mx:Panel>
<pv3d:PV3DScene id="scene3D" width="90%" height="90%">
<pv3d:childrenObjects>
<objects:FxCube faceWidth="400" id="cube" />
</ pv3d: childrenObjects>
</ pv3d: PV3DScene>
</ mx: Panel>
The complete sources of the project (including papervision3D) are available here. Namely it is necessary for the compilation of available sources of Papervision.
This is described in this tutorial, but in order to simplify your task, I will include in the project a copy of these sources and it is just necessary to add these sources in the Source Path through the project: Project menu> Properties> Flex Build Path> Source Path Tab> Add Folder ... and select the folder named PV3D_GreatWhite_rev428.
A second example on the use of Collada object format is being prepared. We'll see how to add an object from 3DSMax into papervision and how to interact with the mouse with him.
If you come for the first time on Flex-info.fr, you can subscribe to the RSS feed. Thank you for your visit!





















February 16th, 2008 at 15 h 44 min
Super article, relevant and clear
February 16th, 2008 at 18 h 04 min
Yes, very good article indeed!
February 21st, 2008 at 11 h 38 min
Great article!
How could I do to import a Collada format object with the class PV3DObject?
Again thank you for this very good tutorial
June 10th, 2008 at 23 h 18 min
thank you for this picture!
September 15th, 2008 at 21 h 44 min
thank you for the ticket, it's always interesting to read. I wonder however why this digression: I wanted to test its integration in a project MXML?
September 15th, 2008 at 22 h 13 min
thank you to you for cett image!
October 7th, 2008 at 15 h 39 min
I can not find the source file: PV3D_GreatWhite_rev428
I have a folder com/fr/flexinfo/pv3d /
but that's all ... I can not, qq'un can help?
thank you
November 14th, 2008 at 19 h 32 min
very interesting ticket.
How can we retrieve an event click on an object.
ex: I create a new kind of type object map (FxCard) along the lines of the cube.
I load several objects on the scene how récépérer event click on an object. For example zoom on this object.
November 25th, 2008 at 17 h 09 min
Hi Mickael, even the Americans speak of you with this article!