bool BoxApp::Init()
{
	if(!D3DApp::Init())
		return false;

	BuildGeometryBuffers();
	BuildFX();
	BuildVertexLayout();
 
    blocks.push_back(new Block(md3dDevice, md3dImmediateContext,
                                XMFLOAT3(-0.5f, -0.5f, -1.0f),
                                XMFLOAT3(-0.5f, +0.5f, -1.0f),
                                XMFLOAT3(+0.5f, +0.5f, -1.0f),
                                XMFLOAT3(+0.5f, -0.5f, -1.0f)));
    /*
    blocks[0]->AddInstance(D3DXVECTOR3(-1.5f, -1.5f, 5.0f));
	blocks[0]->AddInstance(D3DXVECTOR3(-1.5f,  1.5f, 5.0f));
	blocks[0]->AddInstance(D3DXVECTOR3( 1.5f, -1.5f, 5.0f));
	blocks[0]->AddInstance(D3DXVECTOR3( 1.5f,  1.5f, 5.0f));
    */

    figures.push_back(new Line(blocks[0]));
    figures.push_back(new Tank(blocks[0]));
    figures.push_back(new RightBlock(blocks[0]));
    figures.push_back(new LeftBlock(blocks[0]));
    figures.push_back(new Square(blocks[0]));

    figures[1]->move(D3DXVECTOR3(4.0f, 0.0f, 0.0f));
    figures[2]->move(D3DXVECTOR3(-4.0f, 0.0f, 0.0f));
    figures[3]->move(D3DXVECTOR3(0.0f, -3.0f, 0.0f));
    figures[4]->move(D3DXVECTOR3(+2.0f, -2.0f, 0.0f));
	return true;
}
Beispiel #2
0
bool WavesApp::Init()
{
	if (!D3DApp::Init())
	{
		return false;
	}

	m_waves.Init(200, 200, 0.8f, 0.03f, 3.25f, 0.4f);


	BuildLandGeometryBuffers();
	BuildWavesGeometryBuffers();
	BuildFX();
	BuildVertexLayout();

	D3D11_RASTERIZER_DESC wireframeDesc;
	ZeroMemory(&wireframeDesc, sizeof(D3D11_RASTERIZER_DESC));
	wireframeDesc.FillMode = D3D11_FILL_WIREFRAME;
	wireframeDesc.CullMode = D3D11_CULL_BACK;
	wireframeDesc.FrontCounterClockwise = false;
	wireframeDesc.DepthClipEnable = true;

	HR(m_pD3dDevice->CreateRasterizerState(&wireframeDesc, &m_pWireframeRS));

	return true;
}
bool BoxApp::Init()
{
	if(!D3DApp::Init())
		return false;
	GetWindowRect(mhMainWnd,&rc);
	int midX= (rc.right+rc.left)/2;
	int midY= (rc.top+rc.bottom)/2;
	mLastMousePos.x = midX;
	mLastMousePos.y = midY;
	SetCursorPos(midX,midY);
	ClipCursor(&rc);
	w = new World();
	w->Init(md3dDevice,this);

	cam = new Camera();
	cam->Init(&mView, w->playerShip);

	//SetCapture(mhMainWnd);
	ShowCursor(false);

	BuildGeometryBuffers();
	BuildFX();
	BuildVertexLayout();

	HR(D3DX11CreateShaderResourceViewFromFile(md3dDevice,L"Assets/skybox.dds",0,0, &mCubeMapSRV,0));
	CubeMap = mFX->GetVariableByName("gCubeMap")->AsShaderResource();

	CubeMap->SetResource(mCubeMapSRV);
	return true;
}
Beispiel #4
0
bool BoxApp::Init()
{
	if(!D3DApp::Init())
		return false;

	BuildGeometryBuffers();
	BuildFX();
	BuildVertexLayout();

	return true;
}
Beispiel #5
0
	bool LightingApp::Init()
	{
		if (!D3DApp::Init())
			return false;
		mWaves.Init(160, 160, 1.0f, 0.03f, 3.25f, 0.4f);
		BuildLandGeometryBuffers();
		BuildWaveGeometryBuffers();
		BuildFX();
		BuildVertexLayout();
		return TRUE;
	}
Beispiel #6
0
bool HillsApp::Init()
{
	if(!D3DApp::Init())
		return false;

	BuildGeometryBuffers();
	BuildFX();
	BuildVertexLayout();
	BuildRasterState();
	mObjectConstantBuffer.Initialize(md3dDevice);
	return true;
}
Beispiel #7
0
bool BoxApp::Init()
{
	if (!D3DApp::Init())
	{
		return false;
	}

	CreateRasterizerStates();
	BuildFX();
	BuildVertexLayout();
	md3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY::D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	m_Mesh = std::make_unique<Mesh>("Models/MeteorBig.FBX", md3dDevice);
	return true;
}
Beispiel #8
0
bool LightingApp::Init()
{
	if(!D3DApp::Init())
		return false;

	mWaves.Init(160, 160, 1.0f, 0.03f, 3.25f, 0.4f);

	BuildLandGeometryBuffers();
	BuildWaveGeometryBuffers();
	BuildFX();
	BuildVertexLayout();
	mObjectConstantBuffer.Initialize(md3dDevice);
	mFrameConstantBuffer.Initialize(md3dDevice);
	return true;
}
Beispiel #9
0
bool BoxApp::Init()
{
	if(!D3DApp::Init())
		return false;


	D3D11_BLEND_DESC colorDesc = { 0 };
	colorDesc.AlphaToCoverageEnable = false;
	colorDesc.IndependentBlendEnable = false;

	colorDesc.RenderTarget[0].BlendEnable = true;
	colorDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_COLOR;
	colorDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_BLEND_FACTOR;
	colorDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_SUBTRACT;
	colorDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
	colorDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
	colorDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
	colorDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;

	HR(md3dDevice->CreateBlendState(&colorDesc, &ColorBlend));

	D3D11_BLEND_DESC transparentDesc2 = { 0 };
	transparentDesc2.AlphaToCoverageEnable = false;
	transparentDesc2.IndependentBlendEnable = false;

	transparentDesc2.RenderTarget[0].BlendEnable = true;
	transparentDesc2.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
	transparentDesc2.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
	transparentDesc2.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
	transparentDesc2.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
	transparentDesc2.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
	transparentDesc2.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
	transparentDesc2.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;

	HR(md3dDevice->CreateBlendState(&transparentDesc2, &AlphaBlend));

	BuildGeometryBuffers();
	BuildFX();
	BuildVertexLayout();

	return true;
}
Beispiel #10
0
bool wam::Init()
{
	if(!D3DApp::Init())
		return false;

	BuildGeometryBuffers();
	BuildFX();
	BuildVertexLayout();

	D3D11_RASTERIZER_DESC wireframeDesc;
	ZeroMemory(&wireframeDesc, sizeof(D3D11_RASTERIZER_DESC));
	wireframeDesc.FillMode = D3D11_FILL_WIREFRAME;
	wireframeDesc.CullMode = D3D11_CULL_BACK;
	wireframeDesc.FrontCounterClockwise = false;
	wireframeDesc.DepthClipEnable = true;

	HR(md3dDevice->CreateRasterizerState(&wireframeDesc, &mWireframeRS));

	return true;

}
Beispiel #11
0
Scene::Scene(HWND TheWindow, unsigned int WindowWidth, unsigned int WindowHeight):
MyD3D10Code::Direct3D10Class(TheWindow, WindowWidth, WindowHeight),
m_FX(0),
m_Tech(0),
m_fxWVPVar(0),
m_VertexLayout(0),
m_Theta(0.0f),
m_Phi(PI*0.25f),
m_Box(m_Direct3DDevice),
// Delete 5 below variables later from init list
m_FxEyePosVar(0),
m_FxLightVar(0),
m_SpecMapRV(0),
m_FxSpecMapVar(0),
m_FxTexMatVar(0),
m_FxBoxWorldVar(0),
m_EnvironmentMapRV(0),
m_Roof(m_Direct3DDevice),
m_Floor(m_Direct3DDevice)
{
	// Initialise world view projection matrix
	D3DXMatrixIdentity(&m_WorldViewProjection);

	// Set the position of the camera
	GetCamera().position() = D3DXVECTOR3(0.0f, 1.8f, -10.0f);

	// Set the camera up
	float aspect = (float)m_WindowWidth/m_WindowHeight;		// Used in D3DXMatrixPerspectiveFovLH()
	GetCamera().setLens(0.25f*PI, aspect, 0.5f, 1000.0f);

	// Create effects and vertex layouts 
	BuildFX();
	BuildVertexLayouts();
	fx::InitAll(m_Direct3DDevice);
	InputLayout::InitAll(m_Direct3DDevice);

	// Initialise texture manager
	GetTextureMgr().init(m_Direct3DDevice);

	// Create crate resource view
	HR( D3DX10CreateShaderResourceViewFromFile(m_Direct3DDevice,	// The device to create the texture with
											   L"GreyBricks.jpg",	// The name of the file
											   0,					// Optional image info, specify null to use source dimensions and to creat a full chain of mipmap levels
											   0,					// Used to spawn a new thread to load resources, pPump
											   &m_DiffuseMapRV,		// The pointer that is used to interface with the new resource
											   0) );				// Used with pPump

	// Create specular map resource view
	HR( D3DX10CreateShaderResourceViewFromFile(m_Direct3DDevice,	// The device to create the texture with
											   L"defaultspec.dds",	// The name of the file to sue
											   0,					// Optional image info, specify null to use source dimensions and to creat a full chain of mipmap levels 
											   0,					// Used to spawn a new thread to load resources, pPump
											   &m_SpecMapRV,		// The pointer that is used to interface with the new resource
											   0) );				// Used with pPump

	// Create crate resource view
	HR( D3DX10CreateShaderResourceViewFromFile(m_Direct3DDevice,	// The device to create the texture with
											   L"Tiles.jpg",		// The name of the file
											   0,					// Optional image info, specify null to use source dimensions and to creat a full chain of mipmap levels
											   0,					// Used to spawn a new thread to load resources, pPump
											   &m_RoofTilesRV,		// The pointer that is used to interface with the new resource
											   0) );				// Used with pPump

	// Create crate resource view
	HR( D3DX10CreateShaderResourceViewFromFile(m_Direct3DDevice,	// The device to create the texture with
											   L"Grass.jpg",		// The name of the file
											   0,					// Optional image info, specify null to use source dimensions and to creat a full chain of mipmap levels
											   0,					// Used to spawn a new thread to load resources, pPump
											   &m_GrassRV,			// The pointer that is used to interface with the new resource
											   0) );				// Used with pPump

	// Set the sky texture up
	m_EnvironmentMapRV	= GetTextureMgr().createCubeTex(L"grassenvmap1024.dds");

	// Set up parallel light
	m_ParallelLight.dir		 = D3DXVECTOR3(0.57735f, -0.57735f, -0.25f);	// Reveresed
	m_ParallelLight.ambient	 = D3DXCOLOR(0.4f, 0.4f, 0.4f, 1.0f);
	m_ParallelLight.diffuse	 = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
	m_ParallelLight.specular = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);

	// Set box position
	m_Box.SetPosition(0.0f, 1.0f, 0.0f);

	m_Floor.ScaleXZ(10, 10);
	// Initialise sky
	m_Sky.init(m_Direct3DDevice, m_EnvironmentMapRV, 5000.0f);
}