• Create Account

# Beem

Member Since 19 Oct 2002
Offline Last Active Nov 18 2012 11:43 PM

### In Topic: How do Rotation Matrix Work?

18 November 2012 - 08:46 PM

I hate to be the bearer of bad news, but all you really need to know right now, is that nobody knows what the matrix is. If you multiply two of them together it catenates them and then both transformations will occur. The reason you can do this is because 4x4 matrix with multiplication and addition defined as we normally do form a ring. In a ring multiplication is associative, so it matters not which matrices gets multiplied when, but only that they are properly pre-multiplied or post-multiplied depending on what you want to accomplish. For now just follow the formulas that tell you how to form the matrix, where to put the cosine and sine of the angles, and you'll have to be careful about transposes, since some graphics libraries use row vectors and some use column vectors. With row vectors, you post multiply by the matrices, with column vectors you pre multiply them, and when you switch from one to the other you must transpose the matrices. This will potentially cause for the most confusion.

The best way to think of matrices as some kind of black box, a function, that takes a vector as an input and ouputs a vector that has been transformed. With 4x4 matrices, which is what he use in video games, because they allow us to use the magical homogenous transormation, the input will be a 4x1 vector. Just set the w component to 1 for positional transformations, and you're good to go. Don't worry about setting w to antyhing else.

Now the reason I said I had bad news, is because if you truly want to understand matrices, you got to go to college to learn about linear algebra. I'm sorry to say it, but without a strong mathematical background if you tried to just read about matrices you'd think they are just some mystical force in the universe that somehow just work. There are all sorts of interesting reasons why we can pull off what we do in video games using matrices, such as orthogonal transformations, and the like, but it really takes a strong mathematical background to get understand it.

I will say this, however, if you get a degree in mathematics, you can still get a job in video games, and also since you have a degree in math and not computer science, people won't ask you to fix their computers all the time cause they don't know you know about computers.

### In Topic: R-value and L-value confusion

18 November 2012 - 08:04 PM

About that generic renderer, you don't actually want to have direct3d resource laying around in plain sight, correct? It seems to me like your master list, wherever "i" is coming from, should be internal to your renderer, and it should just contain a list of poitners to direct3d resourcees, no casting necessary. Then if you do write an OpenGL renderer, it will have it's own list of OpenGL resources. If you want to use the same code for that list, use a template. The only place where a renderer needs to be generic, is in the interface, in which case you might just return a number that represents where the resource is in some master list, but only the renderer knows if the resource is D3D or OpenGL and what information it's going to send to the video card when you want to use it.

### In Topic: Ideas for Lua integration in a game engine.

18 November 2012 - 10:50 AM

I want to play devil's advocate with this post. Scripting sounds cool and all, but you are making asmall project, and you are going to find that going back in forth between scripting and getting the scripting to work with your engine, is going to be incredibly difficult and take a really long time, and you won't have anything worth showing anyone for a long time. I know a lot of people use Unreal, which is all about scripting, and so when it comes time to make your own engine, you're like "I want scripting, like Unreal". I think you should take a note from id Software, instead of using a scripting language, just use good old C++ and put your AI and game flow into a DLL file, then you just have to write some kind of SDK, a pure virtual class, or list of callback functions. It's going to save you a lot of headache, plus you will know exactly how memory is being managed.

### In Topic: Clear Screen with a transparent color

24 August 2011 - 12:31 AM

There is no such thing as an alpha channel in the back buffer. If you want to blend with the desktop, you'll probably need to render to a GDI surface, then use a Windows API call to blend it to the desktop. Here is something I found on the topic of alpha blending in the windows API http://blog.duck17.net/post/Per-pixel-Alpha-Blending-in-Native-Win32-API.aspx.

### In Topic: can somebody clarify this

24 August 2011 - 12:12 AM

Who knows why that is there. It is perfectly valid to specific an alpha channel in the back buffer. I would ignore this, and move on because it doesn't make any sense.

This guy sort of right. But the real answer is that technically there is no such thing as alpha on the back buffer since that wouldn't have any effect when getting copied to your monitor. (What would the back buffer get blended with? Your monitor is suddenly going to turn partially transparent in real life!) Alpha channels only have meaning if they are somehow getting blended with something. In my experience, though, most video cards could care less if your back buffer format is specified as having an alpha channel. The final value of the alpha channel in the back buffer will either never be written, or will be ignored. I would stick with the documentation, though, and use D3DFMT_X8R8G8B8, just to be safe.

PARTNERS