Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 24 May 2012
Offline Last Active Mar 23 2013 10:03 AM

Topics I've Started

Coding Animation of Armature

26 February 2013 - 10:38 AM

I've been working on a 3d engine from scratch for a while now. I've got my own model format with an export plugin for blender, and models are importing just fine in game. I'm working with a test model - a Hellknight imported from Doom3 and exported to my own format. The mesh draws as expected in my engine. But now I'm designing animation.


Basically, I'm not sure the right way to go about this, either:


A.) I'll export the skeleton with each bone pose (in world space, not relative to any other bones) as an array for each frame - even non-key-frames. this way, I can just set bone pos and be done with it. However, this will take lots of memory and more disk space than option B or C.


B.) I do the same as above, except export only keyframes, but this time interpolate between bone vertex positions. With this, we'd need more informatiion and processing to do the interpolating so that bones/mesh doesn't deform improperly, since point A to point B would need to be on a curve, not linear. This also would have to be relative to it's parent bone.


C.) Same as option B, except bone head/tail positions will be relative to the parent bone's tail position.


What's the standard way of doing this in decent game engines?

APi inconsistencies

30 December 2012 - 03:53 AM

glEnableVertexAttribArray takes am attribute location value which you get with glGetAttribLocation. however, glGetAttribLocation returns a SIGNED integer, and

glEnableVertexAttribArray takes an UNsigned integer, as shown by ths following links (and this is how it is implemented in glew):

GLint glGetAttribLocation(GLuint  program,  const GLchar * name);
void glEnableVertexAttribArray(GLuint  index);



so I ask... "wtf?"


am I overlooking something important?

Unit Cube to Frustum

17 December 2012 - 04:02 PM

I've found countless threads, articles, etc about this topic, but I'm not doing something right. I can create a view frustum but it isn't on the shape of the 'view' (it's much much wider)

I'll explain my process here as best I can without getting too deep into the math. if everything here checks out, I'll look closer at those operations.

steps I take:

1.) create a unit cube (8 vertices) with these bounds:

min/max x: -0.5f to 0.5f
min/max y: -0.5f to 0.5f
min/max z: -0.1f to -1.1f

(if z ranges from positive to negative, the frustum becomes more like an hour glass)

2.) invert my projection matrix
3.) multiply each of my cube's vertices by this inverted projection matrix
4.) ...
5.) profit

I don't know how to apply the view resolution like 800x600 because the thing is already pretty big at this point, with the smallest face of the frustum (the screen) being slightly larger than the actual screen space.

Bottom Row of 4x4 Matrix

15 December 2012 - 09:40 PM

I'm writing a matrix library.

In an opengl matrix, you have:


where R is rotation and T is translation.

what is A and B?

how would I apply A and B to a Vec3? ( I know how to translate and rotate )

how would I invert A and B?

Manual Picking Ray

10 July 2012 - 10:58 PM

For some reason I cannot figure out how to get manual picking working. I've most closely followed Nomagon's post from here: http://stackoverflow...ing-ray-picking

My code does look a bit simple compared to most implementations, but I think it does everything it needs to. I've seen other implementations use things like tan() and some other fluff, but it seems like useless fluff.

Line3f GetPickLine( void ) {
	const int* vp = game->renderer.viewport;

	// map UI mouse pos to [-1,1]
	Vec3f pos( game->input.GetUIMousePos() );

	pos.x = 2 * pos.x / vp[GL_VP_W] - 1; // todo * aspectRatio
	pos.y = 1 - 2 * pos.y / vp[GL_VP_H]; // invert y axis
	pos.z = -1;

	// get the inverted modelViewProjection matrix
	Mat4f mv( game->renderer.modelMatrix );
	Mat4f mvpi = Mat4f( game->renderer.projectionMatrix ) * mv;

	// multiply mouse pos and modelViewProjection matrix to get a point on that ray
	pos = mvpi * pos;

	Vec3f cam( -mv.Column3f(3) ); // camera position is last column of modelView matrix
	return Line3f( cam, pos );

//matrices are column-major
void Mat4f::InvertRotationOrtho( void ) {
	swap( data[0][1], data[1][0] );
	swap( data[0][2], data[2][0] );
	swap( data[1][2], data[2][1] );

void Mat4f::InvertTranspositionOrtho( void ) {
	data[3][0] = -data[3][0];
	data[3][1] = -data[3][1];
	data[3][2] = -data[3][2];

Vec3f Mat4f::Column3f( const int c ) const {
	ASSERT( c >=0 && c <= 3 , "Mat4f::Column3f: Bad argument\n." )
	return Vec3f( data[c][0], data[c][1], data[c][2] );

void swap( float& one, float& two ) {
	float tmp(one);
	one = two;
	two = tmp;