Пример #1
0
	bool BaseGame::IsInFrontOfCamera(const Vector3 &point) const
	{
		// Not work, why?
		//const Matrix4 viewProjMatrix = GetCamera().getViewMatrix() * GetCamera().getProjectionMatrix();
		//Vector4 result = Vector4(point.x, point.y, point.z, 1) * viewProjMatrix;
		//
		//// Is result in front?
		//return result.z > result.w - GetCamera().getNearClipDistance();

		const Vector3 eyeSpacePos = GetCamera().getViewMatrix() * point;
		if (eyeSpacePos.z >= 0)
			return false;

		const Vector3 hcsPos = GetCamera().getProjectionMatrix() * eyeSpacePos;
		if ((hcsPos.x < -1.0f) || (hcsPos.x > 1.0f) || (hcsPos.y < -1.0f) || (hcsPos.y > 1.0f))
			return false;

		return true;
	}
Пример #2
0
void Scene::UpdateScene(float dt)
{
	MyD3D10Code::Direct3D10Class::UpdateScene(dt);

	// Update the camera
	GetCamera().Update(dt);

	// Update the box 
	m_Box.Update(dt);
}
Пример #3
0
void AtlasViewActor::Render()
{
	SViewPort vp = { 0, 0, g_xres, g_yres };
	CCamera& camera = GetCamera();
	camera.SetViewPort(vp);
	camera.SetProjection(2.f, 512.f, DEGTORAD(20.f));
	camera.UpdateFrustum();

	m_ActorViewer->Render();
	Atlas_GLSwapBuffers((void*)g_AtlasGameLoop->glCanvas);
}
Пример #4
0
Файл: Sky.cpp Проект: jcrm/DX
void Sky::draw(){
	D3DXVECTOR3 eyePos = GetCamera().position();

	// center Sky about eye in world space
	Translate(eyePos.x, eyePos.y, eyePos.z);
	HR(mfxCubeMapVar->SetResource(mCubeMap));
	md3dDevice->IASetInputLayout(InputLayout::Pos);
	md3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	
	GfxObj::draw();
}
Пример #5
0
	//--------------------------------------------------------------------------------------
	//	ゲームステージクラス実体
	//--------------------------------------------------------------------------------------
	//ビューとライトの作成
	void GameStage::CreateViewLight() {
		auto PtrView = CreateView<SingleView>();
		//ビューのカメラの設定
		auto PtrCamera = PtrView->GetCamera();
		PtrCamera->SetEye(Vec3(0.0f, 5.0f, -5.0f));
		PtrCamera->SetAt(Vec3(0.0f, 0.0f, 0.0f));
		//シングルライトの作成
		auto PtrSingleLight = CreateLight<SingleLight>();
		//ライトの設定
		PtrSingleLight->GetLight().SetPositionToDirectional(-0.25f, 1.0f, -0.25f);
	}
LRESULT DeferredDemo::msgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
	POINT mousePos;
	int dx = 0;
	int dy = 0;
	switch(msg)
	{
	case WM_LBUTTONDOWN:
		if( wParam & MK_LBUTTON )
		{
			SetCapture(mhMainWnd);

			mOldMousePos.x = LOWORD(lParam);
			mOldMousePos.y = HIWORD(lParam);
		}
		return 0;

	case WM_LBUTTONUP:
		ReleaseCapture();
		return 0;

	case WM_MOUSEMOVE:
		if( wParam & MK_LBUTTON )
		{
			mousePos.x = (int)LOWORD(lParam); 
			mousePos.y = (int)HIWORD(lParam); 

			dx = mousePos.x - mOldMousePos.x;
			dy = mousePos.y - mOldMousePos.y;

			GetCamera().pitch( dy * 0.0087266f );
			GetCamera().rotateY( dx * 0.0087266f );
			
			mOldMousePos = mousePos;
		}
		return 0;
  
	}

	return D3DApp::msgProc(msg, wParam, lParam);
}
Пример #7
0
	void Scene::Render() 
	{
		for ( Layer* pLayer : mLayerList )
		{
			if ( pLayer->GetLayerDepth() & GetLayerMask() )
			{
				glClear(GL_DEPTH_BUFFER_BIT);

				glLoadIdentity();
				Vector3 cPos = GetCamera()->GetPosition();
				Vector3 cTgt = GetCamera()->GetTargetPosition(); 

				if ( pLayer->IsBackground() )
				{
					Vector3 cDiff = cPos - cTgt;
					gluLookAt(cDiff.x, cDiff.y, cDiff.z, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
				}
				else
				{
					gluLookAt(cPos.x, cPos.y, cPos.z, cTgt.x, cTgt.y, cTgt.z, 0.0f, 1.0f, 0.0f);
				}

				pLayer->Render();
			}
		}

		for ( Layer* pLayerToDelete : mLayersToDelete )
		{
			for ( LayerList::iterator it = mLayerList.begin(), itEnd = mLayerList.end(); it != itEnd; )
			{
				if ( *it == pLayerToDelete )
				{
					delete *it;
					it = mLayerList.erase( it );
				}
				else
					it++;
			}
		}
		mLayersToDelete.clear();
	}
Пример #8
0
// 描画.
void CBillboardApp::RenderInternal(izanagi::graph::CGraphicsDevice* device)
{
    izanagi::sample::CSampleCamera& camera = GetCamera();

    //m_Billboard.Render(device, camera);
    //m_YBillboard.Render(device, camera);
    m_ZBillboard.Render(device, camera);

    if (device->Begin2D()) {
        device->End2D();
    }
}
Пример #9
0
// 描画.
void CMouseHit::RenderInternal(izanagi::graph::CGraphicsDevice* device)
{
    izanagi::sample::CSampleCamera& camera = GetCamera();

    device->SetRenderState(
        izanagi::graph::E_GRAPH_RS_CULLMODE,
        izanagi::graph::E_GRAPH_CULL_NONE);

    static const izanagi::math::SVector4 color[2] = {
        { 1.0f, 1.0f, 1.0f, 1.0f },
        { 1.0f, 1.0f, 1.0f, 0.5f },
    };

    m_Shader->Begin(0, IZ_FALSE);
    if (m_Shader->BeginPass(0)) {
        // パラメータ設定
        _SetShaderParam(
            m_Shader,
            "g_mL2W",
            (void*)&m_Triangles.mtx,
            sizeof(m_Triangles.mtx));

        _SetShaderParam(
            m_Shader,
            "g_mW2C",
            (void*)&camera.GetParam().mtxW2C,
            sizeof(camera.GetParam().mtxW2C));

        const izanagi::math::SVector4& clr = (m_IsCross ? color[1] : color[0]);

        _SetShaderParam(
            m_Shader,
            "g_Color",
            (void*)&clr,
            sizeof(clr));

        // シェーダ設定
        m_Shader->CommitChanges();

        device->SetVertexDeclaration(m_VD);
        device->SetVertexBuffer(
            0, 0,
            m_Triangles.vb->GetStride(), 
            m_Triangles.vb);
        device->DrawPrimitive(
            izanagi::graph::E_GRAPH_PRIM_TYPE_TRIANGLELIST,
            0, 1);

        m_Shader->EndPass();
    }

    m_Shader->End();
}
Пример #10
0
// 更新.
void CResourceManagerApp::UpdateInternal(izanagi::graph::CGraphicsDevice* device)
{
    GetCamera().Update();
    
    izanagi::CObject* obj = m_RscMgr->Find(
        IZ_CC3('m', 'd', 'l'),
        izanagi::CKey("Seymour.mdl"));
    if (obj != IZ_NULL) {
        izanagi::CModel* mdl = (izanagi::CModel*)obj;
        mdl->Update();
    }
}
Пример #11
0
void Screen::UpdateY()
{
	float x, y, z;
	x = GetCamera().GetPosition().x;
	y = GetCamera().GetPosition().y;
	z = GetCamera().GetPosition().z;

	mVelocityY -= mGravity*mDeltaTime;

	if(mState == walking)
		GetCamera().SetYPosition(mWorldHandler->GetHeight(x, z) + HeightOffset);
	else
	{
		float newYPos = mWorldHandler->GetHeight(x, z) + HeightOffset;
		if(y + (mVelocityY * mDeltaTime) <= newYPos)
		{
			//Reached ground
			float lDeltaTime = (newYPos - y)/mVelocityY;
			//Calculate new delta time
			y += lDeltaTime*mVelocityY;
			GetCamera().SetYPosition(y);
			//Stop falling
			mVelocityY = 0;
			mState = walking;
			return;
		}
		//Keep falling
		y += mDeltaTime*mVelocityY;
		GetCamera().SetYPosition(y);
	}
}
void EngineStatePoolShowShot::TimerExpired()
{
  // Play wav: cue hits ball
  // TODO find decent wav
  static const std::string sfx = Engine::Instance()->
    GetConfigValue("golf_wav_11");
  SoundFxManager::Instance()->PlayWav(sfx.c_str());

  const PoolGameState::PlayerInfo::PoolStroke& gs = 
    GetEngine()->GetGameState()->GetCurrentPlayerInfo()->m_golfStroke;
 
  EngineStatePoolSetUpShot::TakeShotNowImpl(gs.m_yRot, gs.m_vertVel, gs.m_horVel, gs.m_accel,
    gs.m_english, gs.m_drawRoll);

  // Stop user-controlled camera movement
  GetCamera()->PlusUp(false);
  GetCamera()->PlusDown(false);
  GetCamera()->PlusLeft(false);
  GetCamera()->PlusRight(false);

  ChangeStateToShotInPlay();
}
Пример #13
0
bool GameFlow::Initialize()
{
	IGameApp::Initialize();
	return cPres.Load("configs/game.config", [&](Presentation *, Viewport *aborted)
	{
		if (!aborted)
		{
			pSoundSystem->SetMusicVolume(0.6f);
			pSoundSystem->SetSfxVolume(0.5f);

			// Create the State Machine Data
			gGameData = sdNew(GameData());

			if (this->SaveSystemFlow())
				pSaveSystem->Load(0, &gGameData->sPlayer, &gGameData->sOptions);

			// Create the transitions
			cMenuToGame.Initialize(&cMenu, &cOnGame, &cGame);
			cMenuToOptions.Initialize(&cMenu, &cOnOptions, &cOptions);
			cMenuToCredits.Initialize(&cMenu, &cOnCredits, &cCredits);
			cOptionsToMenu.Initialize(&cOptions, &cOnMenu, &cMenu);
			cCreditsToMenu.Initialize(&cCredits, &cOnMenu, &cMenu);
			cGameToMenu.Initialize(&cGame, &cOnMenu, &cMenu);
			cGameToLoad.Initialize(&cGame, &cOnLoad, &cLoad);
			cLoadToGame.Initialize(&cLoad, &cOnGame, &cGame);

			// Create the State Machine.
			cFlow.RegisterTransition(&cMenuToGame);
			cFlow.RegisterTransition(&cMenuToOptions);
			cFlow.RegisterTransition(&cMenuToCredits);
			cFlow.RegisterTransition(&cOptionsToMenu);
			cFlow.RegisterTransition(&cCreditsToMenu);
			cFlow.RegisterTransition(&cGameToMenu);
			cFlow.RegisterTransition(&cGameToLoad);
			cFlow.RegisterTransition(&cLoadToGame);

			pSystem->AddListener(this);
			pInput->AddKeyboardListener(this);

			auto viewport = cPres.GetViewportByName("MainView");
			pScene = viewport->GetScene();
			pCamera = viewport->GetCamera();

			sdNew(GuiManager());
			gGui->Initialize();
			pScene->Add(gGui->GetSceneObject());

			cFlow.Initialize(&cMenu);
		}
	});
}
Пример #14
0
IZ_BOOL StateMoveToItem::Update(
    IZ_FLOAT time,
    izanagi::graph::CGraphicsDevice* device)
{
    if (m_State == State_Move) {
        m_Timeline.Advance(time);

        IZ_FLOAT t = m_Timeline.GetNormalized();

        const izanagi::math::SMatrix44& from = GetCamera().GetTransform();

        izanagi::math::SMatrix44 mtx;
        izanagi::math::SMatrix44::Lerp(mtx, from, m_TargetMtx, t);

        GetCamera().SetTransform(mtx);

        if (t == 1.0f) {
            m_State = State_Moved;
            m_Timeline.Reset();
        }
    }
    else if (m_State == State_Return) {
        m_Timeline.Advance(time);

        IZ_FLOAT t = m_Timeline.GetNormalized();

        izanagi::math::SMatrix44 mtx;
        izanagi::math::SMatrix44::Lerp(mtx, m_TargetMtx, m_CamMtx, t);

        GetCamera().SetTransform(mtx);

        if (t == 1.0f) {
            StateManager::Instance().ChangeState(State_Default);
        }
    }

    return IZ_TRUE;
}
Пример #15
0
void CameraPropertyControl::OnBoolPropertyChanged(PropertyList *forList, const String &forKey, bool newValue)
{
    if("property.camera.isortho" == forKey)
    {
        Camera *camera = GetCamera(currentSceneNode);
        camera->SetupPerspective(
                      propertyList->GetFloatPropertyValue("property.camera.fov"),
                      320.0f / 480.0f,
                      propertyList->GetFloatPropertyValue("property.camera.znear"),
                      propertyList->GetFloatPropertyValue("property.camera.zfar"));
    }

    NodesPropertyControl::OnBoolPropertyChanged(forList, forKey, newValue);
}
Пример #16
0
void Screen::Update()
{	
	UpdateY();

	float lWalkingSpeed = gPlayerMovementSpeed;

	if(GetAsyncKeyState(VK_LSHIFT) & 0x8000 && mState != falling)
		lWalkingSpeed = gPlayerMovementSpeed*2;
		
	KeyBoardMovement(lWalkingSpeed, mDeltaTime);
		
	mWorldHandler->Update(mDeltaTime);
	mParticleHandler->Update(mDeltaTime, mGameTime);
	
	UpdateSunWVP();
	mGameTimer->Tick();
	mDeltaTime = mGameTimer->GetDeltaTime();
	mGameTime = mGameTimer->GetGameTime();

	//tror det är skillnaden i position i z ledet som ska in som offset, might be wrong, kör på 50 sålänge
	GetCamera().BuildViewReflection(50.0f);
	GetCamera().RebuildView();	
}
Пример #17
0
IZ_BOOL StateMoveToItem::Enter(
    izanagi::IMemoryAllocator* allocator,
    izanagi::graph::CGraphicsDevice* device,
    izanagi::CValue& arg)
{
    PhotoItem* hitItem = (PhotoItem*)arg.GetValueAsPtr();
    IZ_ASSERT(hitItem != IZ_NULL);

    // Keep camera matrix.
    izanagi::math::SMatrix44::Copy(m_CamMtx, GetCamera().GetTransform());

    const izanagi::math::SMatrix44& globalRotMtx = PhotoItemManager::Instance().GetRotationMtx();

    // Compute target matrix.
    {
        izanagi::math::SVector4 pos;
        hitItem->GetCenterPosition(pos);
        izanagi::math::SMatrix44::Apply(pos, pos, globalRotMtx);

        izanagi::math::SVector4 nml;
        hitItem->GetNormal(nml);
        izanagi::math::SMatrix44::ApplyXYZ(nml, nml, globalRotMtx);

        izanagi::math::CVector4 targetPos(
            pos.x + nml.x * Configure::CameraDistanceFromItem,
            pos.y + nml.y * Configure::CameraDistanceFromItem,
            pos.z + nml.z * Configure::CameraDistanceFromItem);
    
        izanagi::math::CVector4 targetAt(pos);

        izanagi::CVectorCamera tmpCam;
        tmpCam.Init(
            targetPos,
            targetAt,
            1.0f,
            500.0f,
            izanagi::math::CMath::Deg2Rad(60.0f),
            1.0f);
        tmpCam.Update();

        izanagi::math::SMatrix44::Copy(m_TargetMtx, tmpCam.GetTransform());
    }

    m_State = State_Move;

    m_Timeline.Reset();
    m_Timeline.Start();

    return IZ_TRUE;
}
Пример #18
0
void Tree::Draw()
{
	D3DXMATRIXA16 a = GetCamera().GetViewMatrix() * GetCamera().GetProjectionMatrix();
	mShaderObject->SetMatrix("viewProj", a);
	mShaderObject->SetFloat3("eyePosW", GetCamera().GetPosition());
	

	mDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_POINTLIST);
	
	UINT stride = sizeof(BillboardVertex);
	UINT offset = 0;

	mDevice->IASetVertexBuffers(0, 1, &mVertexBuffer, &stride, &offset);

	D3D10_TECHNIQUE_DESC techDesc;
	
	mShaderObject->GetTechnique()->GetDesc( &techDesc );
    for(UINT p = 0; p < techDesc.Passes; ++p)
    {
		mShaderObject->Render(p);
		mDevice->Draw(1,0);
    }
}
Пример #19
0
void TurnCamera( float x,float y ){
	void* pcam = GetCamera();
	if( pcam ){
		float xx = x*32/9;
		float yy = y*32/9;
		__asm{
			mov ecx,pcam
			push 0
			push yy
			push xx
			call g_chTurnCamera.pEntryFunc
		}
	}
}
Пример #20
0
void 
ViewerRenderer::Zoom(float delta)
{
	float cameraPosition[3], cameraTarget[3], cameraUp[3];
	GetCamera(cameraPosition, cameraTarget, cameraUp);

	for (int i = 0; i < 3; i++)
	{
		cameraPosition[i] = cameraTarget[i] +
			(delta + 1.f) * (cameraPosition[i] - cameraTarget[i]);
	}
	
	SetCamera(cameraPosition, cameraTarget, cameraUp);
}
Пример #21
0
int GNewObjectHandler::OnMouseMove(UINT nFlags, Point &point)
{
	Point pw,pl;
	Point p ;
	view->World2Screen(GetCamera().target,p);
	point.z = p.z; // which depth plane ?? 
	MapPoint(point,pw,pl);
	CString s;
	s.Format("%g %g %g",pl.x,pl.y,pl.z);
	UpdateDialogValue(s);

//	TRACE("%s:OnMouseMove (%f %f %f) %x \n",this->ClassName(),point.x,point.y,point.z,nFlags);
	return(EV_OK);
}							
Пример #22
0
	//ビュー類の作成
	void GameStage::CreateViews(){
		//最初にデフォルトのレンダリングターゲット類を作成する
		CreateDefaultRenderTargets();
		//マルチビューコンポーネントの取得
		auto PtrMultiView = GetComponent<MultiView>();
		//マルチビューにビューの追加
		auto PtrView = PtrMultiView->AddView();
		//ビューの矩形を設定(ゲームサイズ全体)
		Rect2D<float> rect(0, 0, (float)App::GetApp()->GetGameWidth(), (float)App::GetApp()->GetGameHeight());
		//最初のビューにパラメータの設定
		PtrView->ResetParamaters<LookAtCamera, MultiLight>(rect, Color4(0.0f, 0.125f, 0.3f, 1.0f), 1, 0.0f, 1.0f);
		auto PtrCamera = PtrView->GetCamera();
		PtrCamera->SetEye(Vector3(0.0f, 2.0f, -5.0f));
		PtrCamera->SetAt(Vector3(0.0f, 0.0f, 0.0f));
	}
Пример #23
0
void MyScene::Projection()
{

	if (GetCamera()->projection)
	{
		gluPerspective(60.0, (GLdouble)windowWidth / (GLdouble)windowHeight, 1.0, 100000.0);
		//printf("pers\n");
	}
	else
	{
		//printf("orth\n");
		glOrtho(-1000, 1000, -1000, 1000, 10, 10000);
	}

}
Пример #24
0
void EditDialog::InitCamera(const ee::SprPtr& spr) const
{
	auto canvas = std::dynamic_pointer_cast<ee::CameraCanvas>(m_stage->GetCanvas());
	auto cam = canvas->GetCamera();
	if (cam->Type() == s2::CAM_PSEUDO3D) {
		return;
	}

	wxSize sz = GetSize();
	sm::vec2 r_sz = spr->GetBounding().GetSize().Size();
	float scale = std::min(sz.GetWidth() / r_sz.x, sz.GetHeight() / r_sz.y);

	auto ortho_cam = std::dynamic_pointer_cast<s2::OrthoCamera>(cam);
	ortho_cam->Set(sm::vec2(0, 0), 1 / scale);
}
Пример #25
0
void Terrain::draw(const D3DXMATRIX& world)
{
	md3dDevice->IASetInputLayout(InputLayout::PosNormalTex);

	UINT stride = sizeof(TerrainVertex);
    UINT offset = 0;
    md3dDevice->IASetVertexBuffers(0, 1, &mVB, &stride, &offset);
	md3dDevice->IASetIndexBuffer(mIB, DXGI_FORMAT_R32_UINT, 0);

	D3DXMATRIX view = GetCamera().view();
	D3DXMATRIX proj = GetCamera().proj();

	D3DXMATRIX WVP = world*view*proj;


	mfxWVPVar->SetMatrix((float*)&WVP);
	mfxWorldVar->SetMatrix((float*)&world);

	mfxLayer0Var->SetResource(mLayer0);
	mfxLayer1Var->SetResource(mLayer1);
	mfxLayer2Var->SetResource(mLayer2);
	mfxLayer3Var->SetResource(mLayer3);
	mfxLayer4Var->SetResource(mLayer4);
	mfxBlendMapVar->SetResource(mBlendMap);

    D3D10_TECHNIQUE_DESC techDesc;
    mTech->GetDesc( &techDesc );

    for(UINT i = 0; i < techDesc.Passes; ++i)
    {
        ID3D10EffectPass* pass = mTech->GetPassByIndex(i);
		pass->Apply(0);

		md3dDevice->DrawIndexed(mNumFaces*3, 0, 0);
	}	
}
Пример #26
0
// 更新.
void UnityChanApp::UpdateInternal(izanagi::graph::CGraphicsDevice* device)
{
    GetCamera().Update();

    if (m_enableStepAnm) {
        if (m_step) {
            m_Timeline.Advance(16.67f / 1000.0f);
        }
        m_step = IZ_FALSE;
    }
    else {
        // 時間更新
        IZ_FLOAT fElapsed = GetTimer(0).GetTime();
        fElapsed /= 1000.0f;
        m_Timeline.Advance(fElapsed);
    }

    //m_Timeline.Advance(0.5f);
    IZ_FLOAT t = m_Timeline.GetTime();

    // アニメーション適用
    m_Mdl->ApplyAnimation(t, m_Anm);

    m_Mdl->Update();

    // レンダーグラフに登録
    m_RenderGraph->BeginRegister();
    {
        // 位置は原点なので
        m_RenderGraph->Register(
            GetCamera(),
            izanagi::math::CVector4(),
            m_Mdl);
    }
    m_RenderGraph->EndRegister();
}
Пример #27
0
void EngineRunningBase::DrawLensflare()
{
  // Lensflare: draw if the sparkling sun is on screen.
  if (!m_pLevel->IsCurrentRoomIndoors() && 
      GetEngine()->GetDayNightSky()->IsSparkleVisible())
  {
    // Make a bounding sphere around the sun coords.
    Vec3f sunPos = GetEngine()->GetDayNightSky()->GetSunPosition();
    BoundingSphere sunBs(sunPos, 50.0f); // sun's "radius"
    // Find out if the sun intersects the view frustum
    if (Frustum::Instance()->Contains(sunBs))
    {
      PCamera pCam = GetCamera();
      Assert(pCam.GetPtr());
      Vec3f eyePos(pCam->GetOrientation()->GetX(), 
                        pCam->GetOrientation()->GetY(), 
                        pCam->GetOrientation()->GetZ());

      // We have to draw the lens flare, unless the sun is obscured by part of 
      // the scene.
      // Test the line from camera to sun for obstructions.
      //Mgc::Segment3 seg;
      //seg.Origin() = Mgc::Vector3(eyePos.x, eyePos.y, eyePos.z);
      //seg.Direction() = Mgc::Vector3(
      //  sunPos.x - eyePos.x, 
      //  sunPos.y - eyePos.y, 
      //  sunPos.z - eyePos.z);

      // Do intersection test on the scenery for the current room.
      if (m_pLevel->GetScene()->LineIntersects(eyePos, sunPos, 1.0f /* some radius */ ))
      {
        return; // Sun is obscured.
      }

      // We should draw the lens flare. Get the Camera eye position and 
      // "look at" position (some point along the line we are pointing at).

      GetEngine()->PushColour(1.0f, 1.0f, 1.0f, 1.0f);

      //GetEngine()->GetLensflare()->Draw(
      //  GetEngine()->GetDayNightSky()->GetSunPosition(),
      //  eyePos,
      //  pCam->GetLookAtPos() );

      GetEngine()->PopColour();
    }
  }
}
Пример #28
0
void Test::PrepareCameraAnimation()
{
    Rect rect = rectSequence.front();
    curCameraPosition = GetRealPoint(rect.GetCenter());

    Camera* cam = GetCamera();
    cam->SetPosition(curCameraPosition);
    cam->SetDirection(DEF_CAMERA_DIRECTION);

    nextRectNum = 0;

    curCameraAngle = 0.f;
    float32 maxRotateAngle = 360.f;
    float32 timeToRotate = maxRotateAngle / SettingsManager::Instance()->GetCameraRotationSpeed();
    camRotateAnimation = new LinearAnimation<float32>(this, &curCameraAngle, maxRotateAngle, timeToRotate, Interpolation::LINEAR);
    camRotateAnimation->SetRepeatCount(-1);
}
Пример #29
0
void bsCamera::animate(void)
{
#if 0
	if(mNumFrames>0 && mAnimation)
	{
		double pos[3],dir[3],up[3];
		int gotpos, gotdir;
		GetCamera(mAnimation,mCurrentTime,&gotpos,pos,&gotdir,dir,up);
		if(gotpos) setPosition(Vec3f(pos[0],pos[1],pos[2]));
		if(gotdir)
		{
			setLookAt(Vec3f(pos[0]+dir[0],pos[1]+dir[1],pos[2]+dir[2]));
			setUpVector(Vec3f(up[0],up[1],up[2]));
		}
	}
#endif
}
Пример #30
0
	// Updated version of the lens flare render.
    void Render( Context * pcontext )
    {
        m_vec = Vector(0, 0, 1);

        const Rect& rect        = GetViewRect()->GetValue();
              Point pointCenter = rect.Center();
              float scale       = rect.XSize() / 800.0f;

        Point pointLight;
		if( GetCamera()->TransformDirectionToImage( m_vec, pointLight )) 
		{
            pointLight = rect.TransformNDCToImage(pointLight);

            if( rect.Inside( pointLight ) ) 
			{
                pointLight = pointLight - pointCenter;

				pcontext->SetBlendMode(BlendModeAdd);
				pcontext->SetShadeMode(ShadeModeFlat);
                pcontext->Translate(pointCenter);

				int count = ArrayCount(g_lensFlareData);

				for(int index = 0; index < count; index++) 
				{
					pcontext->PushState();

					pcontext->Translate(pointLight * g_lensFlareData[index].m_pos);
                    pcontext->Scale2(scale * g_lensFlareData[index].m_scale);

					float angle = 0;
					int indexSurface = g_lensFlareData[index].m_index;

					if (indexSurface == 1) 
					{
						pcontext->Rotate((pointLight.X() + pointLight.Y()) / 200.0f);
					}

                    pcontext->DrawImage3D(m_psurfaces[indexSurface], g_lensFlareData[index].m_color, true);
					pcontext->PopState();
				}
            }
		}
    }