Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 01 Sep 2010
Offline Last Active Sep 06 2014 07:42 AM

Topics I've Started

Interactive body parts in 2d game

19 June 2014 - 02:56 PM


I'm wondering what would be the best approach to make a character be completely interactive with the environment just like in the "Happy Wheels" game. How are characters in "Happy Wheels" made anyway? Are they 3d models or each body part is a separate object and everything is just being linked into 1 character in game?

I would like to achieve a similar effect but in a completely 2d game (without 3d models), so that character would bleed just in place where he was shot, could be cut on half in many places of his body etc... ; P

How to prepare yourself for working in game industry?

20 March 2014 - 07:51 AM


I already have quite good knowledge of C++. I've written 2d game in DirectX 9, played with network programming a bit and WinAPI. Now I would like to start learning 3D game programming and I wonder what would be the best approach? Should I learn DirectX 11 and try to create my own engine? I've already tried to learn DX 11 but it seems to be pointless... Going through DX 11 tutorials is a pain for 1 person and takes too much time in comparison to knowledge achieved. So maybe should I learn some 3D library like Ogre or download a game engine like Unity or Unreal? I would like to go with a solution that would give me most abilities and knowledge used in professional game development.

I would be very grateful if someone with experience could share his thoughts!

View matrix - explanation of its elements

29 December 2013 - 04:48 AM

So a common view matrix looks like this:



where n is a vector acting as "z" axis of camera, u as "x" axis and v as "y" axis of camera. u_x, v_x, n_x etc. are coordinates of each vector. c is a vector representing distance of camera from (0,0, 0). u*c, v*c and n*c are dot products

Does somebody know any detailed article which would explain precisely how to create such a matrice from the scratch? Or maybe could someone explain it to me here?

First my assumptions:

When applying this matrix to every object on the scene, this matrix is the first factor of multiplication and a vertex is a second one?

So for example: MAT_12.GIF *

| x |
| y |
| z |
| 1 |

If my assumptions are correct then I don't understand a few things tongue.png. Why 4th row of the matrix must contain a vector representing how much should I move every vertex on the screen? The 4th coordinate in any vertex is "w" right? So what meaning does it have here? I thought it's actually useless but defined only to enable adding matrices in form of multiplication. Now after such mutiplication as above I would get the following vertex transformation:

|x * u_x + y * v_x + z * n_x + 0      |
|x * u_y + y * v_y + z * n_y + 0      |
|x * u_z + y * v_z + z * n_z + 0      |
|-x * (u*c) -y * (v*c) -z * (n*c) + 1 |

And it seems as the "w" component of the vertex was moved but it doesn't make any sense to me : (.


My second issue is rotation in the view matrix so 3 first rows of the view matrix. I completely don't understand why we can put coordinates of the camera axis vectors as rotation factors.


So if anyone could lend me a hand here I would be really grateful!

different colors when using XMVECTOR or XMFLOATs

28 October 2013 - 12:17 PM

So I'm following a tutorial http://www.rastertek.com/dx11tut04.html and managed to convert it from D3DX10math.h to DirectXMath.h but I can't get the same color values when using XMVECTOR or XMFLOATs for my vertices. I want to draw a green triangle and this is how I set positions and colors for vertices using XMVECTOR:

//vertices::position and vertices::color are XMVECTORs alligned to 16 bytes

vertices[0].position = DirectX::XMVectorSet(-1.0f, -1.0f, 0.0f, 0.0f);  // Bottom left.
    vertices[0].color = DirectX::XMVectorSet(0.0f, 1.0f, 0.0f, 1.0f);

    vertices[1].position = DirectX::XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);  // Top middle.
    vertices[1].color = DirectX::XMVectorSet(0.0f, 1.0f, 0.0f, 1.0f);

    vertices[2].position = DirectX::XMVectorSet(1.0f, -1.0f, 0.0f, 0.0f);  // Bottom right.
    vertices[2].color = DirectX::XMVectorSet(0.0f, 1.0f, 0.0f, 1.0f);

This gives me totally blue triangle, whereas such solution:

//vertices::position is XMFLOAT3 and vertices::color is XMFLOAT4    

vertices[0].position = XMFLOAT3(-1.0f, -1.0f, 0.0f);  // Bottom left.
    vertices[0].color = XMFLOAT4(0.0f, 1.0f, 0.0f, 1.0f);

    vertices[1].position = XMFLOAT3(0.0f, 1.0f, 0.0f);  // Top middle.
    vertices[1].color = XMFLOAT4(0.0f, 1.0f, 0.0f, 1.0f);

    vertices[2].position = XMFLOAT3(1.0f, -1.0f, 0.0f);  // Bottom right.
    vertices[2].color = XMFLOAT4(0.0f, 1.0f, 0.0f, 1.0f);

with types changed to XMFLOAT3 for position and XMFLOAT4 for color gives me correct green triangle.


I've played a bit with these coordinates and tried to make a green triangle using XMVECTORs but it doesn't seem to have any sense. The XMVECTOR solution returns wrong colors all the time whatever I set the coordinates to...

I know that it might be hard to guess what's the problem without some details but maybe somebody has an idea of what might be wrong?


PS: When I change the last parameter in XMVECTOR solution for vertices::position to 1.0f it changes the color near that vertex to pink, which is completely wierd for me as position shouldn't have impact on color?

XMVECTOR vs XMFLOAT4 in classes

16 October 2013 - 02:49 AM


I'm wondering how should I get around with those types. I've read that I should use XMFLOATs in classes for storage purposes but for calculations convert it to local XMVECTOR objects.


1. Doesn't converting from one type to another, whenever I need to calculate sth, slow down the performance? Isn't it better to properly align class and then always use XMVECTOR in it?


2. If I should use XMFLOAT for storage purposes, does it mean that I should use XMFLOAT for filling the data as well? Or is it faster and preferred to use XMVECTOR to fill data  in there and then store it in XMFLOAT?


I would be very grateful for answering 2 of my questions!