Join Seb Lee-Delisle for an in-depth discussion in this video Managing hierarchy to add one object to another, part of Papervision3D 2 Essential Training.
So now in this movie, we're going to look at how we can add one object inside another, and then rotate the parent objects and see what effect that has on its child. So, let's just take a look at this Exercise File. Scroll down here. You can see this bit is actually creating our Earth object and same is the example as before, and then we're adding that into the scene here. And then here, we're creating a DAE object loading in the file and moving it over to the right of 300 units. Then crucially instead of adding that into the scene, we're adding it inside the sphere.
So, we're going to add it inside the Earth objects. Of course, it's moved over to the right. So it's not going to be inside of the Earth itself. It's going to over to the right of that Earth. Here, we're adjusting the camera settings, adding an event listener to the enterFrame as before. Let's take a look at the enterFrame function here. You can see that the sphere is rotating around the Y axis and then the dae model is actually rotating it around its own axis as well. So let's take a look at that. Now you can see we've got the Earth there and as it rotate, you can now see our cow model also rotating around the Earth.
So, the cow model actually inherits the rotation from the Earth. You could say that the cow is a child of the Earth. So, in order to properly understand exactly what's going on here, let's take a look inside Flash CS5. Now, here's a little example to illustrate what's going on here. On the left, we've a circle and that's rotating here on the Timeline there. Here is a little square. This is set for display object and this is set for a movie clip on the stage.
Let's just publish this file. You can see that the wheel is turning around and the square is not getting affected by it. Now, let's cut this off the stage and double- click into this movie clip and paste it in. So now, this object is inside this wheel movie clip. So now when we come up to the parent, you can see as that wheel rotates around, the square also rotates around with it. So, this happens in the 2D display object hierarchy in Flash and it also works in exactly the same way in the 3D hierarchy in Papervision3D.
So, let's just look out at the 3D version again. And here it is exactly the same thing excep of course this works fully in three-dimensions. So now, you've learnt in this movie, how you can add one Display Object 3D inside another, and how that child object then inherits the properties of its parent.
Users should have a basic knowledge of Flash Builder and Actionscript 3.
- Creating 3D primitive shapes
- Controlling rotation
- Moving the camera in 3D space
- Creating a particle field with depth-of-field blur
- Importing models from external applications
- Making a simple 3D game
- Using ViewportLayers to selectively render and sort layers
- Placing a custom 3D model into an augmented reality scene
- Creating interactive carousals
- Creating interactive grids
- Working with particles and billboards
Skill Level Beginner
Q: Despite setting Mac OS X to open SWF files with the debug player, it still reverts back to other applications. What is causing this, and how can it be fixed?
A: If you are encountering this problem, check out the solution posted here:
Q: In the "About the COLLADA.dae file format" movie in the "Importing 3D Models" chapter, which version of Maya does the author use to open the included Maya files?
A: The author uses Maya 2010 to open the files.
Q: FlarToolkit.swc is no longer available to download. Where can I find a copy?
A: Download a copy of FlarToolkit here.
Q: Can I use multiple markers with FlarToolkit?
A: No, The swc version of FlarToolkit only supports one marker.