示例#1
0
//----------------------------------------------
void TbulHoming::Render( void )
{
	std::vector<Vector2D> vec;
	vec.push_back(FvPosition);

	// ビューポート変換
	FpGame->ViewPortTransform( vec );
	RECT srcRec =  { TRIMMING__IMAGE_LTX, TRIMMING__IMAGE_LTY, TRIMMING__IMAGE_RBX, TRIMMING__IMAGE_RBY};			
	pos = D3DXVECTOR3( (float)vec[0].x, (float)vec[0].y, 0);
	

	// 弾の後ろにぼかしを入れる
	FpGame->FpSprites->RenderEx(
							&srcRec,
							pos,																// DrawPosition
							D3DXVECTOR3((float)(FvScale.x*1.5) , (float)(FvScale.y*1.5), 1),				// Scaling
							D3DXVECTOR3(0, 0, 0),												// Rotation
							&D3DXVECTOR3 ((float)(FiImageWidth/2), (float)(FiImageHeight/2), 0),	// RotationCenter
							0.4,																// Alpha
							D3DCOLOR(1));	


	// 画像を表示する座標
	FpGame->FpSprites->RenderEx(
							&srcRec,
							pos,																// DrawPosition
							D3DXVECTOR3((float)FvScale.x , (float)FvScale.y, 1),				// Scaling
							D3DXVECTOR3(0, 0, 0),												// Rotation
							&D3DXVECTOR3 ((float)(FiImageWidth/2), (float)(FiImageHeight/2), 0),	// RotationCenter
							1.0,																// Alpha
							D3DCOLOR(1));														// ColorKey

}
示例#2
0
// Call the user's Render() callback (if it exists)
//-----------------------------------------------------------------------------
void CPUT_DX11::InnerExecutionLoop()
{
#ifdef CPUT_GPA_INSTRUMENTATION
    D3DPERF_BeginEvent(D3DCOLOR(0xff0000), L"CPUT User's Render() ");
#endif
    if(!mbShutdown)
    {
        double deltaSeconds = mpTimer->GetElapsedTime();
        Update(deltaSeconds);
        Present(); // Note: Presenting immediately before Rendering minimizes CPU stalls (i.e., execute Update() before Present() stalls)

        double totalSeconds = mpTimer->GetTotalTime();
        UpdatePerFrameConstantBuffer(totalSeconds);
        CPUTMaterialDX11::ResetStateTracking();
        Render(deltaSeconds);
        if(!CPUTOSServices::GetOSServices()->DoesWindowHaveFocus())
        {
            Sleep(100);
        }
    }
    else
    {
#ifndef _DEBUG
        exit(0);
#endif
        Present(); // Need to present, or will leak all references held by previous Render()!
        ShutdownAndDestroy();
    }

#ifdef CPUT_GPA_INSTRUMENTATION
    D3DPERF_EndEvent();
#endif
}
示例#3
0
//----------------------------------------------
void TeffFinalBigExplosion::Render( void )
{
	std::vector<Vector2D> vec;
	vec.push_back(FvPosition);

	// ビューポート変換
	FpGame->ViewPortTransform( vec );
	RECT srcRec =  {  // 画像の中から切り取る座標
		IMAGE_WIDTH * FiFrame % CELL_YOKO,
		IMAGE_HEIGHT * FiFrame / CELL_YOKO,
		IMAGE_WIDTH * ( FiFrame % CELL_YOKO + 1),
		IMAGE_HEIGHT * ( FiFrame / CELL_YOKO + 1),
	};						
	pos = D3DXVECTOR3( (float)vec[0].x, (float)vec[0].y, 0);

	// 画像を表示する座標
	FpGame->FpExplosionSprite->RenderEx(
							&srcRec,
							pos,																// DrawPosition
							D3DXVECTOR3((float)FvScale.x , (float)FvScale.y, 1),				// Scaling
							D3DXVECTOR3(0, 0, 0),												// Rotation
							&D3DXVECTOR3 ((float)(FiImageWidth/2), (float)(FiImageHeight/2), 0),	// RotationCenter
							FiAlpha,																// Alpha
							D3DCOLOR(1));																// ColorKey
}
void CollisionSolver::SolveClothCollision(const D3DXVECTOR3& minBounds, 
                                          const D3DXVECTOR3& maxBounds)
{
    D3DPERF_BeginEvent(D3DCOLOR(), L"CollisionSolver::SolveClothCollision");

    assert(!m_cloth.expired());
    auto cloth = m_cloth.lock();
    auto& particles = cloth->GetParticles();

    for(unsigned int i = 0; i < particles.size(); ++i)
    {
        // Solve the particles against themselves
        for(unsigned int j = i+1; j < particles.size(); ++j)
        {
            SolveParticleCollision(particles[i]->GetCollisionMesh(), 
                particles[j]->GetCollisionMesh());
        }

        // Solve the particle against the eight scene walls
        const D3DXVECTOR3& particlePosition = particles[i]->GetPosition();
        D3DXVECTOR3 position(0.0, 0.0, 0.0);

        // Check for ground and roof collisions
        if(particlePosition.y <= maxBounds.y)
        {
            position.y = maxBounds.y-particlePosition.y;
        }
        else if(particlePosition.y >= minBounds.y)
        {
            position.y = minBounds.y-particlePosition.y;
        }

        // Check for left and right wall collisions
        if(particlePosition.x >= maxBounds.x)
        {
            position.x = maxBounds.x-particlePosition.x;
        }
        else if(particlePosition.x <= minBounds.x)
        {
            position.x = minBounds.x-particlePosition.x;
        }

        // Check for forward and backward wall collisions
        if(particlePosition.z >= maxBounds.z)
        {
            position.z = maxBounds.z-particlePosition.z;
        }
        else if(particlePosition.z <= minBounds.z)
        {
            position.z = minBounds.z-particlePosition.z;
        }

        particles[i]->MovePosition(position);
    }

    D3DPERF_EndEvent();
}
示例#5
0
// start main message loop
//-----------------------------------------------------------------------------
int CPUT_DX11::CPUTMessageLoop()
{
#ifdef CPUT_GPA_INSTRUMENTATION
    D3DPERF_BeginEvent(D3DCOLOR(0xff0000), L"CPUTMessageLoop");
#endif

    return mpWindow->StartMessageLoop();

#ifdef CPUT_GPA_INSTRUMENTATION
    D3DPERF_EndEvent();
#endif
}
示例#6
0
Renderable2D_Comp::Renderable2D_Comp(void)
{
	//default values
	//texture =		Texture();
	texture =		NULL;
	scaling =		1.0f;
	depth =			1.0f;
	visible =		true;
	width =			0;
	height =		0;
	color =			D3DCOLOR(); //funzt net?
}
示例#7
0
// draw all the GUI controls
//-----------------------------------------------------------------------------
void CPUT_DX11::CPUTDrawGUI()
{
#ifdef CPUT_GPA_INSTRUMENTATION
    D3DPERF_BeginEvent(D3DCOLOR(0xff0000), L"CPUT Draw GUI");
#endif

    // draw all the Gui controls
    HEAPCHECK;
        CPUTGuiControllerDX11::GetController()->Draw(mpContext);
    HEAPCHECK;

#ifdef CPUT_GPA_INSTRUMENTATION
        D3DPERF_EndEvent();
#endif
}
//-----------------------------------------------------------------------------
void CPUTMeshDX11::Draw(CPUTRenderParameters &renderParams, CPUTModel *pModel, ID3D11InputLayout *pInputLayout )
{
	mDrawCallCount++;
    // Skip empty meshes.
    if( !mIndexCount ) { return; }

// TODO: Modify CPUTPerfTaskMarker so that calls compile out, instead of explicitly wrapping every call with ifdef CPUT_GPA_INSTRUMENTATION
#ifdef CPUT_GPA_INSTRUMENTATION
    CPUTPerfTaskMarker marker = CPUTPerfTaskMarker(D3DCOLOR(0xff0000), _L("CPUT Draw Mesh"));
#endif
    ID3D11DeviceContext *pContext = ((CPUTRenderParametersDX*)&renderParams)->mpContext;

    pContext->IASetPrimitiveTopology( mD3DMeshTopology );
    pContext->IASetVertexBuffers(0, 1, &mpVertexBuffer, &mVertexStride, &mVertexBufferOffset);
    pContext->IASetIndexBuffer(mpIndexBuffer, mIndexBufferFormat, 0);

    pContext->IASetInputLayout( pInputLayout );

    pContext->DrawIndexed( mIndexCount, 0, 0 );
}
示例#9
0
//----------------------------------------------
void TuiBtnStg3::Render( void )
{
	std::vector<Vector2D> vec;
	vec.push_back(FvPosition);

	// ビューポート変換
	FpStageSelect->ViewPortTransform( vec );
	RECT srcRec =  { TRIMMING__IMAGE_LTX, TRIMMING__IMAGE_LTY, TRIMMING__IMAGE_RBX, TRIMMING__IMAGE_RBY};						// 画像の中から切り取る座標
	pos = D3DXVECTOR3( (float)vec[0].x, (float)vec[0].y, 0);

	// 画像を表示する座標
	FpStageSelect->FpBtnStg3->RenderEx(
							&srcRec,
							pos,																// DrawPosition
							D3DXVECTOR3((float)FvScale.x , (float)FvScale.y, 1),				// Scaling
							D3DXVECTOR3(0, 0, 0),												// Rotation
							&D3DXVECTOR3 ((float)(FiImageWidth/2), (float)(FiImageHeight/2), 0),	// RotationCenter
							FiAlpha,																// Alpha
							D3DCOLOR(1.f));																// ColorKey
}
示例#10
0
//----------------------------------------------
void TshMiniMultipleShot::Render( void )
{
	
	std::vector<Vector2D> vec;
	vec.push_back(FvPosition);

	// ビューポート変換
	FpGame->ViewPortTransform( vec );
	RECT srcRec =  { TRIMMING__IMAGE_LTX, TRIMMING__IMAGE_LTY, TRIMMING__IMAGE_RBX, TRIMMING__IMAGE_RBY};						// 画像の中から切り取る座標
	pos = D3DXVECTOR3( (float)vec[0].x, (float)vec[0].y, 0);

	// 画像を表示する座標
	FpGame->FpSprites->RenderEx(
							&srcRec,
							pos,																	// DrawPosition
							D3DXVECTOR3((float)FvScale.x , (float)FvScale.y, 1),					// Scaling
							D3DXVECTOR3(0, 0, (float)FdTheta),												// Rotation
							&D3DXVECTOR3 ((float)(FiImageWidth/2), (float)(FiImageHeight/2), 0),	// RotationCenter
							1.0,																	// Alpha
							D3DCOLOR(1));															// ColorKey

}
示例#11
0
void Game::init(HWND& hWnd, HINSTANCE& hInst,bool bWindowed) {
	std::ifstream file;
	gameState = preGame;
	PrimObj temp;
	//start Direct X
	vidFram.init(hWnd,hInst,bWindowed);
	vidFram.setViewCount(1);
	vidFram.setCam(1,&camera);
	//start FMOD
	sndFram.Init();
	//start input
	input.init(hWnd,hInst);
	//start resMan
	resMan.changeDevice(&vidFram);
	resMan.changeDevice(&sndFram);

	//create light
	// Ambient light color emitted from this light
	m_Light.Ambient = D3DXCOLOR(0.1f, 0.1f, 0.1f, 1.0f);
	// Diffuse light color emitted from this light
	m_Light.Diffuse = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f);
	// Specular light color emitted from this light
	m_Light.Specular = D3DXCOLOR(0.2f, 0.2f, 0.2f, 1.0f);
	// Light Type (Point) Requires: Position, Range, Attenuation
	m_Light.Type = D3DLIGHT_SPOT;	// Point, alternatively D3DLIGHT_DIRECTIONAL or D3DLIGHT_SPOT
	// Light Position
	m_Light.Position = D3DXVECTOR3(0.0f, 100.0f, 0.0f); 
	m_Light.Direction = D3DXVECTOR3(0.0f, -1.0f, 0.0);
	// Range of Light
	m_Light.Range = 1000.0f;
	// Light Attenuation
	m_Light.Attenuation0 = 0.0f;	// Constant
	m_Light.Attenuation1 = 0.05f;	// Linear
	m_Light.Attenuation2 = 0.0f;	// Quadratic
	//
	m_Light.Phi = D3DXToRadian(90.0f);
	m_Light.Theta = m_Light.Phi;
	// Set Light
	vidFram.setLight(0, &m_Light);
	//turn on light
	vidFram.setLightActive(0,true);

	//set default cam values
	camera.drawDist = 20000.0f;
	camera.fov_deg = 90.f;
	camera.cam_pos.x = 0;
	camera.cam_pos.y = 0;
	camera.cam_pos.z = 0;
	camera.cam_look_pos.x = 0;
	camera.cam_look_pos.y = 0;
	camera.cam_look_pos.z = 0;
	camera.cam_up_vec.x = 0;
	camera.cam_up_vec.y = 1;
	camera.cam_up_vec.z = 0;
	vidFram.setCam(1,&camera);
	//set time
	cTime = timeGetTime();
	lTime = cTime;
	dt = 0;

	//creat default material
	defMat.Ambient = D3DXCOLOR(0.2f, 0.2f, 0.2f, 1.0f);
	defMat.Diffuse = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f);		// Diffuse color reflected
	defMat.Emissive = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);		// Emissive color reflected
	defMat.Specular = D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.0f);		// Specular
	defMat.Power = 0.0f;
	//load player assets
	temp.primInfo = resMan.loadPrim("Player",0,1,-0.5f,0.5f,0.5f,-0.5f);
	temp.Tex = resMan.loadTexture("player.png",0,0,0,0,D3DFMT_UNKNOWN,D3DPOOL_MANAGED,D3DX_DEFAULT,D3DX_DEFAULT,D3DCOLOR_XRGB(255,0,255),0);
	temp.mat = &defMat;

	player.setRender(temp);
	player.setActive(true);
	player.setEat(true);
	player.setCollision(1,1);
	player.setSize(1);
	angle = 0;

	timeTaken = 0;

	//load creature assets
	temp.primInfo = resMan.loadPrim("creature",0,1,-0.5f,0.5f,0.5f,-0.5f);
	temp.Tex = resMan.loadTexture("enemy.png",0,0,0,0,D3DFMT_UNKNOWN,D3DPOOL_MANAGED,D3DX_DEFAULT,D3DX_DEFAULT,D3DCOLOR_XRGB(255,0,255),0);
	temp.mat = &defMat;
	//setup creatures
	for(int i = 0; i < num_Creatures; ++i) {
		creatures[i].setActive(true);
		creatures[i].setPos((5*i)+5,0,0);
		creatures[i].setRender(temp);
		creatures[i].setCollision(1,0.25f);
		creatures[i].setSize(i+1);
	}
	//load building assets
	temp.primInfo = resMan.loadPrim("Building",0,50.0f,-1.0f,1.0f,1.0f,-1.0f);
	temp.Tex = resMan.loadTexture("building.png",0,0,0,0,D3DFMT_UNKNOWN,D3DPOOL_MANAGED,D3DX_DEFAULT,D3DX_DEFAULT,D3DCOLOR_XRGB(255,0,255),0);
	temp.mat = &defMat;
	//setup buildings
	for(int i = 0; i < num_Buildings; ++i) {
		buildings[i].setSize(10*i);
		buildings[i].setActive(true);
		buildings[i].setRender(temp);
		buildings[i].setCollision(-1.0f,1.0f,-1.0f,1.0,50,0);
		buildings[i].setPos(0,0,(100*i)+100);
	}
	//load default settings
	rotSpeed = 0.45f;
	angSpeed = 0.15f;

	level.setMat(&defMat);
	level.loadMap("map.txt",num_Buildings,num_Creatures,buildings,creatures,&resMan);
	sndLis.up.x = 0;
	sndLis.up.y = 1;
	sndLis.up.z = 0;
	eat = resMan.loadSound("eat.wav",100,1000,1);
	sndFram.setNumListen(1);
	sndFram.setListenProp(1,sndLis);
	texOut.textColor = D3DCOLOR(0xFFFFFFFF);
	texOut.text = "Use WASD to move Mouse to move camera, left click to start";
	texOut.rec.left = 0.5;
	texOut.rec.top = 0.5;
	texOut.rec.right = 0.5;
	texOut.rec.bottom = 0.5;
	texRen.asset = &texOut;
	texRen.locCamNum = 1;
	texRen.type = text;
	LPCSTR mapName;
	file.open("options.txt");
	if(file.is_open()) {
		file>>rotSpeed;
		file.ignore();
		file>>angSpeed;
		file.ignore();
		file>>winMsg;
		mapName = winMsg.c_str();
		level.loadMap(mapName,num_Buildings,num_Creatures,buildings,creatures,&resMan);
	}
示例#12
0
void DXTest::init(HWND& hWnd, HINSTANCE& hInst,bool bWindowed) {
	dist = 2;
	rot = 0;
	angle = 0;

	dist2 = 2;
	rot2 = 0;
	angle2 = 0;

	input.init(hWnd,hInst);
	sFrame.Init();
	tTime = cTime = lTime = GetTickCount();
	numCon = input.numGamePads();
	RenInfo tempRen;
	ss<<numCon;
	testText.text = ss.str();
	testText.textColor = D3DCOLOR(0xFFFFFFFF);
	testText.rec.top = 0;
	testText.rec.left = 0;
	testText.rec.right = 100;
	testText.rec.bottom = 100;
	tempRen.asset = &testText;
	tempRen.locCamNum = 5;
	tempRen.type = text;

	DXVid.init(hWnd,hInst,bWindowed);
	DXVid.addRen(tempRen);
	testCube.mat = &testMat;
	testMat.Ambient = D3DXCOLOR(0.2f, 0.2f, 0.2f, 1.0f);
	testMat.Diffuse = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f);		// Diffuse color reflected
	testMat.Emissive = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);		// Emissive color reflected
	testMat.Specular = D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.0f);		// Specular
	testMat.Power = 0.0f;

	//testMod.matrix = testCube.matrix;
	D3DXMatrixScaling(&testMod.matrix,0.01,0.01,0.01);
	testMod.mod = resMan.loadXFile("tiny.x");
	for(int i = 0;i< testMod.mod->numMats;++i) {
		testMod.mod->mats[i].MatD3D = testMat;
	}
	tempRen.type = model;
	tempRen.asset = &testMod;
	tempRen.locCamNum = 0;
	DXVid.addRen(tempRen);

	testCube.Tex = resMan.loadTexture("uvtest.png",0,0,0,0,D3DFMT_UNKNOWN,D3DPOOL_MANAGED,D3DX_DEFAULT,D3DX_DEFAULT,D3DCOLOR_XRGB(0,0,0),0);
	testCube.primInfo = resMan.loadPrim("CuberTest",1,1,1);
	D3DXMatrixIdentity(&testCube.matrix);
	testCube2 = testCube;
	tempRen.asset = &testCube;
	tempRen.type = primitive;
	tempRen.locCamNum = 0;
	DXVid.addRen(tempRen);
	tempRen.asset = &testCube2;
	DXVid.addRen(tempRen);

	testSprite.image = resMan.loadTexture("xboxControllerSpriteFont.tga",0,0,0,0,D3DFMT_UNKNOWN,D3DPOOL_MANAGED,D3DX_DEFAULT,D3DX_DEFAULT,0,0);
	testSprite.posX = 0;
	testSprite.posY = 0;
	testSprite.scalX = 0.1f;
	testSprite.scalY = 0.1f;
	tempRen.asset = &testSprite;
	tempRen.type = sprite;
	tempRen.locCamNum = 0;
	DXVid.addRen(tempRen);

	temp.cam_look_pos.x = 0;
	temp.cam_look_pos.y = 0;
	temp.cam_look_pos.z = 0;
	temp.cam_pos.x = 5;
	temp.cam_pos.y = 0;
	temp.cam_pos.z = 0;
	temp.cam_up_vec.x = 0;
	temp.cam_up_vec.y = 1;
	temp.cam_up_vec.z = 0;
	temp.drawDist = 200.0f;
	temp.fov_deg = 90.0f;

	temp2.cam_look_pos.x = 0;
	temp2.cam_look_pos.y = 0;
	temp2.cam_look_pos.z = 0;
	temp2.cam_pos.x = 5;
	temp2.cam_pos.y = 0;
	temp2.cam_pos.z = 0;
	temp2.cam_up_vec.x = 0;
	temp2.cam_up_vec.y = 1;
	temp2.cam_up_vec.z = 0;
	temp2.drawDist = 200.0f;
	temp2.fov_deg = 90.0f;

	temp3 = temp4 = temp;

	temp3.cam_pos.x = 0;
	temp3.cam_pos.z = -2;

	temp4.cam_pos.x = -2;

	tempProp.pos.x = temp.cam_pos.x;
	tempProp.pos.y = temp.cam_pos.y;
	tempProp.pos.z = temp.cam_pos.z;
	tempProp.up.x = temp.cam_up_vec.x;
	tempProp.up.y = temp.cam_up_vec.y;
	tempProp.up.z = temp.cam_up_vec.z;
	tempProp.vel.x = tempProp.vel.y = tempProp.vel.z = 0;
	tempProp.forward.x = tempProp.forward.y = tempProp.forward.z = 0;
	sFrame.setListenProp(0,tempProp);
	testSound = resMan.loadSound("plinkhit.wav",1,5,1);
	testMusic = resMan.loadMusic("battle.mp3",0.10f);
	sFrame.PlayStream(*testMusic,false);


	// Ambient light color emitted from this light
	m_Light.Ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
	// Diffuse light color emitted from this light
	m_Light.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
	// Specular light color emitted from this light
	m_Light.Specular = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
	// Light Type (Point) Requires: Position, Range, Attenuation
	m_Light.Type = D3DLIGHT_POINT;	// Point, alternatively D3DLIGHT_DIRECTIONAL or D3DLIGHT_SPOT
	// Light Position
	m_Light.Position = D3DXVECTOR3(30.0f, 10.0f, -10.0f); 
	// Range of Light
	m_Light.Range = 100.0f;
	// Light Attenuation
	m_Light.Attenuation0 = 0.0f;	// Constant
	m_Light.Attenuation1 = 0.05f;	// Linear
	m_Light.Attenuation2 = 0.0f;	// Quadratic

	// Set Light
	DXVid.setLight(0, &m_Light);
	//turn on light
	DXVid.setLightActive(0,true);

	DXVid.setViewCount(2);
	DXVid.toggleSS();
	DXVid.setCam(1,&temp);
	DXVid.setCam(2,&temp2);
	DXVid.setCam(3,&temp3);
	DXVid.setCam(4,&temp4);
}