資源簡介
基于體渲染的OpenGL煙霧模擬程序,效率需要提高,煙霧紋理需要改進,有興趣的朋友可以參考下!

代碼片段和文件信息
#include?
#include?“gl\glut.h“
#include?
#include?“maths.h“
/*-----------------------------------------------------------------
The?objects?motion?is?restricted?to?a?rotation?on?a?predefined?axis
The?function?bellow?does?cylindrical?billboarding?on?the?Y?axis?i.e.
the?object?will?be?able?to?rotate?on?the?Y?axis?only.
-----------------------------------------------------------------*/
void?l3dBillboardLocalToWorld(float?*cam?float?*worldPos)?{
float?modelview[16];
glGetFloatv(GL_MODELVIEW_MATRIX?modelview);
//?The?local?origin‘s?position?in?world?coordinates
worldPos[0]?=?cam[0]?+?modelview[12]*modelview[0]?+?modelview[13]?*?modelview[1]?+?modelview[14]?*?modelview[2];
worldPos[1]?=?cam[1]?+?modelview[12]*modelview[4]?+?modelview[13]?*?modelview[5]?+?modelview[14]?*?modelview[6];
worldPos[2]?=?cam[2]?+?modelview[12]*modelview[8]?+?modelview[13]?*?modelview[9]?+?modelview[14]?*?modelview[10];
}
/*-----------------------------------------------------------------
The?objects?motion?is?restricted?to?a?rotation?on?a?predefined?axis
The?function?bellow?does?cylindrical?billboarding?on?the?Y?axis?i.e.
the?object?will?be?able?to?rotate?on?the?Y?axis?only.
-----------------------------------------------------------------*/
void?l3dBillboardCylindricalBegin(float?*cam?float?*worldPos)?{
float?lookAt[3]={001}objToCamProj[3]upAux[3]angleCosine;
//?objToCamProj?is?the?vector?in?world?coordinates?from?the?local?origin?to?the?camera
//?projected?in?the?XZ?plane
objToCamProj[0]?=?cam[0]?-?worldPos[0]?;
objToCamProj[1]?=?0;
objToCamProj[2]?=?cam[2]?-?worldPos[2]?;
//?normalize?both?vectors?to?get?the?cosine?directly?afterwards
mathsNormalize(objToCamProj);
//?easy?fix?to?determine?wether?the?angle?is?negative?or?positive
//?for?positive?angles?upAux?will?be?a?vector?pointing?in?the?
//?positive?y?direction?otherwise?upAux?will?point?downwards
//?effectively?reversing?the?rotation.
mathsCrossProduct(upAuxlookAtobjToCamProj);
//?compute?the?angle
angleCosine?=?mathsInnerProduct(lookAtobjToCamProj);
//?perform?the?rotation.?The?if?statement?is?used?for?stability?reasons
//?if?the?lookAt?and?v?vectors?are?too?close?together?then?|aux|?could
//?be?bigger?than?1?due?to?lack?of?precision
if?((angleCosine?0.99990)?&&?(angleCosine?>?-0.9999))
glRotatef(acos(angleCosine)*180/3.14upAux[0]?upAux[1]?upAux[2]);
}
/*----------------------------------------------------------------
True?billboarding.?With?the?spherical?version?the?object?will?
always?face?the?camera.?It?requires?more?computational?effort?than
the?cylindrical?billboard?though.?The?parameters?camXcamY?and?camZ
are?the?target?i.e.?a?3D?point?to?which?the?object?will?point.
----------------------------------------------------------------*/
void?l3dBillboardSphericalBegin(float?*cam?float?*worldPos)?{
float?lookAt[3]={001}objToCamProj[3]objToCam[3]upAux[3]angleCosi
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????545??2001-10-02?01:15??Smoke_shader\glutsnowman.dsw
?????文件????????489??2001-10-17?23:18??Smoke_shader\fonts.h
?????文件????????419??2001-11-11?04:11??Smoke_shader\l3DBillboard.h
?????文件???????1536??2001-09-27?23:59??Smoke_shader\maths.h
?????文件???????8661??2001-01-02?23:32??Smoke_shader\tga.cpp
?????文件????????827??2000-12-03?00:00??Smoke_shader\tga.h
?????文件?????262683??2000-04-02?00:45??Smoke_shader\tree.tga
?????文件???????1864??2008-11-14?15:40??Smoke_shader\ShaderUtil.h
?????文件?????173056??2008-12-02?16:29??Smoke_shader\glutsnowman.ncb
?????文件???????1784??2008-12-01?16:06??Smoke_shader\glutsnowman.plg
?????文件??????79898??1998-08-18?23:25??Smoke_shader\glut32.lib
?????文件?????169984??1998-08-18?23:25??Smoke_shader\glut32.dll
?????文件???????7105??2008-11-14?15:59??Smoke_shader\billboard.cpp
?????文件???????5176??2002-05-13?15:33??Smoke_shader\spark.bmp
?????文件???????5176??2002-05-15?16:17??Smoke_shader\bubble.bmp
?????文件???????5176??2002-05-15?16:17??Smoke_shader\cloud.bmp
?????文件???????2069??2008-11-14?15:35??Smoke_shader\fonts.cpp
?????文件?????196664??2008-11-14?15:12??Smoke_shader\colorGradient.bmp
?????文件?????192512??2006-03-04?03:19??Smoke_shader\glew32.dll
?????文件?????281360??2006-03-04?03:19??Smoke_shader\glew32.lib
?????文件???????7871??2008-11-14?15:35??Smoke_shader\l3dBillboard.cpp
?????文件??????81920??2008-11-19?16:07??Smoke_shader\glutsnowman.exe
?????文件???????8337??2008-11-14?15:40??Smoke_shader\ShaderUtil.cpp
?????文件????????266??2008-11-14?17:19??Smoke_shader\ParticleUtils.cpp
?????文件????????150??2008-11-14?17:19??Smoke_shader\ParticleUtils.h
?????文件???????2310??2008-11-14?13:45??Smoke_shader\pVector.h
?????文件???????4226??2008-11-18?10:50??Smoke_shader\glutsnowman.dsp
?????文件????????384??2008-11-18?10:45??Smoke_shader\shader\VolumeParticle.vert
?????文件?????169984??1998-08-18?23:25??Smoke_shader\shader\glut32.dll
?????文件?????192512??2006-03-04?03:19??Smoke_shader\shader\glew32.dll
............此處省略49個文件信息
評論
共有 條評論