SDK Question Rotating existing VC mesh element & copying/scaling it into new element

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,327
Reaction score
3,248
Points
138
Location
Massachusetts
I am still flailing away at Kev's Mirage 2000 model and am looking to improve a couple of the VC animations. I'm working on the altimeter now. Currently it is set up with a single needle that rotates around the dial. It works, but there are a couple of things I want to fix to make it more usable:

1. Currently, the initial 0 state of the animation puts the needle in the wrong location. On the dial, it points at the 9 o'clock position where it should be at the 12 o'clock position at zero altitude. I can calculate the animation state to incorporate a rotational offset which corrects this, but it would be easier to rotate the mesh once to set the correct location corresponding to the 0 animation state. I've rummaged around the API Reference and the forums, but all I seem to find is information establishing the animation with MGROUP_ROTATE and establishing the range of rotation, but I'm not seeing how to do a one-time offset before establishing the animation.

2. I'd like to see if I can copy (and possibly scale) this needle to make a new animation to indicate the 10 km scale. I've read a lot of stuff that sounds promising but it devolves into a lot of parent / child terminology and warnings of bad things if done incorrectly which I'm having trouble grokking.

Thanks again!
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
I am still flailing away at Kev's Mirage 2000 model and am looking to improve a couple of the VC animations. I'm working on the altimeter now. Currently it is set up with a single needle that rotates around the dial. It works, but there are a couple of things I want to fix to make it more usable:

1. Currently, the initial 0 state of the animation puts the needle in the wrong location. On the dial, it points at the 9 o'clock position where it should be at the 12 o'clock position at zero altitude. I can calculate the animation state to incorporate a rotational offset which corrects this, but it would be easier to rotate the mesh once to set the correct location corresponding to the 0 animation state. I've rummaged around the API Reference and the forums, but all I seem to find is information establishing the animation with MGROUP_ROTATE and establishing the range of rotation, but I'm not seeing how to do a one-time offset before establishing the animation.

2. I'd like to see if I can copy (and possibly scale) this needle to make a new animation to indicate the 10 km scale. I've read a lot of stuff that sounds promising but it devolves into a lot of parent / child terminology and warnings of bad things if done incorrectly which I'm having trouble grokking.

Thanks again!
Can u just change the VC mesh. If you need help I can
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,327
Reaction score
3,248
Points
138
Location
Massachusetts
Can u just change the VC mesh. If you need help I can
I was really intending to try to keep all the changes within the add-on module. I'm mulling over the idea of releasing a new module for Kev33's existing Mirage2000 add-on and, to that end, I really didn't want to modify his meshes directly.
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,327
Reaction score
3,248
Points
138
Location
Massachusetts
OK, after some flailing around I think I see how things work a little better. What I had to do was specify the level of the animation state corresponding to the initial mesh position when defining the animation:

C++:
anim_altimeter = CreateAnimation(0.75); //loaded mesh group is aligned where state = 0.75

Trying to make a second indicator for the 10 km scale of the altimeter isn't quite there yet. I think I can define a new mesh group reusing mesh components, but for some reason it's not working. This is what I have:

C++:
    // Altimeter Animations in DefineAnimations()

    static UINT wWGrp0[1] = { 2 }; //indicator for 1 km scale
    static MGROUP_ROTATE indicator(1, wWGrp0, 1, _V(-0.1192043, 6.317467E-03, 0), _V(0, 0, 1), (float)(-360 * RAD));
   
    static UINT wWGrp1[1] = { 3 }; //hub
    static MGROUP_ROTATE hub(1, wWGrp1, 1, _V(0.141381, 5.510744E-02, 0), _V(0, 0, 1), (float)(-360 * RAD));
   
    anim_altimeter = CreateAnimation(0.75);

    AddAnimationComponent(anim_altimeter, 0, 1, &indicator);
    AddAnimationComponent(anim_altimeter, 0, 1, &hub);

    static UINT wWGrp3[1] = { 2 }; //indicator for 10 km scale, duplicates indicator for 1 km scale
    static MGROUP_ROTATE indicator10km(1, wWGrp3, 1, _V(-0.1192043, 6.317467E-03, 0), _V(0, 0, 1), (float)(-360 * RAD));

    anim_altimeter10km = CreateAnimation(0.75);
    AddAnimationComponent(anim_altimeter10km, 0, 1, &indicator10km);

And setting the animation states in clbkPostStep:

C++:
    // Altimeter animation

    double altitude_km = GetAltitude() / 1000.0;
   
    altimeter_anim_state = altitude_km - floor(altitude_km);
    altimeter10km_anim_state = (altitude_km / 10.0) - floor(altitude_km / 10.0);

    SetAnimation(anim_altimeter, altimeter_anim_state);
    SetAnimation(anim_altimeter10km, altimeter10km_anim_state);

For some reason this doesn't work. A second indicator does not seem to appear. What seems to be happening (somehow) that the creation of the second indicator animation anim_altimeter10km = CreateAnimation(0.75) is modifying the first animation, causing the 1km indicator to be shifted 0.75 revolutions, but the rate of change is correct for the 1km scale. I have no idea how this can be as I have clearly defined a second animation with separate state and status.

C++ makes me doubt my sanity.
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,327
Reaction score
3,248
Points
138
Location
Massachusetts
It looks like both use the same mesh group (2)
Yes. I'm trying to make a second indicator using the same mesh component. I read in another post where the same mesh components were used to make two different mesh groups and was attempting to do the same here.
 
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Can u comment out the anim_altimeter and see if it works
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
K. I don't think you have the 2 animation control the same mesh. I guess if you below something one moves the needle and if above something then the needle moves.
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,327
Reaction score
3,248
Points
138
Location
Massachusetts
K. I don't think you have the 2 animation control the same mesh. I guess if you below something one moves the needle and if above something then the needle moves.
I'm not exactly sure what you are saying.

I think I'm fundamentally misunderstanding how mesh components are handled. There is a mesh file associated with the VC that contains a bunch of components. Apparently the component that defines the mesh for the indicator is {2}.

What I thought to do was try to define two different mesh groups using that same component, like this:

static UINT first_group[1] = { 2 };
static UINT second_group[1] = { 2 };

and then utilize these different groups in separate animations. But apparently this does not make two components, it simply runs the same component through two different animations in sequence.

Is it possible to create a copy of component {2} from within the module that I can treat independently?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
If you want to use the same needle for both animations. Then is alt below 1000 then altimeter works. But if 1000or above then only km altimeter works
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,327
Reaction score
3,248
Points
138
Location
Massachusetts
If you want to use the same needle for both animations. Then is alt below 1000 then altimeter works. But if 1000or above then only km altimeter works
Not really what I was after. Typical aircraft altimeters use at least two indicators, one showing 1000s in one revolution, the second showing 10,000s per revolution. There is even a third bug that indicates 100,000s per revolution.

Like this:

 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,327
Reaction score
3,248
Points
138
Location
Massachusetts
I actually opened up Kev's VC mesh in a text editor and it appears that there are two separate hubs and indicators for the altimeter, but it's not clear where the second set is located. They are not in the same locations, and I am only seeing the one hub and indicator.
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,327
Reaction score
3,248
Points
138
Location
Massachusetts
Great. It appears that the altimeter parts are the first four components {1,2,3,4} of the cockpit mesh.

I have to get away from the computer for a while.
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,327
Reaction score
3,248
Points
138
Location
Massachusetts
 
Top