私のホームページは複数のサーバーに分割しています。
直接リンク出来ないときはトップページからたどって下さい。
前田稔(Maeda Minoru)の超初心者のプログラム入門
DXUT メッシュ形式 (.sdkmesh) は製品版のタイトルに推奨されるファイル形式ではありません。 この形式は、SDK サンプルの特定の要求に合わせて設計されています。 実際のアプリケーションでは、アプリケーションの特定の要求を満たす形式を優先し、このファイル形式の使用は避けてください。 |
D3DXMatrixLookAtLH(&matView, &D3DXVECTOR3(0.0f, 0.0f, -5.0f), &D3DXVECTOR3(0.0f, 0.0f, 0.0f), &D3DXVECTOR3(0.0f, 1.0f, 0.0f) ); |
m_camera->SetViewParameters( float3(0, 1.0f, 2.0f), float3(0, 0, 0), float3(0, 1, 0) ); |
device.Transform.View = Matrix.LookAtLH( new Vector3( 0.0f, 0.0f, 5.0f ), new Vector3( 0.0f, 0.0f, 0.0f ), new Vector3( 0.0f, 1.0f, 0.0f ) ); |
basicEffect.View = Matrix.CreateLookAt( new Vector3(0.0f, 0.0f, 5.0f), Vector3.Zero, Vector3.Up ); |
反時計回りをカリング | 表面を描画(規定値) | g_pDEV->SetRenderState(D3DRS_CULLMODE,D3DCULL_CCW); |
時計回りをカリング | 裏面を描画 | g_pDEV->SetRenderState(D3DRS_CULLMODE,D3DCULL_CW); |
カリングなし | 両面を描画 | g_pDEV->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE); |
反時計回りをカリング | 表面を描画(規定値) | pattr.setCullFace(PolygonAttributes.CULL_BACK); |
時計回りをカリング | 裏面を描画 | pattr.setCullFace(PolygonAttributes.CULL_FRONT); |
カリングなし | 両面を描画 | pattr.setCullFace(PolygonAttributes.CULL_NONE); |
反時計回りをカリング | 表面を描画(規定値) | device.RenderState.CullMode = Cull.CounterClockwise; |
時計回りをカリング | 裏面を描画 | device.RenderState.CullMode = Cull.Clockwise; |
カリングなし | 両面を描画 | device.RenderState.CullMode = Cull.None; |
反時計回りをカリング | 表面を描画(規定値) | GraphicsDevice.RenderState.CullMode = CullMode.CullCounterClockwiseFace; |
時計回りをカリング | 裏面を描画 | GraphicsDevice.RenderState.CullMode = CullMode.CullClockwiseFace; |
カリングなし | 両面を描画 | GraphicsDevice.RenderState.CullMode = CullMode.None; |
X= sin(36)*半径 |
Y= cos(36)*半径 |
X座標= -(sin(36)*半径), Y座標=-(cos(36)*半径) |
X座標= sin(36)*半径, Y座標=-(cos(36)*半径) |
// 回転計算 void rot(float rt, float len, float *x, float *y) { *x= (LONG)(sin(rt/180*3.14)*len); *y= (LONG)(cos(rt/180*3.14)*len); } |
引数 | 説明 |
---|---|
rt | 回転角度 |
len | 円の半径 |
*x | X座標を格納する領域 |
*y | Y座標を格納する領域 |
void Rotate(D3DXVECTOR3 *Vect, float rt, int xyz) { float px,py,pz; px= Vect->x; py= Vect->y; pz= Vect->z; switch(xyz) { case 0: Vect->z= (float)(pz*cos(rt)-py*sin(rt)); Vect->y= (float)(pz*sin(rt)+py*cos(rt)); return; case 1: Vect->x= (float)(px*cos(rt)-pz*sin(rt)); Vect->z= (float)(px*sin(rt)+pz*cos(rt)); return; case 2: Vect->y= (float)(py*cos(rt)-px*sin(rt)); Vect->x= (float)(py*sin(rt)+px*cos(rt)); return; } } |
引数 | 説明 |
---|---|
*Vect | 元の3次元座標 |
*Vect | 回転した値を格納する |
rt | 回転角度 |
xyz | 回転軸(0:X, 1:Y, 2:Z) |
void Rotate(D3DXVECTOR3 *Vect,D3DXVECTOR3 *Cen,float rt,int xyz) { float px,py,pz; px= Vect->x-Cen->x; py= Vect->y-Cen->y; pz= Vect->z-Cen->z; switch(xyz) { case 0: Vect->z= (float)(pz*cos(rt/180*3.14)-py*sin(rt/180*3.14)+Cen->y); Vect->y= (float)(pz*sin(rt/180*3.14)+py*cos(rt/180*3.14)+Cen->z); return; case 1: Vect->x= (float)(px*cos(rt/180*3.14)-pz*sin(rt/180*3.14)+Cen->x); Vect->z= (float)(px*sin(rt/180*3.14)+pz*cos(rt/180*3.14)+Cen->z); return; case 2: Vect->y= (float)(py*cos(rt/180*3.14)-px*sin(rt/180*3.14)+Cen->x); Vect->x= (float)(py*sin(rt/180*3.14)+px*cos(rt/180*3.14)+Cen->y); return; } } |
引数 | 説明 |
---|---|
*Vect | 元の3次元座標 |
*Vect | 回転後の値を格納する |
*Cen | 回転軸の基点 |
rt | 回転角度 |
xyz | 回転軸(0:X, 1:Y, 2:Z) |
D3DXVECTOR3 vLight(2,-3,2); // ライトの座標の初期値 light.Direction = vLight; g_pDEV->SetLight(0,&light); |
void MatRotate(D3DXVECTOR3 *Vect,float rt) { D3DXMATRIX mat; // 変換マトリックスの作成 D3DXMatrixIdentity(&mat); mat._11 = cos(rt); mat._13 = -sin(rt); mat._31 = sin(rt); mat._33 = cos(rt); D3DXVec3TransformNormal(Vect, Vect, &mat); } |
// 中心点を 0,0,0 として、座標 pos を rx, ry, rz で回転する float3 Rot3D(float3 pos, float rx, float ry, float rz) { float3 ans, wk; ans = pos; wk = pos; ans.y = (float)(wk.y*cos(rz) - wk.x*sin(rz)); ans.x = (float)(wk.y*sin(rz) + wk.x*cos(rz)); wk = ans; ans.x = (float)(wk.x*cos(ry) - wk.z*sin(ry)); ans.z = (float)(wk.x*sin(ry) + wk.z*cos(ry)); wk = ans; ans.z = (float)(wk.z*cos(rx) - wk.y*sin(rx)); ans.y = (float)(wk.z*sin(rx) + wk.y*cos(rx)); return ans; } |
// 中心点を 0,0,0 として、座標 pos を rt で回転する float3 MatRotate(float3 pos, float3 rt) { XMMATRIX mat; float3 ans; XMVECTOR vect; vect = XMVectorSet(pos.x, pos.y, pos.z, 0.0f); mat = XMMatrixRotationRollPitchYaw(-rt.x, -rt.y, -rt.z); vect = XMVector3TransformNormal(vect, mat); ans.x = XMVectorGetX(vect); ans.y = XMVectorGetY(vect); ans.z = XMVectorGetZ(vect); return ans; } |
Matrix4f mat4 = new Matrix4f ( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f ); // X軸で移動 mat4.m03= -0.3f; ( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, -0.3f, 0.0f, 0.0f, 1.0f ); |
// 変換マトリックスの作成 D3DXMatrixIdentity(&mat); mat._11 = cos(rt); mat._13 = -sin(rt); mat._31 = sin(rt); mat._33 = cos(rt); |
D3DXMATRIX matWorld; D3DXMatrixRotationY(&matWorld, rt); |
D3DXMATRIX matWorld; D3DXMatrixRotationX(&matWorld, rt); |
D3DXMATRIX mat1; D3DXMATRIX mat2; D3DXMATRIX mat3; D3DXMatrixRotationY(&mat1, rt); D3DXMatrixRotationX(&mat2, rt); mat3 = mat1 * mat2; |
HRESULT Draw( LPDIRECT3DTEXTURE9 pTexture, CONST RECT *pSrcRect, //Sprite の表示範囲 CONST D3DXVECTOR3 *pCenter, //Sprite の中心点 CONST D3DXVECTOR3 *pPosition, //Sprite の中心点の表示位置 D3DCOLOR Color ); |
HRESULT Draw( LPDIRECT3DTEXTURE9 pSrcTexture, CONST RECT *pSrcRect, CONST D3DXVECTOR2 *pScaling, CONST D3DXVECTOR2 *pRotationCenter, FLOAT Rotation, CONST D3DVECTOR2 *pTranslation, D3DCOLOR Color ); |
Extras Extras ダウンロードには、ソフトウェア開発キットには含まれていない以下の内容が入っています。 ・Visual Studio 6.0 をサポートする d3dx.lib ・以前のバージョンのCDツール プラグイン ・日本語ドキュメント |
--------------------構成: Main - Win32 Debug-------------------- コンパイル中... Main.cpp STAR.cpp リンク中... d3dx9.lib(fastftoa.obj) : error LNK2001: 外部シンボル "__aulldvrm" は未解決です Debug/Main.exe : fatal error LNK1120: 外部参照 1 が未解決です。 link.exe の実行エラー Main.exe - エラー 2、警告 0 |
BadImageFormatException はハンドルされませんでした。 |
Failed create the Direct3D device |
ID3DX10Sprite* g_pSprite = NULL; CDXUTTextHelper* g_pTxtHelper = NULL; SAFE_DELETE( g_pTxtHelper ); SAFE_RELEASE( g_pSprite ); |
#define SAFE_DELETE(p) { if (p) { delete (p); (p)=NULL; } } #define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p)=NULL; } } #define SAFE_DELDC(p) { if (p) { DeleteDC (p); (p)=NULL; } } #define SAFE_DELOBJ(p) { if (p) { DeleteObject(p); (p)=NULL; } } |
#pragma once #pragma comment(lib,"dxerr.lib") #pragma comment(lib,"dxguid.lib") #pragma comment(lib,"winmm.lib") #pragma comment(lib,"comctl32.lib") #pragma comment(lib,"dxgi.lib") #pragma comment(lib,"d3d10.lib") #pragma comment(lib,"d3dx10.lib") |
float fval = 0.123f; char str[80]; sprintf(str,"%8.2f\n",fval); MessageBox(NULL,str,"Debug Message Box",MB_OK); |
float fval = 0.123f; char str[80]; WCHAR wstr[80]; sprintf(str,"%8.2f\n",fval); MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,str,-1,wstr,80); MessageBox(NULL,wstr,L"Debug Message Box",MB_OK); |
HRESULT CTiny::Setup( double dTimeCurrent ) { ・・・ } |
using namespace std; std::vector<CTiny*> *m_pv_pChars; |
try { // 例外が発生する処理 } catch (例外型 変数) { // 例外が発生した後の処理 } |
try { m_v_pAnimInstances.push_back( pAI ); } catch( ... ) { hr = E_OUTOFMEMORY; goto e_Exit; } |
void CAnimInstance::UpdateFrames( MultiAnimFrame * pFrame, D3DXMATRIX * pmxBase ) { assert( pFrame != NULL ); |
V( pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 45, 50, 170), 1.0f, 0) ); V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice ) ); |
#define V(x) { hr = (x); if( FAILED(hr) ) { DXUTTrace( __FILE__, (DWORD)__LINE__, hr, L#x, true ); } } #define V_RETURN(x) { hr = (x); if( FAILED(hr) ) { return DXUTTrace( __FILE__, (DWORD)__LINE__, hr, L#x, true ); } } |
HRESULT WINAPI DXUTTrace( const CHAR* strFile, DWORD dwLine, HRESULT hr, const WCHAR* strMsg, bool bPopMsgBox ) { bool bShowMsgBoxOnError = DXUTGetShowMsgBoxOnError(); if( bPopMsgBox && bShowMsgBoxOnError == false ) bPopMsgBox = false; return DXTrace( strFile, dwLine, hr, strMsg, bPopMsgBox ); } |
// DXTrace // Desc: Outputs a formatted error message to the debug stream // Args: CHAR* strFile The current file, typically passed in using the // __FILE__ macro. // DWORD dwLine The current line number, typically passed in using the // __LINE__ macro. // HRESULT hr An HRESULT that will be traced to the debug stream. // CHAR* strMsg A string that will be traced to the debug stream (may be NULL) // BOOL bPopMsgBox If TRUE, then a message box will popup also containing the passed info. // Return: The hr that was passed in. |
#ifdef DEBUG_VS if( pDeviceSettings->d3d9.DeviceType != D3DDEVTYPE_REF ) { pDeviceSettings->d3d9.BehaviorFlags &= ~D3DCREATE_HARDWARE_VERTEXPROCESSING; pDeviceSettings->d3d9.BehaviorFlags &= ~D3DCREATE_PUREDEVICE; pDeviceSettings->d3d9.BehaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; } #endif |
#define D3DCOLOR_XRGB(r,g,b) D3DCOLOR_ARGB(0xff,r,g,b) #define D3DCOLOR_ARGB(a,r,g,b) \ ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) |
float ClearColor[4] = { 0.1f, 0.3f, 0.8f, 0.0f }; pd3dDevice->ClearRenderTargetView( pWindowObj->pRenderTargetView, ClearColor ); |
D3DXMATRIX matView; D3DXVECTOR3 vFromPt = D3DXVECTOR3( 0.0f, 0.0f, -5.0f ); D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ); D3DXMatrixLookAtLH( &matView, &vFromPt, &vLookatPt, &vUpVec ); m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView ); |
D3DXMatrixLookAtLH(&matView,&D3DXVECTOR3(0.0f, -5.0f, 30.0f), &D3DXVECTOR3(0.0f, 0.0f, 0.0f), &D3DXVECTOR3(0.0f, 1.0f, 0.0f)); |
D3DXMATRIX matWorld; D3DXMatrixIdentity(&matWorld); |
インクルードファイルのパス | c:\mssdk\include |
ライブラリファイルのパス | c:\mssdk\lib |
インクルードファイルのパス | c:\DXSDK\include |
ライブラリファイルのパス | c:\DXSDK\lib |
インクルードファイルのパス | C:\Program Files\Microsoft DirectX 9.0 SDK (April 2005)\Include |
ライブラリファイルのパス | C:\Program Files\Microsoft DirectX 9.0 SDK (April 2005)\Lib\x86 |
インクルードファイルのパス | C:\Program Files\Microsoft DirectX SDK (August 2007)\Include |
ライブラリファイルのパス | C:\Program Files\Microsoft DirectX SDK (August 2007)\Lib\x86 |
インクルードファイルのパス | C:\Program Files (x86)\Microsoft DirectX SDK (November 2008)\Include |
ライブラリファイルのパス | C:\Program Files (x86)\Microsoft DirectX SDK (November 2008)\Lib\x86 |
インクルードファイルのパス | C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include |
ライブラリファイルのパス | C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86 |
#pragma once #pragma comment(lib,"dxerr.lib") #pragma comment(lib,"dxguid.lib") #pragma comment(lib,"d3dx9d.lib") #pragma comment(lib,"d3dx10d.lib") #pragma comment(lib,"d3d9.lib") #pragma comment(lib,"winmm.lib") #pragma comment(lib,"comctl32.lib") |
エラー 1 fatal error C1107: アセンブリ 'Microsoft.DirectX.dll' がみつかりませんでした: /AI または LIBPATH 環境変数を使用してアセンブリ検索パスを指定してください。 |