Jump to content

  • Log In with Google      Sign In   
  • Create Account


SpectreNectar

Member Since 19 Sep 2009
Offline Last Active Oct 16 2012 06:47 AM
-----

Topics I've Started

Separating geometry based on closest points?

11 October 2012 - 04:06 PM

Hi

What is a good way to separate a sphere or a capsule inside a polyhedron?

Thanks!

Distance to collision in AABB world

03 May 2012 - 01:38 PM

I'm trying to write a function for my game that returns the distance to the nearest collision along a direction. It is fed the following data:

Vector3D origin (Point to start search from)
Vector3D volume (Halfwidths)
Vector3D direction (Direction to check)

The function iterates over a list of "Areas" that are really just axis aligned boundary boxes and attempts to return a distance in the form of a double.

But now I've gone and stirred myself blind on it and need some help. The approach that first came to my mind was to project the boxes to the direction, and when I realized that wouldn't work I thought I'd store the normals of the iterated boundary boxes somewhere instead and then do a separating axis test, like what is common in 2D.
But then it seems I'd be needing an oriented bounding box test. Is that really necessary? I mean considering the boxes are all aligned.

I'd like to know what the correct way to do this would be? Thank you.

Help me using buffer objects

05 March 2012 - 05:18 AM

Greetings,

I'm having a bit of trouble grasping the concept of drawing things with buffer objects, and a lot of trouble getting anything to be displayed on screen with one. Up until now I have been using gl_begin/gl_end for drawing.

So I basically have everything set up more or less how I want it, only I need to know what function calls to make and in what order. Here's what I've tried:

//Initialization
trimesh_rendering* t = get_world_trias();

glGenBuffers(1, &vboId);
glBindBuffer(GL_ARRAY_BUFFER, vboId);
glBufferData(GL_ARRAY_BUFFER, sizeof(t->vertices)+sizeof(t->normals)+sizeof(t->colors), 0, GL_STREAM_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(t->vertices), t->vertices);							 // copy vertices starting from 0 offest
glBufferSubData(GL_ARRAY_BUFFER, sizeof(t->vertices), sizeof(t->normals), t->normals);			    // copy normals after vertices
glBufferSubData(GL_ARRAY_BUFFER, sizeof(t->vertices)+sizeof(t->normals), sizeof(t->colors), t->colors);  // copy colours after normals
glBindBuffer(GL_ARRAY_BUFFER, 0);

delete_world_trias(t);

//get_world_trias()
trimesh_rendering* TriMeshRenderer::get_world_trias() {
    trimesh_rendering* t = new trimesh_rendering;
    int num = 0;
    node *q;
    int col, row;
    //Count num trias
for( int r=0; r<world->get_rows()+world->get_cols()-1; r++ ) {
	    for( int c=maximum(0, r-world->get_rows()+1); c<=r && c<world->get_cols(); c++ ) {
		    col = c;
		    row = r-c;
   for( q = world->get(col,row,0); q != 0; q = q->next ) {
    TriMesh *mesh = q->shape;
    if(mesh!=0) {
				    num += mesh->get_numTrias()*9;
    }
   }
  }
}
    triasize = num/9;
    worldsize = num*3;
    t->len = num;
    t->vertices = new GLfloat[t->len];
    t->normals = new GLfloat[t->len];
    t->colors = new GLfloat[t->len];
    int m = 0;
for( int r=0; r<world->get_rows()+world->get_cols()-1; r++ ) {
	    for( int c=maximum(0, r-world->get_rows()+1); c<=r && c<world->get_cols(); c++ ) {
		    col = c;
		    row = r-c;
   for( q = world->get(col,row,0); q != 0; q = q->next ) {
    TriMesh *mesh = q->shape;
    if(mesh!=0) {
				    int n = mesh->get_numTrias();
				    for( int i=0; i<n; i++ ) {
					    Triangle3D tria = mesh->get_tria(i);
					    t->vertices[m+0] = tria.p1.x;
					    t->vertices[m+1] = tria.p1.y-tria.p1.z;
					    t->vertices[m+2] = 0;
					    t->vertices[m+3] = tria.p2.x;
					    t->vertices[m+4] = tria.p2.y-tria.p2.z;
					    t->vertices[m+5] = 0;
					    t->vertices[m+6] = tria.p3.x;
					    t->vertices[m+7] = tria.p3.y-tria.p3.z;
					    t->vertices[m+8] = 0;

					    t->normals[m+0] = tria.normal.x;
					    t->normals[m+1] = tria.normal.y;
					    t->normals[m+2] = tria.normal.z;
					    t->normals[m+3] = tria.normal.x;
					    t->normals[m+4] = tria.normal.y;
					    t->normals[m+5] = tria.normal.z;
					    t->normals[m+6] = tria.normal.x;
					    t->normals[m+7] = tria.normal.y;
					    t->normals[m+8] = tria.normal.z;

					    t->colors[m+0] = 1.0;
					    t->colors[m+1] = 1.0;
					    t->colors[m+2] = 1.0;
					    t->colors[m+3] = 1.0;
					    t->colors[m+4] = 1.0;
					    t->colors[m+5] = 1.0;
					    t->colors[m+6] = 1.0;
					    t->colors[m+7] = 1.0;
					    t->colors[m+8] = 1.0;
					    m+=9;
				    }
    }
   }
  }
}
return t;
}

//Update and draw
glBindBuffer(GL_ARRAY_BUFFER, vboId);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, 0);
trimesh_rendering* t = get_world_trias();
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(t->vertices), t->vertices);							 // copy vertices starting from 0 offest
glBufferSubData(GL_ARRAY_BUFFER, sizeof(t->vertices), sizeof(t->normals), t->normals);			    // copy normals after vertices
glBufferSubData(GL_ARRAY_BUFFER, sizeof(t->vertices)+sizeof(t->normals), sizeof(t->colors), t->colors);  // copy colours after normals
delete_world_trias(t);

glDrawArrays(GL_TRIANGLES, 0, triasize);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glUseProgram(0);


My goal is to use a vertex shader to transform primitives from a square to an isometric view.

Chaos VS Santa

13 December 2010 - 10:08 AM

Chaos VS Santa is the first danish produced wrestling game!
It is a game that focuses on social christmas get together.
Play as Chaos, the toughest wrestler in Denmark, or as everybodys favourite elf Santa.
It is a game that requires you to have lightning fast reactions and perception skills, if you don't want to be the one getting counted out.
So find a "slow" friend and beat him in the christmas game of the year.

http://ddnfilm.dk/game

Which BASIC should I use?

02 January 2010 - 02:03 PM

Hi there, I'm trying to get an overview of the different BASIC languages (preferrably aimed at game development), with the intention of making a game with it. Which do you recommend? I tried blitzmax and freebasic so far, but blitz seemed too limited and undocumented which eventually led me to read a lot up on freebasic only to discover that development has stoppped years ago and there's still lacking important OOP features. I'm not too much into reinventing the wheel (eg. defining that constant TRUE = 1), and really just wants something like blitz but with the ability to eg. make a copy og the player sprite and gradually add transparent pixels to that drawn on top.

PARTNERS