[Papervision3D] ISM in phunky is fixed
John Grden
neoriley at gmail.com
Tue Nov 27 10:20:35 PST 2007
man o man, this was a tricky little bugger but I think I finally nailed it.
ISM and VirtualMouse have been updated and I've tested it with the following
code. Just copy and paste into a new ActionScript project or create a new
AS file and use it with Flash as the main Document.
It addresses:
1. 2 different objects overlapping
2. 2 different objects using different types of materials (1 is movie the
other is a color material)
3. 2 different objects using different types of materials overlapping
4. all 3 types of event dispatch types: ISM, DO3D and MovieClip
5. finds your car keys in 3 seconds flat. Just kidding, I can't back that
up.
anyway, please give it a shot if you were having issues and please let me
know if it fixes your issues. again, this is in the phunky branch.
package {
import flash.display.Sprite;
import com.rockonflash.papervision3d.flex.utils.Papervision3DScene;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.objects.Plane;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.MovieMaterial;
import org.papervision3d.materials.BitmapMaterial;
import flash.display.Bitmap;
import flash.events.Event;
import org.papervision3d.events.InteractiveScene3DEvent;
import flash.events.MouseEvent;
import flash.ui.Mouse;
import com.blitzagency.xray.logger.XrayLog;
import flash.display.MovieClip;
import flash.display.BlendMode;
import org.papervision3d.materials.MovieAssetMaterial;
import org.papervision3d.utils.virtualmouse.IVirtualMouseEvent;
import com.blitzagency.xray.inspector.Xray;
import flash.display.DisplayObjectContainer;
import com.blitzagency.xray.logger.util.ObjectTools;
import com.blitzagency.xray.logger.util.PropertyTools;
import flash.display.DisplayObject;
[SWF(backgroundColor="0xFFFFFF", width="450", height="350",
frameRate="30")]
public class InteractiveSceneManager_test extends Sprite
{
private var pv3dContainer
:Papervision3DScene
private var scene :Scene3D;
private var plane :Plane;
private var clrMat :ColorMaterial
= new ColorMaterial(0x00ff00, 1);
private var bitmapMat
:BitmapMaterial;
private var log :XrayLog =
new XrayLog();
//private var xray :Xray = new
Xray();
//[Embed(source="textures/door.jpg")]
//private var doorTexture:Class;
public function InteractiveSceneManager_test()
{
init();
}
/*
CCCCC RRRRR EEEEEEE AAA TTTTTT EEEEEEE SSSSS
CCCCC EEEEEEE NN NN EEEEEEE
CC CC RR RR EE AAAAA TT EE SS CC
CC EE NNN NN EE
CC RRRRR EEEE AA AA TT EEEE SSSS
CC EEEE NNNNNN EEEE
CC CC RR RR EE AAAAAAA TT EE SS CC
CC EE NN NNN EE
CCCCC RR RR EEEEEEE AA AA TT EEEEEEE SSSSS
CCCCC EEEEEEE NN NN EEEEEEE
*/
public function init():void
{
// stuff is ready to go
pv3dContainer = new Papervision3DScene(true);
pv3dContainer.camera.zoom = 1;
pv3dContainer.camera.focus = 1100;
pv3dContainer.addEventListener(Event.ADDED_TO_STAGE,
handleAddedToStage);
addChild(pv3dContainer);
}
public function handleAddedToStage(e:Event):void
{
scene = pv3dContainer.scene;
//var bm:Bitmap = new doorTexture();
//bitmapMat = new BitmapMaterial(bm.bitmapData);
//bitmapMat.interactive = true;
clrMat.interactive = true;
var mc:MovieClip = new MovieClip();
mc.graphics.beginFill(0xff0000, 1);
mc.graphics.drawRect(0,0,200, 500);
mc.graphics.endFill();
mc.name = "movieMaterialMC";
var movieMat:MovieMaterial = new MovieMaterial(mc, false, true);
movieMat.interactive = true;
movieMat.name = "movieMat";
plane = new Plane(movieMat,200, 500, 3, 3);
plane.name = "plane_0";
var plane1:Plane = new Plane(clrMat,200, 500, 3, 3);
plane1.moveRight(100);
plane1.moveDown(100);
plane1.moveForward(50);
plane1.name = "plane_1";
mc.addEventListener(MouseEvent.MOUSE_OVER, handleMouseOver);
mc.addEventListener(MouseEvent.MOUSE_OUT, handleMouseOut);
mc.addEventListener(MouseEvent.CLICK, handleMouseClick);
plane.addEventListener(InteractiveScene3DEvent.OBJECT_OVER,
handleObjectOver);
plane.addEventListener(InteractiveScene3DEvent.OBJECT_OUT,
handleObjectOut);
plane.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK,
handleObjectClick);
plane1.addEventListener(InteractiveScene3DEvent.OBJECT_OVER,
handleObjectOver);
plane1.addEventListener(InteractiveScene3DEvent.OBJECT_OUT,
handleObjectOut);
plane1.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK,
handleObjectClick);
scene.interactiveSceneManager.addEventListener(
InteractiveScene3DEvent.OBJECT_OVER, handleISMOver);
scene.interactiveSceneManager.addEventListener(
InteractiveScene3DEvent.OBJECT_OUT, handleISMOut);
scene.interactiveSceneManager.addEventListener(
InteractiveScene3DEvent.OBJECT_CLICK, handleISMClick);
scene.addChild(plane);
scene.addChild(plane1);
addEventListener(Event.ENTER_FRAME, handleLoop);
}
public function handleMouseOver(e:MouseEvent):void
{
log.debug("**************MC OVER", e.target.name, e is
IVirtualMouseEvent);
var mc:MovieClip = MovieClip(e.currentTarget);
mc.graphics.clear();
mc.graphics.beginFill(0x0000ff, 1);
mc.graphics.drawRect(0,0,200, 500);
mc.graphics.endFill();
}
public function handleMouseOut(e:MouseEvent):void
{
log.debug("**************MC OUT", e.target.name);
var mc:MovieClip = MovieClip(e.currentTarget);
mc.graphics.clear();
mc.graphics.beginFill(0xff0000, 1);
mc.graphics.drawRect(0,0,200, 500);
mc.graphics.endFill();
}
public function handleMouseClick(e:MouseEvent):void
{
log.debug("MC CLICK", e.type, e.currentTarget.name);
}
public function handleObjectOver(e:InteractiveScene3DEvent):void
{
log.debug("**************OVER", e.displayObject3D.name);
}
public function handleObjectOut(e:InteractiveScene3DEvent):void
{
log.debug("**************OUT", e.displayObject3D.name);
}
public function handleObjectClick(e:InteractiveScene3DEvent):void
{
log.debug("**************CLICK", e.displayObject3D.name);
}
public function handleISMOver(e:InteractiveScene3DEvent):void
{
log.debug("**************ISM OVER", e.displayObject3D.name);
}
public function handleISMOut(e:InteractiveScene3DEvent):void
{
log.debug("**************ISM OUT", e.displayObject3D.name);
}
public function handleISMClick(e:InteractiveScene3DEvent):void
{
log.debug("**************ISM CLICK", e.displayObject3D.name);
}
public function handleLoop(e:Event):void
{
scene.renderCamera(pv3dContainer.camera);
}
}
}
--
[ JPG ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20071127/0a96584e/attachment-0001.html
More information about the Papervision3D
mailing list