• Create Account

Member Since 27 Nov 2002
Offline Last Active Nov 20 2012 09:58 PM

### 3D Perspective Projection (w)

07 October 2012 - 10:01 PM

I'm working on an assignment for my graphics class and I've encountered a problem. Basically I have a set of coordinates in World space and I have to transform them into Screen space and display them. I have to manually build all of the matrices and do the transformations by myself (no opengl or d3d). I have the following 3 matrices
• Xsp (proj to screen transform)
• Xpi (image to projection transform)
• Xiw (world to image transform)
I'm rendering to a 256x256 frame buffer, so my Xsp matrix looks like this:
```128	 0	 0	 128
0	 -128	 0	 128
0	 0	 1	 0
0	 0	 0	 1
```

My Xpi matrix has m[3][2] set to tan(fov / 2) where my fov = 35. (In the matrix .32 was just rounded for easier viewing)
```1	 0	 0	 0
0	 1	 0	 0
0	 0	 1	 0
0	 0	 .32	 0
```

Lastly my Xiw matrix is just the inverse of my camera transform. The camera is at 0,0,-15, looking at 0,0,0 with an up-vector of 0,1,0
```1	 0	 0	 0
0	 1	 0	 0
0	 0	 1	 15
0	 0	 0	 1
```

Using just these three matrices I can multiply them against a coordinate and get it transformed into screen space just fine. The catch is when I want them to be perspective correct. I've tried figuring out what 'w' is, but I cannot find a solid definition of how to calculate it. Some places are saying that the final Z value is used to divide X and Y by, but it doesn't look right. Some places are saying the W coord that is calculated by multiplying the matrix with the coordinate (assuming 1.0 for the 4th coord) is the W to divide by. I can't seem to get either method to work.

My question is what is W and how is it calculated?

Thank you so much in advance!

### super mario derivatives

22 May 2010 - 08:06 AM

I was playing New Super Mario Bros Wii over the past few days and started wondering if there are other games out there that are similar to Super Mario. I started brain storming and was only able to come up with Donkey Kong for the SNES. There were some other titles, but I discarded them because they did not involve the same game mechanics. Take for example Contra. It is a 2D platformer, but I discarded it because it involves shooting. Are there any other games out there that share similarities to Super Mario? If not, why are there none? FPS's are a dime a dozen and there are almost no differences between them.

### C# plugin system

17 April 2010 - 03:19 PM

im trying to build a simple plugin system, but im having some issues. i have an abstract class that all plugin classes need to inherit from. once a plugin is built it will be put into a directory for the program to pull from. i can search the directory from the program to find the dlls and i can load their assembly. the problem that i am having is that i cannot figure out how to create an instance of that plugin class. its very easy when you know the name of the class, but how do you do it when you dont know the name of the class? thanks -adam

### XNA: Initialize and LoadContent not called

14 December 2009 - 09:39 AM

I am running into a weird problem. I have a class that inherits from DrawableGameComponent, and I have overridden the Initialize, LoadContent, UnloadContent, Update and Draw methods. Update and Draw are called as normal by XNA (i dont know who calls the methods exactly, but i know im not calling them explicitly). the weird part is Initialize, and LoadContent are never called. What could be causing this? Thanks -Adam

### C++ virtual function problem

24 September 2009 - 06:00 AM

im having a weird issue with a virtual function. here is my code:
```class Base
{
public:
int num;

virtual void func()
{
cout << "Base func()\n";
}
};

class Child1 : public Base
{
public:
int myNum;

void func()
{
cout << "Child1 " << myNum << endl;
}
};

class Child2 : public Base
{
public:
int myNum;

void func()
{
cout << "Child2 " << myNum << endl;
}
};

void main()
{
vector<Base> obj;
Base	b;
Child1	c1;
Child2	c2;

b.num = 0;
c1.num = 1;
c1.myNum = 2;
c2.num = 3;
c2.myNum = 4;

obj.push_back(b);
obj.push_back(c1);
obj.push_back(c2);

for(size_t i=0; i < obj.size(); i++)
{
cout << obj[i].num << endl;
obj[i].func();
}
}

```

when i compile and run it, i get the following:
```0
Base func()
1
Base func()
3
Base func()
Press any key to continue . . .
```

its my understanding that when i call the function func(), it will call func of the class its defined in, not base class every time. is this a problem with vector maybe?

PARTNERS