资源简介

本资源对应 net_assassin 的博客专栏中的源代码。 简单易懂 敬请阅读

资源截图

代码片段和文件信息

/*
D3DXSprite Test Program
By John Doe Uber Coder Supreme
Don‘t mess with my code!
*/

#include 
#include 
#include 

const bool wireframe = false;
const char *APPtitle = “Lighting Example“;
const int SCREENW = 1024;
const int SCREENH = 768;
HWND window;
bool gameover = false;

//Direct3D objects
LPDIRECT3D9 d3d = NULL; 
LPDIRECT3DDEVICE9 d3ddev = NULL; 

//define the 2D rendering objects
LPD3DXSPRITE d3dxsprite = NULL;

LPD3DXMESH sphere;


//void CreateCube(double width double height double depth)
//{
// D3DXCreateBox(g_engine->getDevice() (float)width (float)height (float)depth &mesh NULL);
//}
//
//void CreateTeapot()
//{
// D3DXCreateTeapot(g_engine->getDevice() &mesh NULL);
//}



void Create_Point_Light(int lightNum D3DXVECTOR3 position double range)
{
D3DLIGHT9 p_light;
//D3DCOLORVALUE p_color;

ZeroMemory( &p_light sizeof(D3DLIGHT9) );

p_light.Diffuse.r = p_light.Ambient.r = 1.0f;
p_light.Diffuse.g = p_light.Ambient.g = 1.0f;
p_light.Diffuse.b = p_light.Ambient.b = 1.0f;
p_light.Diffuse.a = p_light.Ambient.a = 1.0f;

p_light.Range = (float)range;
p_light.Type = D3DLIGHT_POINT;
p_light.Position = position;
p_light.Attenuation0 = 0.1f;

d3ddev->SetLight(lightNum &p_light);
d3ddev->LightEnable(lightNumTRUE);
}

void Set_Camera(float xfloat yfloat z)
{
    D3DXMATRIX p_matrixProj;
    D3DXMATRIX p_matrixView;
D3DXMATRIX p_matrixRot;
    D3DXVECTOR3 p_updir;
double p_nearRange;
double p_farRange;
double p_aspectRatio;
double p_fov;
D3DXVECTOR3 p_position;
D3DXVECTOR3 p_rotation;
D3DXVECTOR3 p_target;

p_position = D3DXVECTOR3(x y z);
p_target = D3DXVECTOR3(0.0f0.0f0.0f);
p_updir = D3DXVECTOR3(0.0f1.0f0.0f);

//hard coded to 1.3333 by default
p_fov = D3DX_PI / 4.0;
p_aspectRatio = 1024 / 768;
p_nearRange = 1.0;
p_farRange = 2000.0;

    //set the camera‘s perspective matrix
    D3DXMatrixPerspectiveFovLH(&p_matrixProj (float)p_fov (float)p_aspectRatio (float)p_nearRange (float)p_farRange);
    d3ddev->SetTransform(D3DTS_PROJECTION &p_matrixProj);

    //set the camera‘s view matrix
    D3DXMatrixLookAtLH(&p_matrixView &p_position &p_target &p_updir);
d3ddev->SetTransform(D3DTS_VIEW &p_matrixView );
}


void Create_Directional_Light(int lightNum D3DXVECTOR3 direction double range)
{
D3DLIGHT9 p_light;
ZeroMemory( &p_light sizeof(D3DLIGHT9) );

p_light.Diffuse.r = p_light.Ambient.r = 1.0f;
p_light.Diffuse.g = p_light.Ambient.g = 1.0f;
p_light.Diffuse.b = p_light.Ambient.b = 1.0f;
p_light.Diffuse.a = p_light.Ambient.a = 1.0f;
p_light.Range = (float)range;

p_light.Type = D3DLIGHT_DIRECTIONAL;
D3DXVec3Normalize( (D3DXVECTOR3*)&p_light.Direction &direction );

d3ddev->SetLight(lightNum &p_light);
d3ddev->LightEnable(lightNumTRUE);
}


//void Create_Spot_Light(int lightNum D3DLIGHTTYPE type D3DXVECTOR3 position D3DXVECTOR3 dir

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        112  2009-06-09 21:54  Begin Game Programming\software\Anim8or Web Site.url

     文件    1818678  2007-04-02 21:46  Begin Game Programming\software\Anim8or.exe

     文件     848182  2009-06-09 21:55  Begin Game Programming\software\animv095c.zip

     文件       4051  2009-06-09 21:31  Begin Game Programming\source\APPEND\Lighting Stock Sphere\Direct3DTest\D3DXSpriteTest.vcproj

     文件       1409  2009-06-09 21:31  Begin Game Programming\source\APPEND\Lighting Stock Sphere\Direct3DTest\D3DXSpriteTest.vcproj.HAL.jonathan.user

     文件      10240  2009-06-09 21:31  Begin Game Programming\source\APPEND\Lighting Stock Sphere\Direct3DTest\LightingExample.exe

     文件      10079  2009-06-09 00:53  Begin Game Programming\source\APPEND\Lighting Stock Sphere\Direct3DTest\main.cpp

     文件        906  2009-02-03 07:27  Begin Game Programming\source\APPEND\Lighting Stock Sphere\LightingExample.sln

     文件       9216  2009-06-09 21:31  Begin Game Programming\source\APPEND\Lighting Stock Sphere\LightingExample.suo

     文件        900  2009-04-15 21:01  Begin Game Programming\source\APPEND\Shader--Color\ColorShader.sln

     文件      49664  2009-06-09 21:31  Begin Game Programming\source\APPEND\Shader--Color\ColorShader.suo

     文件       1648  2009-04-16 02:06  Begin Game Programming\source\APPEND\Shader--Color\Direct3DTest\ambientdiffuse.fx

     文件     196664  2001-01-30 02:58  Begin Game Programming\source\APPEND\Shader--Color\Direct3DTest\apache.bmp

     文件     148209  2003-06-23 01:57  Begin Game Programming\source\APPEND\Shader--Color\Direct3DTest\Apache.X

     文件      75776  2009-06-09 21:31  Begin Game Programming\source\APPEND\Shader--Color\Direct3DTest\ColorShader.exe

     文件       4234  2009-06-09 21:31  Begin Game Programming\source\APPEND\Shader--Color\Direct3DTest\ColorShader.vcproj

     文件       1409  2009-06-09 21:31  Begin Game Programming\source\APPEND\Shader--Color\Direct3DTest\ColorShader.vcproj.HAL.jonathan.user

     文件       7471  2009-06-09 01:02  Begin Game Programming\source\APPEND\Shader--Color\Direct3DTest\main.cpp

     文件       5220  2009-04-16 02:09  Begin Game Programming\source\APPEND\Shader--Color\Direct3DTest\Mesh.cpp

     文件       2467  2009-04-16 01:40  Begin Game Programming\source\APPEND\Shader--Color\Direct3DTest\Mesh.h

     文件      10752  2009-04-17 03:46  Begin Game Programming\source\APPEND\Shader--Color\Direct3DTest\Thumbs.db

     文件       5192  2009-06-09 01:20  Begin Game Programming\source\APPEND\Shader--Wireframe Teapot\Direct3DTest\main.cpp

     文件       1288  2009-06-09 01:20  Begin Game Programming\source\APPEND\Shader--Wireframe Teapot\Direct3DTest\Shader.fx

     文件       4112  2009-06-09 21:32  Begin Game Programming\source\APPEND\Shader--Wireframe Teapot\Direct3DTest\SimpleShader.vcproj

     文件       1409  2009-06-09 21:33  Begin Game Programming\source\APPEND\Shader--Wireframe Teapot\Direct3DTest\SimpleShader.vcproj.HAL.jonathan.user

     文件      57856  2009-06-09 21:33  Begin Game Programming\source\APPEND\Shader--Wireframe Teapot\Direct3DTest\WireframeShader.exe

     文件   15117312  2009-06-09 21:33  Begin Game Programming\source\APPEND\Shader--Wireframe Teapot\WireframeShader.ncb

     文件        902  2009-04-01 22:41  Begin Game Programming\source\APPEND\Shader--Wireframe Teapot\WireframeShader.sln

     文件      18432  2009-06-09 21:33  Begin Game Programming\source\APPEND\Shader--Wireframe Teapot\WireframeShader.suo

     文件       7680  2009-06-09 21:35  Begin Game Programming\source\chapter01\Hello World Demo\HelloWorld.exe

............此处省略386个文件信息

评论

共有 条评论