当前位置: 首页>>代码示例>>C++>>正文


C++ D3DXVECTOR3函数代码示例

本文整理汇总了C++中D3DXVECTOR3函数的典型用法代码示例。如果您正苦于以下问题:C++ D3DXVECTOR3函数的具体用法?C++ D3DXVECTOR3怎么用?C++ D3DXVECTOR3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了D3DXVECTOR3函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LSL_ASSERT

void RenderToCubeTex::BeginCubeSurf(Engine& engine)
{
	LSL_ASSERT(IsBeginRT());

	CameraDesc camDesc = engine.GetContext().GetCamera().GetDesc();
	//camDesc.pos = D3DXVECTOR3(0, 0, 15.0f);
	camDesc.pos = _viewPos;
	camDesc.style = csPerspective;
	camDesc.aspect = 1;
	camDesc.nearDist = 1.0f;
	camDesc.farDist = 100.0f;
	camDesc.fov = D3DX_PI/2;

	switch(_flags.faceType)
	{
	case D3DCUBEMAP_FACE_POSITIVE_X:
		camDesc.dir = D3DXVECTOR3(-1.0f, 0.0f, 0.0f );
		camDesc.up = D3DXVECTOR3( 0.0f, -1.0f, 0.0f );
		break;

	case D3DCUBEMAP_FACE_NEGATIVE_X:			
		camDesc.dir = D3DXVECTOR3(1.0f, 0.0f, 0.0f );			
		camDesc.up = D3DXVECTOR3( 0.0f, -1.0f, 0.0f );
		break; 

	case D3DCUBEMAP_FACE_POSITIVE_Y:			
		camDesc.dir = D3DXVECTOR3( 0.0f, -1.0f, 0.0f );
		camDesc.up = D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
		break;
			
	case D3DCUBEMAP_FACE_NEGATIVE_Y:			
		camDesc.dir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
		camDesc.up = D3DXVECTOR3( 0.0f, 0.0f, -1.0f );
		break;				
			
	case D3DCUBEMAP_FACE_POSITIVE_Z:
		camDesc.dir = D3DXVECTOR3( 0.0f, 0.0f, -1.0f );
		camDesc.up = D3DXVECTOR3( 0.0f, -1.0f, 0.0f );
		break;				
	
	case D3DCUBEMAP_FACE_NEGATIVE_Z:
		camDesc.dir = D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
		camDesc.up = D3DXVECTOR3( 0.0f, -1.0f, 0.0f );
		break;
	}

	_myCamera.SetDesc(camDesc);	
	engine.GetContext().ApplyCamera(&_myCamera);

	ApplyRT(engine, _flags);
}
开发者ID:DimaKirk,项目名称:rrr3d,代码行数:51,代码来源:RenderToTexture.cpp

示例2: D3DXVECTOR3

void LightClass::SetPosition(float x, float y, float z)
{
	m_position = D3DXVECTOR3(x, y, z);
	return;
}
开发者ID:labud,项目名称:DirectX11,代码行数:5,代码来源:LightClass.cpp

示例3: lookAtPos

void GraphicsEngine::Render()
{
  this->camera.Update();
  

  //////////////CAMERA CODE//////////////////////
  // Define camera information.
  /*D3DXVECTOR3 cameraPos(camera.m_pos.x, camera.m_pos.y,
    camera.m_pos.z);
  D3DXVECTOR3 lookAtPos(camera.m_view.x, camera.m_view.y,
    camera.m_view.z);
  D3DXVECTOR3 upDir(camera.m_up.x, camera.m_up.y,
    camera.m_up.z);*/

  //A Matrix to hold the world transforms of the objects
  D3DXMATRIX worldTransform;
  D3DXMatrixIdentity(&worldTransform);

  // Build view matrix.
  /*D3DXMatrixLookAtLH(&g_ViewMatrix, &cameraPos,
    &lookAtPos, &upDir);*/
  g_ViewMatrix = *camera.GetViewMatrix();

  // Apply the view (camera).
  g_D3DDevice->SetTransform(D3DTS_VIEW, &g_ViewMatrix);

  // Set the projection matrix.
  D3DXMatrixPerspectiveFovLH(&g_projection, 45.0f,
    WINDOW_WIDTH/WINDOW_HEIGHT, 0.1f, 1000.0f);

  g_D3DDevice->SetTransform(D3DTS_PROJECTION, &g_projection);
  //////////////////////END CAMERA CODE///////////



  // Clear the backbuffer.
  g_D3DDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
    D3DCOLOR_ARGB(40,40,40,100), 1.0f, 0);


  //Sort the Objects By their z value in view space
  SortBackToFront();


  //////////////////////////////////////////////////////////////////////////////
  ///////////////////////////BEGIN SCENE////////////////////////////////////////
  //////////////////////////////////////////////////////////////////////////////
  
  // Begin the scene.  Start rendering.
  g_D3DDevice->BeginScene();

  //Render Skybox

    static int time = 0; 
    time += 16;
    g_D3DDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
    g_D3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
    
    
    D3DXMatrixIdentity(&worldTransform);
    unsigned int passes;
    effectMap["HackMapping"]->GetEffect()->Begin(&passes, 0);
    effectMap["HackMapping"]->GetEffect()->BeginPass(0);
    GetWorldMtx(&worldTransform, D3DXVECTOR3(gmMgr->graphics_->camera.GetPos().x,gmMgr->graphics_->camera.GetPos().y, gmMgr->graphics_->camera.GetPos().z), D3DXVECTOR3(1,1,1),D3DXVECTOR3(0,time/10000.0f,0));
    effectMap["HackMapping"]->GetEffect()->SetMatrix("g_world", &worldTransform);
    effectMap["HackMapping"]->GetEffect()->SetMatrix("g_wvp", &(worldTransform * g_ViewMatrix * g_projection));


    effectMap["HackMapping"]->GetEffect()->SetTexture("g_texture", this->GetTexture("glow"));
    effectMap["HackMapping"]->GetEffect()->SetTexture("g_normals", textureMap["default"]);

    effectMap["HackMapping"]->GetEffect()->SetBool("Lighting", false);
    effectMap["HackMapping"]->GetEffect()->CommitChanges();

    skybox->mesh->DrawSubset(0);

    effectMap["HackMapping"]->GetEffect()->SetBool("Lighting", true);
    effectMap["HackMapping"]->GetEffect()->CommitChanges();

    effectMap["HackMapping"]->GetEffect()->EndPass();
    effectMap["HackMapping"]->GetEffect()->End();


    g_D3DDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
    g_D3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
  //}

    // Clear the backbuffer.
  g_D3DDevice->Clear(0, NULL, D3DCLEAR_ZBUFFER,
    D3DCOLOR_ARGB(0,0,0,0), 1.0f, 0);


  // Texture filter.
  g_D3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
  g_D3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);

  g_D3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );
  RenderScene();

  g_D3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
//.........这里部分代码省略.........
开发者ID:anthonySerra,项目名称:CodeSamples,代码行数:101,代码来源:GraphicsEngine.cpp

示例4: D3DXVECTOR3

bool SkeletonClass::UpdateBuffers(ID3D10Device* device)
{

	VertexType* vertices;
	void* verticesPtr;
	HRESULT result;

	if((m_SkeletonModel[0].x == 0) && (m_SkeletonModel[0].y == 0) && (m_SkeletonModel[0].z == 0))
	{
		return true; 
	}
	
	// Create the vertex array.
	vertices = new VertexType[m_vertexCount];
	if(!vertices)
	{
		return false;
	}

	for(DWORD i = 0; i < m_vertexCount; ++i) 
	{
		vertices[i].position = D3DXVECTOR3(m_SkeletonModel[i].x, m_SkeletonModel[i].y, m_SkeletonModel[i].z);
		vertices[i].color =  D3DXVECTOR4(0.0f, 1.0f, 0.0f, 1.0f); 

		if( i >= 8 && i <= 11)
		{
			vertices[i].color =  D3DXVECTOR4(1.0f, 1.0f, 0.0f, 1.0f); 
		}

		if(m_Skeleton.eSkeletonPositionTrackingState[i] == NUI_SKELETON_POSITION_INFERRED)
		{
			vertices[i].color =  D3DXVECTOR4(1.0f, 0.0f, 0.0f, 1.0f);
		}

		if(m_Skeleton.eSkeletonPositionTrackingState[i] == NUI_SKELETON_POSITION_NOT_TRACKED)
		{
			vertices[i].color =  D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
		}
	}

	// Initialize the vertex buffer pointer to null first.
	verticesPtr = 0;

	// Lock the vertex buffer.
	result = m_vertexBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&verticesPtr);
	if(FAILED(result))
	{
		return false;
	}

	// Copy the data into the vertex buffer.
	memcpy(verticesPtr, (void*)vertices, (sizeof(VertexType) * m_vertexCount));

	// Unlock the vertex buffer.
	m_vertexBuffer->Unmap();

	// Release the vertex array as it is no longer needed.
	delete [] vertices;
	vertices = 0;

	return true;
}
开发者ID:xtr3m3nerd,项目名称:DirectXKinectFramework,代码行数:62,代码来源:skeleton.cpp

示例5: D3DXVECTOR3

bool ModelClass::InitializeBuffers(ID3D11Device* device)
{
	VertexType* vertices;
	unsigned long* indices;
	D3D11_BUFFER_DESC vertexBufferDesc, indexBufferDesc;
	D3D11_SUBRESOURCE_DATA vertexData, indexData;
	HRESULT result;
	int i;


	// Create the vertex array.
	vertices = new VertexType[m_vertexCount];
	if(!vertices)
	{
		return false;
	}

	// Create the index array.
	indices = new unsigned long[m_indexCount];
	if(!indices)
	{
		return false;
	}

	// Load the vertex array and index array with data.
	for(i=0; i<m_vertexCount; i++)
	{
		vertices[i].position = D3DXVECTOR3(m_model[i].x, m_model[i].y, m_model[i].z);
		vertices[i].texture = D3DXVECTOR2(m_model[i].tu, m_model[i].tv);
		vertices[i].normal = D3DXVECTOR3(m_model[i].nx, m_model[i].ny, m_model[i].nz);
		vertices[i].tangent = D3DXVECTOR3(m_model[i].tx, m_model[i].ty, m_model[i].tz);
		vertices[i].binormal = D3DXVECTOR3(m_model[i].bx, m_model[i].by, m_model[i].bz);

		indices[i] = i;
	}

	// Set up the description of the static vertex buffer.
	vertexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
	vertexBufferDesc.ByteWidth = sizeof(VertexType) * m_vertexCount;
	vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
	vertexBufferDesc.CPUAccessFlags = 0;
	vertexBufferDesc.MiscFlags = 0;
	vertexBufferDesc.StructureByteStride = 0;

	// Give the subresource structure a pointer to the vertex data.
	vertexData.pSysMem = vertices;
	vertexData.SysMemPitch = 0;
	vertexData.SysMemSlicePitch = 0;

	// Now create the vertex buffer.
	result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &m_vertexBuffer);
	if(FAILED(result))
	{
		return false;
	}

	// Set up the description of the static index buffer.
	indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
	indexBufferDesc.ByteWidth = sizeof(unsigned long) * m_indexCount;
	indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
	indexBufferDesc.CPUAccessFlags = 0;
	indexBufferDesc.MiscFlags = 0;
	indexBufferDesc.StructureByteStride = 0;

	// Give the subresource structure a pointer to the index data.
	indexData.pSysMem = indices;
	indexData.SysMemPitch = 0;
	indexData.SysMemSlicePitch = 0;

	// Create the index buffer.
	result = device->CreateBuffer(&indexBufferDesc, &indexData, &m_indexBuffer);
	if(FAILED(result))
	{
		return false;
	}

	// Release the arrays now that the vertex and index buffers have been created and loaded.
	delete [] vertices;
	vertices = 0;

	delete [] indices;
	indices = 0;

	return true;
}
开发者ID:liu1700,项目名称:Fire-Engine,代码行数:85,代码来源:modelclass.cpp

示例6: QuatToVec3

	D3DXVECTOR3 QuatToVec3(D3DXQUATERNION a_Quat)
	{
		return D3DXVECTOR3(a_Quat.x,a_Quat.y,a_Quat.z);
	}
开发者ID:mileswhiticker,项目名称:gam204-assessment-03,代码行数:4,代码来源:utils.cpp

示例7: D3DXVECTOR3

void Enemy::SetPos(D3DXVECTOR3 pos)
{
	obj->position = D3DXVECTOR3(pos.x,pos.y,pos.z);
	actor->setGlobalPose(PxTransform(PxVec3(pos.x,pos.y,pos.z)));
}
开发者ID:Themperror,项目名称:ThempX,代码行数:5,代码来源:Enemy.cpp

示例8: D3DXMatrixTranslation

void EditorLinePrimitive::RecalcTransforms()
{
	//Matrices we need
	D3DXMATRIX matWorld,matScale,MatRot,MatTemp;

	//Temporary translation
	D3DXVECTOR3 Trans;


	//Copy from the original location, 
	//so we can modify it without hurting anything
	Trans=Location;

	//Devide Trans through Scale
	/*Trans.x/=Scale.x;
	Trans.y/=Scale.y;
	Trans.z/=Scale.z;*/


	//Apply translation to the WorldMatrix
	D3DXMatrixTranslation(&matWorld,Trans.x,Trans.y,Trans.z);

	//Now scale another matrix
	D3DXMatrixScaling( &matScale, Scale.x, Scale.y, Scale.z );

	


	//Apply rotation
	D3DXMatrixIdentity(&MatRot);

	D3DXVECTOR3 DeltaRot = Rotation - RotationMatrixAngles;

	if(Rotation != D3DXVECTOR3(0,0,0))
	{
		// Calculate matrix with the new angles
		if(bLocalRotation)
		{
			D3DXVECTOR3 Up(0,1,0);
			D3DXVECTOR3 Front(1,0,0);
			D3DXVECTOR3 Right;
			

			D3DXVec3TransformNormal(&Up, &Up, &RotationMatrix);
			D3DXVec3TransformNormal(&Front, &Front, &RotationMatrix);
			D3DXVec3Cross(&Right, &Up, &Front);

			D3DXMATRIX X;
			D3DXMatrixRotationAxis(&X, &Front, DeltaRot.x);

			D3DXMATRIX Y;
			D3DXMatrixRotationAxis(&Y, &Up, DeltaRot.y);

			D3DXMATRIX Z;
			D3DXMatrixRotationAxis(&Z, &Right, DeltaRot.z);

			RotationMatrix *= X * Y * Z;
		}else
		{
			D3DXMatrixIdentity(&MatRot);

			D3DXMatrixRotationAxis(&MatTemp, &D3DXVECTOR3(1,0,0), Rotation.x);        // Pitch
			D3DXMatrixMultiply(&MatRot, &MatRot, &MatTemp);
			D3DXMatrixRotationAxis(&MatTemp, &D3DXVECTOR3(0,1,0), Rotation.y);         // Yaw
			D3DXMatrixMultiply(&MatRot, &MatRot, &MatTemp);
			D3DXMatrixRotationAxis(&MatTemp, &D3DXVECTOR3(0,0,1), Rotation.z);       // Roll
			D3DXMatrixMultiply(&RotationMatrix, &MatRot, &MatTemp);

			//RotationMatrix = X * Y * Z;
		}

		RotationMatrixAngles = Rotation;
	}else if(!bJustUseRotationMatrix)
	{
		// Reset matrix to identity (Todo: ROTATION! Ò.ó Y U NO WORK!? (As I want))
		D3DXMatrixIdentity(&RotationMatrix);
		RotationMatrixAngles = D3DXVECTOR3(0,0,0);
	}


	WorldMatrix = matScale * RotationMatrix * matWorld;
	
}
开发者ID:parav,项目名称:GD3D11,代码行数:83,代码来源:EditorLinePrimitive.cpp

示例9: D3DXVECTOR3

/** Creates a box of lines */
HRESULT EditorLinePrimitive::CreateLineBoxPrimitive(D3DXVECTOR4* Color)
{
	LineVertex vx[24];

	// Bottom
	vx[0].Position = D3DXVECTOR3(-1,-1,-1);
	EncodeColor(&vx[0], Color);
	vx[1].Position = D3DXVECTOR3(1,-1,-1);
	EncodeColor(&vx[1], Color);

	vx[2].Position = D3DXVECTOR3(1,-1,-1);
	EncodeColor(&vx[2], Color);
	vx[3].Position = D3DXVECTOR3(1,-1,1);
	EncodeColor(&vx[3], Color);

	vx[4].Position = D3DXVECTOR3(1,-1,1);
	EncodeColor(&vx[4], Color);
	vx[5].Position = D3DXVECTOR3(-1,-1,1);
	EncodeColor(&vx[5], Color);

	vx[6].Position = D3DXVECTOR3(-1,-1,1);
	EncodeColor(&vx[6], Color);
	vx[7].Position = D3DXVECTOR3(-1,-1,-1);
	EncodeColor(&vx[7], Color);

	// Sides | | | |

	vx[8].Position = D3DXVECTOR3(-1,-1,-1);
	EncodeColor(&vx[8], Color);
	vx[9].Position = D3DXVECTOR3(-1,1,-1);
	EncodeColor(&vx[9], Color);

	vx[10].Position = D3DXVECTOR3(1,-1,-1);
	EncodeColor(&vx[10], Color);
	vx[11].Position = D3DXVECTOR3(1,1,-1);
	EncodeColor(&vx[11], Color);

	vx[12].Position = D3DXVECTOR3(1,-1,1);
	EncodeColor(&vx[12], Color);
	vx[13].Position = D3DXVECTOR3(1,1,1);
	EncodeColor(&vx[13], Color);

	vx[14].Position = D3DXVECTOR3(-1,-1,1);
	EncodeColor(&vx[14], Color);
	vx[15].Position = D3DXVECTOR3(-1,1,1);
	EncodeColor(&vx[15], Color);

	// Top
	vx[16].Position = D3DXVECTOR3(-1,1,-1);
	EncodeColor(&vx[16], Color);
	vx[17].Position = D3DXVECTOR3(1,1,-1);
	EncodeColor(&vx[17], Color);

	vx[18].Position = D3DXVECTOR3(1,1,-1);
	EncodeColor(&vx[18], Color);
	vx[19].Position = D3DXVECTOR3(1,1,1);
	EncodeColor(&vx[19], Color);

	vx[20].Position = D3DXVECTOR3(1,1,1);
	EncodeColor(&vx[20], Color);
	vx[21].Position = D3DXVECTOR3(-1,1,1);
	EncodeColor(&vx[21], Color);

	vx[22].Position = D3DXVECTOR3(-1,1,1);
	EncodeColor(&vx[22], Color);
	vx[23].Position = D3DXVECTOR3(-1,1,-1);
	EncodeColor(&vx[23], Color);

	HRESULT hr;
	LE(CreatePrimitive(vx, 24));

	return hr;
}
开发者ID:parav,项目名称:GD3D11,代码行数:74,代码来源:EditorLinePrimitive.cpp

示例10: while

/** Creates a plate, not of lines. Can't use intersection on this*/
HRESULT EditorLinePrimitive::CreateFilledCirclePrimitive(float Radius, UINT Detail, const D3DXVECTOR4* Color, int Axis)
{
	UINT NumVerts = Detail*3;
	LineVertex* vx = new LineVertex[NumVerts];

	float Step = (D3DX_PI*2)/((float)(Detail)-1);
	float s = 0;

	int i=0;
	while(i < NumVerts)
	{
		switch(Axis)
		{
		case 0:
			// XZ-Axis
			vx[i].Position = D3DXVECTOR3(sinf(s), 0, cosf(s));
			break;
		
		case 1:
			// YZ-Axis
			vx[i].Position = D3DXVECTOR3(0, sinf(s), cosf(s));
			break;

		case 2:
			// ZY-Axis
			vx[i].Position = D3DXVECTOR3(sinf(s), cosf(s), 0);
			break;
		}
		EncodeColor(&vx[i], Color);
		s+=Step;
		i++;


		switch(Axis)
		{
		case 0:
			// XZ-Axis
			vx[i].Position = D3DXVECTOR3(sinf(s), 0, cosf(s));
			break;
		
		case 1:
			// YZ-Axis
			vx[i].Position = D3DXVECTOR3(0, sinf(s), cosf(s));
			break;

		case 2:
			// ZY-Axis
			vx[i].Position = D3DXVECTOR3(sinf(s), cosf(s), 0);
			break;
		}
		EncodeColor(&vx[i], Color);
		//s+=Step;
		i++;

		vx[i].Position = D3DXVECTOR3(0, 0, 0);
		EncodeColor(&vx[i], Color);
		i++;

	}

	HRESULT hr = CreatePrimitive(vx, NumVerts, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

	delete[] vx;
	return hr;
}
开发者ID:parav,项目名称:GD3D11,代码行数:66,代码来源:EditorLinePrimitive.cpp

示例11: vOrientation

/**
* CAIManager::spawnGroup
* @date Modified May 30, 2006
*/
void CAIManager::spawnGroup(EObjectType eType, D3DXVECTOR3 vPos, int nNum)
{
	CObjectManager* poObjectManager = CObjectManager::getInstancePtr();

	// these values can be different for each enemy type that is being spawned
	// based on the specific models being used
	D3DXVECTOR3 vScale, vOrientation(((float)(rand()%100))+1.0f, 0.0f, ((float)(rand()%100))+1.0f);
	D3DXVec3Normalize(NULL, &vOrientation, &vOrientation);
	float fBVHeight = 0.0f, fBVRadius = 0.0f;
	switch (eType)
	{
	case OBJ_ENEMY_ZOMBIECITIZEN:
		vScale = D3DXVECTOR3(0.5f, 0.5f, 0.5f);
		fBVHeight = 15.0f;
		fBVRadius = 3.0f;
		break;
	case OBJ_ENEMY_GASEOUSCLAY:
		vScale = D3DXVECTOR3(0.75f, 0.75f, 0.75f);
		fBVHeight = 15.0f;
		fBVRadius = 4.0f;
		break;
	case OBJ_ENEMY_ICECREAMMAN:
		vScale = D3DXVECTOR3(0.75f, 0.75f, 0.75f);
		fBVHeight = 15.0f;
		fBVRadius = 4.0f;
		break;
	case OBJ_ENEMY_QUARTERBACK:
		vScale = D3DXVECTOR3(0.75f, 0.75f, 0.75f);
		fBVHeight = 15.0f;
		fBVRadius = 4.0f;
		break;
	}

	// make the new group, local variable problem is not an issue because the newGroup gets pushed into the list
	CAIGroup newGroup;
	newGroup.setAvgPos(vPos);

	// set the center enemy attributes
	CEnemy* newEnemy = (CEnemy*)poObjectManager->createObject(eType);
	newEnemy->setPosition(vPos);
	newEnemy->setBV(D3DXVECTOR3(newEnemy->getPosition().x, fBVHeight, newEnemy->getPosition().z), fBVRadius);
	newEnemy->setActorMatrix(vOrientation, newEnemy->getPosition(), vScale);
	newGroup.getEnemies()->push_back(newEnemy);

	int nNumCreated = 1, nCurrentRing = 0;
	float fRadius = SPAWN_SPACEING, fAngle = 0.0f, fEnemyWidth = newEnemy->getBV().fRadius * 2.0f, fAngleChange = 0.0f;
	// for truncation
	int nNumInRing = (int)((fRadius*2.0f*3.14159f)/fEnemyWidth);
	++nNumInRing;
	fAngleChange = (2.0f*3.14159f)/(float)nNumInRing;

	while (nNumCreated < nNum)
	{
		// another ring
		if (nCurrentRing == nNumInRing)
		{
			fRadius += SPAWN_SPACEING;
			// update offset
			nNumInRing = (int)((fRadius*2.0f*3.14159f)/fEnemyWidth);
			++nNumInRing;
			fAngleChange = (2.0f*3.14159f)/(float)nNumInRing;
			nCurrentRing = 0;
		}

		CEnemy* newEnemy = (CEnemy*)poObjectManager->createObject(eType);
		newEnemy->setPosition(D3DXVECTOR3(vPos.x + (fRadius * cos(fAngle)), vPos.y, vPos.z + (fRadius * sin(fAngle))));
		newEnemy->setBV(D3DXVECTOR3(newEnemy->getPosition().x, fBVHeight, newEnemy->getPosition().z), fBVRadius);
		newEnemy->setActorMatrix(vOrientation, newEnemy->getPosition(), vScale);
		newGroup.getEnemies()->push_back(newEnemy);

		// keep going around the circle
		fAngle += fAngleChange;
		++nNumCreated;
		++nCurrentRing;
	}

	m_loGroups.push_back(newGroup);
	m_loGroups.back().updateLeader(true);

	// AwesomeTime code
	CObjectManager::ObjectList loPlayers;
	CObjectManager::getInstance().getObjects(OBJ_PLAYER, &loPlayers);
	((CPlayer*)(loPlayers.front()))->m_oStats.addEnemiesSpawned((unsigned int)nNum);
	if(((CPlayer*)(loPlayers.front()))->isAwesome()) ((CPlayer*)(loPlayers.front()))->m_oStats.addAwesomeEnemiesSpawned(nNum);

	// Play spawn sound
	CSoundManager::getInstance().playSound(SND_EFFECT_ZOMBIESPAWN);
}
开发者ID:mattrudder,项目名称:AckZombies,代码行数:92,代码来源:AIManager.cpp

示例12: while

/**
* CAIManager::updateCurrentObjective
* @date Modified June 2, 2006
*/
void CAIManager::updateCurrentObjective(void)
{
	// if we don't have an objective we need to find the first one
	if (m_poCurrentObjective == NULL)
	{
		CObjectManager::ObjectList loObjectives;
		CObjectManager::getInstance().getObjects(OBJ_OBJECTIVE_TRIGGER, &loObjectives);
		CObjectManager::ObjectList::iterator oObjectiveIter = loObjectives.begin();
		while (oObjectiveIter != loObjectives.end())
		{
			if (((CObjectiveTrigger*)(*oObjectiveIter))->m_unOrderNumber == 0)
			{
				m_poCurrentObjective = ((CObjectiveTrigger*)(*oObjectiveIter));
				D3DXVECTOR3 pos = m_poCurrentObjective->getPosition();
				pos.y += 5.0f;
				m_poObjectiveEmitter->setActorMatrix(m_poCurrentObjective->getOrientation(), pos, D3DXVECTOR3(1,1,1));
				m_poObjectiveEmitter->play();

				// if this is a OJT_GOTO activate the barriers
				if (m_poCurrentObjective->m_eObjectiveType == CObjectiveTrigger::OJT_GOTO)
				{
					if (!m_poCurrentObjective->m_loBarriers.empty())
					{
						// activate the barriers
						std::list<CObjectiveBarrier*>::iterator oBarrierIter = m_poCurrentObjective->m_loBarriers.begin();
						while (oBarrierIter != m_poCurrentObjective->m_loBarriers.end())
						{
							((CObjectiveBarrier*)(*oBarrierIter))->activate();
							((CObjectiveBarrier*)(*oBarrierIter))->setMesh((CMesh*)CResourceManager::getInstance().loadResource(RES_MESH, "roadBlockSign.x"));
							((CObjectiveBarrier*)(*oBarrierIter))->m_pExplosion->setActorMatrix(((CObjectiveBarrier*)(*oBarrierIter))->getOrientation(), ((CObjectiveBarrier*)(*oBarrierIter))->getPosition(), ((CObjectiveBarrier*)(*oBarrierIter))->getScale());
							((CObjectiveBarrier*)(*oBarrierIter))->m_pExplosion->play();
							oBarrierIter++;
						}

						int nRand = rand() % 3;
						switch (nRand)
						{
						case 0:
							CSoundManager::getInstance().playSound(SND_EFFECT_EXPLOSION1);
							break;
						case 1:
							CSoundManager::getInstance().playSound(SND_EFFECT_EXPLOSION2);
							break;
						case 2:
							CSoundManager::getInstance().playSound(SND_EFFECT_EXPLOSION3);
							break;
						default:
							break;
						}
					}
				}
				break;
			}
			oObjectiveIter++;
		}

		// if we couldn't find it just get out of here
		if (m_poCurrentObjective == NULL)
			return;
	}

	// check for people trying to cheat
	if (m_poCurrentObjective->m_eObjectiveType == CObjectiveTrigger::OJT_GOTO && m_bSkipCurrentObjective)
	{
		m_poCurrentObjective->m_bTriggered = true;
	}

	// if it isn't triggered check to see if it can be
	if (!m_poCurrentObjective->m_bTriggered)
	{
		m_poCurrentObjective->checkTriggerActivate();
	}

	// check to see if it has been triggered because it could have been updated by the function call above
	if (m_poCurrentObjective->m_bTriggered)
	{
		m_poObjectiveEmitter->pause();
		// if it is complete we can move to the next trigger
		if (m_poCurrentObjective->checkTriggerComplete(m_bSkipCurrentObjective))
		{
			// if this was the goal objective we are done
			if (m_poCurrentObjective->m_bGoal)
			{
				CGameKernel::getInstance().changeState(CWinState::getInstancePtr());
				return;
			}
			else
			{
				// find the next goal
				CObjectManager::ObjectList loObjectives;
				CObjectManager::getInstance().getObjects(OBJ_OBJECTIVE_TRIGGER, &loObjectives);
				CObjectManager::ObjectList::iterator oObjectiveIter = loObjectives.begin();
				unsigned int unNextObjective = m_poCurrentObjective->m_unOrderNumber + 1;
				m_poCurrentObjective = NULL;
				while (oObjectiveIter != loObjectives.end())
				{
//.........这里部分代码省略.........
开发者ID:mattrudder,项目名称:AckZombies,代码行数:101,代码来源:AIManager.cpp

示例13: ndc

Vector3f Camera::screenToWorld(const Vector2f& pos) {
	
	mat4 ma1 = m_View * m_Proj;
	mat4 inv1 = matrix::mat4Inverse(ma1);

	Vector4f in;
	in.x = (pos.x - 1024.0f) / 1024.0f;
	in.y = (768.0f - pos.y) / 768.0f;
	in.z = 1.0f;
	in.w = 1.0;

	// Map to range -1 to 1
	in.x = in.x * 2.0 - 1.0;
	in.y = in.y * 2.0 - 1.0;
	in.z = in.z * 2.0 - 1.0;

	Vector4f o4 = inv1 * in;
	o4 *= 1.0f / o4.w;
	/*
	//Vector4f ndc(2 * pos.x / 1024 - 1,2 * (768 - pos.y) / 768 - 1,1, 1);

	Vector3f ndc(2 * pos.x / 1024 - 1, 2 * (768 - pos.y) / 768 - 1, 1);

	Vector3f tmp = m * ndc;
	//tmp *= 1.0f / tmp.w;

	return Vector3f(tmp.x, tmp.y, tmp.z);
	*/
	
	/*
	Vector3f v;
	v.x = (((2.0f * pos.x) / 1024) - 1) / m_Proj._11;
	v.y = (-2.0f * pos.y / 768 + 1) / m_Proj._22;
	v.z = 1.0f;

	//LOG << "v: " << DBG_V3(v);

	mat4 matInvView = matrix::mat4Inverse(m_View);

	//Vector4f ndc((2 * (pos.x - 1024)) / 1024 - 1,(2 * (768 - pos.y)) / 768 - 1, 0, 1);

	Vector3f rayDir = matInvView * v;

	Vector3f rayOrigin;

	rayOrigin.x = matInvView._41;
	rayOrigin.y = matInvView._42;
	rayOrigin.z = matInvView._43;
	//LOG << "v: " << DBG_V3(v);
	return rayDir;
	*/


	D3DXMATRIX tm;
	D3DXMatrixPerspectiveFovLH(&tm, 0.25f*PI, 1024.0f / 768.0f, 0.1f, 1000.0f);
	mat4 m = m_View;// *m_Proj;
	mat4 inv = matrix::mat4Inverse(m_Proj);
	D3DXMATRIX itm;
	D3DXMatrixInverse(&itm,NULL,&tm);

	D3DXMATRIX viewMatrix;
	D3DXMatrixLookAtLH(&viewMatrix,
		&D3DXVECTOR3(0.0f, 0.0f, -16.0f), //position
		&D3DXVECTOR3(0.0f, 0.0f, 0.0f), //Look at
		&D3DXVECTOR3(0.0f, 1.0f, 0.0f));

	D3DXMATRIX worldMatrix;
	D3DXMatrixIdentity(&worldMatrix);

	D3DXMATRIX m1, m2, m3;
	D3DXVECTOR3 vvec,outv;
	D3DXMatrixMultiply(&m1, &worldMatrix, &viewMatrix);
	D3DXMatrixMultiply(&m2, &m1, &tm);
	D3DXMatrixInverse(&m3, NULL, &m2);
	vvec.x = 2.0f * (pos.x - 1024.0f) / 1024.0f - 1.0f;
	vvec.y = 1.0f - 2.0f * (pos.y - 768.0f) / 768.0f;
	vvec.z = 1.0f;// (pv->z - pviewport->MinZ) / (pviewport->MaxZ - pviewport->MinZ);
	D3DXVec3TransformCoord(&outv, &vvec, &m3);

	//LOG << "screen pos: " << DBG_V2(pos);
	Vector3f vec;
	vec.x = (((2.0f * pos.x) / 1024.0f) - 1.0f);// / m_Proj._11;
	vec.y = -(((2.0f * pos.y) / 768.0f) - 1.0f);// / m_Proj._22;

	//vec.x = (2.0f * pos.x - 1024.0f) / 1024.0f - 1.0f;
	//vec.y = 1.0f - (2.0f * pos.y - 768.0f) / 768.0f;
	vec.z = 1.0f;// (pos.z - 0.1) / (1000 - pviewport->MinZ);
	Vector3f pout = vec * inv;
	//D3DXVec3TransformCoord(pout, &vec, &inv);
	return vec;
	
}
开发者ID:amecky,项目名称:diesel2D,代码行数:92,代码来源:Camera.cpp

示例14: ShutDown

bool GraphicsClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
{
	bool result;

	//如果对象已经存在,先释放掉它们
	ShutDown();

	// 创建一个D3DClass对象
	m_D3D = new D3DClass;
	if(!m_D3D)
		return false;

	// 调用D3DClass初始化函数 
	result = m_D3D->Initialize(screenWidth, screenHeight, VSYNC_ENABLED, hwnd, FULL_SCREEN, 
		SCREEN_DEPTH, SCREEN_NEAR);
	if(!result)
	{
		MessageBox(hwnd, TEXT("Could not initialize Direct3D"), TEXT("Error"), MB_OK); 
		return false; 
	}

	//创建摄像机对象
	m_Camera = new CameraClass;
	if(!m_Camera)
		return false;

	// 设置摄像机位置
	D3DXVECTOR3 campos = D3DXVECTOR3(0.0f, 0.0f, -10.0f);
	m_Camera->setPosition(&campos);

	// 创建模型对象
	m_Model = new ModelClass;
	if(!m_Model)
		return false;

	// 初始化模型对象
	result = m_Model->Initialize(m_D3D->GetDevice(), 300, 300, 1.0f);
	if(!result)
	{
		MessageBox(hwnd, TEXT("Could not initialize the model object."), TEXT("Error"), MB_OK);
		return false;
	}

	// 创轴建模型对象
	m_AxisModel = new AxisModelClass;
	if(!m_AxisModel)
		return false;

	// 初始化坐标轴模型对象
	result = m_AxisModel->Initialize(m_D3D->GetDevice());
	if(!result)
	{
		MessageBox(hwnd, TEXT("Could not initialize the axis model object."), TEXT("Error"), MB_OK);
		return false;
	}

	// 创建shader对象
	m_ColorShader = new ColorShaderClass;
	if(!m_ColorShader)
		return false;

	// 初始化shader对象
	result = m_ColorShader->Initialize(m_D3D->GetDevice(), hwnd);
	if(!result)
	{
		MessageBox(hwnd, TEXT("Could not initialize the color shader object."), TEXT("Error"), MB_OK);
		return false;
	}

	return true;
}
开发者ID:Jesna,项目名称:DirectX,代码行数:71,代码来源:GraphicsClass.cpp

示例15: if

void cPlayer::Update(float delta){
	
	if (GetKeyState(VK_SPACE) & 0x8000 && m_eCurrAnim != E_ANIM_ATTACK){
		m_fAttackAnimationTime += delta;
		m_eCurrAnim = E_ANIM_ATTACK;
		m_pRoot->SetState(cPart::eAnimationPT::E_STATE_ATTACK);
	}
	else if (m_eCurrAnim == E_ANIM_ATTACK){	// 공격중인 상태일때
		m_fAttackAnimationTime += delta;
	
		if (m_fAttackAnimationTime > 0.180f && m_bAttacked == false){
			// Attack triggered (callback) 0.125sec
			m_bAttacked = true;
			//m_pGame->CollisionCheck(this);
		}
		else if (m_fAttackAnimationTime > 0.25f){
			m_bAttacked = false;
			m_fAttackAnimationTime = 0;
			m_eCurrAnim = E_ANIM_IDLE;
			m_pRoot->SetState(cPart::eAnimationPT::E_STATE_IDLE);
			m_pRoot->SetForcedXangle(D3DXToRadian(240.0f));
		}
	}
	else { // 공격 상태중이 아닐때
		if (GetKeyState('A') & 0x8000)
		{
			m_fAngle -= 4.0f * delta;
			D3DXMATRIXA16 matR;
			D3DXMatrixRotationY(&matR, m_fAngle);
			m_vForward = D3DXVECTOR3(0, 0, 1);
			D3DXVec3TransformNormal(&m_vForward, &m_vForward, &matR);
		}
		else if (GetKeyState('D') & 0x8000)
		{
			m_fAngle += 4.0f * delta;
			D3DXMATRIXA16 matR;
			D3DXMatrixRotationY(&matR, m_fAngle);
			m_vForward = D3DXVECTOR3(0, 0, 1);
			D3DXVec3TransformNormal(&m_vForward, &m_vForward, &matR);
		}

		if (GetKeyState('W') & 0x8000)
		{
			m_eCurrAnim = E_ANIM_WALK;
			m_pRoot->SetState(cPart::eAnimationPT::E_STATE_WALK);
			m_vPosition += (m_vForward * m_fSpeed * delta);
		}
		else if (GetKeyState('S') & 0x8000)
		{
			m_eCurrAnim = E_ANIM_WALK;
			m_pRoot->SetState(cPart::eAnimationPT::E_STATE_WALK);
			m_vPosition -= (m_vForward * m_fSpeed * delta);
		}
		else
		{
			m_eCurrAnim = E_ANIM_IDLE;
			m_pRoot->SetState(cPart::eAnimationPT::E_STATE_IDLE);
		}

	}

	if (m_eCurrAnim == E_ANIM_IDLE)
	{
		m_pRoot->SetForcedAngle(0.0f);
	}

	D3DXMATRIXA16 matR, matT, matWorld;
	D3DXMatrixRotationY(&matR, m_fAngle);
	D3DXMatrixTranslation(&matT, m_vPosition.x, m_vPosition.y, m_vPosition.z);
	matWorld = matR * matT;

	m_pRoot->Update(delta, &matWorld);
}
开发者ID:arkiny,项目名称:Direct3D,代码行数:73,代码来源:cPlayer.cpp


注:本文中的D3DXVECTOR3函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。