本文整理汇总了C++中CGutModel_DX9类的典型用法代码示例。如果您正苦于以下问题:C++ CGutModel_DX9类的具体用法?C++ CGutModel_DX9怎么用?C++ CGutModel_DX9使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CGutModel_DX9类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReleaseResourceDX9
bool ReleaseResourceDX9(void)
{
g_Model_DX9.Release();
g_SpotLightModel_DX9.Release();
return true;
}
示例2: InitResourceDX9
bool InitResourceDX9(void)
{
// 取得Direct3D 9裝置
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
// 設定視角轉換矩陣
g_projection_matrix = GutMatrixPerspectiveRH_DirectX(g_fFOV, 1.0f, 0.1f, 100.0f);
InitStateDX9();
CGutModel::SetTexturePath("../../textures/");
g_Model_DX9.ConvertToDX9Model(&g_Model);
g_SpotLightModel_DX9.ConvertToDX9Model(&g_SpotLightModel);
g_material_stencilpass.m_bCullFace = false;
g_material_spotlightpass.m_bBlend = true;
g_material_spotlightpass.m_SrcBlend = D3DBLEND_ONE;
g_material_spotlightpass.m_DestBlend = D3DBLEND_ONE;
g_material_spotlightpass.m_Material.Diffuse.r =
g_material_spotlightpass.m_Material.Diffuse.g =
g_material_spotlightpass.m_Material.Diffuse.b =
g_material_spotlightpass.m_Material.Diffuse.a = 0.3f;
return true;
}
示例3: ReleaseResourceDX9
bool ReleaseResourceDX9(void)
{
SAFE_RELEASE(g_pTexture);
SAFE_RELEASE(g_pDepthStencil);
SAFE_RELEASE(g_pBlurTextures[0]);
SAFE_RELEASE(g_pBlurTextures[1]);
g_Model_DX9.Release();
g_Terrain_DX9.Release();
return true;
}
示例4: RenderFrameDX9
// 使用DirectX9來繪圖
void RenderFrameDX9(void)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
// `把隱藏面測試規則設為小於或等於` <=
device->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
// `設定轉換矩陣`
Matrix4x4 view_matrix = g_Control.GetViewMatrix();
Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &view_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &world_matrix);
// `開始下繪圖指令`
device->BeginScene();
// `前8盞光`
if ( g_iSwitch & 0x01 )
{
SetupLightingDX9(&g_Lights[0], 8);
g_Model_DX9.Render();
}
// `後8盞光`
if ( g_iSwitch & 0x02 )
{
SetupLightingDX9(&g_Lights[8], 8);
if ( g_iSwitch & 0x01 )
{
// 如果前8盞光有開, 要使用混色來把下8盞光疊加上去.
device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
// ~SUBMIT_BLEND 會取消套用檔案中的混色設定.
g_Model_DX9.Render(~SUBMIT_BLEND);
}
else
{
g_Model_DX9.Render();
}
}
// `宣告所有的繪圖指令都下完了`
device->EndScene();
// `把背景backbuffer的畫面呈現出來`
device->Present( NULL, NULL, NULL, NULL );
}
示例5: InitResourceDX9
bool InitResourceDX9(void)
{
// 取得Direct3D 9裝置
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
// 設定視角轉換矩陣
g_projection_matrix = GutMatrixPerspectiveRH_DirectX(g_fFOV, 1.0f, 0.1f, 100.0f);
device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &g_projection_matrix);
// 關閉打光
device->SetRenderState(D3DRS_LIGHTING, FALSE);
// 改變三角形正面的面向
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
// 使用自動normalize功能
device->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);
// 配置動態貼圖
{
device->CreateTexture(g_framebuffer_w, g_framebuffer_h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pTexture, NULL);
device->CreateDepthStencilSurface(g_framebuffer_w, g_framebuffer_h, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0, FALSE, &g_pDepthStencil, NULL);
device->CreateTexture(g_framebuffer_w, g_framebuffer_h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pBlurTextures[0], NULL);
device->CreateTexture(g_framebuffer_w, g_framebuffer_h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pBlurTextures[1], NULL);
}
// 載入模型
{
CGutModel::SetTexturePath("../../textures/");
g_Model_DX9.ConvertToDX9Model(&g_Model);
g_Terrain_DX9.ConvertToDX9Model(&g_Terrain);
}
// 設定貼圖內插方法
{
device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
device->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
device->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
device->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
}
return true;
}
示例6: InitResourceDX9
bool InitResourceDX9(void)
{
g_orient_matrix.Identity();
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
if ( !ReInitResourceDX9() )
return false;
g_pPostEffect = GutLoadFXShaderDX9("../../shaders/Posteffect.fx");
if ( NULL==g_pPostEffect )
return false;
g_pWaterEffect = GutLoadFXShaderDX9("../../shaders/Watereffect.fx");
if ( NULL==g_pWaterEffect )
return false;
g_pWaterTexture = GutLoadTexture_DX9("../../textures/lena.tga");
if ( NULL==g_pWaterTexture )
return false;
g_Model_DX9.ConvertToDX9Model(&g_Model);
return true;
}
示例7: RenderFrameDX9
// 使用DirectX 9來繪圖
void RenderFrameDX9(void)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
device->SetRenderState(D3DRS_LIGHTING, FALSE);
// 設定轉換矩陣
Matrix4x4 view_matrix = g_Control.GetViewMatrix();
Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &view_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &world_matrix);
// 開始下繪圖指令
device->BeginScene();
SetupLightingDX9();
g_Model_DX9.Render();
// 宣告所有的繪圖指令都下完了
device->EndScene();
// 把背景backbuffer的畫面呈現出來
device->Present( NULL, NULL, NULL, NULL );
}
示例8: InitResourceDX9
bool InitResourceDX9(void)
{
// 取得Direct3D 9裝置
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
// 設定視角轉換矩陣
int w, h;
GutGetWindowSize(w, h);
float aspect = (float) h / (float) w;
g_projection_matrix = GutMatrixPerspectiveRH_DirectX(g_fFovW, aspect, 0.1f, 100.0f);
device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &g_projection_matrix);
// 畫出正向跟反向的三角形
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
CGutModel::SetTexturePath("../../textures/");
for ( int t=0; t<MAX_NUM_TEXTURES; t++ )
{
// trilinear filter
device->SetSamplerState(t, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(t, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(t, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
}
g_Model_DX9.ConvertToDX9Model(&g_Model);
return true;
}
示例9: RenderFrameDX9
// 使用DirectX 9來繪圖
void RenderFrameDX9(void)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
// 消除畫面
device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
// 開始下繪圖指令
device->BeginScene();
// 設定座標轉換矩陣
Matrix4x4 view_matrix = GutMatrixLookAtRH(g_eye, g_lookat, g_up);
device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &view_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &g_world_matrix);
// 套用貼圖
device->SetTexture(0, g_pTexture);
// trilinear filter
device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
// 自動產生貼圖座標
device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
//device->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3);
// 使用自動normalize功能
device->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);
// 畫模型
// 傳入0代表不套用模型中的材質, 經由外部來設定.
g_Model_DX9.Render(0);
// 宣告所有的繪圖指令都下完了
device->EndScene();
// 把背景backbuffer的畫面呈現出來
device->Present( NULL, NULL, NULL, NULL );
}
示例10: DrawObject
void DrawObject(void)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
Matrix4x4 view_matrix = g_Control.GetViewMatrix();
Matrix4x4 scale_matrix;
scale_matrix.Scale_Replace(g_fRippleSize, g_fRippleSize, 1.0f);
Matrix4x4 world_matrix = g_orient_matrix * scale_matrix;
world_matrix[3] = g_vPosition;
device->SetVertexShader(NULL);
device->SetPixelShader(NULL);
device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*) &g_proj_matrix);
device->SetTransform(D3DTS_VIEW, (D3DMATRIX*) &view_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX*) &world_matrix);
device->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS);
device->SetRenderState(D3DRS_ZENABLE, TRUE);
device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
g_Model_DX9.Render();
device->SetRenderState(D3DRS_LIGHTING, FALSE);
}
示例11: MirrorPoint
static void RenderModelDX9(bool mirror, Vector4 *pPlane)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
Matrix4x4 view_matrix;
Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
if ( mirror )
{
Vector4 vEye = g_Control.GetCameraPosition();
Vector4 vUp = g_Control.m_vUp;
Vector4 vLookAt = g_Control.m_vLookAt;
Vector4 mirror_eye = MirrorPoint(vEye, *pPlane);
Vector4 mirror_lookat = MirrorPoint(vLookAt, *pPlane);
Vector4 mirror_up = MirrorPoint(vUp, *pPlane);
view_matrix = GutMatrixLookAtRH(mirror_eye, mirror_lookat, mirror_up);
g_mirror_view_matrix = view_matrix;
}
else
{
view_matrix = g_Control.GetViewMatrix();
}
device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &view_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &world_matrix);
g_Model_DX9.Render();
}
示例12: RenderFrameDX9
void RenderFrameDX9(void)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
device->BeginScene();
Matrix4x4 view_matrix = g_Control.GetViewMatrix();
Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
// normal pass
if ( g_bPosteffect )
{
device->SetRenderTarget(0, g_pFrameSurface[FULLSIZE]);
device->SetDepthStencilSurface(NULL);
}
else
{
device->SetRenderTarget(0, g_pMainSurface);
device->SetDepthStencilSurface(NULL);
}
device->Clear(0, NULL, D3DCLEAR_TARGET, 0x0, 1.0f, 0);
device->SetVertexShader(NULL);
device->SetPixelShader(NULL);
device->SetRenderState(D3DRS_LIGHTING, FALSE);
device->SetRenderState(D3DRS_ZENABLE, FALSE);
device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)&g_proj_matrix);
device->SetTransform(D3DTS_VIEW, (D3DMATRIX*)&view_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&world_matrix);
g_Model_DX9.Render();
if ( g_bPosteffect )
{
ConverToLogLuminance(g_pFrameBuffer[FULLSIZE], &g_ImageInfo);
// ExpLuminance(g_pFrameSurface[FULLSIZE], g_pFrameBuffer[DOWNSAMPLED_256x256], &g_Image256x256);
AverageLuminance(g_pFrameBuffer[DOWNSAMPLED_256x256]);
ExpLuminance();
AdaptiveLuminance();
device->SetRenderTarget(0, g_pMainSurface);
device->SetDepthStencilSurface(NULL);
//device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 0x0, 1.0f, 0);
AutoExposure();
if ( g_iMode & 0x01 )
{
DrawImage(g_pFrameBuffer[LUMINANCE_TEMP], &g_Image1x1, -1.0f, -1.0f, 0.1f, 0.1f);
DrawImage(g_pFrameBuffer[LUMINANCE_CURRENT], &g_Image1x1, -0.9f, -1.0f, 0.1f, 0.1f);
}
}
device->EndScene();
device->Present( NULL, NULL, NULL, NULL );
}
示例13: AddImpulse
static void AddImpulse(void)
{
static Vector4 vPosition(0.0f, 0.0f, 0.0f, 0.0f);
//Vector4 vDiff = vPosition - g_vPosition;
Vector4 vDiff = g_vPosition - vPosition;
Vector4 vLength = vDiff.Length();
if ( vLength[0]<2.0f )
return;
Vector4 vDir = vDiff / vLength;
Vector4 vVec0(vDir[1],-vDir[0], 0.0f, 0.0f);
Vector4 vVec1(vDir[0], vDir[1], 0.0f, 0.0f);
vPosition = g_vPosition;
Vector4 vVec0_old = g_orient_matrix[0];
Vector4 vVec1_old = g_orient_matrix[1];
Vector4 vVec0_new = VectorLerp(vVec0_old, vVec0, 0.2f);
Vector4 vVec1_new = VectorLerp(vVec1_old, vVec1, 0.2f);
vVec0_new.Normalize();
vVec1_new.Normalize();
Vector4 vVec2_new = Vector3CrossProduct(vVec0_new, vVec1_new);
g_orient_matrix.Identity();
g_orient_matrix[0] = vVec0_new;
g_orient_matrix[1] = vVec1_new;
g_orient_matrix[2] = vVec2_new;
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
device->SetRenderTarget(0, g_pSurfaces[TEX_HEIGHT1]);
device->SetDepthStencilSurface(NULL);
Matrix4x4 view_matrix = g_Control.GetViewMatrix();
Matrix4x4 world_matrix;
world_matrix.Scale_Replace(g_fRippleSize, g_fRippleSize, 1.0f);
world_matrix[3] = g_vPosition;
Matrix4x4 wvp_matrix = g_orient_matrix * world_matrix * view_matrix * g_proj_matrix;
D3DXHANDLE shader = g_pWaterEffect->GetTechniqueByName("AddImpulse");
D3DXHANDLE wvp_matrix_var = g_pWaterEffect->GetParameterByName(NULL, "wvp_matrix");
D3DXHANDLE force_var = g_pWaterEffect->GetParameterByName(NULL, "fForce");
g_pWaterEffect->SetTechnique(shader);
g_pWaterEffect->SetMatrix(wvp_matrix_var, (D3DXMATRIX *)&wvp_matrix);
g_pWaterEffect->SetFloat(force_var, 0.05f);
g_pWaterEffect->Begin(NULL, 0);
g_pWaterEffect->BeginPass(0);
g_Model_DX9.Render(0);
g_pWaterEffect->EndPass();
g_pWaterEffect->End();
vPosition = g_vPosition;
}
示例14: InitResourceDX9
bool InitResourceDX9(void)
{
// 取得Direct3D 9裝置
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
// 設定視角轉換矩陣
g_projection_matrix = GutMatrixPerspectiveRH_DirectX(g_fFOV, 1.0f, 0.1f, 100.0f);
InitStateDX9();
CGutModel::SetTexturePath("../../textures/");
g_Model_DX9.ConvertToDX9Model(&g_Model_textured);
return true;
}
示例15: MirrorPoint
static void RenderModelDX9(bool mirror, Vector4 *pPlane)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
Matrix4x4 view_matrix;
if ( mirror )
{
Vector4 vEye = g_Control.GetCameraPosition();
Vector4 vLookAt = g_Control.m_vLookAt;
Vector4 vUp = g_Control.m_vUp;
Vector4 mirror_eye = MirrorPoint(vEye, *pPlane);
Vector4 mirror_lookat = MirrorPoint(vLookAt, *pPlane);
Vector4 mirror_up = MirrorVector(vUp, *pPlane);
Matrix4x4 temp_matrix = GutMatrixLookAtRH(mirror_eye, mirror_lookat, mirror_up);
// 因為是鏡射, 在轉換到鏡頭座標系後要做個左右對調的動作.
Matrix4x4 mirror_x;
mirror_x.Identity();
mirror_x.Scale(-1.0f, 1.0f, 1.0f);
view_matrix = temp_matrix * mirror_x;
// 右左對調後, 3角形的頂點排列順序會被反過來.
GutSetDX9BackFace(D3DCULL_CCW);
}
else
{
view_matrix = g_Control.GetViewMatrix();
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
GutSetDX9BackFace(D3DCULL_CW);
}
Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &view_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &world_matrix);
g_Model_DX9.Render();
GutSetDX9BackFace(D3DCULL_CW);
}