Ejemplo n.º 1
0
void LineModel::RotateVertsAroundOrigin( Vector3 Rotation )
{
	SetRotation(Rotation);
	Vector3 tempOrigin = newOrigin;
	ChangeOrigin(-newOrigin);
	for (int i = 0; i <  FinalList.size(); i++)
	{
		D3DXVECTOR3 outv;
		D3DXVECTOR3 temp (FinalList[i].X,FinalList[i].Y,FinalList[i].Z);
		D3DXMatrixRotationYawPitchRoll(&rotationMatrix,Rotation.Y,Rotation.X,Rotation.Z);
		D3DXVec3TransformCoord(&outv, &temp, &rotationMatrix);
		FinalList[i] = Vector3(outv.x,outv.y,outv.z);
	}
	ChangeOrigin(tempOrigin);
}
Ejemplo n.º 2
0
		void GetMatrixWorld(MyMath::MatrixF* pWorld) const
		{
			// スケーリングは考慮しない。
#if 0
			D3DXMatrixRotationYawPitchRoll(pWorld,
				m_vRotation.y,
				m_vRotation.x,
				m_vRotation.z);
#else
			MyMath::CreateMatrixRotationZXY(pWorld, &m_vRotation);
#endif
			pWorld->_41 = m_vTranslation.x;
			pWorld->_42 = m_vTranslation.y;
			pWorld->_43 = m_vTranslation.z;
		}
Ejemplo n.º 3
0
Missile1::Missile1(D3DXVECTOR3 spawnPosition, D3DXVECTOR3 direction,float scale)
{
	position = startPosition = spawnPosition;
	this->direction = direction;
	D3DXMatrixScaling(&scaleMat, scale, scale, scale);
	D3DXMatrixRotationYawPitchRoll(&rotateMat, 0, 0,-1.55f);
	destroyObject = isExpanding = false;
	m_rotateAngle = 0;
	projectileType = MISSILE1;
	isBlastMesh = false;
	blastRadiusScale = 0.0f;
	radiusTimeTrack = 0.0;

	Initialize();
}
Ejemplo n.º 4
0
void Camera::updateView(float dt)
{
	//rotation
	D3DXMatrixRotationYawPitchRoll(&rotationMatrix, heading, pitch, 0);

	D3DXVec3TransformCoord(&view,&dV,&rotationMatrix);
	D3DXVec3TransformCoord(&up,&dU,&rotationMatrix);

	D3DXVec3Normalize(&forward,&view);
	D3DXVec3Cross(&strafeRight,&up,&view);
	D3DXVec3Normalize(&strafeRight,&strafeRight);

	view = eye + view;
	D3DXMatrixLookAtLH(&viewMatrix,&eye,&view,&up);
}
Ejemplo n.º 5
0
void CameraClass::Render()
{
	D3DXVECTOR3 lookAt;
	float yaw, pitch, roll;
	D3DXMATRIX rotationMatrix;


	// Setup the vector that points upwards.
	m_up.x = 0.0f;
	m_up.y = 1.0f;
	m_up.z = 0.0f;

	// Setup the position of the camera in the world.
	//position.x = m_positionX;
	//position.y = m_positionY;
	//position.z = m_positionZ;

	// Setup where the camera is looking by default.
	m_direction.x = 0.0f;
	m_direction.y = 0.0f;
	m_direction.z = 1.0f;

	// Set the yaw (Y axis), pitch (X axis), and roll (Z axis) rotations in radians.
	pitch = m_rotationX * 0.0174532925f;
	yaw   = m_rotationY * 0.0174532925f;
	roll  = m_rotationZ * 0.0174532925f;

	// Create the rotation matrix from the yaw, pitch, and roll values.
	D3DXMatrixRotationYawPitchRoll(&rotationMatrix, yaw, pitch, roll);

	// Transform the lookAt and up vector by the rotation matrix so the view is correctly rotated at the origin.
	D3DXVec3TransformCoord(&m_direction, &m_direction, &rotationMatrix);
	D3DXVec3TransformCoord(&m_up, &m_up, &rotationMatrix);

	//m_direction = D3DXVECTOR3(lookAt);

	m_right.x = -(m_direction.y*m_up.z - m_direction.z*m_up.y);
	m_right.y = -(m_direction.z*m_up.x - m_direction.x*m_up.z);
	m_right.z = -(m_direction.x*m_up.y - m_direction.y*m_up.x);

	// Translate the rotated camera position to the location of the viewer.
	lookAt = m_position + m_direction;

	// Finally create the view matrix from the three updated vectors.
	D3DXMatrixLookAtLH(&m_viewMatrix, &m_position, &lookAt, &m_up);

	return;
}
Ejemplo n.º 6
0
void MESHINSTANCE::Render()
{
	//Set World-Transform, then render the mesh
	if(m_pMesh != NULL)
	{
		D3DXMATRIX p, r, s;
		D3DXMatrixTranslation(&p, m_pos.x, m_pos.y, m_pos.z);
		D3DXMatrixRotationYawPitchRoll(&r, m_rot.y, m_rot.x, m_rot.z);
		D3DXMatrixScaling(&s, m_sca.x, m_sca.y, m_sca.z);
		
		D3DXMATRIX world = s * r * p;
		m_pMesh->m_pDevice->SetTransform(D3DTS_WORLD, &world);

		m_pMesh->Render();
	}
}
Ejemplo n.º 7
0
// 座標変換
void Camera::TransForm(D3DXVECTOR3 pos, D3DXVECTOR3 rota)
{
	D3DXMATRIX *m_temp = new D3DXMATRIX;
	D3DXMatrixIdentity(&m_view);
	D3DXMatrixIdentity(m_temp);

	// 行列を回転する
	D3DXMatrixRotationYawPitchRoll(m_temp, rota.y, rota.x, rota.z);
	m_view *= *m_temp;

	// 行列を平行移動させる
	D3DXMatrixTranslation(m_temp, pos.x, pos.y, pos.z);
	m_view *= *m_temp;

	delete m_temp;
}
Ejemplo n.º 8
0
void EffectSwirl::apply()
{
	D3DXVECTOR3 pos;
	D3DXMATRIX mat;
	for (int i = 0; i < swirlImages; i++)
	{
		float offset = (float)i * 2*3.14159f / (float)swirlImages;
		D3DXMatrixRotationYawPitchRoll(&mat, 0,0,offset);
		pos.z = 3.0f+2.5f*sin(m_pSettings->frame*0.007f+offset);
		//Pretty sinusoidal swimming
		pos.x = minx + scalex/2.0f + (float)7.0f/20.0f*minscale*sin(m_pSettings->frame*0.035f);
		pos.y = miny + scaley/2.0f +(float)7.0f/20.0f*minscale*cos(m_pSettings->frame*0.045f);
		TransformCoord(&pos,&pos,&mat);
		m_pSettings->waterField->SetHeight(pos.x,pos.y,2.5f,-2.5f*(invertSwirls ? (i%2)*2-1:1), palette[i]);
	}
}
Ejemplo n.º 9
0
Map::Map(void)
{
	//マップ登録
	D3DXMATRIX cube_rot_mat;
	D3DXVECTOR3 cube_vec[3];
	cube_vec[0] = D3DXVECTOR3(1.0f, 0.0f, 0.0f);
	cube_vec[1] = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
	cube_vec[2] = D3DXVECTOR3(0.0f, 0.0f, 1.0f);
	D3DXMatrixRotationYawPitchRoll( &cube_rot_mat, 0, 0, 0 );
	D3DXVec3TransformCoord(&cube_vec[0], &cube_vec[0], &cube_rot_mat);
	D3DXVec3TransformCoord(&cube_vec[1], &cube_vec[1], &cube_rot_mat);
	D3DXVec3TransformCoord(&cube_vec[2], &cube_vec[2], &cube_rot_mat);
	obb->SetNormDirect(cube_vec[0], cube_vec[1], cube_vec[2]);
	D3DXVECTOR3 cube_length(1.0f, 1.0f, 1.0f);
	obb->SetLength(cube_length.x, cube_length.y, cube_length.z);
}
Ejemplo n.º 10
0
/////////////////////////////////////////////////////////////////////////
//  ’e”­ŽË
/////////////////////////////////////////////////////////////////////////
void MoveShell(Shell &shell, Tank(&tank)[myTANKNUM], float speed, float cd)
{

	D3DXVECTOR3 vec;
	if (shell.fireOK == false)
	{
		if (shell.time < cd / FPS * 60.f)
		{
			shell.time += fpTimeDelta;
		}
		else
		{
			shell.fireOK = true;
			shell.time = cd / FPS * 60.f;
		}
	}
	if (shell.fireOK &&key&mLbtn)
	{
		shell.hitmax += 1;
		shell.active = true;
		shell.fireOK = false;
		shell.time = 0.f;
	}
	if (shell.active == false)
	{
		shell.position = tank[myGUN].position;
		shell.prePos = tank[myGUN].position;

		D3DXMatrixRotationYawPitchRoll(&shell.mat, D3DXToRadian(tank[myGUN].direction), tank[myGUN].pitch, tank[myGUN].roll);
		D3DXMatrixMultiply(&shell.mat, &shell.mat, &tank[myGUN].mat);
		D3DXVec3TransformCoord(&vec, &D3DXVECTOR3(0.f, 0.f, 0.5f), &shell.mat);
		D3DXVec3Add(&shell.position, &tank[myGUN].position, &vec);
	}

	else if (shell.active)
	{
		shell.prePos = shell.position;
		D3DXVECTOR3 dist(0.0f, 0.0f, speed / 150.f);
		D3DXVec3TransformCoord(&dist, &dist, &shell.mat);
		D3DXVec3Add(&shell.position, &shell.position, &dist);

		if (D3DXVec3Length(D3DXVec3Subtract(&vec, &shell.position, &tank[myGUN].position)) > 600.f)
		{
			shell.active = false;
		}
	}
}
Ejemplo n.º 11
0
void CDofEditing::UpdateAngles(void)
{
	CString	Angle;
	Angle.Format("%05.2f", D3DXToDegree(m_Yaw));
	m_YawAngle.SetWindowText(Angle);
	Angle.Format("%05.2f", D3DXToDegree(m_Pitch));
	m_PitchAngle.SetWindowText(Angle);
	Angle.Format("%05.2f", D3DXToDegree(m_Roll));
	m_RollAngle.SetWindowText(Angle);
	D3DXMatrixRotationYawPitchRoll(&m_Dof->dof.rotation, m_Yaw, m_Pitch, m_Roll);

	Angle.Format("%7.3f", m_Dof->dof.translation.x);
	m_XPos.SetWindowText(Angle);
	Angle.Format("%7.3f", m_Dof->dof.translation.y);
	m_YPos.SetWindowText(Angle);
	Angle.Format("%7.3f", m_Dof->dof.translation.z);
	m_ZPos.SetWindowText(Angle);

	Angle.Format("%7.3f", m_Dof->dof.scale.x);
	m_XScale.SetWindowText(Angle);
	Angle.Format("%7.3f", m_Dof->dof.scale.y);
	m_YScale.SetWindowText(Angle);
	Angle.Format("%7.3f", m_Dof->dof.scale.z);
	m_ZScale.SetWindowText(Angle);

	Angle.Format("%7.3f", m_Dof->dof.multiplier);
	m_DofCx.SetWindowText(Angle);


	m_DofInvCheck.SetCheck(m_Dof->dof.flags&XDOF_NEGATE);
	m_DofLimits.SetCheck(m_Dof->dof.flags&XDOF_MINMAX);
	m_DofDegrees.SetCheck(m_Dof->dof.flags&XDOF_ISDOF);
	m_DofScale.SetCheck(m_Dof->dof.flags&XDOF_SUBRANGE);

	Angle.Format("%7.3f", (m_Dof->dof.flags&XDOF_ISDOF)?D3DXToDegree(m_Dof->dof.max):m_Dof->dof.max);
	m_DofMax.SetWindowText(Angle);
	Angle.Format("%7.3f", (m_Dof->dof.flags&XDOF_ISDOF)?D3DXToDegree(m_Dof->dof.min):m_Dof->dof.min);
	m_DofMin.SetWindowText(Angle);

	CString Caption;
	Caption.Format("DOF Nr : %03d", m_Dof->dof.dofNumber);
	SetWindowText(Caption);

	m_DofList.SetCurSel(m_Dof->dof.Type);

}
Ejemplo n.º 12
0
void Meshes::draw_meshes(LPDIRECT3DDEVICE9 pD3DDevice)
{ 
	D3DXMatrixRotationYawPitchRoll(&matRotate, D3DXToRadian(rot.y), D3DXToRadian(rot.x), D3DXToRadian(rot.z));
	D3DXMatrixScaling(&matScale, scale.x, scale.y, scale.z);
	D3DXMatrixTranslation(&matTranslate, pos.x, pos.y, pos.z);

	pD3DDevice->SetTransform(D3DTS_WORLD, &(matRotate* matScale * matTranslate));


	for(DWORD i = 0; i < numMaterials; i++) 
	{
		pD3DDevice->SetMaterial(&material[i]);
		pD3DDevice->SetTexture(0,texture[i]);
		Model->DrawSubset(i);
		//return;
	}
}
Ejemplo n.º 13
0
//----[  getTransform  ]-------------------------------------------------------
void Mesh::getTransform(D3DXMATRIX* matrix) {
    D3DXMATRIX s, r, t;
    D3DXMatrixScaling(&s,
                      scaling_.getX()->getValue(),
                      scaling_.getY()->getValue(),
                      scaling_.getZ()->getValue());
    D3DXMatrixRotationYawPitchRoll(&r,
                                   D3DXToRadian(rotation_.getY()->getValue()),
                                   D3DXToRadian(rotation_.getX()->getValue()),
                                   D3DXToRadian(rotation_.getZ()->getValue()));
    D3DXMatrixTranslation(&t,
                          translation_.getX()->getValue(),
                          translation_.getY()->getValue(),
                          translation_.getZ()->getValue());
    D3DXMatrixMultiply(matrix, &s, &r);
    D3DXMatrixMultiply(matrix, matrix, &t);
}
Ejemplo n.º 14
0
void DXFrame::rotateCam(cam& camr, float dist, float rot, float angle) {
	D3DXMATRIX total;
	D3DXMATRIX temp;
	D3DXVECTOR3 out;
	D3DXVECTOR3 scal;
	D3DXQUATERNION r;
	D3DXMatrixIdentity(&total);
	temp = total;
	D3DXMatrixTranslation(&total,0,0,-dist);
	D3DXMatrixRotationYawPitchRoll(&temp,D3DXToRadian(rot),D3DXToRadian(angle),0);
	total *= temp;
	D3DXMatrixIdentity(&temp);
	D3DXMatrixTranslation(&temp,camr.cam_look_pos.x,camr.cam_look_pos.y,camr.cam_look_pos.z);
	total *= temp;
	D3DXMatrixDecompose(&scal,&r,&out,&total);
	camr.cam_pos = out;
}
Ejemplo n.º 15
0
Map::Map(D3DXVECTOR3 posi, FLOAT length_x, FLOAT length_y, FLOAT length_z)
{
	//マップ登録
	D3DXMATRIX cube_rot_mat;
	D3DXVECTOR3 cube_vec[3];
	cube_vec[0] = D3DXVECTOR3(1.0f, 0.0f, 0.0f);
	cube_vec[1] = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
	cube_vec[2] = D3DXVECTOR3(0.0f, 0.0f, 1.0f);
	D3DXMatrixRotationYawPitchRoll( &cube_rot_mat, 0, 0, 0 );
	D3DXVec3TransformCoord(&cube_vec[0], &cube_vec[0], &cube_rot_mat);
	D3DXVec3TransformCoord(&cube_vec[1], &cube_vec[1], &cube_rot_mat);
	D3DXVec3TransformCoord(&cube_vec[2], &cube_vec[2], &cube_rot_mat);
	
	obb->SetPos(posi);
	obb->SetNormDirect(cube_vec[0], cube_vec[1], cube_vec[2]);
	obb->SetLength(length_x, length_y, length_z);
}
void DXCamera::Update(float _dt)
{
	D3DXMatrixRotationYawPitchRoll(&m_matrixRotation, m_yaw, m_pitch, 0);
	D3DXVec3TransformCoord(&m_vec3Target, &m_vec3DefaultForward, &m_matrixRotation);
	D3DXVec3Normalize(&m_vec3Target, &m_vec3Target);

	switch (m_type)
	{
		case eCamera::ECAMERA_DEFAULT:
		{
			D3DXVec3TransformNormal(&m_vec3Right, &m_vec3DefaultRight, &m_matrixRotation);
			D3DXVec3TransformNormal(&m_vec3Forward, &m_vec3DefaultForward, &m_matrixRotation);
			D3DXVec3Cross(&m_vec3Up, &m_vec3Forward, &m_vec3Right);
		}
		break;
		case eCamera::ECAMERA_FPS:
		{
			D3DXMATRIX RotateYTempMatrix;
			D3DXMatrixRotationY(&RotateYTempMatrix, m_yaw);

			D3DXVec3TransformNormal(&m_vec3Right, &m_vec3DefaultRight, &RotateYTempMatrix);
			D3DXVec3TransformNormal(&m_vec3Up, &m_vec3DefaultUp, &RotateYTempMatrix);
			D3DXVec3TransformNormal(&m_vec3Forward, &m_vec3DefaultForward, &RotateYTempMatrix);
		}
		break;
		case eCamera::ECAMERA_THIRD:
		{
			// TODO
		}
		break;
	}
	
	// Update position
	m_vec3Position += m_moveLR * m_vec3Right * _dt;
	m_vec3Position += m_moveFB * m_vec3Forward * _dt;

	// Reset the movement
	m_moveLR = 0.0f;
	m_moveFB = 0.0f;

	// Adjust the target
	m_vec3Target = m_vec3Position + m_vec3Target;

	D3DXMatrixLookAtLH(&m_matrixView, &m_vec3Position, &m_vec3Target, &m_vec3Up);
}
Ejemplo n.º 17
0
void BlastRadius::Update(float dt)
{
	m_rotateAngle += 0.5 ;

	if(m_rotateAngle >=360) m_rotateAngle = 0;

	D3DXMatrixRotationYawPitchRoll(&rotateMat, 
		D3DXToRadian(m_rotateAngle), D3DXToRadian(0), 0);
	// Set the translate matrix based on the player's current position
	D3DXMatrixTranslation(&translateMat, position.x, position.y, position.z);

	// Set the world matrix
	// Note: world = scale * rotate * translate
	worldMat = scaleMat * rotateMat* translateMat;

	// Set the collision box based on the player's world position
	//meshBox.xform(worldMat, meshBox);
}
Ejemplo n.º 18
0
void Camera::GetBillboardedWorldMatrix(D3DXMATRIX & out, D3DXVECTOR3 position) const
{
	D3DXMATRIX rotationMatrix, translationMatrix;
	D3DXVECTOR3 up = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
	D3DXVECTOR3 direction = D3DXVECTOR3(position.x - m_positionX, position.y - m_positionY, position.z - m_positionZ);
	//D3DXVECTOR3 direction = D3DXVECTOR3(m_positionX - position.x, m_positionY - position.y , m_positionZ - position.z);
	D3DXVECTOR3 right;
	D3DXVec3Cross(&right, &direction, &up);

	float magnitude = D3DXVec3Length(&direction);
	float yaw = atan2(direction.x, direction.z);
	float pitch = float(D3DX_PI/2 - acos(-direction.y / magnitude));

	D3DXMatrixRotationYawPitchRoll(&rotationMatrix, yaw, pitch, 0.0f);
	D3DXMatrixTranslation(&translationMatrix, position.x, position.y, position.z);

	out = rotationMatrix * translationMatrix;
}
Ejemplo n.º 19
0
//座標変換
void Object::TransForm()
{
	D3DXMATRIX m_temp;
	D3DXMatrixIdentity(&m_world);
	D3DXMatrixIdentity(&m_temp);

	//行列を拡大縮小
	D3DXMatrixScaling(&m_temp, scale.x, scale.y, scale.z);
	m_world *= m_temp;

	//行列を拡大縮小する
	D3DXMatrixRotationYawPitchRoll(&m_temp, rotation.y, rotation.x, rotation.z);
	m_world *= m_temp;

	//行列を平行移動する
	D3DXMatrixTranslation(&m_temp, position.x, position.y, position.z);
	m_world *= m_temp;
}
Ejemplo n.º 20
0
	void Mesh::Transform()
	{
		//set rotation matrix
		double x = D3DXToRadian(rotation.x);
		double y = D3DXToRadian(rotation.y);
		double z = D3DXToRadian(rotation.z);
		D3DXMatrixRotationYawPitchRoll(&matRotate, (float)x, (float)y, (float)z);

		//set scaling matrix
		D3DXMatrixScaling(&matScale, scale.x, scale.y, scale.z);

		//set translation matrix
		D3DXMatrixTranslation(&matTranslate, position.x, position.y, position.z);

		//transform the mesh
		matWorld = matRotate * matScale * matTranslate;
		g_engine->getDevice()->SetTransform(D3DTS_WORLD, &matWorld);
	}
Ejemplo n.º 21
0
enINITERROR Shield::Init( void )
{
	m_vPos	= D3DXVECTOR3(5, 1, 0);
	m_vRot	= D3DXVECTOR3(0, 0, 0);
	m_vScale= D3DXVECTOR3(1, 1, 1);

	D3DXMatrixIdentity(&m_mTM);
	D3DXMatrixIdentity(&m_mScale);
	D3DXMatrixIdentity(&m_mRot);
	D3DXMatrixIdentity(&m_mTrans);

	// 변환행렬 //
	D3DXMatrixScaling(&m_mScale, m_vScale.x, m_vScale.y, m_vScale.z);
	D3DXMatrixRotationYawPitchRoll(&m_mRot, m_vRot.x, m_vRot.y, m_vRot.z);
	D3DXMatrixTranslation(&m_mTrans, m_vPos.x, m_vPos.y, m_vPos.z);

	return InitVTX();
}
Ejemplo n.º 22
0
void CubeEnvMapping::render()
{
	if(m_pEffect == NULL)
		return;
	HRESULT hr;

	//-- ÉèÖÃeffect²ÎÊý
	hr = m_pEffect->SetTexture("cubeMapTexture",m_pCubeMap);
	hr = m_pEffect->SetTexture("sphereMapTexture",m_pSphereMap);
	hr = m_pEffect->SetFloatArray("eyePos",(float*)&g_camera.getEyePos(),3);

	D3DXMATRIX matWorld;
	float t = timeGetTime()/4000.0f;
	float r = D3DX_PI;
	float yaw = sinf(t) * r;
	float pitch = cosf(t) * r;
	D3DXMatrixRotationYawPitchRoll(&matWorld,yaw,pitch,(yaw+pitch)*0.5f);

	D3DXMATRIX matTmp;
	D3DXMatrixTranslation(&matTmp,sinf(t)*100,0,0);
	matWorld = matWorld*matTmp;

	D3DXMATRIX matWorldViewProj = matWorld * g_camera.getViewMat() * g_camera.getProjectMat();

	m_pEffect->SetMatrix("matWorldViewPrj",&matWorldViewProj);
	hr = m_pEffect->SetMatrix("matWorld",&matWorld);
	hr = m_pEffect->SetMatrix("matView",&g_camera.getViewMat());
	
	//-- äÖȾÇòÌå
	UINT numPass = 0;
	hr = m_pEffect->Begin(&numPass,0);

	for(UINT i=0;i<numPass;i++)
	{
		m_pEffect->BeginPass(i);
		drawMesh();
		m_pEffect->EndPass();
	}

	hr = m_pEffect->End();

	DrawingUtil::getInst()->drawText("Key S : sphere, Key C : cube", 0, 32);
	ShaderSimpler::render();
}
Ejemplo n.º 23
0
//**関数***************************************************************************
//	概要	:	アフィン
//*********************************************************************************
void CObjBase::Affine()
{
	if(!m_bUseFlg)				// 描画しないときは処理なし
		return;

	D3DXMATRIX	matTrans , matRot , matScall;

	// 初期化
	D3DXMatrixIdentity(&matTrans);
	D3DXMatrixIdentity(&matRot);
	D3DXMatrixIdentity(&matScall);

	// アフィン
	D3DXMatrixTranslation(&matTrans , m_Pos.x , m_Pos.y , m_Pos.z);			// 移動
	D3DXMatrixRotationYawPitchRoll(&matRot , m_Rot.y , m_Rot.x , m_Rot.z);	// 回転
	D3DXMatrixScaling(&matScall , m_Scall.x , m_Scall.y , m_Scall.z);		// 拡縮

	m_Matrix = matRot * matScall * matTrans;
}
Ejemplo n.º 24
0
void MoveEmyShell(Shell &shell, Enemy(&enemy)[eTANKNUM], float speed, float cd)
{
	D3DXVECTOR3 vec;
	if (shell.fireOK == false)
	{
		if (shell.time < cd / FPS * 60.f)
		{
			shell.time += fpTimeDelta;
		}
		else
		{
			shell.fireOK = true;
		}
	}
	else if (shell.fireOK)
	{
		shell.active = true;
		shell.fireOK = false;
		shell.time = 0.f;
	}
	if (shell.active == false)
	{
		shell.position = enemy[eGUN].position;
		shell.prePos = enemy[eGUN].position;

		D3DXMatrixRotationYawPitchRoll(&shell.mat, D3DXToRadian(enemy[eGUN].direction), enemy[eGUN].pitch, enemy[eGUN].roll);
		D3DXMatrixMultiply(&shell.mat, &shell.mat, &enemy[eGUN].mat);
	}
	else if (shell.active)
	{
		shell.prePos = shell.position;
		D3DXVECTOR3 dist;
		dist = { 0.0f, 0.0f, speed / 150.f };
		D3DXVec3TransformCoord(&dist, &dist, &shell.mat);
		D3DXVec3Add(&shell.position, &shell.position, &dist);

		if (D3DXVec3Length(D3DXVec3Subtract(&vec, &shell.position, &enemy[eGUN].position)) > 600.f)
		{
			shell.active = false;
		}
	}
}
Ejemplo n.º 25
0
void CameraClass::Render()
{
	D3DXVECTOR3 up, position, lookAt;
	float yaw, pich, roll;
	D3DXMATRIX rotationMatrix;

	// Setup the vector, points upwards
	up.x = 0.0f;
	up.y = 1.0f;
	up.z = 0.0f;

	// Setup the position of the camera in the world 
	position.x = m_positionX;
	position.y = m_positionY;
	position.z = m_positionZ;

	// Setup camera direction
	lookAt.x = 0.0f;
	lookAt.y = 0.0f;
	lookAt.z = 1.0f;

	// Set the yaw (Y axis), pitch (X axis) and roll (Z axis) rotation in radians.
	pich = m_rotationX * 0.0174532925f;
	yaw   = m_rotationY * 0.0174532925f;
	roll  = m_rotationZ * 0.0174532925f;

	// Create the rotation matrix from the yaw, pitch and roll values 
	D3DXMatrixRotationYawPitchRoll(&rotationMatrix, yaw, pich, roll);

	// Transform the lookAt and up vector by the rotation matrix 
	// so the view is correctly rotated at the origin.
	D3DXVec3TransformCoord(&lookAt, &lookAt, &rotationMatrix);
	D3DXVec3TransformCoord(&up, &up, &rotationMatrix);

	// Translate the rotated camera position to the location of the viewer.
	lookAt = position + lookAt;

	// Create the view matrix from updated vectors
	D3DXMatrixLookAtLH(&m_viewMatrix, &position, &lookAt, &up);
	
	return;
}
Ejemplo n.º 26
0
//*****************************************************************************
//	描画
//	引数:
//	LPDIRECT3DDEVICE9 pDevice:デバイスポインタ
//	戻り値:
//	なし
//*****************************************************************************
void	CPlayer::Draw(LPDIRECT3DDEVICE9	pDevice)
{
	//マトリックス変数宣言
	D3DXMATRIX	mTrans,mScale,mRotate;		//左から座標、大きさ、回転

	//描画タイプの変更
	CRenderer::SetRenderType(CRenderer::NOMAL);

			//マトリックス初期化
			D3DXMatrixIdentity(&m_mtxWorld);

			//大きさ設定
			D3DXMatrixScaling(&mScale, 0.6f, 0.6f, 0.6f);

			//合成
			D3DXMatrixMultiply(&m_mtxWorld,&m_mtxWorld,&mScale);

			//角度設定
			D3DXMatrixRotationYawPitchRoll(&mRotate, D3DX_PI * m_Vertex_3d.Rot_vtx.y + D3DX_PI, D3DX_PI * m_Vertex_3d.Rot_vtx.x, D3DX_PI * m_Vertex_3d.Rot_vtx.z);

			//合成
			D3DXMatrixMultiply(&m_mtxWorld,&m_mtxWorld,&mRotate);

			//座標設定
			D3DXMatrixTranslation(&mTrans, m_Vertex_3d.vtx.x, m_Vertex_3d.vtx.y, m_Vertex_3d.vtx.z);

			//合成
			D3DXMatrixMultiply(&m_mtxWorld,&m_mtxWorld,&mTrans);

			//セッティング
			pDevice->SetTransform(D3DTS_WORLD,&m_mtxWorld);

		//モデルの各パーツの描画
		for(int	i = 0 ; i < MODELPARTS_MAX; i++)
		{
			if(m_apModel[i])
			{
				m_apModel[i]->Draw(pDevice);
			}
		}

}
Ejemplo n.º 27
0
void CameraClass::RenderReflection(float height)
{
    D3DXVECTOR3 up, position, lookAt;
    float yaw, pitch, roll;
    D3DXMATRIX rotationMatrix;


    // Setup the vector that points upwards.
    up.x = 0.0f;
    up.y = 1.0f;
    up.z = 0.0f;

    // Setup the position of the camera in the world.  For planar reflection invert the Y position of the camera.
    position.x = m_positionX;
    position.y = -m_positionY + (height * 2.0f);
    position.z = m_positionZ;

    // Setup where the camera is looking by default.
    lookAt.x = 0.0f;
    lookAt.y = 0.0f;
    lookAt.z = 1.0f;

    // Set the yaw (Y axis), pitch (X axis), and roll (Z axis) rotations in radians.  Invert the X rotation for reflection.
    pitch = -m_rotationX * 0.0174532925f;
    yaw   = m_rotationY * 0.0174532925f;
    roll  = m_rotationZ * 0.0174532925f;

    // Create the rotation matrix from the yaw, pitch, and roll values.
    D3DXMatrixRotationYawPitchRoll(&rotationMatrix, yaw, pitch, roll);

    // Transform the lookAt and up vector by the rotation matrix so the view is correctly rotated at the origin.
    D3DXVec3TransformCoord(&lookAt, &lookAt, &rotationMatrix);
    D3DXVec3TransformCoord(&up, &up, &rotationMatrix);

    // Translate the rotated camera position to the location of the viewer.
    lookAt = position + lookAt;

    // Finally create the reflection view matrix from the three updated vectors.
    D3DXMatrixLookAtLH(&m_reflectionViewMatrix, &position, &lookAt, &up);

    return;
}
Ejemplo n.º 28
0
void gShadowRender()
{
	// position the light camera
	gLightIntensity = gUISldLightIntensity->getValue() * 0.1f;
	gShadowYaw = D3DXToRadian( gUISldLightYaw->getValue() );
	gShadowPitch = D3DXToRadian( gUISldLightPitch->getValue() );
	D3DXMatrixRotationYawPitchRoll( &gShadowLight.mWorldMat, gShadowYaw, gShadowPitch, 0.0f );
	gShadowLight.mWorldMat.getOrigin() = gSceneCenter;
	gShadowLight.mWorldMat.getOrigin() -= gShadowLight.mWorldMat.getAxisZ() * gShadowDist;
	gLightPos = gSceneCenter;
	gLightPos -= gShadowLight.mWorldMat.getAxisZ() * gShadowDist * 20.0f;

	gShadowDist = gSceneRadius * 1.5f;
	gShadowLight.setOrthoParams( gSceneRadius*2, gSceneRadius*2, gSceneRadius*0.3f, gSceneRadius*4.0f );
	// update matrices
	gShadowLight.setOntoRenderContext();
	gShadowLightViewProj = G_RENDERCTX->getCamera().getViewProjMatrix();
	gfx::textureProjectionWorld( gShadowLightViewProj, SZ_SHADOWMAP, SZ_SHADOWMAP, gShadowTexProj );

	//gShadowBias = gSceneRadius * 0.001f;

	// render shadow map
	CD3DDevice& dx = CD3DDevice::getInstance();
	if( gUseDSTShadows ) {
		dx.setRenderTarget( RGET_S_SURF(RT_SHADOW_DSTRT) );
		dx.setZStencil( RGET_S_SURF(RT_SHADOW) );
		dx.getStateManager().SetRenderState( D3DRS_COLORWRITEENABLE, 0 );
		dx.clearTargets( false, true, false, 0xFFffffff, 1.0f );
	} else {
		dx.setRenderTarget( RGET_S_SURF(RT_SHADOW) );
		dx.setZStencil( RGET_S_SURF(RT_SHADOWZ) );
		dx.clearTargets( true, true, false, 0xFFffffff, 1.0f );
	}

	G_RENDERCTX->applyGlobalEffect();
	G_RENDERCTX->attach( *gMeshCaster );
	G_RENDERCTX->perform();

	if( gUseDSTShadows ) {
		dx.getStateManager().SetRenderState( D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_ALPHA );
	}
}
Ejemplo n.º 29
0
void TransformNode::Update(float elapsedTime)
{
  
  //Yo, update here dogg.
  float movement = 0.01f;

  D3DXMATRIXA16 mRotate;
  D3DXMatrixIdentity( &mRotate );
  D3DXMatrixRotationYawPitchRoll( &mRotate, movement, movement, movement );

  m_Transform =  m_Transform * mRotate ;

  std::vector<SceneGraphNode*> children = this->GetChildren();
  for(std::vector<SceneGraphNode*>::iterator iterator = children.begin();
    iterator != children.end();
    iterator++)
  {
    (*iterator)->Update(elapsedTime);
  }
}
Ejemplo n.º 30
0
// Draws and rotates our cube
void DrawAndRotateCube()
{
	const float kAngleInc = DEG2RAD(2); // Add 2° each update
	static float angle = 0; // The angle of rotation
	D3DXMATRIXA16 matrix;

	g3D->begin(); // Begin the scene
	g3D->clear(D3DCOLOR_XRGB(200, 0, 0)); // Clear the viewport
	
	// Rotate the cube
	D3DXMatrixRotationYawPitchRoll(&matrix, angle, angle, angle);
	g3D->setWorldMatrix(&matrix);

	// Render the cube
	g3D->render(gCubeVerts, kCubeVertCount, gCubeIndices, kCubeIndiceCount);

	g3D->end(); // End the scene
	
	angle += kAngleInc; // Update the angle for next render
}