2158 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says

Hi guys, I have a question, I want to load a 3D human model into papervision and then when someone clicks different parts of the human body things will happened…. Loading a 3D model is easy but any idea how to make different parts active (addEventListener) ?

271 posts
  • Bought between 1 and 9 items
  • Contributed a Tutorial to a Tuts+ Site
  • Europe
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 5 000 and 10 000 dollars
07happydays says

You must do something like this:

var child : DisplayObject3D = object.getChildByName(“mesh”, true); child.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, objectClickHandler, false, 0, true);

Or something like this for all:

for each(var child : DisplayObject3D in obj.children) { child.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, objectClickHandler, false, 0, true); }

2158 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says

You must do something like this:

var child : DisplayObject3D = object.getChildByName(“mesh”, true); child.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, objectClickHandler, false, 0, true);

Or something like this for all:

for each(var child : DisplayObject3D in obj.children) { child.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, objectClickHandler, false, 0, true); }

Yeah ok but how can I divide the mesh into sections, so I can add different listener to different parts of the body ?

271 posts
  • Bought between 1 and 9 items
  • Contributed a Tutorial to a Tuts+ Site
  • Europe
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 5 000 and 10 000 dollars
07happydays says

Maybe this will help you.

function daeLoadHandler(event : Event) : void { var daeInstance = event.target; }

for(var name : String in daeInstance.children)
{
    var mesh = daeInstance.getChildByName(name);
}
for(var name:String in mesh.materials.materialsByName)
  {
       var meshMaterial : MaterialObject3D = mesh.materials.materialsByName[name];
       meshMaterial.interactive = true;
  }
mesh.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, animateDae, false, 0,    true);
2158 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says

Thanks for that, I am not really looking into coded solution just wanted to hear from you, as far as I know when you load a 3D model it is recognize as one single object so it is hard to determine what part of it was clicked…

271 posts
  • Bought between 1 and 9 items
  • Contributed a Tutorial to a Tuts+ Site
  • Europe
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 5 000 and 10 000 dollars
07happydays says

Yes, but if you will divide your dae object into sub-objects and you will give them names in maya, 3d studio or whatever, you can use this solution. :)

2158 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says

Yes, but if you will divide your dae object into sub-objects and you will give them names in maya, 3d studio or whatever, you can use this solution. :)

Oh this is great :D I will have to do that! :)

by
by
by
by
by
by