Tutorial: Making Your PV3D Object Interactive



Making Your PV3D Object Interactive Screenshot

Objective

  • Learn how to make your Papervision3D object interactive.

Prerequisite

Files Required

Let’s Get Started!

From the last tutorial where I loaded an external image using BitmapFileMaterial, you should have guessed that this tutorial is next to come. *lol~* The purpose of breaking them up into 2 separate tutorials is to modularise them, just like programming. ;)

First off, we have to edit our viewport instance in the init3D function.

viewport = new Viewport3D( 0, 0, true, true );

The fourth parameter, “interactive”, determines whether the viewport should listen for Mouse events. Since we want to make things interactive, we pass in true for it.

[UPDATE]: With thanks to Marco for pointing this out, to show the hand cursor when rolling over interactive objects, you can add the following line after you create the viewport instance.

viewport.containerSprite.buttonMode = true;

Next up, in our createPlane function, we have to change the interactive property of the material that we created for the plane to be true as well.

material.interactive = true;

To listen for the events, we will add the event listener in the addEventListeners function:

plane.addEventListener( InteractiveScene3DEvent.OBJECT_CLICK, __onPlaneClick );

(Note: Don’t forget to import the InteractiveScene3DEvent!)

To wrap things up, we have to create the new listener function __onPlaneClick, which for the purpose of this tutorial, navigates to my blog’s RSS feed. :D

private function __onPlaneClick ( e:InteractiveScene3DEvent ):void 
{
	navigateToURL( new URLRequest("http://feeds.feedburner.com/flashmech"), "_blank" );
}

Final Note

At this point of writing, it seems that there’s no easy way to make use of useHandCursor. From my research online, probably the best way to do that is from Papervision 2’s tutorial of Advanced Interactivity 2.

Hope the guys over at Papervision3D will add this functionality into the engine soon. :)

AddThis Social Bookmark Button


3 Comments to “Tutorial: Making Your PV3D Object Interactive”


rss Comments RSS
trackback Trackback
  1. Marco on July 14th, 2008 at 6:27 pm

    This will enable the hand cursor for the viewport.

    viewport.containerSprite.buttonMode = true;

  2. flashmech on July 14th, 2008 at 9:37 pm

    Thanks Marco for the tip! :D

  3. Bookmarks about Interactive on September 20th, 2008 at 6:30 am

    […] - bookmarked by 5 members originally found by hannahp on 2008-08-25 Tutorial: Making Your PV3D Object Interactive http://blog.flashmech.net/2008/07/tutorial-making-your-pv3d-object-interactive/ - bookmarked by 3 […]

Leave a reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">