資源簡(jiǎn)介
自己最近用SPH方法做的一個(gè)經(jīng)典流體模擬實(shí)例,花了很長(zhǎng)時(shí)間才圓滿完成,已實(shí)測(cè),可行!
代碼片段和文件信息
/*A?3D?Real?Time?Fluid?Solver?Demo.
?*Currentlythe?grid?size?is?M*N*O(16*16*16)?you?can?modify?them?depend?on?your?hardware?performance.
?*Also?you?can?modify?temp?step?diffuse?factor?viscous?factor?force?and?source?added?each?time.
?*Press?‘SPACE‘?key?to?add?source?of?fluid?‘W‘?or?‘S‘?or?‘D‘??key?to?add?force.
?*Right?click?and?hold?to?rotate.?Left?click?and?hold?to?move.?Hold?Left?and?Right?buttons?to?zoom.?
?*Press?‘V‘?key?to?display?velocity?field?‘D‘??to?display?density?field?‘C‘?to?clear?display?‘H‘?to?toggle?help?information.
?*The?code?is?only?for?research.?
?*By?SoRoMan.
?*/
#include?
#include?
#include? /*?must?include?this?before?GL/gl.h?*/
/*#include?*/ /*?OpenGL?header?file?*/
/*#include?*/ /*?OpenGL?utilities?header?file?*/
#include?
/*?macros?*/
#define?IX(ijk)?((i)+(M+2)*(j)?+?(M+2)*(N+2)*(k))?
#define?MAX(ab)????????????(((a)?>?(b))???(a)?:?(b))
#define?WINDOW_title?“Fluid?Solver?2.0?Demo“
#define?WINDOW_WIDTH?512
#define?WINDOW_HEIGHT?512
/*?external?definitions?*/
extern?void?dens_step?(?int?M?int?N?int?O?float?*?x?float?*?x0?float?*?u?float?*?v?float?*?w?float?diff?float?dt?);
extern?void?vel_step?(int?M?int?N?int?O?float?*?u?float?*?v??float?*?w?float?*?u0?float?*?v0?float?*?w0?float?visc?float?dt?);
/*?game?console*/
int?Game_Init(void);
int?Game_Shutdown(void);
int?Game_Main(void);
void?Game_Reset();
void?display();
/*?global?variables?*/
/*fluid?field?information*/
static?int?M?=?16;?/*grid?size?x*/
static?int?N?=?16;?/*grid?size?y*/
static?int?O?=?16;?/*grid?size?z*/
static?float?dt?=?0.4f;?/*time?step*/
static?float?diff?=?0.0f;?/*diffuse?factor*/
static?float?visc?=?0.0f;?/*viscous?factor*/
static?float?force?=?10.0f;??/*force?added?each?time*/
static?float?source?=?200.0f;?/*source?added?each?time*/
static?boolean?addforce[3]?=?{FALSE?FALSE?FALSE};
static?boolean?addsource?=?FALSE;
static?float?*?u?*?v?*w?*?u_prev?*?v_prev?*?w_prev;
static?float?*?dens?*?dens_prev;
/*draw?information*/
static?int?dvel?=?0;
static?int?dhelp?=?1;
char?fpsinfo[255];
char?fieldinfo[255];
/*window*/
static?int?win_id;
static?int?win_x?win_y;
static?int?mouse_down[3];
static?int?omx?omy?mx?my;
static?float?alpha[8];
static?float?ex?=?2.718282;
enum?{?
PAN?=?1 /*?pan?state?bit?*/
ROTATE /*?rotate?state?bits?*/
ZOOM /*?zoom?state?bit?*/
};
HDC?hDC; /*?device?context?*/
HPALETTE?hPalette?=?0; /*?custom?palette?(if?needed)?*/
/*?3d?control.?Like?Li*/
GLfloat?trans[3]; /*?current?translation?*/
GLfloat?rot[2]; /*?current?rotation?*/
static?void?free_data?(?void?)
{
if?(?u?)?free?(?u?);
if?(?v?)?free?(?v?);
if?(?w?)?free?(?w?);
if?(?u_prev?)?free?(?u_prev?);
if?(?v_prev?)?free?(?v_prev?);
if?(?w_prev?)?free?(?w_prev?);
if?(?dens?)?free?(?dens?);
if?(?dens_prev?)?free?(?dens_prev?);
}
static?void?c
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-08-01?10:02??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\
?????目錄???????????0??2018-08-01?10:02??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\
?????文件?????????398??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\BscMake.command.1.tlog
?????文件???????14156??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\CL.read.1.tlog
?????文件????????1158??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\CL.write.1.tlog
?????文件?????4287488??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\FluidSolver2.bsc
?????文件??????465920??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\FluidSolver2.exe
?????文件?????????406??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\FluidSolver2.exe.em
?????文件?????????472??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\FluidSolver2.exe.em
?????文件?????????381??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\FluidSolver2.exe.intermediate.manifest
?????文件?????1146168??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\FluidSolver2.ilk
?????文件??????????70??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\FluidSolver2.lastbuildstate
?????文件????????4084??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\FluidSolver2.log
?????文件?????1887232??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\FluidSolver2.pdb
?????文件?????????713??2018-07-30?16:51??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\FluidSolver2.vcxprojResolveAssemblyReference.cache
?????文件???????????0??2018-07-30?16:51??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\FluidSolver2.write.1.tlog
?????文件?????????220??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\FluidSolver2_manifest.rc
?????文件?????????652??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\bscmake.read.1.tlog
?????文件?????????380??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\bscmake.write.1.tlog
?????文件????????1450??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\cl.command.1.tlog
?????文件???????????2??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\li
?????文件???????????2??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\li
?????文件???????????2??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\li
?????文件???????????2??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\li
?????文件???????????2??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\li
?????文件???????????2??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\li
?????文件????????1734??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\li
?????文件????????4036??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\li
?????文件?????????996??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\li
?????文件???????70314??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\main.obj
?????文件???????????0??2018-07-30?17:06??一個(gè)經(jīng)典的流體模擬源代碼,花了很長(zhǎng)時(shí)間在網(wǎng)上找到的\Debug\main.sbr
............此處省略26個(gè)文件信息
- 上一篇:s32k-rm參考手冊(cè)
- 下一篇:x-studio365.zip
評(píng)論
共有 條評(píng)論