コード例 #1
0
void DrawGraphics( World *pWorld )
{
	GraphicsManagerComponent *pGraphicsManager = pWorld->GetComponents().GetFirst<GraphicsManagerComponent>();
	HELIUM_ASSERT( pGraphicsManager );

	pGraphicsManager->GetGraphicsScene()->Update( pWorld );
}
コード例 #2
0
ファイル: Sprite.cpp プロジェクト: justinliew/Helium
void DrawSprites( World *pWorld )
{
#if !GRAPHICS_SCENE_BUFFERED_DRAWER
	HELIUM_ASSERT( 0 );
#else // GRAPHICS_SCENE_BUFFERED_DRAWER

	GraphicsManagerComponent *pGraphicsManager = pWorld->GetComponents().GetFirst<GraphicsManagerComponent>();
	HELIUM_ASSERT( pGraphicsManager );

	g_pBufferedDrawer = &pGraphicsManager->GetBufferedDrawer();
	QueryComponents< SpriteComponent, TransformComponent, DrawSprite >( pWorld );
#endif
}
コード例 #3
0
ファイル: MeshComponent.cpp プロジェクト: kevindqc/Helium
void MeshComponent::Initialize( const MeshComponentDefinition& definition )
{
	GraphicsManagerComponent *pGraphicsManagerComponent = GetWorld()->GetComponents().GetFirst<GraphicsManagerComponent>();
	HELIUM_ASSERT( pGraphicsManagerComponent );
	GraphicsScene *pScene = pGraphicsManagerComponent->GetGraphicsScene();
	HELIUM_ASSERT( pScene );

	ComponentCollection *pCollection = GetComponentCollection();

	if (definition.m_Mesh)
	{
		m_Mesh = definition.m_Mesh;
		TransformComponent *transform = pCollection->GetFirst<TransformComponent>();

		if (transform)
		{
			Attach(pScene, transform);
		}
	}
}
コード例 #4
0
ファイル: PlayerInput.cpp プロジェクト: Fantasticer/Helium
void GatherInput( PlayerInputComponent *pPlayerInput )
{
	float x = 0.0f;
	float y = 0.0f;

	if ( Helium::Input::IsKeyDown(Input::KeyCodes::KC_LEFT) )
	{
		x -= 1.0f;
	}
	
	if ( Helium::Input::IsKeyDown(Input::KeyCodes::KC_RIGHT) )
	{
		x += 1.0f;
	}

	if ( Helium::Input::IsKeyDown(Input::KeyCodes::KC_UP) )
	{
		y += 1.0f;
	}

	if ( Helium::Input::IsKeyDown(Input::KeyCodes::KC_DOWN) )
	{
		y -= 1.0f;
	}
	
	pPlayerInput->m_ScreenSpaceFocusPosition = Helium::Input::GetMousePosNormalized();


	GraphicsManagerComponent *pGraphics = pPlayerInput->GetWorld()->GetComponents().GetFirst<GraphicsManagerComponent>();
	GraphicsSceneView *pSceneView = pGraphics->GetGraphicsScene()->GetSceneView(0);

	Simd::Vector3 from;
	Simd::Vector3 to;
	pSceneView->ConvertNormalizedScreenCoordinatesToRaycast(pPlayerInput->m_ScreenSpaceFocusPosition, from, to);

	Simd::Plane plane(Simd::Vector3::BasisZ, -750.0f);
	Simd::Vector3 raycastNormalized = (to - from).GetNormalized();
	Simd::Vector3 pointOnPlane;
	
	if ( plane.CalculateLineIntersect( from, raycastNormalized, pointOnPlane) )
	{
#if GRAPHICS_SCENE_BUFFERED_DRAWER
		SimpleVertex verts[2];
		verts[0].position[0] = pointOnPlane.GetElement(0) - 30.0f;
		verts[0].position[1] = pointOnPlane.GetElement(1);
		verts[0].position[2] = pointOnPlane.GetElement(2);
		verts[0].color[0] = 0xFF;
		verts[0].color[1] = 0xFF;
		verts[0].color[2] = 0xFF;
		verts[0].color[3] = 0xFF;

		verts[1].position[0] = pointOnPlane.GetElement(0) + 30.0f;
		verts[1].position[1] = pointOnPlane.GetElement(1);
		verts[1].position[2] = pointOnPlane.GetElement(2);
		verts[1].color[0] = 0xFF;
		verts[1].color[1] = 0xFF;
		verts[1].color[2] = 0xFF;
		verts[1].color[3] = 0xFF;

		pGraphics->GetBufferedDrawer().DrawLineStrip(verts, 2);

		verts[0].position[0] = pointOnPlane.GetElement(0);
		verts[0].position[1] = pointOnPlane.GetElement(1) - 30.0f;

		verts[1].position[0] = pointOnPlane.GetElement(0);
		verts[1].position[1] = pointOnPlane.GetElement(1) + 30.0f;

		pGraphics->GetBufferedDrawer().DrawLineStrip(verts, 2);
#endif

		pPlayerInput->m_bFirePrimary = Helium::Input::IsMouseButtonDown( Helium::Input::MouseButtons::Left );
		pPlayerInput->m_WorldSpaceFocusPosition = pointOnPlane;
		pPlayerInput->m_bHasWorldSpaceFocus = true;
	}
	else
	{
		pPlayerInput->m_bFirePrimary = false;
		pPlayerInput->m_WorldSpaceFocusPosition = Simd::Vector3::Zero;
		pPlayerInput->m_bHasWorldSpaceFocus = false;
	}
	
	pPlayerInput->m_MoveDir = Simd::Vector2(x, y);
	pPlayerInput->m_MoveDir.NormalizeOrZero();

}