[Papervision3D] InteractiveSceneManager on a Cube

juanit0 juan at sonikweb.com
Mon Nov 26 13:31:30 PST 2007


Hi, I've been working for a few days to get a Cube working with interactive
faces and movieclips streaming FLV's, I based my work on the Cube example
file. 

Right now I'm able to trace the clicked face with
"trace(e.face3d.material.name);" but I can't find how to stop/play the
movieclip or how to interact with buttons the elements it contains. Any help
would be appreciated, I think I read all the threads around on the subject
but I'm stucked, I'm using the 1.7 version.

Thanks!

// ___________________________

package com.components
{
import flash.display.*;
import flash.events.*;

// Import Papervision3D
import org.papervision3d.events.*;
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import org.papervision3d.utils.*;
import org.papervision3d.objects.*;
				
public class BellCube extends Sprite
{
	// ___________________________________________________________________
Static

	static public var SCREEN_WIDTH  :int = 1024;
	static public var SCREEN_HEIGHT :int = 768;

	// ___________________________________________________________________ 3D
vars

	private var container :Sprite;
	private var scene     :InteractiveScene3D;
	private var camera    :Camera3D;
	private var cube      :Cube;
	private var xRot      :Number;
	private var yRot      :Number;
	private var _ism	  :InteractiveSceneManager;
	
	// ___________________________________________________________________ main

	public function BellCube()
	{
		init3D();
		createCube();
		this.addEventListener( Event.ENTER_FRAME, loop );
	}


	// ___________________________________________________________________
Init3D

	private function init3D():void
	{
		// Create container sprite and center it in the stage
		container = new InteractiveSprite();
		addChild( container );
		container.x = SCREEN_WIDTH  /2;
		container.y = SCREEN_HEIGHT /2;
		container.name = "_container";
		 
		// Create scene
		scene = new InteractiveScene3D( container );
		_ism = scene.interactiveSceneManager;
		_ism.faceLevelMode = true;
		_ism.buttonMode = true;
		
		// Create camera
		camera = new Camera3D();
		camera.zoom = 1;
		camera.focus = 1650;
		camera.z = -1500;
		
		//initial rotation
		xRot = 180;
		yRot = 0;
	}


	// ___________________________________________________________________
Create Cube

	private function createCube()
	{
		// Attributes
		var cubeWidth :Number = 1000;
		var cubeHeight :Number = 565.2;
		var quality :Number = 6;
		
		var front:InteractiveMovieAssetMaterial = new
InteractiveMovieAssetMaterial("Front", true, true);
		var back:InteractiveMovieAssetMaterial = new
InteractiveMovieAssetMaterial("Back", true, true);
		var left:InteractiveMovieAssetMaterial = new
InteractiveMovieAssetMaterial("Left", true, true);
		var right:InteractiveMovieAssetMaterial = new
InteractiveMovieAssetMaterial("Right", true, true);
		var top:InteractiveMovieAssetMaterial = new
InteractiveMovieAssetMaterial("Top", true, true);
		var bottom:InteractiveMovieAssetMaterial = new
InteractiveMovieAssetMaterial("Bottom", true, true);
		
		// Materials
		var materials:MaterialsList = new MaterialsList(
		{
			front:  front,
			back:   back,
			right:  right,
			left:  left,
			top:   top,
			bottom: bottom
		} );
		
		front.name = "front";
		back.name = "back";
        right.name = "right";
		left.name = "left";
		top.name = "top";
		bottom.name = "bottom";
		
		// Create the cube: materials, width, depth, height
		cube = new Cube( materials, cubeWidth, cubeWidth, cubeHeight, quality);
		
		//add cube to the scene and set initial rotation angle
		scene.addChild( cube, "Cube" );
		cube.rotationY = xRot;
		cube.rotationX = yRot;
		
		//ISM
	
scene.interactiveSceneManager.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK,
handleClick);
	}


	// ___________________________________________________________________ Loop

	private function loop(event:Event):void
	{
		update3D();
	}
	   
	protected function handleClick(e:InteractiveScene3DEvent):void
	{
		trace(e.face3d.material.name);
	}

	
	private function update3D():void
	{		
		// Render
		scene.renderCamera( this.camera );
	}
}
}

// ___________________________
-- 
View this message in context: http://www.nabble.com/InteractiveSceneManager-on-a-Cube-tf4877784.html#a13958174
Sent from the Papervision3D mailing list archive at Nabble.com.




More information about the Papervision3D mailing list