Skip to main content
gamedev.net
🔒 Locked

Please Translate

Started by Sean Doherty 2 replies 700+ views
Original Post
Sean Doherty
Sean Doherty
Since I know next to nothing about OpenGL, would someone please explain what this is doing? The following is partial source code if from Free Space:
trail_calc_facing_pts( &topv, &botv, fvec, &pos, w );

g3_rotate_vertex( ⊤, &topv );
g3_rotate_vertex( ⊥, &botv );
top.a = bot.a = l;	

vertex *vlist[4];
vlist[0] = &last_bot;
vlist[1] = ⊥
vlist[2] = ⊤
vlist[3] = &last_top;

vlist[0]->u = 0.0f;  vlist[0]->v = 0.0f;
vlist[1]->u = 1.0f;  vlist[1]->v = 0.0f;
vlist[2]->u = 1.0f;  vlist[2]->v = 1.0f;
vlist[3]->u = 0.0f;  vlist[3]->v = 1.0f;

gr_set_bitmap(ti->bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, l/255.0f );
if ( D3D_enabled )	{
    g3_draw_poly( 4, vlist, TMAP_FLAG_TEXTURED|TMAP_FLAG_ALPHA|TMAP_FLAG_GOURAUD );
}
else
{
    g3_draw_poly( 4, vlist, TMAP_FLAG_TEXTURED );
}
It looks similar to locking the vertex buffer in DirectX and manipulating the vertices; but I have no idea what "g3_rotate_vertex( ⊤, &topv );" is doing? _______________________________________ Understanding is a three edged sword...
_______________________________________Understanding is a three edged sword...Freelance Games - Home of XBLIG Starchonwww.FreelanceGames.com
Sean Doherty
Sean Doherty
quote:

And neither have I, since none of that is actually OpenGL code. All those underscored_function_names must be somewhere else in the source.



Fair enough; how about describing this in terms of DirectX (it is OpenGL):


void VectorAlignedBillBoard::display(
const Vector &cameraLocation,
const Vector &billBoardLocation,
const Vector &billBoardAxis,
float halfLength,
float halfWidth)
{
//the camera location is the camera view point (naming issues)


//we define the four corners based on the direction of

//travel and the cross product of the direction of travel

//with the camera direction. so that the billboard is allways

//showing as much as it can towards the camera

Vector cameraDirection = cameraLocation - billBoardLocation;
Vector lateralVector = crossProduct(cameraDirection,billBoardAxis);

//the travel direction and the lateral vector will

//be used to construct the four points of the quad that

//defines the objects display primitive

lateralVector = lateralVector.withLength(halfWidth);
Vector forwardVector = billBoardAxis.withLength(halfLength);

glBegin(GL_TRIANGLE_STRIP);
//top right

glTexCoord2f(1.0,0.0);
gVertex(forwardVector + lateralVector + billBoardLocation);
//top left

glTexCoord2f(0.0,0.0);
gVertex(lateralVector - forwardVector + billBoardLocation);
//bottom right

glTexCoord2f(1.0,1.0);
gVertex(forwardVector - lateralVector + billBoardLocation);
//bottom left

glTexCoord2f(0.0,1.0);
gVertex(-lateralVector - forwardVector + billBoardLocation);
glEnd();
}


_______________________________________
Understanding is a three edged sword...
_______________________________________Understanding is a three edged sword...Freelance Games - Home of XBLIG Starchonwww.FreelanceGames.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.