The game supports both Single Player and Multiplayer Modes.
This also means that I have the following modules finished
- Game Logic
What does making Pong take
Next, I will be working on making a installer using nsis
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
- 2 Paddles
- 1 Ball
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
- the start index
- the number of indices in this subset
- the diffuse color
- the texture file
Next on the agenda is to get the paddles and ball moving and adding a collision checker
andreialex28 Sep 2015 - 00:50
Ceelos197416 Dec 2014 - 10:04
D.V.D14 Nov 2014 - 00:46
stitchs11 Jun 2014 - 06:13
Gaiiden23 May 2014 - 18:48
IvIurph23 May 2014 - 15:53
StaticPoof23 May 2014 - 13:43
kubera23 May 2014 - 11:42
delagames23 May 2014 - 11:24
YodamanJer23 May 2014 - 10:58
dmatter23 May 2014 - 05:35
Rorakin22 May 2014 - 20:59
NewVoxel22 May 2014 - 16:19
Rastamanbegood21 May 2014 - 09:25
SerialKicked20 May 2014 - 22:03
Gooey20 May 2014 - 14:31
achild20 May 2014 - 08:56
Buster200020 May 2014 - 08:21
imoogiBG20 May 2014 - 07:30
detlion164320 May 2014 - 06:58
gmaclachlan20 May 2014 - 04:01
OzgurEra19 May 2014 - 17:18
ByteTroll19 May 2014 - 14:07
Matthewj23419 May 2014 - 12:25
Aardvajk19 May 2014 - 10:54
DpakoH19 May 2014 - 06:30
Silvanis19 May 2014 - 01:17
polyfrag18 May 2014 - 05:48
RudolfVonKrugstein18 May 2014 - 05:14
Noob C++17 May 2014 - 16:25