mouseEvent3D and material name

0 views
Skip to first unread message

Cyril D.

unread,
Jul 9, 2009, 12:13:21 PM7/9/09
to away3...@googlegroups.com
Hello,
i'm looking for solution to resolve a problem on mesh event
here's the problem:
I load a collada file that i've made with sketchup
This collada present 2 room

each room use a unique material.

I'm looking for a way to implement differente action on each room/material that is hovered

So i thinked that the easiest way was to specified a name for a material, and add action when i hovered this material...

But the only thing that i can have when i hovered a room is the name of the shape (ex: mesh1 / mesh2).

I can't (or don't know) how specified  a name to mesh in sketchup...,
but i can specified a name to a material.

i've not find the way yet.

Can you help me please ?
thanks


Colir

ben

unread,
Jul 9, 2009, 3:41:10 PM7/9/09
to away3d.dev
Hi Cyril !
" implement differente action on each room/material "
well if you won't change the material, why not use the mesh as
reference for your actions ??

Object3D(yourMesh).addOnMouseOver(action);

function action(e:MouseEvent3D):void
{
var id:String = e.target.name;
switch(id){
case "horseAss":
kickit();
break;
case " LauraBushAss"
kickItTwice();
break;
case " CarlaAss"
kickItTen();
break;
default:
trace(e.target.name);
}
}

if not, I know that a materialData (including name property) do exist,
but don't know how to access it... take a look at the API !

Away3D

unread,
Jul 10, 2009, 2:58:26 AM7/10/09
to away3d.dev
The problem is that i will have a lot of room (it will be a plan of an
hospital) and i can't name my mesh in sketchup...so it will be very
long to setup correct information on correct room:
I will have to trace each mesh name and associated the room action....
and find for example " mesh12 = urgency " it will be very long....
an another trouble is that my room have commun plan so 1mesh can be 2
or more room...
It will be very easier if i can use material: in sketuchup i define
the name of material with the name of a service and apply action for
one color...

I see in the api an intersting property which is "view.mouseMaterial"
but i haven't find the way to use it....
thanks

Rob Bateman

unread,
Jul 15, 2009, 12:13:04 PM7/15/09
to away3...@googlegroups.com
Hey Cyril

the MouseEvent3D returns a property "material" which is the material instance you have rolled over in the mesh. if you use an if statement in your listener, you can check which instance is which by comparing it to all material instances:

if (mouseEvent3D.material is myFirstMaterial)
...do something
else if (mouseEvent3D.material is mySecondMaterial)
...do something else
else if (mouseEvent3D.material is myThirdMaterial)
...etc

I agree that keeping a name property in the material object would help though - will look into implementing that in the future

cheers


Rob
--
Rob Bateman
Flash Development & Consultancy

rob.b...@gmail.com
www.infiniteturtles.co.uk
www.away3d.com

CUfon

unread,
Jul 20, 2009, 3:57:37 AM7/20/09
to away3d.dev
Thanks for you suggest
but i dont understand something
here is my code:

var room = Collada.load("floor0.dae",{materials:
{urgenceID:colorShad1,Color_A06ID:colorShad2},autoLoadTextures :
false,scaling:0.005});
room.addOnSuccess(onLoaderSuccess);

function onLoaderSuccess(event:LoaderEvent):void{
room = ObjectContainer3D(event.loader.handle);
room.addOnMouseOver(onMouseOverOnObject);
View.scene.addChild(room);
}

function onMouseOverOnObject(event:MouseEvent3D):void {
var object:Object3D = event.object;
var myMesh = event.object as Mesh
trace(myMesh.material)
}

this always return "null"...and i don't understand why
can you help me ?
> rob.bate...@gmail.comwww.infiniteturtles.co.ukwww.away3d.com

Peter Kapelyan

unread,
Jul 20, 2009, 9:13:55 AM7/20/09
to away3...@googlegroups.com
Can you try something like:

trace(event.children);
--
___________________

Actionscript 3.0 Flash 3D Graphics Engine

HTTP://AWAY3D.COM

CUfon

unread,
Jul 20, 2009, 11:34:08 AM7/20/09
to away3d.dev
return that there a no property "children" on mouseevent3D

Peter Kapelyan

unread,
Jul 20, 2009, 11:40:36 AM7/20/09
to away3...@googlegroups.com
whoops I wrote that when I was sleepy, sorry :O

maybe event.target.children ?

I was hoping you'd be able to get at least the children names, so you can then maybe access each one.

-Pete

Colir

unread,
Jul 20, 2009, 11:46:22 AM7/20/09
to away3d.dev
in fact i will be able to have the material name whan i rollover it...
but nevermind i find an other way to do what im looking for.
thanks for your help
Reply all
Reply to author
Forward
0 new messages