addChild problem

Software: Away3D 4.x

datouaizi, Member
Posted: 15 March 2012 08:44 AM   Total Posts: 98

i create a floor model with many doors.
that i can add doors into floor use for loopping.

if i have many floors,and many doors.
every floor can be doubleCkick to be hided,and door in floor should be hide also. problem is how to add doors into certain floor? use for loopping?


away3d doesn`t` support group!

in flare3d .it support group .floor and it`s doors is child of group ,easy to hide floor and it`s` doors.

   

Avatar
Matse, Sr. Member
Posted: 15 March 2012 09:10 AM   Total Posts: 149   [ # 1 ]

It’s a bit hard to understand what you mean, any class extending ObjectContainer3D, and ObjectContainer3D itself are “groups” : they can have children, and removing the group will remove all children of that group.

   

datouaizi, Member
Posted: 16 March 2012 03:09 AM   Total Posts: 98   [ # 2 ]
Matse - 15 March 2012 09:10 AM

It’s a bit hard to understand what you mean, any class extending ObjectContainer3D, and ObjectContainer3D itself are “groups” : they can have children, and removing the group will remove all children of that group.

I create two floors ues 3dmax named 001001 and 001002,
and each floor has many doors ,named door_001001(building1floor1),and door_001002(building1floor2).

I want achieve the effect that ,when click floor named 001001 ,and doors named door_001001 hide too.

now I must serach doors named door_001001,and added into floor 001001 in away3d.use
for(var i:int = 0 ;i< 3ds.numchildren ; i++)
{
  if(doorName == door_001001)
  {
    001001.addChild(door_001001)
  }else if(doorName == door_001002))
  {
    001002.addChild(door_001002)
  }
}

but flare3d ,i can group floor and it`s` doors in 3dmax then export named 001001 .doors auto become floor child.

so ,if i have lots of floors and ten thousands of doors ,what shoud i do?

 

   

Avatar
Matse, Sr. Member
Posted: 16 March 2012 02:10 PM   Total Posts: 149   [ # 3 ]

Ok I get it now : away3D doesn’t import groups from 3DS format.

I would try 2 approaches :
1. Use a mesh instead of a group, since Mesh extends ObjectContainer3D it can be used exactly the same : you just need to test if the import and parsing in away3d keeps the hierarchy.

2. Just use a naming convention like you seem to have already and re-create your groups using that when your program starts.

if your doors are named doorxxx_<floorID> you can use the underscore “_” as a delimiter for the split function.

for example :

var floorLibrary:Object {};
floorLibrary["001001"[];
floorLibrary["001002"[];

var 
door:Mesh;
var array:Array;
for(var 
i:int ;i3ds.numchildren i++) {
  door 
3ds.getChildAt(i);
  array = 
door.name.split("_");
  
floorLibrary[array[1]] door;

You can adapt that to fit your needs

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X