資源簡介
opengl的一個CS三維場景,很逼真,適合opengl游戲開發和opengl初學者學習的一個很好地代碼

代碼片段和文件信息
#include?“Defines.h“
#include?“Quake3BSP.h“
#include?“LoadTexture.h“
#include?“Glext.h“
#include?“Camera.h“
#include?“Frustum.h“
#include?“FPS.h“
//FIXME:?ugly?externs?and?globals?and?defines?again?:(
#define ENDL?“\n“
#define LMAPSIZE (128*128*3)
int closestplane;?
float RADIUS?=?10.0f;?//not?sure?what?this?should?be?defined?as
#define?EPSILON?.03125
int LastPlaneCrossed;
extern Vector3 BoxMaxs;
extern?PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB;
extern?PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
extern?Camera?cam;
extern?Frustum?frus;
extern?FPS_t?FPS;
std::ofstream?trace(“Trace.txt“);
std::ofstream textures(“textures.txt“);
struct pixelf
{
pixelf(){}
pixelf(float?rtfloat?gtfloat?bt):r(rt)g(gt)b(bt){}
float rgb;
};
struct pixelfa
{
pixelfa(){}
pixelfa(float?rtfloat?gtfloat?btfloat?at):r(rt)g(gt)?b(bt)?a(at){}
float rgba;
};
//To?make?Y?up?swap?the?Y?and?Z?values?and?negate?new?Z
void BSP::MakeYUp(Vector3 *?a)
{
float temp?=?a->z;
a->z?=?-a->y;
a->y?=?temp;
}
//for?leaf?bounding?boxes
void BSP::MakeYUp(tVector3i *a)
{
float temp?=?a->z;
a->z?=?-a->y;
a->y?=?temp;
}
//byte?[128][128][3]
//equals?to?rgb?for?128?x?128?map
UINT BSP::GenLightmap(tBSPLightmap?*?lightmap)
{
UINT texture?=?0;
glGenTextures(1?&texture);
//FIXME:?look?more?into?how?these?texture?functions?work?possible?optimizations?anywhere?
//this?function?determines?how?the?pixel?data?is?stored?in?memory?not?significant?unless?you?are
//reading?the?data?from?screen?for?a?screenshot?or?something
//?the?second?parameter?is?how?many?bytes?between?rows?of?pixel?memory
glPixelStorei(GL_UNPACK_ALIGNMENT?1);
//creates/selects?the?texture
glBindTexture(GL_TEXTURE_2D?texture);
pixelf?pixel;
float max temp;
//touch?every?single?pixel?and?manipulate?its?color?while?keeping?things?in?range
byte *ImageData = &lightmap->imageBits[0][0][0];
for(int?i?=?0;?i? {
max?=?1.0f;
temp = 0.0f;
pixel=pixelf(((float)ImageData[i]*3.1)/255.0f((float)ImageData[i+1]*3.1)/255.0f((float)ImageData[i+2]*3.1)/255.0f);
if(pixel.r?>?1.0f)
if((1.0f/pixel.r)? max?=?1.0f/pixel.r;
if(pixel.g?>?1.0f)
if((1.0f/pixel.g)? max?=?1.0f/pixel.g;
if(pixel.b?>?1.0f)
if((1.0f/pixel.b)? max?=?1.0f/pixel.b;
max*=255;
pixel=pixelf(pixel.r*max?pixel.g*max?pixel.b*max);
ImageData[i]?=?(byte)pixel.r;
ImageData[i+1]?=?(byte)pixel.g;
ImageData[i+2]?=?(byte)pixel.b;
}
//mip?maps?generate?arrays?of?the?same?texture?information?so?that?it?uses?lower?resolution?textures
//when?you?are?far?away?and?higher?resolution?textures?when?you?are?up?close
//because?our?lightmaps?are?128x128?that?is?static?to?this?function
//second?parameter?is?number?of?channels?rgb?(+a?if?4?channels)
gluBuild2DMipmaps(GL_TEXTURE_2D?3?128?128?GL_RGB?GL_UNSIGNED_BYTE?lightmap->imageBits);
//sets?up?variou
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????639078??2003-07-21?21:51??OPenglCS三維場景\Demo\BSP.exe
?????文件????1922308??2002-08-07?22:41??OPenglCS三維場景\Demo\GameTutorialsBSP.bsp
?????文件??????????0??2013-12-12?16:58??OPenglCS三維場景\Demo\textureerror.txt
?????文件?????714389??2001-01-11?21:08??OPenglCS三維場景\Demo\textures\frozendusk\frozendusk_bk.tga
?????文件?????769520??2001-01-11?21:16??OPenglCS三維場景\Demo\textures\frozendusk\frozendusk_dn.tga
?????文件?????616955??2001-01-11?21:02??OPenglCS三維場景\Demo\textures\frozendusk\frozendusk_ft.tga
?????文件?????553935??2001-01-11?21:05??OPenglCS三維場景\Demo\textures\frozendusk\frozendusk_lf.tga
?????文件?????629842??2001-01-11?21:25??OPenglCS三維場景\Demo\textures\frozendusk\frozendusk_rt.tga
?????文件?????297903??2001-01-11?21:13??OPenglCS三維場景\Demo\textures\frozendusk\frozendusk_up.tga
?????文件??????49196??2000-10-08?18:48??OPenglCS三維場景\Demo\textures\q3hh2\2r_plaster_floor01.tga
?????文件??????49196??2000-10-08?18:48??OPenglCS三維場景\Demo\textures\q3hh2\2r_plaster_floor02.tga
?????文件??????24620??2000-10-28?21:50??OPenglCS三維場景\Demo\textures\q3hh2\2_256_red_thin01.tga
?????文件??????24620??2000-10-28?21:50??OPenglCS三維場景\Demo\textures\q3hh2\2_256_red_thin02.tga
?????文件??????98348??2000-11-16?02:55??OPenglCS三維場景\Demo\textures\q3hh2\2_256_white_sup03.tga
?????文件??????24620??2000-11-16?02:53??OPenglCS三維場景\Demo\textures\q3hh2\2_32_red_thin02.tga
?????文件??????24620??2000-10-19?19:57??OPenglCS三維場景\Demo\textures\q3hh2\2_8_step03.tga
?????文件???????6188??2000-10-19?19:57??OPenglCS三維場景\Demo\textures\q3hh2\2_8_step03b.tga
?????文件?????196652??2000-10-26?00:49??OPenglCS三維場景\Demo\textures\q3hh2\2_circuit_overlay.tga
?????文件??????49196??2000-10-28?21:17??OPenglCS三維場景\Demo\textures\q3hh2\2_conc01.tga
?????文件??????98348??2000-11-16?02:37??OPenglCS三維場景\Demo\textures\q3hh2\2_conc02.tga
?????文件??????98348??2000-11-16?02:37??OPenglCS三維場景\Demo\textures\q3hh2\2_conc03.tga
?????文件?????196652??2000-10-08?18:43??OPenglCS三維場景\Demo\textures\q3hh2\2_conc_celing01.tga
?????文件?????196652??2000-11-16?02:34??OPenglCS三維場景\Demo\textures\q3hh2\2_conc_floorpat01.tga
?????文件?????196652??2000-11-16?02:33??OPenglCS三維場景\Demo\textures\q3hh2\2_conc_floorpat02.tga
?????文件??????49196??2000-11-16?02:38??OPenglCS三維場景\Demo\textures\q3hh2\2_conc_l01.tga
?????文件??????49196??2000-11-16?02:38??OPenglCS三維場景\Demo\textures\q3hh2\2_conc_l04.tga
?????文件??????49196??2000-11-16?02:38??OPenglCS三維場景\Demo\textures\q3hh2\2_conc_l05.tga
?????文件?????196652??2000-10-08?15:12??OPenglCS三維場景\Demo\textures\q3hh2\2_conc_wall01.tga
?????文件??????65580??2000-10-18?16:49??OPenglCS三維場景\Demo\textures\q3hh2\2_c_128_trellis01b2.tga
?????文件??????32812??2000-10-28?22:31??OPenglCS三維場景\Demo\textures\q3hh2\2_c_thinredtrim03.tga
............此處省略52個文件信息
- 上一篇:北京市王府井平面圖
- 下一篇:《大學物理基礎吳百詩編》課后題答案上下全
評論
共有 條評論