Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 07 Nov 2012
Offline Last Active Jan 08 2013 06:05 PM

Posts I've Made

In Topic: Need help getting a child object to orbit a parent object ...

03 January 2013 - 05:15 AM

It might be just me, but even now, the snapshot that you have provided and your problem statement seem to be complementing each other.

In simple words, I think you're trying to achieve what you already have in this snapshot.

Perhaps, an altered snapshot with expected behaviour might help.


The snapshot shows the expected behaviour. He wrote that the parent ship rotates about the origin instead.

In Topic: Anti-Aliased Lines from ShaderX7 not working

03 January 2013 - 05:10 AM

I'm afraid to post the whole shader code due to copyright issues. If you have the book, it is printed in chapter 2.3. I wanted to use the original shader to prevent error infusion.

What I can do is post my own adaptation of that code. It uses the original math/shader, but I added hardware instancing, so it should be ok. I also attached the class that manages the buffers.
My main change is that the texture coordinates are now in input.Position.xy instead of weights.zw

I applied your change to both versions, i.e. use float2 instead of float4 for the texture coordinates und tex2D instead of tex2Dproj. The output is the same every time.

In Topic: Need help getting a child object to orbit a parent object ...

02 January 2013 - 06:44 PM

What you have to do is transform the difference vector between parent and child, not the child position itself.

Rotations matrices always rotate about the origin, so the easiest thing is to (temporarily) change your coordinate system so the parent ship's position is the origin:



Vector2 d = childShipPositionPoint - parentShipPositionPoint;
d = Vector2.Transform(d, Matrix.CreateRotationZ(15));
childShipPositionPoint = parentShipPositionPoint + d;


Let me know if this is what you are looking for.

In Topic: Space game graphics with Depth perception

25 December 2012 - 02:54 PM

Thanks for the answers. I see now that fog really was the wrong approach.
I have worked on the suggestions and thought I'd share the results:
  • I had a hard time drawing a Skybox myself, mostly due to parallax errors in the corners and my inability to mask the transitions at the edges. For anyone searching, try Spacespace (http://alexcpeterson.com/spacescape). It does the job beatifully and I'm glad I stumbled on this. For the time being, I could get away with a single rendering pass, since there are no distant objects and the skybox is 10000 big, as suggested.

  • The Skybox helped with orientation in a relative manner, like you can tell which way you are turning/looking. But what I needed was an absolute reference point, so I followed Prinz Eugn's advice and added a milky way band all arround one axis (It's actually tilted, but there is no way to notice, which I'm pretty happy about). The galaxy is additively blended over the background which works great.

  • The galactic core on the side of the sky box further helps with orientation. I made it really bright and added directional lighting. sharp lighting really is the way to go, I more than doubled the intensity and it looks good. smile.png

  • HUD: For now I added a line for each ship to indicate its current target. There is a lot to be done, like showing the estimated flight path (which should be curved rather than straight). Right now it is a wirefrime line, but I would want it to be a translucent and add a subtle glow effect.

  • Particles: Added a threaded particle system. This makes things come to life, I added basic explosions and engine trails, but they are really ugly because I can't draw ;). I am working on that "star dust" thing right now, which will be hard because I cannot reposition particles right now to implement an infinite scrolling cube, only spawn new particles.
I attached a few screenshots.

In Topic: Problem with Billboarding Instanced Particles

13 November 2012 - 03:21 PM

Feeling like a total scrub now. Your correction works.
The particles are visible now and do turn (arround some wrong axis, though).
I think I can safely work from here. ^^

Thanks a lot, and sorry for this stupidity.

Here is the new shader with a workarround using the View matrix for the billdboard orientation.
This way I don't need to use float3 at all.

[source lang="cpp"]VSOutput ParticleVS(VSInput input, InstanceData instance){ VSOutput output = (VSOutput)0;float lifeTimeFactor = (instance.T1 - T) / (instance.T1 - instance.T0);input.Position *= instance.Size * lifeTimeFactor;// transform to Screenspacefloat4x4 transform = transpose(View);transform[3] = 0;input.Position = mul(input.Position, transform); // Calculate the particle's position float dt = T - instance.T0; input.Position += instance.Position; input.Position += dt * instance.Velocity; input.Position += 0.5 * dt * dt * instance.Acceleration; float4 pos4 = mul(input.Position, World); pos4.w = 1; pos4 = mul(pos4, View); pos4 = mul(pos4, Projection); output.Position = pos4; output.TextureCoordinate = input.TextureCoordinate; output.Alpha = lifeTimeFactor; return output;}[/source]