Jump to content

  • Log In with Google      Sign In   
  • Create Account

SpeedRun's Journal

New Release : Mpong

Posted by , in MPong 20 December 2012 - - - - - - · 820 views

So I finally got around to making an installer using nsis.
The setup can be downloaded here

The Archive can be downloaded here



In Game Screen #1

Playable Prototype

Posted by , in MPong 18 December 2012 - - - - - - · 807 views

I have finally got a playable prototype up and running.
The game supports both Single Player and Multiplayer Modes.

This also means that I have the following modules finished
  • Game Logic
  • Graphics
  • Input
  • UI
  • AI
You can see the whole list here
What does making Pong take

Next, I will be working on making a installer using nsis

Screen To World Coordinates

Posted by , in Tutorial, Snippet 06 December 2012 - - - - - - · 1,002 views

This snippet shows how to convert a point on screen to a corresponding point in the world. It borrows heavily from the concept of ray-tracing.

Let x and y be the point on the screen which we want to convert to the world space.
We need to create a ray which passes through the camera and the point(x, y) in worldSpace
This ray needs to satisfy the line equation (1)
where Pl = point along the line.
C = Point on the line. In this case the camera position
D = the Direction of the ray
t = some float

Now we need to get the direction of the ray.

First we transform the point to our View space coordinates. View space ranges from -1 to 1 on the x and y axis and 0 to 1 on the z axis with (0,0) being the center of the screen. We can set viewSpaceZ to 1 since the ray goes into the screen

We just reverse the following formula which is used to scale the the position in the world to fit the viewport size.
x = (ViewSpaceX + 1) * Viewport.Width * 0.5 + Viewport.TopLeftX
y = (1 - ViewSpaceY) * Viewport.Height * 0.5 + Viewport.TopLeftY
z = Viewport.MinDepth + ViewSpaceZ * (Viewport.MaxDepth - Viewport.MinDepth)


Next we adjust the points using the projection matrix to account for the aspect ratio of the viewport.

To get our world matrix we just need to invert our view matrix.
Once we have our world matrix we can get the direction of our ray by transforming the viewspace point with the world matrix and then normalize the resultant vector.

At this stage, we have an infinite number of positions in the world which will fall on this ray(depending on the value of t)

To get the exact point in the world we need the intersection of this ray with the viewing plane.
The viewing plane be defined by the plane equation
where N = (A, B, C) = the plane normal vector
k = Distance from the origin
Alternatively, the plane equation can be written as (2)
where Pp is the point on plane

To get the normal of our viewing plane in world space, we need the combination matrix of our view and projection matrix

Once we have our matrix M, the viewing plane normal is simply the normalized vector of (M._13, M._23, M._33)

When the plane and line intersect ,
Substituting (1) in 2, we get

Using distribution, we get

Solving for t, we get

Once we have t, we can plug it back in equation (1) to get the point in our world.

This ends this mini tutorial of converting our screen coordinates to world coordinates

Added Game Elements

Posted by , in MPong 03 December 2012 - - - - - - · 557 views
I have added the basic Game elements which are
  • Walls
  • 2 Paddles
  • 1 Ball
I have also added a UI to display the score.

I have also written a model converter which takes an wavefront .obj file and converts it into a format which is easier to parse in my game engine. Currently the converter writes out the
  • the total number of vertices
  • vertex data (position and texture coordinate),
  • the total no of indices
  • the triangle data i.e the index data for each triangle
It also creates a subset for each material which contains
  • the start index
  • the number of indices in this subset
  • the diffuse color
  • the texture file
The in game Screen after clicking Single Player or Multiplayer

Next on the agenda is to get the paddles and ball moving and adding a collision checker

December 2012 »


Recent Entries

Recent Comments

Latest Visitors