DX11 and ISV Pegasus

Mr Martian

Orbinaut/Addon dev/Donator
Addon Developer
Donator
Joined
Jun 6, 2012
Messages
309
Reaction score
103
Points
43
Location
Sydney, Australia, Earth, Sol
Website
www.orbithangar.com
I have been playing Orbiter for about a year now, And in all that time, i only just relised that you can install visual plugins and clients. So over the past couple of days i have been mucking around with those, but to my dissapointment, i discovered that the DX9 and DX11 clients are not compatible with the ISV Pegasus V2.0 which i am currently working on. There are two main problems that cause this. Firstly, the centrifuge conflicts with the client because i have put what would normally be defined in "defineanimations" into clbkPostStep to give the gravity wheel the slow speed increase, like the one in dansteph's UCGO arrow. This can be fixed at a cost of the centrifuge speed effect, the other issue that i don't know how to fix is the MFDs, which either do not appear, or are completely distorted. If anyone knows how to address this, any help would be appreciated.

Thanks in advance :)
 

n122vu

Addon Developer
Addon Developer
Donator
Joined
Nov 1, 2007
Messages
3,196
Reaction score
51
Points
73
Location
KDCY
Well, you could download my [ame="http://orbithangar.com/searchid.php?ID=5477"]EAS Cortez[/ame] (source code included in zip) and see what I did to animate the gradual spinup/spindown of the gravity wheel. I haven't tested it in the DX11 client yet, but it works very well in the DX9 client.

But since it's Friday, I'm feeling generous enough to not make you dig through all my beacon light definitions to find my clbkPostStep.


I have these variables defined in my header file:
Code:
double gravwheel_proc = 0.0;
double gravwheel_speed = 0.0;
double gravwheel_run = 0; 

UINT anim_grav = 0;

DefineAnimations looks like this:
Code:
//Define animation for gravity wheel
void Explorer::DefineAnimations()
{
    static UINT gravwheel_groups[2] = {34, 35};
    static MGROUP_ROTATE gravwheel (0,gravwheel_groups, 2,_V(0,-20,0),_V(0,0,-1),(float)(360*RAD));
    anim_grav = CreateAnimation(0.0);
    AddAnimationComponent (anim_grav, 0, 1, &gravwheel);
}

And this is the code from my clbkPostStep
Code:
//-----------------------------------------------------
	//Gravity Wheel Animation
	//-----------------------------------------------------
	if (gravwheel_run == 1) //Test - if wheel is supposed to be running, then execute animation based on variable params
	{
		if (gravwheel_speed < 0.016) gravwheel_speed = gravwheel_speed + 0.00001;

		double da = oapiGetSimStep() * gravwheel_speed; 
				

		if (gravwheel_proc >= 1) gravwheel_proc = 0; //Check animation state.  If complete, reset (keep wheel running)
		gravwheel_proc = gravwheel_proc + da; //Increase animation state variable for sim step based on defined wheel speed

		SetAnimation (anim_grav, gravwheel_proc); //Set animation state based on animation state variable value
		
	}
	
	if (gravwheel_run == 0)  //Test - if wheel is supposed to stop, then set state based on animation variable params
	{
		if (gravwheel_speed > 0) gravwheel_speed = gravwheel_speed - 0.00001; 
		double da = oapiGetSimStep() * gravwheel_speed;
		gravwheel_proc = gravwheel_proc + da;
		SetAnimation (anim_grav, gravwheel_proc);
	}

That's how I did it anyway. Hope this helps.

Regards,
n122vu
 

Mr Martian

Orbinaut/Addon dev/Donator
Addon Developer
Donator
Joined
Jun 6, 2012
Messages
309
Reaction score
103
Points
43
Location
Sydney, Australia, Earth, Sol
Website
www.orbithangar.com
Well, you could download my EAS Cortez (source code included in zip) and see what I did to animate the gradual spinup/spindown of the gravity wheel. I haven't tested it in the DX11 client yet, but it works very well in the DX9 client.

But since it's Friday, I'm feeling generous enough to not make you dig through all my beacon light definitions to find my clbkPostStep.


That's how I did it anyway. Hope this helps.

Regards,
n122vu



thanks for the help n122vu, EAS Cortez: great ad-on by the way :thumbup:
 

Izack

Non sequitur
Addon Developer
Joined
Feb 4, 2010
Messages
6,665
Reaction score
13
Points
113
Location
The Wilderness, N.B.
You shouldn't need to define your animations every time step.

I can't speak for the D3D11 client, which isn't runnable on my machine, but in the D3D9-compatible Deepstar, these things work fine when placed in a helper called DefineAnimations() called during clbkSetClassCaps(). The vessel, like Cortez and the Arrow, has a gradual spin-up and slow-down period.

The animation happens thusly in clbkPreStep():
Code:
if (!state_cent)
	{
		if (rot_speed > 0.0)
			rot_speed -= 0.0001*SimDT;
		if (rot_speed < 0.0)
			rot_speed = 0.0;
	}

	else if (state_cent)
	{
		if (rot_speed < (4.7 / 360))
			rot_speed += 0.0002*SimDT;
		else if (rot_speed > (4.7 / 360))
			rot_speed = (4.7 / 360);
	}

	if (state_cent)
	{
		double s = SimDT * rot_speed;
		rot_angle += s;
		if (rot_angle > 1.0)
			rot_angle -= floor(rot_angle);
		SetAnimation(anim_centrifuge,rot_angle);
	}

If you also want the centrifuge to be independant of time acceleration like the UCGO Arrow, simply remove SimDT from the calculations.
 
Top