Calculating 3 Dimensions in 2D plane

Topics: Developer Forum
Mar 5, 2011 at 7:50 PM

Hey.

 I'm creating a silverlight game and would like to use the Farseer engine. My game is a pool game (birds eye view) and this would be straight forward enough to create. The problem lies in the fact that I'd like the user to be able to 'chip' the cue ball and thus push it into the Z-axis. Faking the illusion is straight forward, (scale sprite etc..), but I'm not sure how I can use the Farseer engine in order to calculate the cue ball's trajectory in three dimensions. Is there a way to extract just the 'height' information? Can I somehow use the engine to do two calculations (one in the XY dimension looking side on and one in the XY dimension from the birds eye perspective)? I may be overcomplicating this, so any suggestions would be most welcome. Thanks. 

Mar 6, 2011 at 12:53 AM

sorry if i misunderstand your think.

in demo Helloworld , they use MeterinPixel variable, it just like Z-axis and u only need scale texture of object

maybe scale = 1f * Meterinpixel

Mar 6, 2011 at 3:11 AM

Hey namkazt. Thanks for the help, but it's not quite what I need. Although then scaling part is fine, and it would be useful, I'm not sure how I can calculate the trajectory of the cue ball if the user chips it. The ball would go in the air (into the 3rd dimension) but the entire game is a birds eye view of a pool table. Once I have the height information, I can then tie that to the sprite scaling method. 

Mar 6, 2011 at 11:05 AM

awww, ok ok you mean Z-axis of ball when it fly.

set Scale in Ball.UserData
and when user chips the ball, you can calculate the trajectory of the cue ball

maybe like that :

user chips ball : Ball_Body.ApplyLinearImpulse(Vector2.UnitX * 20f) && isFly = true;
in Update : if(Ball_Body.LinearVelocity != Vector2.Zero && isFly) Ball_Body.UserData = Vector2.One + (Vector2.One - Vector2.One / Ball_Body.LinearVelocity);

in Draw : u need draw with (Vector2) Ball_Body.UserData as Scale

i dont test it:D

Developer
Mar 6, 2011 at 8:11 PM

To achieve realistic 3D effects like your describing you should use a 3D engine like Jitter. But, if your determined to use Farseer you would have to  use 2 separate World's, one from the birds eye and one from a side view. You would somehow have to mask the side views collisions based on the birds-eye view. Past that I'm not sure...my head is already hurting ;)

If I was you I would use Jitter (it should work without XNA in a pure Silverlight environment) and just simply render the spheres as sprites.

Mar 6, 2011 at 8:32 PM

Thanks Matt, I'll take a look at Jitter. I'm glad I'm not missing something obvious as I've had a headache about this for a couple of days :D

Developer
Mar 6, 2011 at 10:04 PM

NP, Jitter is a really good free engine with awesome support...just like Farseer... ;)