Advanced Question Parent/child assistance

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,728
Reaction score
2,692
Points
203
Location
Dallas, TX
I am working on an elevator door where one dorr open and when it is to a point they both open some more and then when they reach a point all 3 door open.

NO errors in coding but only the 1st door opens.
Code:
//HANGARDOORS
    ANIMATIONCOMPONENT_HANDLE parent;  
//HANGARDOOR
      static UINT EGrp78[2] = {4,28};//door1
   static MGROUP_TRANSLATE hdoor1 (0,EGrp78, 2, _V(0,0,-.6));
anim_HANGARDOOR = CreateAnimation (0); 
parent = AddAnimationComponent (anim_HANGARDOOR, 0, 1, &hdoor1);
//door2
static UINT EGrp79[2] = {3,27};//door2
hdoor1a = new MGROUP_TRANSLATE (0, EGrp79, 2,_V(0,0,-1.2));
anim_HANGARDOOR1a = CreateAnimation (0.0);
parent = AddAnimationComponent (anim_HANGARDOOR1a, 0, 1, hdoor1a, parent);
//DOOR3
static UINT EGrp76[2] = {2,31};//door3
hdoor1b = new MGROUP_TRANSLATE (0, EGrp76, 2,_V(0,0,-1.85));
anim_HANGARDOOR1b = CreateAnimation (0.0);
parent = AddAnimationComponent (anim_HANGARDOOR1b, 0,1, hdoor1b, parent);

where is were it gets moves:
Code:
if (LP5_status >= HATCH_RAISING) {

        double da = simdt * LIFT_SPEED;
        if (LP5_status == HATCH_RAISING) {
            if (LP5_proc > 0.0) LP5_proc = max (0.0, LP5_proc-da);
            else                LP5_status = HATCH_UP;
        } else {
            if (LP5_proc < 1.0) LP5_proc = min (1.0, LP5_proc+da);
            else                LP5_status = HATCH_DOWN;
        }
        
        SetAnimation (anim_HANGARDOOR, LP5_proc);
        SetAnimation (anim_HANGARDOOR1a, LP5_proc);
        SetAnimation (anim_HANGARDOOR1b, LP5_proc);
        
    

}
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,627
Reaction score
2,345
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
The error sits between keyboard and chair... Keep it simple, stupid. then you will see why the animations move so strange. because your code does not at all do what you want (I wish I had an Euro every time I say this to a student...I would be a rich man by now). And that happens because you don't think about the animation, you just copy and paste unsuitable code around. You don't understand your code, you do cargo cult coding.

Did you ever think about what the constants 0 and 1 in AddAnimationComponent mean?

Next, you should quickly look into the Orbiter header files for a class named "AnimState". This does all the stuff for you, that you do wrong here.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,728
Reaction score
2,692
Points
203
Location
Dallas, TX
Thanks. O and 1. 0 is the start and 1 is the end. So door 1 starts at 0 and then moves til it gets to 1 then dorr2 does the same but taking door 1....:thankyou:
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,627
Reaction score
2,345
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Thanks. O and 1. 0 is the start and 1 is the end. So door 1 starts at 0 and then moves til it gets to 1 then dorr2 does the same but taking door 1....:thankyou:

You failed the unplanned exam.

Animations ALWAYS run from 0 to 1. Animation components cover a subinterval of this range. If you have three door components, which should be moving in your desired pattern, you should have one component starting at 0 and run to 1, have one at 0.333 and run to 1 and the last from 0.667 and run to 1.

You also don't need no parent-child stuff there, especially since your translation vectors don't read like you take the previous translation in account.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,728
Reaction score
2,692
Points
203
Location
Dallas, TX
Thanks
I redid the code removing the parent/child stuff.
Code:
//HANGARDOOR
      static UINT EGrp78[2] = {7,30};//door1
   static MGROUP_TRANSLATE hdoor1 (0,EGrp78, 2, _V(0,0,-1.85));
anim_HANGARDOOR = CreateAnimation (0); 
AddAnimationComponent (anim_HANGARDOOR, 0, 1, &hdoor1);
//door2
static UINT EGrp79[2] = {6,29};//door2
static MGROUP_TRANSLATE hdoor1a(0, EGrp79, 2,_V(0,0,-1.85));
anim_HANGARDOOR1a = CreateAnimation (0.0);
AddAnimationComponent (anim_HANGARDOOR1a, .3, 1, &hdoor1a);
//DOOR3
static UINT EGrp76[2] = {5,28};//door3
static MGROUP_TRANSLATE hdoor1b(0, EGrp76, 2,_V(0,0,-1.85));
anim_HANGARDOOR1b = CreateAnimation (0.0);
AddAnimationComponent (anim_HANGARDOOR1b, .6,1, &hdoor1b);
But now just the first door moves.
UPDATE: Works now. Something else was messing with it.

Thanks
 
Last edited:
Top