Initial commit: ROW Client source code
Game client codebase including: - CharacterActionControl: Character and creature management - GlobalScript: Network, items, skills, quests, utilities - RYLClient: Main client application with GUI and event handlers - Engine: 3D rendering engine (RYLGL) - MemoryManager: Custom memory allocation - Library: Third-party dependencies (DirectX, boost, etc.) - Tools: Development utilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
BIN
Library/dxx8/samples/Multimedia/Direct3D/Pick/directx.ico
Normal file
BIN
Library/dxx8/samples/Multimedia/Direct3D/Pick/directx.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
718
Library/dxx8/samples/Multimedia/Direct3D/Pick/pick.cpp
Normal file
718
Library/dxx8/samples/Multimedia/Direct3D/Pick/pick.cpp
Normal file
@@ -0,0 +1,718 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Pick.cpp
|
||||
//
|
||||
// Desc: Example code showing how to do picking in D3D.
|
||||
//
|
||||
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <D3DX8.h>
|
||||
#include "D3DApp.h"
|
||||
#include "D3DFont.h"
|
||||
#include "D3DFile.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "DXUtil.h"
|
||||
#include "Resource.h"
|
||||
|
||||
|
||||
struct D3DVERTEX
|
||||
{
|
||||
D3DXVECTOR3 p;
|
||||
D3DXVECTOR3 n;
|
||||
FLOAT tu, tv;
|
||||
};
|
||||
|
||||
#define D3DFVF_VERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
|
||||
|
||||
|
||||
struct INTERSECTION
|
||||
{
|
||||
DWORD dwFace; // mesh face that was intersected
|
||||
FLOAT fBary1, fBary2; // barycentric coords of intersection
|
||||
FLOAT fDist; // distance from ray origin to intersection
|
||||
FLOAT tu, tv; // texture coords of intersection
|
||||
};
|
||||
|
||||
// For simplicity's sake, we limit the number of simultaneously intersected
|
||||
// triangles to 16
|
||||
#define MAX_INTERSECTIONS 16
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CMyD3DApplication
|
||||
// Desc: Application class. The base class (CD3DApplication) provides the
|
||||
// generic functionality needed in all Direct3D samples. CMyD3DApplication
|
||||
// adds functionality specific to this sample program.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMyD3DApplication : public CD3DApplication
|
||||
{
|
||||
CD3DFont* m_pFont; // Font for drawing text
|
||||
CD3DFont* m_pFontSmall; // Font for drawing text
|
||||
CD3DMesh* m_pObject; // Object to render
|
||||
DWORD m_dwNumIntersections; // Number of faces intersected
|
||||
INTERSECTION m_IntersectionArray[MAX_INTERSECTIONS]; // Intersection info
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pVB; // VB for picked triangles
|
||||
BOOL m_bShowHelp; // Whether to show help
|
||||
BOOL m_bUseD3DX; // Whether to use D3DXIntersect
|
||||
BOOL m_bClosestOnly; // Whether to just get the closest intersection
|
||||
|
||||
// Internal member functions
|
||||
HRESULT Pick();
|
||||
BOOL IntersectTriangle( const D3DXVECTOR3& orig, const D3DXVECTOR3& dir,
|
||||
D3DXVECTOR3& v0, D3DXVECTOR3& v1, D3DXVECTOR3& v2,
|
||||
FLOAT* t, FLOAT* u, FLOAT* v );
|
||||
HRESULT ConfirmDevice( D3DCAPS8*, DWORD, D3DFORMAT );
|
||||
|
||||
protected:
|
||||
HRESULT OneTimeSceneInit();
|
||||
HRESULT InitDeviceObjects();
|
||||
HRESULT RestoreDeviceObjects();
|
||||
HRESULT InvalidateDeviceObjects();
|
||||
HRESULT DeleteDeviceObjects();
|
||||
HRESULT Render();
|
||||
HRESULT FrameMove();
|
||||
HRESULT FinalCleanup();
|
||||
|
||||
public:
|
||||
LRESULT MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
|
||||
CMyD3DApplication();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: WinMain()
|
||||
// Desc: Entry point to the program. Initializes everything, and goes into a
|
||||
// message-processing loop. Idle time is used to render the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
|
||||
{
|
||||
CMyD3DApplication d3dApp;
|
||||
|
||||
if( FAILED( d3dApp.Create( hInst ) ) )
|
||||
return 0;
|
||||
|
||||
return d3dApp.Run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CMyD3DApplication()
|
||||
// Desc: Application constructor. Sets attributes for the app.
|
||||
//-----------------------------------------------------------------------------
|
||||
CMyD3DApplication::CMyD3DApplication()
|
||||
{
|
||||
m_strWindowTitle = _T("Pick: D3D Picking Sample");
|
||||
m_bUseDepthBuffer = TRUE;
|
||||
m_bShowCursorWhenFullscreen = TRUE;
|
||||
|
||||
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
|
||||
m_pFontSmall = new CD3DFont( _T("Arial"), 9, D3DFONT_BOLD );
|
||||
m_pObject = new CD3DMesh();
|
||||
m_dwNumIntersections = 0;
|
||||
m_pVB = NULL;
|
||||
m_bShowHelp = FALSE;
|
||||
m_bUseD3DX = TRUE;
|
||||
m_bClosestOnly = FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: OneTimeSceneInit()
|
||||
// Desc: Called during initial app startup, this function performs all the
|
||||
// permanent initialization.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::OneTimeSceneInit()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: Pick()
|
||||
// Desc: Checks if mouse point hits geometry
|
||||
// the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::Pick()
|
||||
{
|
||||
HRESULT hr;
|
||||
D3DXVECTOR3 vPickRayDir;
|
||||
D3DXVECTOR3 vPickRayOrig;
|
||||
|
||||
m_dwNumIntersections = 0L;
|
||||
|
||||
// Get the pick ray from the mouse position
|
||||
if( GetCapture() )
|
||||
{
|
||||
D3DXMATRIX matProj;
|
||||
m_pd3dDevice->GetTransform( D3DTS_PROJECTION, &matProj );
|
||||
|
||||
POINT ptCursor;
|
||||
GetCursorPos( &ptCursor );
|
||||
ScreenToClient( m_hWnd, &ptCursor );
|
||||
|
||||
// Compute the vector of the pick ray in screen space
|
||||
D3DXVECTOR3 v;
|
||||
v.x = ( ( ( 2.0f * ptCursor.x ) / m_d3dsdBackBuffer.Width ) - 1 ) / matProj._11;
|
||||
v.y = -( ( ( 2.0f * ptCursor.y ) / m_d3dsdBackBuffer.Height ) - 1 ) / matProj._22;
|
||||
v.z = 1.0f;
|
||||
|
||||
// Get the inverse view matrix
|
||||
D3DXMATRIX matView, m;
|
||||
m_pd3dDevice->GetTransform( D3DTS_VIEW, &matView );
|
||||
D3DXMatrixInverse( &m, NULL, &matView );
|
||||
|
||||
// Transform the screen space pick ray into 3D space
|
||||
vPickRayDir.x = v.x*m._11 + v.y*m._21 + v.z*m._31;
|
||||
vPickRayDir.y = v.x*m._12 + v.y*m._22 + v.z*m._32;
|
||||
vPickRayDir.z = v.x*m._13 + v.y*m._23 + v.z*m._33;
|
||||
vPickRayOrig.x = m._41;
|
||||
vPickRayOrig.y = m._42;
|
||||
vPickRayOrig.z = m._43;
|
||||
}
|
||||
|
||||
// Get the picked triangle
|
||||
if( GetCapture() )
|
||||
{
|
||||
LPD3DXBASEMESH pMesh = m_pObject->GetLocalMesh();
|
||||
LPDIRECT3DVERTEXBUFFER8 pVB;
|
||||
LPDIRECT3DINDEXBUFFER8 pIB;
|
||||
|
||||
pMesh->GetVertexBuffer( &pVB );
|
||||
pMesh->GetIndexBuffer( &pIB );
|
||||
|
||||
WORD* pIndices;
|
||||
D3DVERTEX* pVertices;
|
||||
|
||||
pIB->Lock( 0,0,(BYTE**)&pIndices, 0 );
|
||||
pVB->Lock( 0,0,(BYTE**)&pVertices, 0 );
|
||||
|
||||
if( m_bUseD3DX )
|
||||
{
|
||||
// When calling D3DXIntersect, one can get just the closest intersection and not
|
||||
// need to work with a D3DXBUFFER. Or, to get all intersections between the ray and
|
||||
// the mesh, one can use a D3DXBUFFER to receive all intersections. We show both
|
||||
// methods.
|
||||
if( m_bClosestOnly )
|
||||
{
|
||||
// Collect only the closest intersection
|
||||
BOOL bHit;
|
||||
DWORD dwFace;
|
||||
FLOAT fBary1, fBary2, fDist;
|
||||
D3DXIntersect(pMesh, &vPickRayOrig, &vPickRayDir, &bHit, &dwFace, &fBary1, &fBary2, &fDist,
|
||||
NULL, NULL);
|
||||
if( bHit )
|
||||
{
|
||||
m_dwNumIntersections = 1;
|
||||
m_IntersectionArray[0].dwFace = dwFace;
|
||||
m_IntersectionArray[0].fBary1 = fBary1;
|
||||
m_IntersectionArray[0].fBary2 = fBary2;
|
||||
m_IntersectionArray[0].fDist = fDist;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dwNumIntersections = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Collect all intersections
|
||||
BOOL bHit;
|
||||
LPD3DXBUFFER pBuffer = NULL;
|
||||
D3DXINTERSECTINFO* pIntersectInfoArray;
|
||||
if( FAILED( hr = D3DXIntersect(pMesh, &vPickRayOrig, &vPickRayDir, &bHit, NULL, NULL, NULL, NULL,
|
||||
&pBuffer, &m_dwNumIntersections) ) )
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
if( m_dwNumIntersections > 0 )
|
||||
{
|
||||
pIntersectInfoArray = (D3DXINTERSECTINFO*)pBuffer->GetBufferPointer();
|
||||
if( m_dwNumIntersections > MAX_INTERSECTIONS )
|
||||
m_dwNumIntersections = MAX_INTERSECTIONS;
|
||||
for( DWORD iIntersection = 0; iIntersection < m_dwNumIntersections; iIntersection++ )
|
||||
{
|
||||
m_IntersectionArray[iIntersection].dwFace = pIntersectInfoArray[iIntersection].FaceIndex;
|
||||
m_IntersectionArray[iIntersection].fBary1 = pIntersectInfoArray[iIntersection].U;
|
||||
m_IntersectionArray[iIntersection].fBary2 = pIntersectInfoArray[iIntersection].V;
|
||||
m_IntersectionArray[iIntersection].fDist = pIntersectInfoArray[iIntersection].Dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not using D3DX
|
||||
DWORD dwNumFaces = m_pObject->GetLocalMesh()->GetNumFaces();
|
||||
FLOAT fBary1, fBary2;
|
||||
FLOAT fDist;
|
||||
for( DWORD i=0; i<dwNumFaces; i++ )
|
||||
{
|
||||
D3DXVECTOR3 v0 = pVertices[pIndices[3*i+0]].p;
|
||||
D3DXVECTOR3 v1 = pVertices[pIndices[3*i+1]].p;
|
||||
D3DXVECTOR3 v2 = pVertices[pIndices[3*i+2]].p;
|
||||
|
||||
// Check if the pick ray passes through this point
|
||||
if( IntersectTriangle( vPickRayOrig, vPickRayDir, v0, v1, v2,
|
||||
&fDist, &fBary1, &fBary2 ) )
|
||||
{
|
||||
if( !m_bClosestOnly || m_dwNumIntersections == 0 || fDist < m_IntersectionArray[0].fDist )
|
||||
{
|
||||
if( m_bClosestOnly )
|
||||
m_dwNumIntersections = 0;
|
||||
m_IntersectionArray[m_dwNumIntersections].dwFace = i;
|
||||
m_IntersectionArray[m_dwNumIntersections].fBary1 = fBary1;
|
||||
m_IntersectionArray[m_dwNumIntersections].fBary2 = fBary2;
|
||||
m_IntersectionArray[m_dwNumIntersections].fDist = fDist;
|
||||
m_dwNumIntersections++;
|
||||
if( m_dwNumIntersections == MAX_INTERSECTIONS )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now, for each intersection, add a triangle to m_pVB and compute texture coordinates
|
||||
if( m_dwNumIntersections > 0 )
|
||||
{
|
||||
D3DVERTEX* v;
|
||||
D3DVERTEX* vThisTri;
|
||||
WORD* iThisTri;
|
||||
D3DVERTEX v1, v2, v3;
|
||||
INTERSECTION* pIntersection;
|
||||
|
||||
m_pVB->Lock( 0, 0, (BYTE**)&v, 0 );
|
||||
|
||||
for( DWORD iIntersection = 0; iIntersection < m_dwNumIntersections; iIntersection++ )
|
||||
{
|
||||
pIntersection = &m_IntersectionArray[iIntersection];
|
||||
|
||||
vThisTri = &v[iIntersection * 3];
|
||||
iThisTri = &pIndices[3*pIntersection->dwFace];
|
||||
// get vertices hit
|
||||
vThisTri[0] = pVertices[iThisTri[0]];
|
||||
vThisTri[1] = pVertices[iThisTri[1]];
|
||||
vThisTri[2] = pVertices[iThisTri[2]];
|
||||
|
||||
// If all you want is the vertices hit, then you are done. In this sample, we
|
||||
// want to show how to infer texture coordinates as well, using the BaryCentric
|
||||
// coordinates supplied by D3DXIntersect
|
||||
FLOAT dtu1 = vThisTri[1].tu - vThisTri[0].tu;
|
||||
FLOAT dtu2 = vThisTri[2].tu - vThisTri[0].tu;
|
||||
FLOAT dtv1 = vThisTri[1].tv - vThisTri[0].tv;
|
||||
FLOAT dtv2 = vThisTri[2].tv - vThisTri[0].tv;
|
||||
pIntersection->tu = vThisTri[0].tu + pIntersection->fBary1 * dtu1 + pIntersection->fBary2 * dtu2;
|
||||
pIntersection->tv = vThisTri[0].tv + pIntersection->fBary1 * dtv1 + pIntersection->fBary2 * dtv2;
|
||||
}
|
||||
m_pVB->Unlock();
|
||||
}
|
||||
|
||||
pVB->Unlock();
|
||||
pIB->Unlock();
|
||||
|
||||
pVB->Release();
|
||||
pIB->Release();
|
||||
|
||||
}
|
||||
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FrameMove()
|
||||
// Desc: Called once per frame, the call is the entry point for animating
|
||||
// the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FrameMove()
|
||||
{
|
||||
// Rotate the camera about the y-axis
|
||||
D3DXVECTOR3 vFromPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
|
||||
vFromPt.x = -cosf(m_fTime/3.0f) * 4.0f;
|
||||
vFromPt.y = 1.0f;
|
||||
vFromPt.z = sinf(m_fTime/3.0f) * 4.0f;
|
||||
|
||||
D3DXMATRIX matView;
|
||||
D3DXMatrixLookAtLH( &matView, &vFromPt, &vLookatPt, &vUpVec );
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: Render()
|
||||
// Desc: Called once per frame, the call is the entry point for 3d
|
||||
// rendering. This function sets up render states, clears the
|
||||
// viewport, and renders the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::Render()
|
||||
{
|
||||
// Set up the cursor
|
||||
POINT ptCursor;
|
||||
GetCursorPos( &ptCursor );
|
||||
ScreenToClient( m_hWnd, &ptCursor );
|
||||
m_pd3dDevice->SetCursorPosition( ptCursor.x, ptCursor.y, 0L );
|
||||
|
||||
// Check for picked triangles
|
||||
Pick();
|
||||
|
||||
// Clear the viewport
|
||||
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
|
||||
0x000000ff, 1.0f, 0L );
|
||||
|
||||
// Begin the scene
|
||||
if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
|
||||
{
|
||||
// Set render mode to lit, solid triangles
|
||||
m_pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
|
||||
|
||||
// If a triangle is picked, draw it
|
||||
if( m_dwNumIntersections > 0 )
|
||||
{
|
||||
// Draw the picked triangle
|
||||
m_pd3dDevice->SetVertexShader( D3DFVF_VERTEX );
|
||||
m_pd3dDevice->SetStreamSource( 0, m_pVB, sizeof(D3DVERTEX) );
|
||||
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, m_dwNumIntersections );
|
||||
|
||||
// Set render mode to unlit, wireframe triangles
|
||||
m_pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
|
||||
}
|
||||
|
||||
// Render the mesh
|
||||
m_pObject->Render( m_pd3dDevice );
|
||||
|
||||
// Output statistics
|
||||
m_pFont->DrawText( 2, 0, D3DCOLOR_ARGB(255,255,255,0), m_strFrameStats );
|
||||
m_pFont->DrawText( 2, 20, D3DCOLOR_ARGB(255,255,255,0), m_strDeviceStats );
|
||||
|
||||
// Output help
|
||||
FLOAT yText = 40.0f;
|
||||
if( m_bShowHelp )
|
||||
{
|
||||
m_pFontSmall->DrawText( 2, yText, D3DCOLOR_ARGB(255,255,255,255), _T("F1: Toggle Help") );
|
||||
yText += 20.0f;
|
||||
m_pFontSmall->DrawText( 2, yText, D3DCOLOR_ARGB(255,255,255,255), _T("F2: Change Device") );
|
||||
yText += 20.0f;
|
||||
m_pFontSmall->DrawText( 2, yText, D3DCOLOR_ARGB(255,255,255,255), _T("F3: Toggle D3DX Usage") );
|
||||
yText += 20.0f;
|
||||
m_pFontSmall->DrawText( 2, yText, D3DCOLOR_ARGB(255,255,255,255), _T("F4: Toggle All Hits") );
|
||||
yText += 20.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pFontSmall->DrawText( 2, yText, D3DCOLOR_ARGB(255,255,255,255), _T("Press F1 for Help") );
|
||||
yText += 20.0f;
|
||||
}
|
||||
|
||||
// Output info
|
||||
m_pFontSmall->DrawText( 2, yText, D3DCOLOR_ARGB(255,255,255,255), m_bUseD3DX ? _T("Using D3DX") : _T("Not Using D3DX") );
|
||||
yText += 20.0f;
|
||||
|
||||
m_pFontSmall->DrawText( 2, yText, D3DCOLOR_ARGB(255,255,255,255), m_bClosestOnly ? _T("Showing First Hit") : _T("Showing All Hits") );
|
||||
yText += 20.0f;
|
||||
|
||||
CHAR strBuffer[90];
|
||||
|
||||
if( m_dwNumIntersections > 0 )
|
||||
{
|
||||
for( DWORD iIntersection = 0; iIntersection < m_dwNumIntersections; iIntersection++ )
|
||||
{
|
||||
INTERSECTION* pIntersection = &m_IntersectionArray[iIntersection];
|
||||
sprintf( strBuffer, _T("Face=%d, tu=%3.02f, tv=%3.02f"), pIntersection->dwFace, pIntersection->tu, pIntersection->tv );
|
||||
m_pFontSmall->DrawText( 2, yText, D3DCOLOR_ARGB(255,0,255,255), strBuffer );
|
||||
yText += 20;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( strBuffer, _T("Use mouse to pick a polygon") );
|
||||
m_pFontSmall->DrawText( 2, yText, D3DCOLOR_ARGB(255,0,255,255), strBuffer );
|
||||
}
|
||||
|
||||
|
||||
// End the scene.
|
||||
m_pd3dDevice->EndScene();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitDeviceObjects()
|
||||
// Desc: Initialize scene objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InitDeviceObjects()
|
||||
{
|
||||
// Restore the font
|
||||
m_pFont->InitDeviceObjects( m_pd3dDevice );
|
||||
m_pFontSmall->InitDeviceObjects( m_pd3dDevice );
|
||||
|
||||
if( FAILED( m_pObject->Create( m_pd3dDevice, _T("Tiger.x") ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
m_pObject->SetFVF( m_pd3dDevice, D3DFVF_VERTEX );
|
||||
|
||||
// Create the vertex buffer
|
||||
DWORD dwNumVertices = MAX_INTERSECTIONS * 3;
|
||||
if( FAILED( m_pd3dDevice->CreateVertexBuffer( dwNumVertices*sizeof(D3DVERTEX),
|
||||
D3DUSAGE_WRITEONLY, D3DFVF_VERTEX,
|
||||
D3DPOOL_MANAGED, &m_pVB ) ) )
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreDeviceObjects()
|
||||
// Desc: Initialize scene objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RestoreDeviceObjects()
|
||||
{
|
||||
m_pFont->RestoreDeviceObjects();
|
||||
m_pFontSmall->RestoreDeviceObjects();
|
||||
|
||||
// Restore device-memory objects for the mesh
|
||||
m_pObject->RestoreDeviceObjects( m_pd3dDevice );
|
||||
|
||||
// Set up the textures
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
|
||||
// Set miscellaneous render states
|
||||
m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, FALSE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00444444 );
|
||||
|
||||
// Set the world matrix
|
||||
D3DXMATRIX matIdentity;
|
||||
D3DXMatrixIdentity( &matIdentity );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matIdentity );
|
||||
|
||||
// Set the projection matrix
|
||||
D3DXMATRIX matProj;
|
||||
FLOAT fAspect = ((FLOAT)m_d3dsdBackBuffer.Width) / m_d3dsdBackBuffer.Height;
|
||||
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, 1.0f, 100.0f );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
|
||||
|
||||
// Setup a material
|
||||
D3DMATERIAL8 mtrl;
|
||||
D3DUtil_InitMaterial( mtrl, 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
m_pd3dDevice->SetMaterial( &mtrl );
|
||||
|
||||
// Set up lighting states
|
||||
D3DLIGHT8 light;
|
||||
D3DUtil_InitLight( light, D3DLIGHT_DIRECTIONAL, 0.1f, -1.0f, 0.1f );
|
||||
m_pd3dDevice->SetLight( 0, &light );
|
||||
m_pd3dDevice->LightEnable( 0, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InvalidateDeviceObjects()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
|
||||
{
|
||||
m_pFont->InvalidateDeviceObjects();
|
||||
m_pFontSmall->InvalidateDeviceObjects();
|
||||
m_pObject->InvalidateDeviceObjects();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DeleteDeviceObjects()
|
||||
// Desc: Called when the app is exiting, or the device is being changed,
|
||||
// this function deletes any device dependent objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::DeleteDeviceObjects()
|
||||
{
|
||||
m_pFont->DeleteDeviceObjects();
|
||||
m_pFontSmall->DeleteDeviceObjects();
|
||||
m_pObject->Destroy();
|
||||
|
||||
SAFE_RELEASE( m_pVB );
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FinalCleanup()
|
||||
// Desc: Called before the app exits, this function gives the app the chance
|
||||
// to cleanup after itself.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FinalCleanup()
|
||||
{
|
||||
SAFE_DELETE( m_pFont );
|
||||
SAFE_DELETE( m_pFontSmall );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ConfirmDevice()
|
||||
// Desc: Called during device intialization, this code checks the device
|
||||
// for some minimum set of capabilities
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::ConfirmDevice( D3DCAPS8* pCaps, DWORD dwBehavior,
|
||||
D3DFORMAT Format )
|
||||
{
|
||||
if( dwBehavior & D3DCREATE_PUREDEVICE )
|
||||
return E_FAIL; // GetTransform doesn't work on PUREDEVICE
|
||||
|
||||
// If this is a TnL device, make sure it supports directional lights
|
||||
if( (dwBehavior & D3DCREATE_HARDWARE_VERTEXPROCESSING ) ||
|
||||
(dwBehavior & D3DCREATE_MIXED_VERTEXPROCESSING ) )
|
||||
{
|
||||
if( !(pCaps->VertexProcessingCaps & D3DVTXPCAPS_DIRECTIONALLIGHTS ) )
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: MsgProc()
|
||||
// Desc: Overrrides the main WndProc, so the sample can do custom message
|
||||
// handling (e.g. processing mouse, keyboard, or menu commands).
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CMyD3DApplication::MsgProc( HWND hWnd, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam )
|
||||
{
|
||||
switch( msg )
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
// User pressed left mouse button
|
||||
SetCapture( hWnd );
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
// The user released the left mouse button
|
||||
ReleaseCapture();
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
if( LOWORD(wParam) == IDM_HELP )
|
||||
m_bShowHelp = !m_bShowHelp;
|
||||
if( LOWORD(wParam) == IDM_TOGGLED3DX )
|
||||
m_bUseD3DX = !m_bUseD3DX;
|
||||
else if( LOWORD(wParam) == IDM_TOGGLEALLHITS )
|
||||
m_bClosestOnly = !m_bClosestOnly;
|
||||
break;
|
||||
}
|
||||
|
||||
return CD3DApplication::MsgProc( hWnd, msg, wParam, lParam );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: IntersectTriangle()
|
||||
// Desc: Given a ray origin (orig) and direction (dir), and three vertices of
|
||||
// of a triangle, this function returns TRUE and the interpolated texture
|
||||
// coordinates if the ray intersects the triangle
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL CMyD3DApplication::IntersectTriangle( const D3DXVECTOR3& orig,
|
||||
const D3DXVECTOR3& dir, D3DXVECTOR3& v0,
|
||||
D3DXVECTOR3& v1, D3DXVECTOR3& v2,
|
||||
FLOAT* t, FLOAT* u, FLOAT* v )
|
||||
{
|
||||
// Find vectors for two edges sharing vert0
|
||||
D3DXVECTOR3 edge1 = v1 - v0;
|
||||
D3DXVECTOR3 edge2 = v2 - v0;
|
||||
|
||||
// Begin calculating determinant - also used to calculate U parameter
|
||||
D3DXVECTOR3 pvec;
|
||||
D3DXVec3Cross( &pvec, &dir, &edge2 );
|
||||
|
||||
// If determinant is near zero, ray lies in plane of triangle
|
||||
FLOAT det = D3DXVec3Dot( &edge1, &pvec );
|
||||
|
||||
D3DXVECTOR3 tvec;
|
||||
if( det > 0 )
|
||||
{
|
||||
tvec = orig - v0;
|
||||
}
|
||||
else
|
||||
{
|
||||
tvec = v0 - orig;
|
||||
det = -det;
|
||||
}
|
||||
|
||||
if( det < 0.0001f )
|
||||
return FALSE;
|
||||
|
||||
// Calculate U parameter and test bounds
|
||||
*u = D3DXVec3Dot( &tvec, &pvec );
|
||||
if( *u < 0.0f || *u > det )
|
||||
return FALSE;
|
||||
|
||||
// Prepare to test V parameter
|
||||
D3DXVECTOR3 qvec;
|
||||
D3DXVec3Cross( &qvec, &tvec, &edge1 );
|
||||
|
||||
// Calculate V parameter and test bounds
|
||||
*v = D3DXVec3Dot( &dir, &qvec );
|
||||
if( *v < 0.0f || *u + *v > det )
|
||||
return FALSE;
|
||||
|
||||
// Calculate t, scale parameters, ray intersects triangle
|
||||
*t = D3DXVec3Dot( &edge2, &qvec );
|
||||
FLOAT fInvDet = 1.0f / det;
|
||||
*t *= fInvDet;
|
||||
*u *= fInvDet;
|
||||
*v *= fInvDet;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
155
Library/dxx8/samples/Multimedia/Direct3D/Pick/pick.dsp
Normal file
155
Library/dxx8/samples/Multimedia/Direct3D/Pick/pick.dsp
Normal file
@@ -0,0 +1,155 @@
|
||||
# Microsoft Developer Studio Project File - Name="Pick" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=Pick - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "pick.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "pick.mak" CFG="Pick - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Pick - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Pick - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Pick - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 d3dx8.lib d3d8.lib d3dxof.lib dxguid.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /machine:I386 /stack:0x200000,0x200000
|
||||
|
||||
!ELSEIF "$(CFG)" == "Pick - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 d3dx8dt.lib d3d8.lib d3dxof.lib dxguid.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /stack:0x200000,0x200000
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Pick - Win32 Release"
|
||||
# Name "Pick - Win32 Debug"
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WinMain.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\d3dapp.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\d3dapp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\d3dfile.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\d3dfile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\d3dfont.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\d3dfont.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\d3dutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\d3dutil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\dxutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\dxutil.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\pick.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
29
Library/dxx8/samples/Multimedia/Direct3D/Pick/pick.dsw
Normal file
29
Library/dxx8/samples/Multimedia/Direct3D/Pick/pick.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Pick"=.\pick.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
251
Library/dxx8/samples/Multimedia/Direct3D/Pick/pick.mak
Normal file
251
Library/dxx8/samples/Multimedia/Direct3D/Pick/pick.mak
Normal file
@@ -0,0 +1,251 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on pick.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=Pick - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to Pick - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "Pick - Win32 Release" && "$(CFG)" != "Pick - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "pick.mak" CFG="Pick - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Pick - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Pick - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "Pick - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\pick.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\pick.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\WinMain.res"
|
||||
-@erase "$(OUTDIR)\pick.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\pick.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\WinMain.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\pick.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8.lib d3d8.lib d3dxof.lib dxguid.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\pick.pdb" /machine:I386 /out:"$(OUTDIR)\pick.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\pick.obj" \
|
||||
"$(INTDIR)\WinMain.res"
|
||||
|
||||
"$(OUTDIR)\pick.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "Pick - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\pick.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\pick.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(INTDIR)\WinMain.res"
|
||||
-@erase "$(OUTDIR)\pick.exe"
|
||||
-@erase "$(OUTDIR)\pick.ilk"
|
||||
-@erase "$(OUTDIR)\pick.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\pick.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\WinMain.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\pick.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8dt.lib d3d8.lib d3dxof.lib dxguid.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\pick.pdb" /debug /machine:I386 /out:"$(OUTDIR)\pick.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\pick.obj" \
|
||||
"$(INTDIR)\WinMain.res"
|
||||
|
||||
"$(OUTDIR)\pick.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("pick.dep")
|
||||
!INCLUDE "pick.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "pick.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "Pick - Win32 Release" || "$(CFG)" == "Pick - Win32 Debug"
|
||||
SOURCE=.\WinMain.rc
|
||||
|
||||
"$(INTDIR)\WinMain.res" : $(SOURCE) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\d3dapp.cpp
|
||||
|
||||
"$(INTDIR)\d3dapp.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\d3dfile.cpp
|
||||
|
||||
"$(INTDIR)\d3dfile.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\d3dfont.cpp
|
||||
|
||||
"$(INTDIR)\d3dfont.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\d3dutil.cpp
|
||||
|
||||
"$(INTDIR)\d3dutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\dxutil.cpp
|
||||
|
||||
"$(INTDIR)\dxutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=.\pick.cpp
|
||||
|
||||
"$(INTDIR)\pick.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
48
Library/dxx8/samples/Multimedia/Direct3D/Pick/readme.txt
Normal file
48
Library/dxx8/samples/Multimedia/Direct3D/Pick/readme.txt
Normal file
@@ -0,0 +1,48 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: Pick Direct3D Sample
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
The Pick sample shows how to implement "picking" which is finding which
|
||||
triangle in a mesh is intersected by a ray. In this case, the ray comes
|
||||
from mouse coordinates.
|
||||
|
||||
|
||||
Path
|
||||
====
|
||||
Source: DXSDK\Samples\Multimedia\D3D\Pick
|
||||
Executable: DXSDK\Samples\Multimedia\D3D\Bin
|
||||
|
||||
|
||||
User's Guide
|
||||
============
|
||||
The following keys are implemented. The dropdown menus can be used for the
|
||||
same controls.
|
||||
<Enter> Starts and stops the scene
|
||||
<Space> Advances the scene by a small increment
|
||||
<F1> Shows help or available commands.
|
||||
<F2> Prompts user to select a new rendering device or display mode
|
||||
<Alt+Enter> Toggles between fullscreen and windowed modes
|
||||
<Esc> Exits the app.
|
||||
|
||||
Use the mouse to "pick" any spot in the mesh to see that triangle.
|
||||
|
||||
|
||||
Programming Notes
|
||||
=================
|
||||
When the user clicks the mouse, the code reads the screen coordinates of the
|
||||
cursor. These coordinates are converted, via the projection and view matrices,
|
||||
into a ray which goes from the eye point through the point clicked on the screen
|
||||
and into the scene. This ray is passed to IntersectTriangle along with each
|
||||
triangle of the loaded model to determine which triangles, if any, are
|
||||
intersected by the ray. The texture coordinates of the intersected triangle
|
||||
is also determined.
|
||||
|
||||
This sample makes use of common DirectX code (consisting of helper functions,
|
||||
etc.) that is shared with other samples on the DirectX SDK. All common
|
||||
headers and source code can be found in the following directory:
|
||||
DXSDK\Samples\Multimedia\Common
|
||||
38
Library/dxx8/samples/Multimedia/Direct3D/Pick/resource.h
Normal file
38
Library/dxx8/samples/Multimedia/Direct3D/Pick/resource.h
Normal file
@@ -0,0 +1,38 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by WinMain.rc
|
||||
//
|
||||
#define IDI_MAIN_ICON 101
|
||||
#define IDR_MAIN_ACCEL 113
|
||||
#define IDR_MENU 141
|
||||
#define IDR_POPUP 142
|
||||
#define IDD_SELECTDEVICE 144
|
||||
#define IDC_DEVICE_COMBO 1000
|
||||
#define IDC_MODE_COMBO 1001
|
||||
#define IDC_ADAPTER_COMBO 1002
|
||||
#define IDC_FULLSCREENMODES_COMBO 1003
|
||||
#define IDC_MULTISAMPLE_COMBO 1005
|
||||
#define IDC_WINDOWED_CHECKBOX 1012
|
||||
#define IDC_FULLSCREEN_TEXT 1014
|
||||
#define IDC_WINDOW 1016
|
||||
#define IDC_FULLSCREEN 1018
|
||||
#define IDM_CHANGEDEVICE 40002
|
||||
#define IDM_TOGGLEFULLSCREEN 40003
|
||||
#define IDM_TOGGLESTART 40004
|
||||
#define IDM_SINGLESTEP 40005
|
||||
#define IDM_EXIT 40006
|
||||
#define IDM_TOGGLED3DX 40011
|
||||
#define IDM_HELP 40012
|
||||
#define IDM_TOGGLEALLHITS 40013
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_3D_CONTROLS 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 146
|
||||
#define _APS_NEXT_COMMAND_VALUE 40014
|
||||
#define _APS_NEXT_CONTROL_VALUE 1027
|
||||
#define _APS_NEXT_SYMED_VALUE 102
|
||||
#endif
|
||||
#endif
|
||||
181
Library/dxx8/samples/Multimedia/Direct3D/Pick/winmain.rc
Normal file
181
Library/dxx8/samples/Multimedia/Direct3D/Pick/winmain.rc
Normal file
@@ -0,0 +1,181 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#define IDC_STATIC -1
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_MAIN_ICON ICON DISCARDABLE "DirectX.ico"
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define IDC_STATIC -1\r\n"
|
||||
"#include <windows.h>\r\n"
|
||||
"\r\n"
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_MAIN_ACCEL ACCELERATORS DISCARDABLE
|
||||
BEGIN
|
||||
VK_ESCAPE, IDM_EXIT, VIRTKEY, NOINVERT
|
||||
VK_F1, IDM_HELP, VIRTKEY, NOINVERT
|
||||
VK_F2, IDM_CHANGEDEVICE, VIRTKEY, NOINVERT
|
||||
VK_F3, IDM_TOGGLED3DX, VIRTKEY, NOINVERT
|
||||
VK_F4, IDM_TOGGLEALLHITS, VIRTKEY, NOINVERT
|
||||
VK_RETURN, IDM_TOGGLESTART, VIRTKEY, NOINVERT
|
||||
VK_RETURN, IDM_TOGGLEFULLSCREEN, VIRTKEY, ALT, NOINVERT
|
||||
VK_SPACE, IDM_SINGLESTEP, VIRTKEY, NOINVERT
|
||||
"X", IDM_EXIT, VIRTKEY, ALT, NOINVERT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_SELECTDEVICE, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 259
|
||||
TOPMARGIN, 7
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_SELECTDEVICE DIALOG DISCARDABLE 0, 0, 267, 138
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Select Device"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
GROUPBOX "Rendering device",IDC_STATIC,5,5,200,45
|
||||
LTEXT "&Adapter:",IDC_STATIC,22,17,65,10,SS_CENTERIMAGE
|
||||
COMBOBOX IDC_ADAPTER_COMBO,90,15,105,100,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "&Device:",IDC_STATIC,22,32,65,10,SS_CENTERIMAGE
|
||||
COMBOBOX IDC_DEVICE_COMBO,90,30,105,100,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
GROUPBOX "Rendering mode",IDC_STATIC,5,52,200,45
|
||||
CONTROL "Use desktop &window",IDC_WINDOW,"Button",
|
||||
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,10,62,85,15
|
||||
CONTROL "&Fullscreen mode:",IDC_FULLSCREEN,"Button",
|
||||
BS_AUTORADIOBUTTON,10,77,75,15
|
||||
COMBOBOX IDC_FULLSCREENMODES_COMBO,90,77,105,204,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_GROUP | WS_TABSTOP
|
||||
GROUPBOX "Multisample",IDC_STATIC,5,101,200,28
|
||||
LTEXT "&Multisample Type:",IDC_STATIC,22,113,62,10,
|
||||
SS_CENTERIMAGE
|
||||
COMBOBOX IDC_MULTISAMPLE_COMBO,90,111,105,100,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
DEFPUSHBUTTON "OK",IDOK,210,10,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,210,30,50,14
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Go/stop\tEnter", IDM_TOGGLESTART
|
||||
MENUITEM "&Single step\tSpace", IDM_SINGLESTEP
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Change device...\tF2", IDM_CHANGEDEVICE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit\tESC", IDM_EXIT
|
||||
END
|
||||
END
|
||||
|
||||
IDR_POPUP MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "Popup"
|
||||
BEGIN
|
||||
MENUITEM "&Go/stop", IDM_TOGGLESTART
|
||||
MENUITEM "&Single step", IDM_SINGLESTEP
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Change device...", IDM_CHANGEDEVICE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", IDM_EXIT
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
Reference in New Issue
Block a user