(February 2018) Monthly WIP screenshot thread

Looks really coherent! good job

So I’ve recently thrown out most of the old spaceship steering code and replaced it with PID controllers and a slightly different interface. It was actually rather simple once I had all the angular targets defined properly.

Now all rotations are done with physics forces only and with no more angular velocity setting hackery.

I even have the option to have ships bank into corners, but that just makes everything less stable for very high twr ships and causes the nose to rise slightly.

Here’s the PID library I found btw:


So you run a PID controller for each axis?


Yep, that’s right. Roll always tries to correct to vertical (or the banking angle that scales with the turn), pitch and yaw take the values from the mouse point vector and convert it to local angles, then the system tries to match them.


Brilliant! I am so stealing this :slight_smile:



Here’s some of the main math (with some stuff generalized) as well if it comes in handy:

	Node ship; 
	float force;

	Vector3f foreward = ship.getLocalRotation().getRotationColumn(2);
	Vector3f yaw = ship.getLocalRotation().getRotationColumn(1);
	Vector3f pitch = ship.getLocalRotation().getRotationColumn(0);
	float[] angles = new float[3];
	angles = ship.getLocalRotation().toAngles(angles);
	// yaw and pitch
	float dist = CPU.game.getCamera().getViewToProjectionZ(5000);
	Vector3f targetpos = CPU.game.getCamera().getWorldCoordinates(new Vector2f(mau5pos.x, mau5pos.y), dist).clone();
	Vector3f tgt = ship.worldToLocal(targetpos, new Vector3f()).normalizeLocal();
	Vector3f local = new Vector3f(tgt.x,0f,tgt.z);

	float pad2 = -FastMath.atan2(local.x, local.z);
	float x = ship.yawPID.getOutput(pad2*10f,0f);
	float y = ship.pitchPID.getOutput(FastMath.asin(tgt.y)*10f,0f);
	float tilt = FastMath.clamp(-x, -45*FastMath.DEG_TO_RAD, 45*FastMath.DEG_TO_RAD); //90 deg banking limit example
	if(FastMath.abs(x) < 0.4)
		tilt = 0f;
	float corrector = ship.rollPID.getOutput(angles[2],tilt);

I have Z defined as ship forward and Y is up.


I am currently ‘rolling my own’. I was unable to find anything suitable available already.


1 Like

The example for BigBanana looks like this. My game is already using it :slight_smile:

(Removed offending image)

What, image upload works again???


Oh, time to switch over to Lemur and the big banana then! :slight_smile:
Maybe I can port some of my cool widgets over to this UI library. We’ll see. :wink:

1 Like

We had to turn it on for avatars to work. If people keep using it for screenshots then I guess we’ll have to turn it off again.


Fixed, but… discourse hates monekeys :stuck_out_tongue:

1 Like

While I’m using it, I don’t reccommend yet to use… might do more harm than good in its current form.


Star Trek Beyond, directed by Mel Brooks

Turns out PID controllers work on other things as well :stuck_out_tongue:

Edit: more pics:

And some reaction wheels I had to add to stop huge ships from turning like a building, despite being the same size:


? Look like gyroscopic stabilizers. Could you explain a little more about those? :slight_smile:

Well in the real life physics sense they’re flywheels that can be spun in order to induce angular momentum, used on satelites and the like. Supposedly the difference from gyroscopes is that they don’t spin constantly but only when you need to rotate and are fixed in place.

Here’s a sort of real use case demonstration I guess.

They do have a few drawbacks though, you need one per each axis, they can only induce a very limited rotation speed and aren’t exactly the most reliable things ever.

To keep things simple I’ve more or less just copied the KSP simplification - that means one wheel can add forces to all axes and just pretty much acts as a rotational thruster while only using electric power.

I didn’t want sideways attached engines ruining sleek ship designs :stuck_out_tongue:


So my show off is not exactly spectacular after seeing @MoffKalast update there or any of the other updates earlier BUT I’m fairly proud of my progress at learning shaders.

So I set myself a simple goal after reading a buncha material on how this stuff works. Goal #1… Load 2 cubes one with a custom material that shifts everything 1 unit along the X Axis.

Then I decided to muck with applying changes over time. Which got me to making this morphing cube wireframe that is sorta sensually moving.

So ya. The list of people that I really need to thank for listening to my questions and taking time to answer them is kinda huge. So thanks to all!


Nice. How did you offset the vertex in the first screenshot?

Just add a vector to the input inPosition before doing the transforms.

E.g. :

vec3 pos = inPosition + vec3(1.0, 0.0, 0.0);

Stuff like this shouldn’t work though:

inPosition.x += 1.0;

Since any input values are effectively final iirc.


More or less I did exactly what @MoffKalast said. I’m not at my computer right now but when I get a chance (tomorrow night) I can show you line for line if you want. :grinning:

Does the winnebago go at ludicrous speed?