# SDK QuestionRotating existing VC mesh element & copying/scaling it into new element

#### Thunder Chicken

Donator
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

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

Donator
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

Donator
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);

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.

#### gattispilot

It looks like both use the same mesh group (2)

#### Thunder Chicken

Donator
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

Are u animating both indicators

#### Thunder Chicken

Donator
Are u animating both indicators
Yes, two separate animations anim_altimeter and anim_altimeter10km.

#### gattispilot

Can u comment out the anim_altimeter and see if it works

#### Thunder Chicken

Donator
Can u comment out the anim_altimeter and see if it works
Yep, here is the indicator for km passing 3 km (Kev's textures are low resolution photos, not the prettiest).

#### gattispilot

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

Donator
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

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

Donator
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:

#### gattispilot

You may need to redo the VC mesh

#### Thunder Chicken

Donator
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.

#### gattispilot

Ok. I can take a look. It might be tomorrow

#### Thunder Chicken

Donator
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.

#### gattispilot

Where is the original mesh Kev33 Mirage 2000

Donator

Replies
3
Views
741
Replies
31
Views
1K
Replies
12
Views
1K
Replies
5
Views
585
Replies
11
Views
1K