Home > Papervision3d > Actionscript 3 – Papervision3D Interactive Collada, DAE objects.

Actionscript 3 – Papervision3D Interactive Collada, DAE objects.

If you dont know what is a collada object. The Collada files, are 3d models exported to xml format. With Papervision3D we can create the models into our flash. If you need more info you could read the next link

Collada Files in wikipedia

If you need interactive collada, must meet the following requirements:

  • Thw viewport must be interactive…. viewport.interactive = true.
  • All materials of the DAE object must be interactive also.
  • You need to add a listener for the InteractiveScene3DEvent that you want into each child of your collada.

Here a example how to set all materials to interactive :

1
2
3
4
5
6
7
private function setInteractiveMaterials(targetObject:DisplayObject3D, value:Boolean):void
{
	for each(var mat:MaterialObject3D in _targetObject.materials.materialsByName)
	{
		mat.interactive = value;
	}
}

How to put a eventListener into each child.

1
2
3
4
5
6
7
8
private function addEventListeners(displayObject:DisplayObject3D, eventType:String, listener:Function):void
{
	displayObject.addEventListener(eventType, listener);
 
	for each(var child:DisplayObject3D in displayObject.children) {
		addEventListeners(child, eventType, listener);
	}
}

The call of the last function will be this:

1
addEventListeners(_obj, InteractiveScene3DEvent.OBJECT_PRESS, daePressedHandler);

I’m not sure if this way is the better. If you have some idea or suggest please post your comments.

VIEW EXAMPLE
DOWNLOAD EXAMPLE FOR CS4
DOWNLOAD EXAMPLE FOR CS3



Categories: Papervision3d Tags:
  1. November 6th, 2009 at 05:35 | #1

    Thanks! This helped us but we had to add the missing caurina and PV3D classes as well. :)

  2. Jake
    November 30th, 2009 at 09:18 | #2

    What is the missing code as i can’t seem to get the example working. Thanks

  3. November 30th, 2009 at 09:40 | #3

    Hi Jake, sorry about that. You need to include Tweener and Papervision3D libraries in your source path of flash. Or directly put the sources into the same folder of the example.

  4. January 6th, 2010 at 18:29 | #4

    As much as Flex is a powerful tool for scripting, I would like to stay in the Flash AS3 environment for now(Artist). Is it possible for you to give a demo using CS3 structure. You are the only one who seems to have solve to problem of DisplayObject3d material being interactive with functions. I tried to translate from flex to CS3, but not completely understanding constructors I get lost. I am new to having to writing logic on visuals. Help please.

    Note: I am a Mac please plain text, zip

  5. January 6th, 2010 at 19:44 | #5

    Hi Phaze, now you could download the example for cs3. http://www.miguelmoraleda.com/examples/daeInteractive.rar Good Luck

Spam Protection by WP-SpamFree

Get Adobe Flash playerPlugin by wpburn.com wordpress themes