SDK Question Pulse Laser

Hachimaki

New member
Joined
Jun 1, 2014
Messages
2
Reaction score
0
Points
0
Hi Guys,

Iam currently trying to make a Tie Fighter for Orbiter 2010. Right now, iam working at the laser weapons. I used two thrusters and altered the exhaust texture, but that leads -of course- only to a long continuous ray.
So can anybody give me a hint how to make this a pulsed laser, as its seen in the movies?
Thanks in advance!
 
Have a look at how some of the startrek addons do the photon torpedoes and you could use that as a basis.

I think they create a new vessel with a mesh of the projectile and fire it off in a set direction. But its best to have a look at how they did it. (I think one of the delta flyer addons has it but I'm not certain)
 
You could also simulate this in your vessel, by having a set of mesh groups for the pulses and only simulate their motion relative to the vessel. Is likely better by the performance than creating new vessels.
 
Is this a .dll or a Spacecraft3 addon?
If the former, then it should be pretty easy to do as Evil Onyx says and generate a new vessel that is the laser bolt. You should also look at giving the created a vessels a lifetime so they don't just sit around cluttering up Orbiter. I can conceptually see it being implemented in either the parent vessel or the child vessels. Also, don't forget to give them unique names.

You could also simulate this in your vessel, by having a set of mesh groups for the pulses and only simulate their motion relative to the vessel. Is likely better by the performance than creating new vessels.
But wouldn't you have to code the physics so the bolts stay on their own course instead of staying with your ship?
 
But wouldn't you have to code the physics so the bolts stay on their own course instead of staying with your ship?

Yes - but just Newtonian and just for a short distance. No need for full orbital madness. Even a coarse simulation would be accurate.
 
BrianJ had a LIDAR in his [ame="http://orbithangar.com/searchid.php?ID=3470"]ART add on.[/ame] When I made my ChapmanModules add on with laser altimeter, he showed me the code for how to make a LIDAR.

Here it is:
In PostStep
PHP:
// Laser. All credit goes to BrianJ!
	if (laser_on == true && laser_switch == 0)
	{
		SetThrusterLevel (laser, 1);
		laser_switch = 1;
	}
	else if (laser_on == true && laser_switch == 1)
	{
		SetThrusterLevel (laser, 0);
		laser_switch = 2;
	}
	else if (laser_on == true && laser_switch == 2)
	{
		SetThrusterLevel (laser, 0);
		laser_switch = 0;
	}
	else
	{
		SetThrusterLevel (laser, 0);
	}

In SetClassCaps
PHP:
laser = CreateThruster (_V( 0, 0, 1), _V(0, 0, 1), 0, RCSTank, 0);
SURFHANDLE laserTexture = oapiRegisterExhaustTexture ("ChapmanModules\\Laser");
AddExhaust (laser, 100, 0.02, _V(0.4551005, -0.0763425, 1.46), _V( 0, 0, 1), laserTexture);

In ConsumeBufferedKey:
PHP:
case OAPI_KEY_L: // activate/deactivate laser
				if (laser_on == false && VesselDestroyed == false)
				{
					laser_on = true;
				}
				else if (VesselDestroyed == false)
				{
					laser_on = false;
				}

Tell me if you need explanations.
You can find the entire code in the Orbitersdk folder in my add on here: [ame="http://orbithangar.com/searchid.php?ID=6379"]Chapman Modules v.3[/ame]
 
Last edited:
I would make 3 or 4 textures, each offset in longitudinal direction by a third or fourth of a pulse length. Then I'd specify 3 or 4 thrusters at the same location, pointing in the same direction and switch them on and off consequently
frame 1: 1 on,
frame 2: 1 off, 2 on,
frame 3: 2 off, 3 on ...
each frame or each nth frame. This should give the impression of the light pulse moving forward. Kind of stop-motion animation.
 
Thanks for all the information!

@Zatnikitelman:

I can't do it as a SPACECRAFT3 addon, because I wanna run this vessel on a simulator at my university that, as far as i know, doesn't have the SPACECRAFT3 files. So it will be made as .dll.

@Urwumpe:

How do I create a new vessel relative to my own craft? Iam pretty new to programming a spacecraft for Orbiter, so I barley found out how to put a new vessel in my scenario:lol:
Do you have by any chance some sample code?
 
Back
Top