Jump to content

  • Log In with Google      Sign In   
  • Create Account


Michael Wojcik

Member Since 28 Aug 2007
Offline Last Active Feb 19 2014 01:23 PM

Topics I've Started

Fell: Escape Cyrocon

22 November 2012 - 10:52 PM

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, here it is! Posted Image.

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!

Lua: A return keyword followed by a table

23 August 2012 - 04:32 PM

I recently obtained a lua file like this,

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...
},
}

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,

Vector rotation via Quaternion

09 July 2012 - 10:52 PM

Hello,

I am using this webpage to build some of my methods for my game engine's quaternion class.

I am having trouble with the vector rotation via quaternion code. In the webpage cited above, this is what it looks like.

// Multiplying a quaternion q with a vector v applies the q-rotation to v
Vector3 Quaternion::operator* (const Vector3 &vec) const
{
Vector3 vn(vec);
vn.normalise();

Quaternion vecQuat, resQuat;
vecQuat.x = vn.x;
vecQuat.y = vn.y;
vecQuat.z = vn.z;
vecQuat.w = 0.0f;

resQuat = vecQuat * getConjugate();
resQuat = *this * resQuat;

return (Vector3(resQuat.x, resQuat.y, resQuat.z));
}

So I use it in my quaternion class but I get incorrect results.

This is what I do to test the method...

Vector3 pos = new Vector3(1.0f, 0.0f ,0.0f);
		
		Quaternion q = new Quaternion(0.0f, 0.0f, 45f);
		
		pos = q.Rotate(pos);

To my current perspective, this will give me <~-0.707, ~0.707, 0.0f>. But it doesn't, I get <-0.13529904, 0.3535534, -0.3744762>, which seems to me to be way off.

Here is my code for the quaternion-vector rotation method...

/**
  * 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;
}

My code is in Java, so that is why it looks different. I apprecaite any help or ideas!!

Thanks!

Getting frustum planes from orthogonal projection

12 April 2012 - 03:42 PM

Hello,
I have read through most of this paper 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!

The uniform qualifier and for loop

24 November 2011 - 01:19 AM

Hello all.

I checked out the glsl specs and looked in google, but surprisingly, I can't seem to find the answer for this question. Here goes..

Can I have a uniform variable be used like this in my for loop's condition expression?

	for(int i = 0; i < u_texCount; i++)
	{
 		//.....
	}

where u_texCount is declared like so...

uniform int u_texCount;

I am currently doing this right now, but my shader freaks out. When I replace u_texCount with say, 2, it works.

PARTNERS