Esempio n. 1
0
void CFlashAnimation::RepositionFlashAnimation()
{
	if(m_pFlashPlayer)
	{
		IRenderer *pRenderer = gEnv->pRenderer;

		float fMovieRatio		=	((float)m_pFlashPlayer->GetWidth()) / ((float)m_pFlashPlayer->GetHeight());
		float fRenderRatio	=	((float)pRenderer->GetWidth()) / ((float)pRenderer->GetHeight());

		float fWidth				=	pRenderer->GetWidth();
		float fHeight				=	pRenderer->GetHeight();
		float fXPos = 0.0f;
		float fYPos = 0.0f;

		float fXOffset			= (fWidth - (fMovieRatio * fHeight));

		if(fRenderRatio != fMovieRatio && !(m_dock & eFD_Stretch))
		{
			fWidth = fWidth-fXOffset;

			if (m_dock & eFD_Left)
				fXPos = 0;
			else if (m_dock & eFD_Right)
				fXPos = fXOffset;
			else if (m_dock & eFD_Center)
				fXPos = fXOffset * 0.5;
		}

		m_pFlashPlayer->SetViewport(int(fXPos),0,int(fWidth),int(fHeight));
	}
}
Esempio n. 2
0
void PaintWidget::wheelEvent( QWheelEvent * event )
{
	IRenderer* renderer = MapData::instance()->renderer();
	if ( renderer == NULL )
		return;

	// 15 degrees is a full mousewheel "click"
	int numDegrees = event->delta() / 8 + m_wheelDelta;
	int numSteps = numDegrees / 15;
	m_wheelDelta = numDegrees % 15;

	// limit zoom
	int newZoom = m_request.zoom + numSteps;
	if ( newZoom < 0 )
		newZoom = 0;
	if ( newZoom > m_maxZoom )
		newZoom = m_maxZoom;

	// avoid looping event calls
	if ( newZoom == m_request.zoom )
		return;

	// zoom in/out on current mouse position
	m_request.center = renderer->Move( width() / 2 - event->x(), height() / 2 - event->y(), m_request );
	m_request.zoom = newZoom;
	m_request.center = renderer->Move( event->x() - width() / 2, event->y() - height() / 2, m_request );

	emit zoomChanged( newZoom );
	update();
	event->accept();
}
void CameraApplication::CreateCamera()
{
    if (!lastScene_)
        return;

    StringVector components;
    components.Push("Placeable");
    components.Push("Camera");
    Entity* cameraEntity = lastScene_->CreateEntity(0, components, AttributeChange::LocalOnly, false, false, true);
    if (!cameraEntity)
    {
        LogError("CameraApplication::CreateCamera: failed to create camera entity");
        return;
    }
    cameraEntity->SetName("FreeLookCamera");
    IRenderer* renderer = framework->Renderer();
    if (!renderer)
    {
        LogError("CameraApplication::CreateCamera: can not assign camera; no renderer assigned");
        return;
    }
    renderer->SetMainCamera(cameraEntity);
    TundraLogic* logic = framework->Module<TundraLogic>();
    if (logic)
        logic->SyncManager()->SetObserver(EntityPtr(cameraEntity));

    lastCamera_ = cameraEntity;

    lastScene_->EntityCreated.Connect(this, &CameraApplication::CheckCameraSpawnPos);

    CheckCameraSpawnPos(lastScene_->EntityByName("FreeLookCameraSpawnPos"), AttributeChange::Default);
}
Esempio n. 4
0
void PaintWidget::mouseMoveEvent( QMouseEvent* event )
{
	event->accept();
	if ( m_fixed || !m_mouseDown )
		return;
	if ( ( event->buttons() & Qt::LeftButton ) == 0 )
		return;
	int minDiff = 7;
#ifdef Q_WS_MAEMO_5
	minDiff = 15;
#endif
	if ( abs( event->x() - m_startMouseX ) + abs( event->y() - m_startMouseY ) > minDiff )
		m_drag = true;
	if ( !m_drag )
		return;

	IRenderer* renderer = MapData::instance()->renderer();
	if ( renderer == NULL )
		return;

	m_request.center = renderer->Move( event->x() - m_lastMouseX, event->y() - m_lastMouseY, m_request );
	m_lastMouseX = event->x();
	m_lastMouseY = event->y();

	setKeepPositionVisible( false );

	update();
}
Esempio n. 5
0
    void SkyDomeNode::_VRender(ISceneGraph* graph, chimera::RenderPath& path)
    {
        switch(path)
        {
        case CM_RENDERPATH_SKY :
            {
                if(m_textureHandle->VIsReady())
                {
                    m_textureHandle->VUpdate();
                    //LOG_CRITICAL_ERROR("remember me, this code is untested!, @sky.hlsl");
                    //tbd::TransformComponent* tc = m_actor->GetComponent<tbd::TransformComponent>(tbd::TransformComponent::COMPONENT_ID).lock().get();
                    //util::ICamera* cam = graph->GetCamera().get();
                    //tc->GetTransformation()->SetTranslate(cam->GetEyePos().x, cam->GetEyePos().y, cam->GetEyePos().z);
                    IRenderer* renderer = CmGetApp()->VGetHumanView()->VGetRenderer();
                    renderer->VPushWorldTransform(*VGetTransformation());
                    renderer->VSetTexture(eDiffuseColorSampler, m_textureHandle.get());
                    //chimera::GetContext()->OMSetDepthStencilState(chimera::m_pDepthCmpStencilState, 0);
                    m_pGeometry->VBind();
                    m_pGeometry->VDraw();
                    
                }
                else
                {
                    m_textureHandle = std::static_pointer_cast<IDeviceTexture>(CmGetApp()->VGetHumanView()->VGetVRamManager()->VGetHandle(m_TextureRes));
                }
            } break;
        }

    }
// ------------------------------------------------------------------------
void CInputDevice::CDebugPressedButtons::DebugRender()
{
	if (g_pInputCVars->i_debugDigitalButtons) 
	{
		static float deltaY = 15.f;
		static float startX = 50;
		static float startY = 400.f;
		static float fontSize = 1.2f;

		IRenderer* pRenderer = gEnv->pRenderer;
		if (pRenderer)
		{
			ColorF colDefault(1.f, 1.f, 0.f,1.f);
			m_textPos2d.x = startX;
			m_textPos2d.y = startY;
			pRenderer->Draw2dLabel(m_textPos2d.x, m_textPos2d.y, 1.1f, ColorF(0.f,1.f,0.f,1.f), false, "Controller's Digital Buttons Activity"); m_textPos2d.y+= deltaY;
			pRenderer->Draw2dLabel(m_textPos2d.x, m_textPos2d.y, 1.1f, ColorF(1.f,1.f,1.f,1.f), false, string().Format("CurrentFrame:[%d]", m_frameCnt)); m_textPos2d.y+= deltaY;

			for (size_t i=0, kSize=m_history.size(); i< kSize; ++i)
			{
				string s = string().Format("[%d] %s [%s]", m_history[i].frame, m_history[i].key.c_str(), m_history[i].state.c_str());
				pRenderer->Draw2dLabel(m_textPos2d.x, m_textPos2d.y, fontSize, m_history[i].color, false, s.c_str());
				m_textPos2d.y+= deltaY;
			}
			++m_frameCnt;
		}
	}
}
	virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		switch (event)
		{
		case eFE_Initialize:
			pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true );
			break;
		case eFE_Update:
			{
				ISystem *pSystem = GetISystem();
				IRenderer *pRenderer = gEnv->pRenderer;

				int sysMem = pSystem->GetUsedMemory();
				size_t vidMemThisFrame( 0 );
				size_t vidMemRecently( 0 );
				pRenderer->GetVideoMemoryUsageStats( vidMemThisFrame, vidMemRecently );
				int meshMem = 0;
				pRenderer->EF_Query(EFQ_Alloc_APIMesh, meshMem);
				
				ActivateOutput(pActInfo, OUT_SYSMEM, sysMem);
				// potentially unsafe if we start using >2gb of video memory...?
				ActivateOutput(pActInfo, OUT_VIDEOMEM_THISFRAME, int(vidMemThisFrame));
				ActivateOutput(pActInfo, OUT_VIDEOMEM_RECENTLY, int(vidMemRecently));
				ActivateOutput(pActInfo, OUT_MESHMEM, meshMem);
			}
			break;
		}
	}
Esempio n. 8
0
void View::ApplyToRenderer( IRenderer& Renderer ) const
{
	XTRACE_FUNCTION;

	Renderer.SetViewMatrix( GetViewMatrix() );
	Renderer.SetProjectionMatrix( GetProjectionMatrix() );
}
Esempio n. 9
0
void CStereoZoom::PrintDebugOutput()
{

  ICVar* pICVar = gEnv->pConsole->GetCVar("r_StereoScreenDist");
  float dist;
  if ( pICVar != NULL)
  {
    dist = pICVar->GetFVal();
  }
  else
  {
    dist = -10.f;
  }

  pICVar = gEnv->pConsole->GetCVar("r_StereoEyeDist");
  float eyedist;
  if ( pICVar != NULL)
  {
    eyedist = pICVar->GetFVal();
  }
  else
  {
    eyedist = -10.f;
  }


  IRenderer* pRenderer = gEnv->pRenderer;
  static float color[4] = {1,1,1,1};    
  float y=50.f, step1=15.f, step2=20.f, size1=1.3f, size2=1.5f;

  pRenderer->Draw2dLabel(5.0f,  y         , size2, color, false, "Current PlaneDist: %f", dist);
  pRenderer->Draw2dLabel(5.0f,  y += step1, size2, color, false, "Current EyeDist  : %f", eyedist);
}
Esempio n. 10
0
ExecutionResult ShaderSetUniformsCommand::execute(ICommandExecutor* executor)
{
    Scene& scene = *(executor->getScene());

    ExecutionResult result = ExecutionSuccessRedraw;

    // get shader by its ID
    ShaderMap &shaderMap = scene.m_shaderMap;
    ShaderMapIterator iter = shaderMap.find(m_shaderid);
    ShaderMapIterator iterEnd = shaderMap.end();

    if (iter != iterEnd)
    {
        Shader* shader = (*iter).second;

        if (shader)
        {
            // get uniform descriptions
            const std::vector<std::string> uniformDesc = m_uniforms;
            std::vector<std::string>::const_iterator uiterator;

            for (uiterator=uniformDesc.begin(); uiterator != uniformDesc.end(); ++uiterator)
            {
                // parse description string and create uniform object
                ShaderUniform* uniform = ShaderUniform::createFromStringDescription(*uiterator);
                if (uniform)
                {
                    shader->setUniform(*uniform);
                    delete uniform;
                }
                else
                {
                    LOG_ERROR("ShaderSetUniformsCommand", "Failed to parse uniform description");
                    result = ExecutionFailed;
                }
            }
        }
        else
        {
            // shader not found
            LOG_ERROR("ShaderSetUniformsCommand", "shader ID " << m_shaderid << " found but object was null");
            result = ExecutionFailed;
        }
    }
    else
    {
        // shader not found
        LOG_ERROR("ShaderSetUniformsCommand", "shader ID "<<m_shaderid<<" not found");
        result = ExecutionFailed;
    }

    if (result == ExecutionSuccessRedraw)
    {
        IRenderer* renderer = *((executor->getRendererList())->begin());
        renderer->forceCompositionWindowSystem();
    }

    return result;
}
Esempio n. 11
0
void PaintWidget::setDestination(qint16 x, quint16 y) {
	IRenderer* renderer = MapData::instance()->renderer();
	if ( renderer == NULL )
		return;

	UnsignedCoordinate coordinate(renderer->PointToCoordinate(x - width() / 2, y - height() / 2, m_request));
	RoutingLogic::instance()->setWaypoint( 0, coordinate ); //0 should be real current waypoint
}
Esempio n. 12
0
void PaintWidget::setSource(qint16 x, quint16 y) {
	IRenderer* renderer = MapData::instance()->renderer();
	if ( renderer == NULL )
		return;

	UnsignedCoordinate coordinate(renderer->PointToCoordinate(x - width() / 2, y - height() / 2, m_request));
	RoutingLogic::instance()->setSource( coordinate );
}
	virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		CRY_ASSERT(pActInfo != NULL);

		switch (event)
		{
		case eFE_Initialize:
			{
				pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false );
				Reset();
			}
			break;

		case eFE_Activate:
			{
				if (IsPortActive(pActInfo, eIN_Start))
				{
					pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true );
				}
				if (IsPortActive(pActInfo, eIN_Stop))
				{
					pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false );
				}
				if (IsPortActive(pActInfo, eIN_Reset))
				{
					Reset();
				}
			}
			break;

		case eFE_Update:
			{
				IRenderer *pRenderer = gEnv->pRenderer;

				float fFrameTime = gEnv->pTimer->GetFrameTime();
				float fFrameRate = gEnv->pTimer->GetFrameRate();
				int fFrameId = pRenderer->GetFrameID(false);

				m_fMinFrameRate = min(fFrameRate, m_fMinFrameRate);
				m_fMaxFrameRate = max(fFrameRate, m_fMaxFrameRate);
				m_fSumFrameRate += fFrameRate;
				++m_lFrameCounter;

				ActivateOutput(pActInfo, eOUT_FrameTime, fFrameTime);
				ActivateOutput(pActInfo, eOUT_FrameRate, fFrameRate);
				ActivateOutput(pActInfo, eOUT_FrameID, fFrameId);
				ActivateOutput(pActInfo, eOUT_Min, m_fMinFrameRate);
				ActivateOutput(pActInfo, eOUT_Max, m_fMaxFrameRate);
				ActivateOutput(pActInfo, eOUT_Average, (m_fSumFrameRate/m_lFrameCounter));
			}
			break;

		default:
			break;
 		}
	}
	void OnUpdate( SActivationInfo* pActInfo )
	{
		const Vec3 positionOffsetLocal = GetPortVec3( pActInfo, PORT_IN_POSITION_OFFSET_LOCAL );
		const float maxDistance = max( 0.f, GetPortFloat( pActInfo, PORT_IN_MAX_LENGTH ) );

		const CCamera& camera = GetISystem()->GetViewCamera();
		
		const Vec3 cameraDirection = camera.GetViewdir();
		const Vec3 cameraPositionWorld = camera.GetPosition();
		const Matrix33 cameraOrientation = Matrix33::CreateRotationVDir( cameraDirection );
		const Vec3 positionOffsetWorld = cameraOrientation * positionOffsetLocal;

		const Vec3 rayOriginWorld = cameraPositionWorld + positionOffsetWorld;
		const Vec3 raySegment = cameraDirection * maxDistance;


		IPhysicalWorld* pWorld = gEnv->pPhysicalWorld;

		const int objectTypes = ent_all;
		const unsigned int raycastFlags = rwi_stop_at_pierceable | rwi_colltype_any;

		ray_hit hit;
		const int hitCount = pWorld->RayWorldIntersection( rayOriginWorld, raySegment, objectTypes, raycastFlags, &hit, 1 );
		
		float hitDistance = maxDistance;
		if ( 0 < hitCount )
		{
			hitDistance = hit.dist;
		}

		const float timeDelta = 0.1f;
		const float smoothTime = max( 0.f, GetPortFloat( pActInfo, PORT_IN_SMOOTH_TIME ) );
		SmoothCD( m_smoothedHitDistance, m_hitDistanceChangeRate, timeDelta, hitDistance, smoothTime );
		
		ActivateOutput( pActInfo, PORT_OUT_FOCUS_DISTANCE, m_smoothedHitDistance );

		const float focusRangeFactor = max( 0.f, GetPortFloat( pActInfo, PORT_IN_FOCUS_RANGE_FACTOR ) );
		const float focusRange = focusRangeFactor * m_smoothedHitDistance;

		ActivateOutput( pActInfo, PORT_OUT_FOCUS_RANGE, focusRange );


		const bool drawDebugInfo = GetPortBool( pActInfo, PORT_IN_DEBUG_ENABLED );
		if ( ! drawDebugInfo )
		{
			return;
		}

		IRenderer* pRenderer = gEnv->pRenderer;
		IRenderAuxGeom* pRenderAuxGeom = pRenderer->GetIRenderAuxGeom();

		ColorB rayColor = ( 0 < hitCount ) ? ColorB( 255, 255, 0 ) : ColorB( 255, 0, 0 );
		pRenderAuxGeom->DrawSphere( hit.pt, 0.1f, rayColor );
		pRenderAuxGeom->DrawLine( rayOriginWorld, rayColor, hit.pt, rayColor );

	}
Esempio n. 15
0
	void BasicSkin::drawCheckBox(IRenderer &r, const AWidget &cb, bool checked)
	{
		IntRect boxBounds = cb.getBounds();
		boxBounds.max.x = boxBounds.min.x + boxBounds.height();
		boxBounds.pad(-2);

		static const Color borderColor(0, 0, 0);
		static const Color fillColor(96, 96, 96);
		static const Color fillColorPress(128, 128, 128);
		static const Color uncheckColor(48, 48, 48);

		if(cb.isPressed())
			r.setColor(fillColorPress);
		else
			r.setColor(fillColor);
		r.drawRect(boxBounds.pad(1), true); // Fill

		if(cb.isFocused())
			r.setColor(lightColor);
		else
			r.setColor(borderColor);
		r.drawRect(boxBounds, false); // Border

		if(checked)
			r.setColor(lightColor);
		else
			r.setColor(uncheckColor);
		r.drawRect(boxBounds.pad(-3, -4, -4, -3), true);
	}
Esempio n. 16
0
void PaintWidget::move(QVariantList list, QVariantList idlist) {
	if ( m_fixed )
		return;
		
	if (list.size() == 0) {
		return;
	}

	QMap<int, QPointF> touch_last_pos = touch_current_pos;
	
	for (unsigned i = 0; i < list.size(); i++) {
		touch_current_pos[idlist[i].toInt()] = list[i].value<QPointF>();
	}
	
	QPointF average = calcAverage(touch_current_pos);
	QPointF last_average = calcAverage(touch_last_pos);
	QPointF start_average = calcAverage(touch_start_pos);
	
	int minDiff = 7;
	if ( abs( average.x() - start_average.x() ) + abs( average.y() - start_average.y() ) > minDiff )
		m_drag = true;

	IRenderer* renderer = MapData::instance()->renderer();
	if ( renderer == NULL )
		return;
	
	m_request.center = renderer->Move( average.x() - last_average.x(), average.y() - last_average.y(), m_request );
	
	setKeepPositionVisible( false );
	
	if (touch_current_pos.size() > 1) {
		QPointF first = *touch_current_pos.begin();
		QPointF second = *(touch_current_pos.begin()+1);
		qreal distance = sqrt(pow(first.x() - second.x(), 2) + pow(first.y() - second.y(), 2));
		
		QPointF first_start = *touch_start_pos.begin();
		QPointF second_start = *(touch_start_pos.begin()+1);
		distance /= sqrt(pow(first_start.x() - second_start.x(), 2) + pow(first_start.y() - second_start.y(), 2));
		
		m_request.center = renderer->Move( width() / 2 - average.x(), height() / 2 - average.y(), m_request );
		m_request.zoom = m_startZoom + log2(distance);
		if ( m_request.zoom > m_maxZoom ) {
			m_request.zoom = m_maxZoom;
		}
		if ( m_request.zoom < 0 ) {
			m_request.zoom = 0;
		}
		m_request.virtualZoom = m_request.zoom - (int) m_request.zoom + 1;
		m_request.center = renderer->Move( average.x() - width() / 2, average.y() - height() / 2, m_request );
		emit zoomChanged( m_request.zoom );
	}
	
	update();
}
Esempio n. 17
0
	void BasicSkin::drawDragZone(IRenderer & r, const AWidget & dz)
	{
		IntRect bounds = dz.getBounds();

		static const Color fillColor(64, 64, 64);
		static const Color fillColorHover(72, 72, 72);

		r.setColor(dz.isHovered() ? fillColorHover : fillColor);
		if(dz.isFocused())
			r.setColor(Color(96,96,96));
		r.drawRect(bounds, true); // Fill
	}
Esempio n. 18
0
		void Tracer::Render3D() 
		{
			float startDist = curDistance;
			float endDist = curDistance + visibleLength;
			startDist = std::max(startDist, 8.f);
			endDist = std::min(endDist, length);

			if (startDist >= endDist || length < 8)
			{
				return;
			}
			
			Vector3 pos1 = startPos + dir * startDist;
			Vector3 pos2 = startPos + dir * endDist;
			IRenderer *r = client->GetRenderer();
			
			Vector4 col = { colour.x, colour.y, colour.z, 0.01f };

			r->SetColorAlphaPremultiplied(col*0.5f);
			
			float sizeScale = 1.f;
			if (player)
			{
				sizeScale = sizeScale*sqrt((pos1 - player->GetPosition()).GetLength());
			}

			if (EqualsIgnoringCase(r_renderer, "sw") && (int)opt_tracers == 1)
			{
				r->AddSprite(image, pos1, .025f, 0);
				r->AddSprite(image, (pos1+pos1+pos2)/3.f, .05f, 0);
				r->AddSprite(image, (pos1+pos2)/2.f, .05f, 0);
				r->AddSprite(image, (pos1+pos2+pos2)/3.f, .075f, 0);
				r->AddSprite(image, pos2, .1f, 0);
			}
			else if ((int)opt_tracers == 1)
			{
				r->AddLongSprite(image, pos1, pos2, 0.005f*sizeScale);
			}
			else if ((int)opt_tracers == 2)
			{
				ModelRenderParam param;
				param.matrix = matrix * Matrix4::Scale(0.01f*sizeScale);
				param.customColor = colour;
				r->RenderModel(model, param);
			}

			//r->AddSprite(image2, pos2, .2f, 0);

			if (dlight)
			{
				DynamicLightParam l;
				l.origin = (pos1 + pos2)*0.5f;
				l.radius = 2.f;
				l.type = DynamicLightTypePoint;
				l.color = colour;
				client->flashDlights.push_back(l);
			}
		}
Esempio n. 19
0
void PaintWidget::paintEvent( QPaintEvent* )
{
	if ( !isVisible() )
		return;

	IRenderer* renderer = MapData::instance()->renderer();
	if ( renderer == NULL )
		return;

	if ( m_fixed ){
		m_request.center = m_request.position.ToProjectedCoordinate();

		if ( GlobalSettings::autoRotation() )
		{
			//gradually change the screen rotation to match the heading
			double diff = m_request.rotation + m_request.heading;
			while ( diff <= -180 )
				diff += 360;
			while ( diff >= 180 )
				diff -=360;
			//to filter out noise stop when close enough
			if ( diff > 0 )
				diff = std::max( 0.0, diff - 15 );
			if ( diff < 0 )
				diff = std::min( 0.0, diff + 15 );
			m_request.rotation -= diff / 2;

			//normalize
			while ( m_request.rotation < 0 )
				m_request.rotation += 360;
			while ( m_request.rotation >= 360 )
				m_request.rotation -= 360;

			int radius = height() * 0.25;
			m_request.center = renderer->PointToCoordinate( 0, -radius, m_request );
		} else {
			m_request.rotation = 0;
		}
	} else {
		m_request.rotation = 0;
	}

	if (m_keepPositionVisible)
		m_request.center = m_request.position.ToProjectedCoordinate();

#ifndef SAILFISH
	QPainter painter( this );
	Timer time;
	renderer->Paint( &painter, m_request );
	qDebug() << "Rendering:" << time.elapsed() << "ms";
#endif
}
Esempio n. 20
0
void
DlgAtomics::update() {
//#if NAU_OPENGL_VERSION >= 420
	IRenderer *renderer = RENDERER;
	std::vector<unsigned int> atValues = renderer->getAtomicCounterValues();
	std::map<std::pair<std::string, unsigned int>, std::string>::iterator iter;
	iter = renderer->m_AtomicLabels.begin();
	for (unsigned int i = 0; i < renderer->m_AtomicLabels.size(); ++i, ++iter) {
		if (m_propertyGrid1->GetProperty(wxString(iter->second.c_str())))
			m_propertyGrid1->SetPropertyValue(wxString(iter->second.c_str()),(int)(atValues[i]));
	}
//#endif
}
Esempio n. 21
0
bool Default::beginScene (Core::Slackgine* sg, Core::Camera* cam)
{   
    if ( !initialize(sg) ) {
      return false;
    }
    
    IRenderer* renderer = sg->getRenderer();
    renderer->setProgram( m_program );
    
    m_matLookAt = LookatMatrix ( cam->transform().orientation(), cam->transform().translation() );
    
    return this->isOk();
}
NVECTOR2 IGraphicObject::GetBasePosOffset()
{
	IRenderer* pRenderer = GetScene()->GetRenderer();
	UINT mainWidth = pRenderer->GetMainBufferWidth();
	UINT mainHeight = pRenderer->GetMainBufferHeight();

	//Position Offset
	NVECTOR2 outBaseTopLeftPixel = *m_pBaseScreenSpacePosOffset;
	//mFunction_ConvertFloatVec2PixelVec(outBaseTopLeftPixel);
	outBaseTopLeftPixel.x = outBaseTopLeftPixel.x *float(mainWidth) / 2.0f;
	outBaseTopLeftPixel.y = - outBaseTopLeftPixel.y * float(mainHeight) / 2.0f;
	return outBaseTopLeftPixel;
}
Esempio n. 23
0
	void BasicSkin::drawPushButton(IRenderer &r, const AWidget &btn)
	{
		IntRect bounds = btn.getBounds();

		static const Color borderColor(0, 0, 0);
		static const Color borderColorHover(0, 0, 0);
		static const Color fillColor(96, 96, 96);
		static const Color fillColorPress(112, 112, 112);

		if(btn.isPressed())
			r.setColor(fillColorPress);
		else
			r.setColor(fillColor);

		r.drawRect(bounds.pad(1), true); // Fill

		if(btn.isHovered())
		{
			if(btn.isFocused())
				r.setColor(lightColor);
			else
				r.setColor(borderColorHover);
		}
		else
		{
			if(btn.isFocused())
				r.setColor(lightColor);
			else
				r.setColor(borderColor);
		}

		r.drawRect(bounds, false); // Border
	}
Esempio n. 24
0
void HelpCommand::Execute() {
	IRenderer *pRenderer = GetEngine()->GetRenderer();
	pRenderer->Render("Available commands:\n");
	CommandFactory::CommandMap mapCommands = GetEngine()->GetCommandFactory()->GetCommandMap();

	CommandFactory::CommandMap::iterator itr;
	for (itr = mapCommands.begin(); itr != mapCommands.end(); itr++) {
		std::stringstream s;
		ICommand *pCommand = itr->second(GetEngine(), "");
		s << itr->first << " " << pCommand->GetParamTypes() << " " << pCommand->GetDescription() << "\n";
		pRenderer->Render(s.str());
		delete pCommand;
	}
}
Esempio n. 25
0
void CFlashMenuScreen::UpdateRatio()
{
    if(IsLoaded())
    {
        IFlashPlayer* pFlashPlayer = GetFlashPlayer();
        IRenderer* pRenderer = gEnv->pRenderer;

        // Native width/height/ratio
        float fMovieWidth			= (float) pFlashPlayer->GetWidth();
        float fMovieHeight		= (float) pFlashPlayer->GetHeight();
        float fMovieRatio			=	fMovieWidth / fMovieHeight;

        // Current renderer width/height/ratio
        float fRendererWidth	=	(float) pRenderer->GetWidth();
        float fRendererHeight	=	(float) pRenderer->GetHeight();
        float fRendererRatio	=	fRendererWidth / fRendererHeight;

        // Compute viewport so that it fits
        float fViewportX			= 0.0f;
        float fViewportY			= 0.0f;
        float fViewportWidth	= 0.0f;
        float fViewportHeight	= 0.0f;

        /*
        	All the Flash files have been designed either in 4/3 or 16/9 aspect ratios in resolutions
        	such as 1024x768 or 1366x768. Problem is that minimum aspect ratio is NOT 4/3 but 5/4,
        	mainly because of LCD monitors. We need to rescale accordingly in screen resolutions like
        	1280x1024	so that we use the file in its 4/3 mode. Hence, there is wasted place in both
        	vertical and horizontal areas but this is the only way to fits right.
        */

        if(fRendererRatio >= 4.0f/3.0f)
        {
            fViewportHeight	= fRendererHeight;

            fViewportX = (fRendererWidth - (fRendererHeight * fMovieRatio)) * 0.5f;
            fViewportWidth = fRendererHeight * fMovieRatio;
        }
        else
        {
            fViewportX = (fRendererWidth - ((fRendererWidth * 3.0f / 4.0f) * fMovieRatio)) * 0.5f;
            fViewportY = (fRendererHeight - (fRendererWidth * 3.0f / 4.0f)) * 0.5f;

            fViewportWidth = (fRendererWidth * 3.0f / 4.0f) * fMovieRatio;
            fViewportHeight = fRendererWidth * 3.0f / 4.0f;
        }

        pFlashPlayer->SetViewport((int)fViewportX,(int)fViewportY,(int)fViewportWidth,(int)fViewportHeight);
    }
}
Esempio n. 26
0
int main(void) 
{
	//_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
	Configuration *config = Configuration::getInstance();
	config->load("config.cfg");

	std::string type = config->getConfiguration("API");

	IRenderer* renderer = RendererFactory::makeRenderer(type);

	renderer->loop();

	return 0;
}
Esempio n. 27
0
void CRateOfDeathSimple::DebugDraw()
{
	IRenderer* pRenderer = gEnv->pRenderer;
	const float color[ 4 ] = { 1, 1, 1, 1 };

	float drawPosY = 20;

	pRenderer->Draw2dLabel( 5, drawPosY, 1.2f, color, false, "Rate of Death '%s'", m_pOwner->GetName() );
	drawPosY += 15;

	m_rateOfDeathTarget.DebugDraw( drawPosY );
	drawPosY += 15;

	pRenderer->Draw2dLabel( 5, drawPosY, 1.2f, color, false, "Can damage? %s", m_canDamageTarget ? "yes" : "no" );
	drawPosY += 15;

	pRenderer->Draw2dLabel( 10, drawPosY, 1.2f, color, false, "Target Offset <%f, %f, %f>", m_targetOffset.x, m_targetOffset.y, m_targetOffset.z );
	drawPosY += 15;

	pRenderer->Draw2dLabel( 10, drawPosY, 1.2f, color, false, "Miss Offset Update [%f/%f] [time left/ update interval]", m_missOffsetNextUpdateSeconds, m_missOffsetIntervalSeconds );
	drawPosY += 15;

	pRenderer->Draw2dLabel( 10, drawPosY, 1.2f, color, false, "Miss Range [%f-%f]", m_missMinRange, m_missMaxRange );
	drawPosY += 15;

	pRenderer->Draw2dLabel( 10, drawPosY, 1.2f, color, false, "Hit Offset Update [%f/%f] [time left/ update interval]", m_hitOffsetNextUpdateSeconds, m_hitOffsetIntervalSeconds );
	drawPosY += 15;

	pRenderer->Draw2dLabel( 10, drawPosY, 1.2f, color, false, "Hit Range [%f-%f]", m_hitMinRange, m_hitMaxRange );
	drawPosY += 15;
}
Esempio n. 28
0
void CRateOfDeathHelper_HealthThreshold::DebugDraw( float& drawPosY )
{
	IRenderer* pRenderer = gEnv->pRenderer;
	const float color[ 4 ] = { 1, 1, 1, 1 };

	pRenderer->Draw2dLabel( 20, drawPosY, 1.2f, color, false, "Stay Alive Time: %f", m_stayAliveTime );
	drawPosY += 15;

	pRenderer->Draw2dLabel( 20, drawPosY, 1.2f, color, false, "Normalized Health: %f", m_normalizedHealth );
	drawPosY += 15;

	pRenderer->Draw2dLabel( 20, drawPosY, 1.2f, color, false, "Normalized Health Threshold: %f", m_normalizedHealthThreshold );
	drawPosY += 15;
}
Esempio n. 29
0
void
MaterialSortRenderQueue::processQueue (void)
{
	PROFILE ("Process queue");

	IRenderer *renderer = RENDERER;

	std::map <int, std::map<Material*, std::vector<pair_MatGroup_Transform >* >* >::iterator renderQueueIter;

	renderQueueIter = m_RenderQueue.begin();

	for (; renderQueueIter != m_RenderQueue.end(); ++renderQueueIter) {
		std::map<Material*, std::vector<pair_MatGroup_Transform >* >::iterator materialMapIter;

		materialMapIter = (*renderQueueIter).second->begin();

		for (; materialMapIter != (*renderQueueIter).second->end(); materialMapIter++) {
			Material *aMat = (*materialMapIter).first;
			
			{
				PROFILE ("Material prepare");
				aMat->prepare();
			}
			
			std::vector<pair_MatGroup_Transform >::iterator matGroupsIter;

			matGroupsIter = (*materialMapIter).second->begin();
			
			{
				PROFILE ("Geometry rendering");
				for (; matGroupsIter != (*materialMapIter).second->end(); ++matGroupsIter) {
					bool b = (*matGroupsIter).second->isIdentity();
					if (!b) {
						renderer->pushMatrix(IRenderer::MODEL_MATRIX);
						renderer->applyTransform(IRenderer::MODEL_MATRIX, *(*matGroupsIter).second);
						aMat->setUniformValues();
						aMat->setUniformBlockValues();
					}
					{	PROFILE("Draw");
						renderer->drawGroup ((*matGroupsIter).first);
					}
					if (!b)
						renderer->popMatrix(IRenderer::MODEL_MATRIX);
				}
			}
			aMat->restore();
		}
	}
}
Esempio n. 30
0
	void Rendering::Update(GameObject* obj)
	{
		Camera* camera = obj->GetCamera();
		if( camera != 0 && camera->isEnabled() )
		{
			cameras.insert( camera );
			camera->containingSet = &cameras;
		}

		IRenderer* renderer = obj->GetRenderer();
		if( renderer != 0 )
		{
			renderer->ClearLights();

			if( renderer->renderableTreeLeaf == 0 )
			{
				renderer->renderableTreeLeaf = renderableTree.Insert(renderer);
				renderer->containingTree = &renderableTree;
			}
			else
				renderableTree.Update( renderer->renderableTreeLeaf );
		}
		
		ILight* light = obj->GetLight();
		if( light != 0 )
		{
			light->Update();
					
			if( light->GetLightType() != ILight::DIRECTIONAL )
			{
				IPointLight* pointlight = (IPointLight*)light;
						
				if( pointlight->lightTreeLeaf == 0 )
				{
					pointlight->lightTreeLeaf = lightTree.Insert(pointlight);
					pointlight->containingTree = &lightTree;
				}
				else
					lightTree.Update( pointlight->lightTreeLeaf );
			}
			else
			{
				IDirectionalLight* directionalLight = (IDirectionalLight*)light;

				directionalLightList.push_back( directionalLight );
				directionalLight->containingList = &directionalLightList;
			}
		}
	}