Exemple #1
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pIterator - 
//-----------------------------------------------------------------------------
void CSplashParticle::SimulateParticles( CParticleSimulateIterator *pIterator )
{
	float timeDelta = pIterator->GetTimeDelta();

	SimpleParticle *pParticle = (SimpleParticle*)pIterator->GetFirst();
	
	while ( pParticle )
	{
		//Update velocity
		UpdateVelocity( pParticle, timeDelta );
		pParticle->m_Pos += pParticle->m_vecVelocity * timeDelta;

		// Clip by height if requested
		if ( m_bUseClipHeight )
		{
			// See if we're below, and therefore need to clip
			if ( pParticle->m_Pos.z + UpdateScale( pParticle ) < m_flClipHeight )
			{
				pIterator->RemoveParticle( pParticle );
				pParticle = (SimpleParticle*)pIterator->GetNext();
				continue;
			}
		}

		//Should this particle die?
		pParticle->m_flLifetime += timeDelta;
		UpdateRoll( pParticle, timeDelta );

		if ( pParticle->m_flLifetime >= pParticle->m_flDieTime )
			pIterator->RemoveParticle( pParticle );

		pParticle = (SimpleParticle*)pIterator->GetNext();
	}
}
//-----------------------------------------------------------------------------
// Purpose: Simulate motion and render all child particles
// Input  : *pInParticle - 
//			*pDraw - 
//			&sortKey - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CSimpleEmitter::SimulateAndRender( Particle *pInParticle, ParticleDraw *pDraw, float &sortKey)
{
	SimpleParticle *pParticle = (SimpleParticle *) pInParticle;
	float timeDelta = pDraw->GetTimeDelta();

	//Render
	Vector	tPos;

	TransformParticle( g_ParticleMgr.GetModelView(), pParticle->m_Pos, tPos );
	sortKey = (int) tPos.z;

	//Render it
	RenderParticle_ColorSizeAngle(
		pDraw,
		tPos,
		UpdateColor( pParticle, timeDelta ),
		UpdateAlpha( pParticle, timeDelta ) * GetAlphaDistanceFade( tPos, m_flNearClipMin, m_flNearClipMax ),
		UpdateScale( pParticle, timeDelta ),
		UpdateRoll( pParticle, timeDelta ) );

	//Update velocity
	UpdateVelocity( pParticle, timeDelta );
	pParticle->m_Pos += pParticle->m_vecVelocity * timeDelta;

	//Should this particle die?
	pParticle->m_flLifetime += timeDelta;

	if ( pParticle->m_flLifetime >= pParticle->m_flDieTime )
		return false;

	return true;
}
Exemple #3
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_FireSmoke::Update( void )
{
	//If we haven't already, find the clip plane for smoke effects
	if ( ( m_nFlags & bitsFIRESMOKE_SMOKE ) && ( m_bClipTested == false ) )
	{
		FindClipPlane();
	}

	//Update all our parts
	UpdateEffects();
	UpdateScale();
	UpdateAnimation();
	UpdateFlames();

	//See if we should emit smoke
	if ( m_nFlags & bitsFIRESMOKE_SMOKE )
	{
		float tempDelta = Helper_GetFrameTime();

		while( m_tParticleSpawn.NextEvent( tempDelta ) )
		{
			SpawnSmoke();
		}
	}
}
Exemple #4
0
    void TranslationTool::ImpulseBegin(const Ray& ray) {
        UpdateScale();

        Vector3f position = transformable->GetPosition();
        Matrix transform = Matrix::CreateScale(Vector3f(scale)) * Matrix::CreateTranslation(position);
        BoundingBox xBox = BoundingBox::Transform(xAxisBBox, transform);    
        BoundingBox yBox = BoundingBox::Transform(yAxisBBox, transform);
        BoundingBox zBox = BoundingBox::Transform(zAxisBBox, transform);

        F32 distance;
        if (ray.Intersects(xBox, &distance)) {
            if (ray.Intersects(Plane(Vector3f::Up, -position.y), &distance)) {
                type = XAxis;
                prevPoint = ray.GetOrigin() + ray.GetDirection() * distance;
            }
        } else if (ray.Intersects(yBox, &distance)) {
            if (ray.Intersects(Plane(Vector3f::Backward, -position.z), &distance)) {
                type = YAxis;
                prevPoint = ray.GetOrigin() + ray.GetDirection() * distance;
            }
        } else if (ray.Intersects(zBox, &distance)) {
            if (ray.Intersects(Plane(Vector3f::Right, -position.x), &distance)) {
                type = ZAxis;
                prevPoint = ray.GetOrigin() + ray.GetDirection() * distance;
            }
        }
    }
void CLocalSpaceEmitter::RenderParticles( CParticleRenderIterator *pIterator )
{
	const matrix3x4_t &mLocalToWorld = GetTransformMatrix();
	const VMatrix &mModelView = ParticleMgr()->GetModelView();

	const SimpleParticle *pParticle = (const SimpleParticle *)pIterator->GetFirst();
	while ( pParticle )
	{
		// Transform it
		Vector screenPos, worldPos;
		VectorTransform( pParticle->m_Pos, mLocalToWorld, worldPos );
		
		// Correct viewmodel squashing
		if ( m_fFlags & FLE_VIEWMODEL )
		{
			FormatViewModelAttachment( NULL, worldPos, false );
		}

		TransformParticle( mModelView, worldPos, screenPos );
		
		float sortKey = (int) screenPos.z;

		// Render it
		RenderParticle_ColorSizeAngle(
			pIterator->GetParticleDraw(),
			screenPos,
			UpdateColor( pParticle ),
			UpdateAlpha( pParticle ) * GetAlphaDistanceFade( screenPos, m_flNearClipMin, m_flNearClipMax ),
			UpdateScale( pParticle ),
			pParticle->m_flRoll 
			);

		pParticle = (const SimpleParticle *)pIterator->GetNext( sortKey );
	}
}
bool FXBezier::Update( void )
{
	vec3_t	new_origin;
	float	ftime, time2;

	VectorMA( m_control1_velocity, cg.frametime * 0.001f, m_control1_acceleration, m_control1_velocity );
	VectorMA( m_control2_velocity, cg.frametime * 0.001f, m_control2_acceleration, m_control2_velocity );

	ftime = cg.frametime * 0.001f;
	time2 = ftime * ftime * 0.5f;

	for ( int i = 0 ; i < 3 ; i++ ) 
	{
		new_origin[i] = m_control1[i] + ftime * m_control1_velocity[i] + time2 * m_control1_velocity[i];
	}

	VectorCopy( new_origin, m_control1 );

	for ( i = 0 ; i < 3 ; i++ ) 
	{
		new_origin[i] = m_control2[i] + ftime * m_control2_velocity[i] + time2 * m_control2_velocity[i];
	}

	VectorCopy( new_origin, m_control2 );

	UpdateAlpha();
	UpdateScale();
	UpdateRGB();

	return true;
}
Exemple #7
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : fTimeDelta - 
//-----------------------------------------------------------------------------
void C_Plasma::Update( void )
{
	//Update all our parts
	UpdateScale();
	UpdateAnimation();
	UpdateFlames();

	if (m_flScaleRegister > 0.1)
	{
		float tempDelta = gpGlobals->frametime;
		while( m_tDecalSpawn.NextEvent( tempDelta ) )
		{
			// Add decal to floor
			C_BaseEntity *ent = cl_entitylist->GetEnt( 0 );
			if ( ent )
			{
				int index = decalsystem->GetDecalIndexForName( "PlasmaGlowFade" );
				if ( index >= 0 )
				{
					effects->DecalShoot( index, 0, ent->GetModel(), ent->GetAbsOrigin(), ent->GetAbsAngles(), GetAbsOrigin(), 0, 0 );
				}
			}
		}
	}
}
void OpSpeedDialView::DoLayout()
{
	OpRect rect = GetRect();
	m_background->GetBorderSkin()->AddPadding(rect);
	int scrollbar_width = static_cast<int>(m_content->GetScrollbarSize());
	scrollbar_width = min(scrollbar_width, rect.width);

	if (GetVisibleThumbnailCount() > 0)
	{
		// if number_of_columns is 0, number of colums are determined automatically
		int number_of_columns = g_pcui->GetIntegerPref(PrefsCollectionUI::NumberOfSpeedDialColumns);
		if (number_of_columns <= 0)
		{
			if (g_speeddial_manager->IsScaleAutomatic())
			{
				m_thumbnail_flow->ResetBreaks();
			}
			else
			{
				SetCellsSizes();
				m_thumbnail_flow->FitToWidth(rect.width - scrollbar_width);
			}
		}
		else
		{
			if (!SpeedDialManager::GetInstance()->IsScaleAutomatic())
			{
				/* if we are in automatic mode cells sizes will be set in UpdateScale()
				   and this if is cheaper than redundant call of SetCellsSizes
				 */
				SetCellsSizes();
			}
			m_thumbnail_flow->SetHardBreak(number_of_columns);
		}

		if (g_speeddial_manager->IsScaleAutomatic())
		{
			SetMinimumAndPreferredSizes();
			OpRect modified_rect = rect;
			modified_rect.width  -= scrollbar_width;
			modified_rect.height -= static_cast<int>(m_top_line_layout->GetPreferredHeight(modified_rect.width));
			m_thumbnail_flow->FitToRect(modified_rect);
			// QuickFlowLayout calculated new dimensions for speed dial's cells so we must set new scale
			UpdateScale();
		}

		if (m_global_config_dialog != NULL)
			m_global_config_dialog->OnThumbnailScaleChanged(g_speeddial_manager->GetThumbnailScale());

		UpdateZoomButton();
	}

	OpWindow* window = GetParentOpWindow();
	unsigned window_width, window_height;
	window->GetInnerSize(&window_width, &window_height);
	m_top_line_layout->CropToWidth(window_width, scrollbar_width);

	m_content->Layout(GetBounds());
}
	void GOComponent::NotifyOwnerGO()
	{
		GameObjectPtr ownerGO = mOwnerGO.lock();
		if (!ownerGO.get()) return;
		UpdatePosition(ownerGO->GetGlobalPosition());
		UpdateOrientation(ownerGO->GetGlobalOrientation());
		UpdateScale(ownerGO->GetGlobalScale());
	}
bool FXQuad::Update( void )
{
	UpdateRoll();
	UpdateScale();
	UpdateAlpha();
	UpdateRGB();

	return true;
}
bool FXCylinder::Update( void )
{
	UpdateScale();
	UpdateHeight();
	UpdateAlpha();
	UpdateRGB();

	return true;
}
Exemple #12
0
void reGizmoHandle::Draw() {
	UpdateScale();

	rRenderMode renderMode = m_engine->renderer->GetModelRenderMode();
	m_engine->renderer->SetModelRenderMode(_renderModeOverride);

	rProp::Draw();

	m_engine->renderer->SetModelRenderMode(renderMode);
}
bool FXPrimitive::Update( void )
{
	//Move the object
	UpdateOrigin();

	UpdateScale();
	UpdateAlpha();
	UpdateRGB();

	return true;
}
Exemple #14
0
void CHUDDamageDir::UpdateLayout()
{
	int nCurrentLayout = GetConsoleInt("HUDLayout",0);

	m_nSize = g_pLayoutMgr->GetDamageSize(nCurrentLayout);

	if (m_nSize == 0)
		m_nSize = 48;

	UpdateScale();

}
Exemple #15
0
void RigidBody::CreateCollisionShape()
{
    RemoveCollisionShape();
    
    float3 sizeVec = size.Get();
    // Sanitize the size
    if (sizeVec.x < 0)
        sizeVec.x = 0;
    if (sizeVec.y < 0)
        sizeVec.y = 0;
    if (sizeVec.z < 0)
        sizeVec.z = 0;
        
    switch (shapeType.Get())
    {
    case Box:
        // Note: Bullet uses box halfsize
        impl->shape = new btBoxShape(btVector3(sizeVec.x * 0.5f, sizeVec.y * 0.5f, sizeVec.z * 0.5f));
        break;
    case Sphere:
        impl->shape = new btSphereShape(sizeVec.x * 0.5f);
        break;
    case Cylinder:
        impl->shape = new btCylinderShape(btVector3(sizeVec.x * 0.5f, sizeVec.y * 0.5f, sizeVec.z * 0.5f));
        break;
    case Capsule:
        impl->shape = new btCapsuleShape(sizeVec.x * 0.5f, sizeVec.y * 0.5f);
        break;
    case TriMesh:
        if (impl->triangleMesh)
        {
            // Need to first create a bvhTriangleMeshShape, then a scaled version of it to allow for individual scaling.
            impl->childShape = new btBvhTriangleMeshShape(impl->triangleMesh.get(), true, true);
            impl->shape = new btScaledBvhTriangleMeshShape(static_cast<btBvhTriangleMeshShape*>(impl->childShape), btVector3(1.0f, 1.0f, 1.0f));
        }
        break;
    case HeightField:
        CreateHeightFieldFromTerrain();
        break;
    case ConvexHull:
        CreateConvexHullSetShape();
        break;
    case Cone:
        impl->shape = new btConeShape(sizeVec.x * 0.5f, sizeVec.y);
        break;
    }
    
    UpdateScale();
    
    // If body already exists, set the new collision shape, and remove/readd the body to the physics world to make sure Bullet's internal representations are updated
    ReaddBody();
}
Exemple #16
0
SearchBarSpinner::SearchBarSpinner()
  : nux::View(NUX_TRACKER_LOCATION)
  , scale(1.0)
  , state_(STATE_READY)
  , search_timeout_(-1)
  , rotation_(0.0f)
{
  rotate_.Identity();
  rotate_.Rotate_z(0.0);
  UpdateScale(scale);

  scale.changed.connect(sigc::mem_fun(this, &SearchBarSpinner::UpdateScale));
}
void ScoreCounterProcess::UpdateImage()
{
	if(m_pScoreImage)
		g_pApp->GetGfxMgr()->RemoveElement(m_pScoreImage);
		
	std::ostringstream stream;
	stream << m_currentScore;
		
	m_pScoreImage.reset(new GfxText(2, "operator.ttf", stream.str()));
	g_pApp->GetGfxMgr()->AddElement(m_pScoreImage);
	m_pScoreImage->SetPosition(m_posX, m_posY);
	UpdateScale();
}
bool FXTrail::Update( void )
{
	//Move the object
	UpdateOrigin();

	UpdateTailPoint();

	UpdateScale();
	UpdateAlpha();
	UpdateRGB();

	return true;
}
void CCEtoODBView::recallView(CNamedView& namedView)
{
   ScaleNum   = namedView.getScaleNum();
   ScaleDenom = namedView.getScaleDenom();

   UpdateScale();

   SetXPos(namedView.getScrollX());
   SetYPos(namedView.getScrollY());

   GetDocument()->setLayerViewData(namedView);
   GetDocument()->UpdateAllViews(NULL);
}
Exemple #20
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pParticle - 
// Output : float
//-----------------------------------------------------------------------------
float CSplashParticle::UpdateAlpha( const SimpleParticle *pParticle )
{
	if ( m_bUseClipHeight )
	{
		float flAlpha = pParticle->m_uchStartAlpha / 255.0f;

		return  flAlpha * RemapValClamped(pParticle->m_Pos.z,
								m_flClipHeight,
								m_flClipHeight - ( UpdateScale( pParticle ) * 0.5f ),
								1.0f,
								0.0f );
	}

	return (pParticle->m_uchStartAlpha/255.0f) + ( (float)(pParticle->m_uchEndAlpha/255.0f) - (float)(pParticle->m_uchStartAlpha/255.0f) ) * (pParticle->m_flLifetime / pParticle->m_flDieTime);
}
bool FXSprite::Update( void )
{
	if (m_start_time > cg.time)
	{//i was created in the future, right after un-pausing
		return false;
	}
	//Move the object
	UpdateOrigin();

	UpdateRoll();
	UpdateScale();
	UpdateAlpha();
	UpdateRGB();

	return true;
}
	virtual void Update( float deltaTime )
	{	
		AU_ASSERT(m_pBehaviorTree);
		m_pBehaviorTree->Execute(this);
		
		AU_ASSERT(m_pBehavior);
		IBehavior* pBehavior = m_pBehavior; //Demo
		
		pBehavior->Update(deltaTime);

		UpdateScale();
		m_scaleModulationTime += deltaTime;
		
		//m_pRenMesh->SetColor( AUColor(1,1,1) ); // Demo

		SetRotation((float)M_PI_4 * 0.5f * deltaTime); // Demo
	}
	void GOComponent::ReceiveMessage(Msg &msg)
	{
		if (msg.typeID == GameObject::MessageIDs::UPDATE_COMPONENT_TRANSFORM)
		{
			GameObjectPtr owner = mOwnerGO.lock();
			if (owner)
			{
				UpdatePosition(owner->GetGlobalPosition());
				UpdateOrientation(owner->GetGlobalOrientation());
			}
		}
		if (msg.typeID == GameObject::MessageIDs::UPDATE_COMPONENT_POSITION)
			UpdatePosition(msg.params.GetValue<Ogre::Vector3>(0));
		else if (msg.typeID == GameObject::MessageIDs::UPDATE_COMPONENT_ORIENTATION)
			UpdateOrientation(msg.params.GetValue<Ogre::Quaternion>(0));
		else if (msg.typeID == GameObject::MessageIDs::UPDATE_COMPONENT_SCALE)
			UpdateScale(msg.params.GetValue<Ogre::Vector3>(0));
	}
Exemple #24
0
void Particle::Update ()
{
	if (!_alive) {
		return;
	}

	unsigned int udt = Time::GetDeltaTimeMS ();

	_timeAlive += udt;

	if (_timeAlive >= _lifetime) {
		_alive = false;

		return ;
	}

	UpdatePosition ();
	UpdateScale ();
}
Exemple #25
0
void CHUDDamageDir::Update()
{
	if (m_nSize <= 0)
	{
		m_bDraw = LTFALSE;
		return;
	}

	if (m_fScale != g_pInterfaceResMgr->GetXRatio())
		UpdateScale();

	float fAlphaRange = g_vtDamageMaxAlpha.GetFloat() - g_vtDamageMinAlpha.GetFloat();

	float fDamTotal = 0.0f;
	for (uint8 i = 0; i < kNumDamageSectors; i++)
	{
		float fDam = g_pPlayerMgr->GetDamageFromSector(i);
		fDam = LTCLAMP( fDam, 0.0f, 1.0f );

		if (g_vtDamageShowAll.GetFloat() > 0.0f && fDam < 0.1f)
			fDam = 0.1f;

		fDamTotal += fDam;

		uint8 nAlpha = 0;

			
		
		if (fDam > 0.0f)
		{
			float fA = g_vtDamageMinAlpha.GetFloat() + fDam * fAlphaRange;
			nAlpha = (uint8) (fA * 255.0f);
			
		}

		uint32 argbCol = SET_ARGB(nAlpha,255,255,255);
		g_pDrawPrim->SetRGBA(&m_Poly[i],argbCol);
	}

	m_bDraw = (fDamTotal > 0.0f);

}
Exemple #26
0
void PaymentPreview::SetupViews()
{
  full_data_layout_ = new nux::LayeredLayout();

  // layout to be used to show the info
  content_data_layout_ = new nux::VLayout();
  content_data_layout_->SetSpaceBetweenChildren(CONTENT_DATA_CHILDREN_SPACE.CP(scale));
  content_data_layout_->SetPadding(CONTENT_DATA_PADDING.CP(scale), CONTENT_DATA_PADDING.CP(scale), 0, CONTENT_DATA_PADDING.CP(scale));

  header_layout_ = GetHeader();

  content_data_layout_->AddLayout(header_layout_.GetPointer(), 1);

  body_layout_ = GetBody();
  content_data_layout_->AddLayout(body_layout_.GetPointer(), 1);

  footer_layout_ = GetFooter();
  content_data_layout_->AddLayout(footer_layout_.GetPointer(), 1);

  full_data_layout_->AddLayout(content_data_layout_.GetPointer());

  // layout to draw an overlay
  overlay_layout_ = new nux::VLayout();
  calculating_ = new StaticCairoText(
                                   "Performing purchase", true,
                                   NUX_TRACKER_LOCATION);

  OverlaySpinner* spinner_ = new OverlaySpinner();
  overlay_layout_->AddSpace(OVERLAY_LAYOUT_SPACE.CP(scale), 1);
  overlay_layout_->AddView(calculating_, 0, nux::MINOR_POSITION_CENTER);
  overlay_layout_->AddView(spinner_, 1, nux::MINOR_POSITION_CENTER);
  overlay_layout_->AddSpace(OVERLAY_LAYOUT_SPACE.CP(scale), 1);
  scale.changed.connect([this, spinner_] (double scale) { spinner_->scale = scale; });

  full_data_layout_->AddLayout(overlay_layout_.GetPointer());

  UpdateScale(scale);
  SetLayout(full_data_layout_.GetPointer());
}
Exemple #27
0
static NOINLINE int UpdateParam(equalizer* p)
{
	if (p->Codec.In.Format.Type == PACKET_AUDIO)
	{
		int n;
		const eqfilter *src;
		eqfilter *dst;

		src = Band44100;
		dst = p->Filter;
		for (n=0;n<MAXFILTER;++n,++src,++dst)
		{
			dst->alpha0 = fix_mul(src->alpha,Pow(p->Eq[n])-FIXC(1.));
			dst->beta = ACCFAST_BSHIFT(src->beta);
			dst->gamma = ACCFAST_BSHIFT(src->gamma);
		}

		p->ScalePreamp = Pow(p->Amplify);
		UpdateScale(p);
	}
	return ERR_NONE;
}
	void FringeTileEditor::Update()
	{
		if (isOn)
		{
			UpdateCamera();

			if (state == FTES_NONE)
			{
				UpdateSelect();
			}

			if (selectedEntity)
			{
				switch (state)
				{
				case FTES_NONE:
					UpdateOpportunity();
					break;

				case FTES_COMMAND:
					UpdateCommand();
					break;

				case FTES_MOVE:
					UpdateMove();
					break;

				case FTES_ROTATE:
					UpdateRotate();
					break;

				case FTES_SCALE:
					UpdateScale();
					break;
				}
			}
		}
	}
Exemple #29
0
void RigidBody::PlaceableUpdated(IAttribute* attribute, AttributeChange::Type /*change*/)
{
    // Do not respond to our own change
    if (impl->disconnected || !impl->body)
        return;
    
    Placeable* placeable = impl->placeable;
    if (!placeable)
        return;
    
    if (attribute == &placeable->transform)
    {
        // Important: when changing both transform and parent, always set parentref first, then transform
        // Otherwise the physics simulation may interpret things wrong and the object ends up
        // in an unintended location
        UpdatePosRotFromPlaceable();
        UpdateScale();

        // Since we programmatically changed the orientation of the object outside the simulation, we must recompute the 
        // inertia tensor matrix of the object manually (it's dependent on the world space orientation of the object)
        impl->body->updateInertiaTensor();
    }
}
void ScoreCounterProcess::VUpdate(unsigned int elapsedTime)
{
	if(m_score != m_currentScore)
	{
		m_bIsCounting = true;
		unsigned int speed = (m_score - m_currentScore)*elapsedTime*0.005f;
		
		if(speed > m_score - m_currentScore)
			m_currentScore = m_score;
		else if(speed < 1)
			m_currentScore += 1;
		else if(speed > 10)
			m_currentScore += 10;
		else
			m_currentScore += speed;
		
		UpdateImage();
	}
	
	if(m_bIsCounting)
	{
		m_angle += elapsedTime*0.008f;
		if(m_angle > 3*PI/2)
		{
			if(m_currentScore == m_score)
			{
				m_bIsCounting = false;
				m_angle = PI/2;
			}
			else
				m_angle -= PI;
		}
			
		m_currentScale = m_scale + fabs(cos(m_angle)*0.3f);
		UpdateScale();
	}
}