Hello fellow developers,
Some of you might remember me posting on game dev to get some help and in some cases helping others. I am happy to announce that I have finished my first game for Android. It is my game engine's first release. If you have an Android device, [url="https://play.google.com/store/apps/details?id=com.voidseer.voidengine&feature=search_result#?t=W251bGwsMSwxLDEsImNvbS52b2lkc2Vlci52b2lkZW5naW5lIl0."]here it is![/url] [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img].
Thank you all from this great community for your help. This is the first game of many games to come from me and my future company. If you buy it, thank you for your support! I hope you enjoy Escape Cyrocon!

I recently obtained a lua file like this,
[CODE]
return {
file="Optimus.png",
height=62,
description={
family="Optimus",
style="Regular",
size=32
},
metrics={
ascender=46,
descender=-16,
height=62
},
texture={
file="IM:Textures:1:Textures/Optimus.png",
width=512,
height=256
},
chars={
{char=" ",width=13,x=1,y=39,w=0,h=0,ox=0,oy=0},
{char="!",width=10,x=2,y=9,w=8,h=30,ox=0,oy=30},
{char='"',width=20,x=11,y=9,w=17,h=11,ox=0,oy=30},
-- so on...
},
}
[/CODE]
I don't see where the return keyword followed by the table would put the table in the global enviroment and can't seem to shed light on it from my lua book and googling. I am trying to parse it in luaj api and am in need of knowing where are the table is stored in the global enviroment after running the script. I do know that technically, a function in lua is a closure assigned to a variable. I would peronally just use the three tables as global variables here, but now I am quite curious what the original author did here.
Thanks,

To the method to rotate the vector by a quaternion.
[CODE]
/**
* Multiplys a quaternion q with a vector v to apply the q-rotation to v
*/
public Vector3 Rotate (Vector3 vec)
{
vecnormal.Set(vec);
vecnormal.Normalize();
qVec.x = vecnormal.X;
qVec.y = vecnormal.Y;
qVec.z = vecnormal.Z;
qVec.w = 0.0f;
qConjugate.Set(this).Conjugate();
Quaternion qRes = qVec.Multiply(qConjugate);
qTmpThis.Set(this);
qRes = qTmpThis.Multiply(qRes);
vec.X = qRes.x; vec.Y = qRes.y; vec.Z = qRes.z;
return vec;
}[/CODE]
The result is always normal, no matter the magnitude of the input vector. Is this correct in the context of vector rotation via a quaternion? I was expecting the vector to be returned as a coordinate. I could ofcourse, could mutiply the result normal by the magnitude of the input vector. But I want to be sure if by definition, q * p * q-1 returns a rotated normal, or coordinate.

Cool! Thats was indeed the issue! You saved me alot of time, thanks! I have another question regarding the result of quaternion - vector rotation. I noticed that If I were to pass <5.0, 0.0,0.0> I get a normal (0.707107,0.707107,0) as If I passed in <1.0, 0.0,0.0>.
Does quaternion rotation with vector only work with vector normals? Or might I have messed something else up in my class?

I suppose the paper's frustum extraction routine only works for perspective matrices. I just double checked my implementation of the paper's routine and the normal I am getting for top plane for example is [0.0, 0.3737926, 0.9275124] not [0.0, 1.0, 0.0] as I would suspect.

Indeed, I appreciate your confirmation, that what I had in mind as how to calculate the frustums for an orthogonal projection matrix is correct. In terms of the routine as explained in the paper, does that only work for perspective matrices though?

Hello,
I have read through most of this [url="http://www.cs.otago.ac.nz/postgrads/alexis/planeExtraction.pdf"]paper [/url]here that explains how to extract your camera's frustum planes. For my game I am using a orthogonal projection matrix which might explain why I am getting seemingly off plane normals.
My question is, does the equation on that paper for the opengl version of frustum plane extraction work also for orthogonal projection matrices? If not, then I suppose I could create a routine myself since orthogonal projection is a box anyways. I don't want to do that though unless I know that this routine will not work for orthogonal matrices.
I appreciate any help,
Thanks!

Okay, thanks for the clarification. Well, in my engine code side, I simply set the uniform to 1, for testing purposes. Still renders erroneously though. I suppose that might mean my hardware might not support it. I too saw that the specification made no specific rules about the concept.

Thanks for the replies.
What I mean by 'freak out' is that it compiles and links fine, but when my code is running and rendering the shader program, it draws sort of a lightshow instead of my texture. When I replace the uniform variable with a constant, I get my normal textures being rendered. So some things in GLSL from what samoth mentioned can be thought of as, it will compile for now, but it might not work. Good to know.
Yet it is interesting that gdmarkou code works. My video card is a NVIDIA GeForce GTX 260. I verified that the uniform is also being set.
I would prefer to make the iteration based on a uniform variable but I'll use constants if I must.