MouseEvent3D at imported .3ds model not working

Software: Away3D 3.x

Mike Samuel, Newbie
Posted: 26 March 2012 06:32 PM   Total Posts: 30

Hello all,
First time poster here, so watch out smile

I’m having trouble getting MouseEvent3D working on an imported model.

The code I use is more or less taken from the beta 4 examples (The Ant and the Click event cubes)
The model loads fine, It’s exported from blender 2.6 as 3ds. The names, mesh, material, texture, all ok.
The Sign Plane is also working. It’s added, it has a red bound, and on hover the hand cursor

The loaded model shows the blue bounds around the mesh. Which leads me to belief I am doing something right, but on hover, nothing happens.

The only differences I can find in the the two approaches is that with the plane, I add it directly to the scene where as with the model, it is added to the loader, which is on the scene. But loader has no mouseEnabled or anything

Am I missing something or is , what I am try’n to do just not possible?

PS: I’m using Flex 4.6, FlashDevlop and the Swc download provided, I do not compile away3d myself

Any idea, pointers would be very much appreciated
Thanx

The main code parts use:

this is working

_sign = new Mesh(new PlaneGeometry(256128), _signMat);
...
_sign.addEventListenerMouseEvent3D.MOUSE_OVERonMouseOver);
_sign.addEventListenerMouseEvent3D.MOUSE_OUTonMouseOut);
_sign.mouseHitMethod MouseHitMethod.MESH_CLOSEST_HIT;
_sign.mouseEnabled true;
_sign.showBounds true;
_sign.bounds.boundingRenderable.color 0xff0000;
_scene.addChild(_sign); 

This is only partially working

private function onAssetComplete(event:AssetEvent):void
{
if (event.asset.assetType == AssetType.MESH)
    
{
 
var m:Mesh event.asset as Mesh;
 
m.castsShadows true
        
m.mouseEnabled true;
 
m.addEventListenerMouseEvent3D.MOUSE_OVERonMouseOver);
 
m.addEventListenerMouseEvent3D.MOUSE_OUT,onMouseOut);
 
m.mouseHitMethod MouseHitMethod.MESH_ANY_HIT;
 
m.showBounds true;
 
m.bounds.boundingRenderable.color 0x0000ff;
}


The events, simplified but working

private function onMouseOver(event:MouseEvent3D):void
  {
   Mouse
.cursor "hand";
}
private function onMouseOut(event:MouseEvent3D):void
  {
   Mouse
.cursor "auto";
   

Ontheronix, Jr. Member
Posted: 03 April 2012 01:19 PM   Total Posts: 37   [ # 1 ]

try trace(“blabla”) in stead of mouse.cursor, i’m struggling with the handcursor atm, sometimes it shows, sometimes it doesn’t.

My qeustion: what’s the difference between MESH_ANY_HIT and MESH_CLOSEST_HIT ?

   

Vice, Member
Posted: 03 April 2012 02:55 PM   Total Posts: 58   [ # 2 ]

make a trace in your onMouseOver function to check if mouseover etc. running correct. and it is best practice to put the mesh into a container and then add the events to the container.

   

Mike Samuel, Newbie
Posted: 03 April 2012 04:52 PM   Total Posts: 30   [ # 3 ]

@Ontheronix,
I do remember I read about the differences somewhere, but I can’t find it anymore, however, As I was play’n around with the option, I turned the hit Methode to ‘MouseHitMethod.BOUNDS_ONLY’ and ever since then, onHover, OnClick, they all fire as expected.

@Vice
True, and usually, I do put my objects into containers. But this loads the model from 3ds file, and I am not sure how to do that using the ModelLoader.
Are you suggesting I take each mesh in the ‘onAssetComplete’ add it into a container and then to the scene?

Regards

   

Ontheronix, Jr. Member
Posted: 03 April 2012 05:06 PM   Total Posts: 37   [ # 4 ]

offtopic:
BOUNDS_ONLY is the fastest, but if you need details like UV on the mouseevent3d, than you have to set it to MESH_ANY_HIT or MESH_CLOSEST_HIT. That’s the only thing i know…

   

Vice, Member
Posted: 04 April 2012 08:34 AM   Total Posts: 58   [ # 5 ]

after loading your model e.g.:

var mesh : Mesh = Mesh(event.asset);

var container : ObjectContainer3D = new ObjectContainer3D();

container.addChild(mesh);

and then do the other stuff…

at least bring it to the scene like:

_scene.addChild(container);

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X