Example #1
0
END_CLASS

/*
==============
sdSnowEffect::Spawn
==============
*/
void				sdSnowEffect::Spawn( void ) {
    renderEntity_t *re = GetRenderEntity();

    re->numInsts = MAX_GROUPS;
    re->insts = new sdInstInfo[ re->numInsts ];

    idVec3 zero;
    idMat3 I;
    zero.Zero();
    I.Identity();
    this->SetPosition( zero, I );

    idBounds modelbb = re->hModel->Bounds();
    idVec3 extents = (modelbb.GetMaxs() - modelbb.GetMins()) * 0.5f;
    idPlayer *p = gameLocal.GetLocalViewPlayer();
    idVec3 const &v = p->GetViewPos();

    for (int i=0; i<MAX_GROUPS; i++) {
        groups[i].time = -1.f;
    }

    BecomeActive( TH_THINK );
    UpdateVisuals();
}
Example #2
0
/*
==============
sdRainEffect::Think
==============
*/
void		sdRainEffect::Think( void ) {
	renderEntity_t *re = GetRenderEntity();
	if ( re->hModel == NULL ) {
		return;
	}

	idBounds modelbb = re->hModel->Bounds();
	idVec3 extents = (modelbb.GetMaxs() - modelbb.GetMins()) * 0.5f;

	idPlayer *p = gameLocal.GetLocalViewPlayer();
	idVec3 const &v = p->GetViewPos();
	int gridx = idMath::Ftoi( idMath::Floor(v.x / extents.x) );
	int gridy = idMath::Ftoi( idMath::Floor(v.y / extents.y) );

	idBounds bounds;
	bounds.Clear();
	sdInstInfo *inst = re->insts;
	for (int y=-1; y<=1; y++) {
		for (int x=-1; x<=1; x++) {
			idBounds bb2;
			inst->fadeOrigin = inst->inst.origin = idVec3( (x + gridx) * extents.x, (y + gridy) * extents.y, v.z );
			inst->inst.axis.Identity();
			inst->maxVisDist = 0;
			inst->minVisDist = 0.f;
			bb2 = modelbb.Translate( inst->inst.origin );
			bounds.AddBounds( bb2 );
			inst++;
		}
	}
	re->flags.overridenBounds = true;
	re->bounds = bounds;

	UpdateVisuals();
	Present();
}
Example #3
0
/*
==============
sdSnowPrecipitation::sdSnowPrecipitation
==============
*/
sdSnowPrecipitation::sdSnowPrecipitation( sdPrecipitationParameters const &_parms ) : parms(_parms) {
    renderEntity_t *re = GetRenderEntity();

    renderEntityHandle = -1;
    memset( re, 0, sizeof( renderEntity ) );
    re->hModel = parms.model;

    re->axis.Identity();
    re->origin.Zero();

    re->numInsts = MAX_GROUPS;
    re->insts = new sdInstInfo[ re->numInsts ];

    idBounds modelbb = re->hModel->Bounds();
    idVec3 extents = (modelbb.GetMaxs() - modelbb.GetMins()) * 0.5f;
    idPlayer *p = gameLocal.GetLocalViewPlayer();
    idVec3 const &v = p->GetViewPos();

    for (int i=0; i<MAX_GROUPS; i++) {
        groups[i].time = -1.f;
    }

    SetupEffect();
}
Example #4
0
END_CLASS

/*
==============
sdRainEffect::Spawn
==============
*/
void		sdRainEffect::Spawn( void ) {
	renderEntity_t *re = GetRenderEntity();

	re->numInsts = 9;
	re->insts = new sdInstInfo[ re->numInsts ];

	idVec3 zero;
	idMat3 I;
	zero.Zero();
	I.Identity();
	this->SetPosition( zero, I );


	BecomeActive( TH_THINK );
	UpdateVisuals();

}
Example #5
0
/*
================
idTarget_SetInfluence::Event_RestoreInfluence
================
*/
void idTarget_SetInfluence::Event_RestoreInfluence()
{
	int i, j;
	idEntity *ent;
	idLight *light;
	idSound *sound;
	idStaticEntity *generic;
	bool update;
	idVec3 color;
	idVec4 colorTo;
	
	if( flashOut )
	{
		PostEventSec( &EV_Flash, 0.0f, flashOut, 1 );
	}
	
	if( switchToCamera )
	{
		switchToCamera->PostEventMS( &EV_Activate, 0.0f, this );
	}
	
	for( i = 0; i < genericList.Num(); i++ )
	{
		ent = gameLocal.entities[genericList[i]];
		if( ent == NULL )
		{
			continue;
		}
		generic = static_cast<idStaticEntity *>( ent );
		colorTo.Set( 1.0f, 1.0f, 1.0f, 1.0f );
		generic->Fade( colorTo, spawnArgs.GetFloat( "fade_time", "0.25" ) );
	}
	
	for( i = 0; i < lightList.Num(); i++ )
	{
		ent = gameLocal.entities[lightList[i]];
		if( ent == NULL || !ent->IsType( idLight::Type ) )
		{
			continue;
		}
		light = static_cast<idLight *>( ent );
		if( !light->spawnArgs.GetBool( "leave_demonic_mat" ) )
		{
			const char *texture = light->spawnArgs.GetString( "texture", "lights/squarelight1" );
			light->SetShader( texture );
		}
		color = light->spawnArgs.GetVector( "_color" );
		colorTo.Set( color.x, color.y, color.z, 1.0f );
		light->Fade( colorTo, spawnArgs.GetFloat( "fade_time", "0.25" ) );
	}
	
	for( i = 0; i < soundList.Num(); i++ )
	{
		ent = gameLocal.entities[soundList[i]];
		if( ent == NULL || !ent->IsType( idSound::Type ) )
		{
			continue;
		}
		sound = static_cast<idSound *>( ent );
		sound->StopSound( SND_CHANNEL_ANY, false );
		sound->SetSound( sound->spawnArgs.GetString( "s_shader" ) );
	}
	
	for( i = 0; i < guiList.Num(); i++ )
	{
		ent = gameLocal.entities[guiList[i]];
		if( ent == NULL || GetRenderEntity() == NULL )
		{
			continue;
		}
		update = false;
		for( j = 0; j < MAX_RENDERENTITY_GUI; j++ )
		{
			if( ent->GetRenderEntity()->gui[ j ] )
			{
#ifdef _D3XP
				ent->GetRenderEntity()->gui[ j ] = savedGuiList[i].gui[j];
#else
				ent->GetRenderEntity()->gui[ j ] = uiManager->FindGui( ent->spawnArgs.GetString( j == 0 ? "gui" : va( "gui%d", j + 1 ) ) );
#endif
				update = true;
			}
		}
		if( update )
		{
			ent->UpdateVisuals();
			ent->Present();
		}
	}
	
	idPlayer *player = gameLocal.GetLocalPlayer();
	player->SetInfluenceLevel( 0 );
	player->SetInfluenceView( NULL, NULL, 0.0f, NULL );
	player->SetInfluenceFov( 0 );
	gameLocal.SetGlobalMaterial( NULL );
	float fadeTime = spawnArgs.GetFloat( "fadeWorldSounds" );
	if( fadeTime )
	{
		gameSoundWorld->FadeSoundClasses( 0, 0.0f, fadeTime / 2.0f );
	}
	
}
Example #6
0
/*
==============
sdSnowEffect::Think
==============
*/
void		sdSnowEffect::Think( void ) {
    renderEntity_t *re = GetRenderEntity();
    if ( re->hModel == NULL ) {
        return;
    }

    idBounds modelbb = re->hModel->Bounds();
    idVec3 extents = (modelbb.GetMaxs() - modelbb.GetMins()) * 0.5f;

    idPlayer *p = gameLocal.GetLocalViewPlayer();
    idVec3 const &v = p->GetViewPos();

    for (int i=0; i<MAX_GROUPS; i++) {
        groups[i].time -= 1.f / 30.f;
        if ( groups[i].time < 0.f ) {
            groups[i].axis = idVec3( idRandom::StaticRandom().RandomFloat()- 0.15f , idRandom::StaticRandom().RandomFloat() - 0.5f , idRandom::StaticRandom().RandomFloat() - 0.5f );
            groups[i].axis.z *= 40.25f;
            groups[i].axis.Normalize();
            groups[i].rotate = 0.f;
            groups[i].rotateSpeed = idRandom::StaticRandom().RandomFloat() * 50.f + 50.f;
            groups[i].rotationPoint = idVec3( idRandom::StaticRandom().RandomFloat() * extents.x,
                                              idRandom::StaticRandom().RandomFloat() * extents.y,
                                              idRandom::StaticRandom().RandomFloat() * extents.z );

            groups[i].alpha = 0.f;
            groups[i].time = idRandom::StaticRandom().RandomFloat() * 1.f + 1.f;
            groups[i].worldPos = v + idVec3( (idRandom::StaticRandom().RandomFloat()-0.5f) * extents.x * 3,
                                             (idRandom::StaticRandom().RandomFloat()-0.5f) * extents.y * 3,
                                             (idRandom::StaticRandom().RandomFloat()-0.5f) * extents.z * 3 );
        } else {
            if ( groups[i].time > 0.25f ) {
                groups[i].alpha += 1.f / 7.5f;
                if ( groups[i].alpha > 1.f ) {
                    groups[i].alpha = 1.f;
                }
            } else {
                groups[i].alpha = groups[i].time * 4.f;
                if ( groups[i].alpha < 0.f ) {
                    groups[i].alpha = 0.f;
                }
            }
            groups[i].worldPos += idVec3( 0.f, 0.f, -600.f ) * 1.f / 30.f;
            groups[i].rotate += groups[i].rotateSpeed * 1.f / 30.f;
        }
    }


    int gridx = idMath::Ftoi( idMath::Floor(v.x / extents.x) );
    int gridy = idMath::Ftoi( idMath::Floor(v.y / extents.y) );

    idBounds bounds;
    bounds.Clear();
    sdInstInfo *inst = re->insts;
    for (int i=0; i<MAX_GROUPS; i++) {
        idRotation r( groups[i].rotationPoint, groups[i].axis, groups[i].rotate );

        idBounds bb2;
        inst->inst.color[0] = 0xff;
        inst->inst.color[1] = 0xff;
        inst->inst.color[2] = 0xff;
        inst->inst.color[3] = 0xff;
        inst->fadeOrigin = inst->inst.origin = groups[i].worldPos;
        inst->inst.axis = r.ToMat3();
        inst->maxVisDist = 0;
        inst->minVisDist = 0.f;
        bb2.FromTransformedBounds( modelbb, inst->inst.origin, inst->inst.axis );
        bounds.AddBounds( bb2 );
        inst++;
    }
    re->flags.overridenBounds = true;
    re->bounds = bounds;

    UpdateVisuals();
    Present();
}
Example #7
0
/*
==============
sdSnowPrecipitation::Update
==============
*/
void sdSnowPrecipitation::Update( void ) {
    renderEntity_t *re = GetRenderEntity();
    if ( re->hModel == NULL ) {
        return;
    }

    idBounds modelbb = re->hModel->Bounds();
    idVec3 extents = (modelbb.GetMaxs() - modelbb.GetMins()) * 0.5f;

    idPlayer *p = gameLocal.GetLocalViewPlayer();
    idVec3 const &v = p->GetViewPos();

    for (int i=0; i<MAX_GROUPS; i++) {
        groups[i].time -= 1.f / 30.f;
        if ( groups[i].time < 0.f ) {
            groups[i].axis = idVec3( idRandom::StaticRandom().RandomFloat()- 0.15f , idRandom::StaticRandom().RandomFloat() - 0.5f , idRandom::StaticRandom().RandomFloat() - 0.5f );
            groups[i].axis.z *= 40.25f;
            groups[i].axis.Normalize();
            groups[i].rotate = 0.f;
            groups[i].rotateSpeed = idRandom::StaticRandom().RandomFloat() * 50.f + 50.f;
            groups[i].rotationPoint = idVec3( idRandom::StaticRandom().RandomFloat() * extents.x,
                                              idRandom::StaticRandom().RandomFloat() * extents.y,
                                              idRandom::StaticRandom().RandomFloat() * extents.z );

            groups[i].alpha = 0.f;
            groups[i].time = idRandom::StaticRandom().RandomFloat() * 1.f + 1.f;
            groups[i].worldPos = v + idVec3( (idRandom::StaticRandom().RandomFloat()-0.5f) * extents.x * 3,
                                             (idRandom::StaticRandom().RandomFloat()-0.5f) * extents.y * 3,
                                             (idRandom::StaticRandom().RandomFloat()-0.5f) * extents.z * 3 );
        } else {
            if ( groups[i].time > 0.25f ) {
                groups[i].alpha += 1.f / 7.5f;
                if ( groups[i].alpha > 1.f ) {
                    groups[i].alpha = 1.f;
                }
            } else {
                groups[i].alpha = groups[i].time * 4.f;
                if ( groups[i].alpha < 0.f ) {
                    groups[i].alpha = 0.f;
                }
            }
            groups[i].worldPos += idVec3( 0.f, 0.f, -600.f ) * 1.f / 30.f;
            groups[i].rotate += groups[i].rotateSpeed * 1.f / 30.f;
        }
    }


    int gridx = idMath::Ftoi( idMath::Floor(v.x / extents.x) );
    int gridy = idMath::Ftoi( idMath::Floor(v.y / extents.y) );

    idBounds bounds;
    bounds.Clear();
    sdInstInfo *inst = re->insts;
    for (int i=0; i<MAX_GROUPS; i++) {
        idRotation r( groups[i].rotationPoint, groups[i].axis, groups[i].rotate );

        idBounds bb2;
        inst->inst.color[0] = 0xff;
        inst->inst.color[1] = 0xff;
        inst->inst.color[2] = 0xff;
        inst->inst.color[3] = 0xff;
        inst->fadeOrigin = inst->inst.origin = groups[i].worldPos;
        inst->inst.axis = r.ToMat3();
        inst->maxVisDist = 0;
        inst->minVisDist = 0.f;
        bb2.FromTransformedBounds( modelbb, inst->inst.origin, inst->inst.axis );
        bounds.AddBounds( bb2 );
        inst++;
    }
    re->flags.overridenBounds = true;
    re->bounds = bounds;

    if ( renderEntityHandle == -1 ) {
        renderEntityHandle = gameRenderWorld->AddEntityDef( re );
    } else {
        gameRenderWorld->UpdateEntityDef( renderEntityHandle, re );
    }

    if ( !effect.GetRenderEffect().declEffect ) return;

    idVec3 viewOrg;
    renderView_t view;
    if ( sdDemoManager::GetInstance().CalculateRenderView( &view ) ) {
        viewOrg = view.vieworg;
    } else {
        // If we are inside don't run the bacground effect
        idPlayer* player = gameLocal.GetLocalViewPlayer();

        if ( player == NULL ) {
            return;
        }
        viewOrg = player->GetRenderView()->vieworg;
    }

    int area = gameRenderWorld->PointInArea( viewOrg );
    bool runEffect = false;
    if ( area >= 0 ) {
        if ( gameRenderWorld->GetAreaPortalFlags( area ) & ( 1 << PORTAL_OUTSIDE ) ) {
            runEffect = true && !g_skipLocalizedPrecipitation.GetBool();
        }
    }

    // Update the background effect
    if ( runEffect ) {
        effect.GetRenderEffect().origin = viewOrg;
        if ( !effectRunning ) {
            effect.Start( gameLocal.time );
            effectRunning = true;
        } else {
            effect.Update();
        }
    } else {
        effect.StopDetach();
        effectRunning = false;
    }
}
Example #8
0
/*
==============
sdRainPrecipitation::Update
==============
*/
void sdRainPrecipitation::Update( void ) {
	renderEntity_t *re = GetRenderEntity();
	if ( re->hModel == NULL ) {
		return;
	}

	idBounds modelbb = re->hModel->Bounds();
	idVec3 extents = (modelbb.GetMaxs() - modelbb.GetMins()) * 0.5f;

	idPlayer *p = gameLocal.GetLocalViewPlayer();
	idVec3 const &v = p->GetViewPos();
	int gridx = idMath::Ftoi( idMath::Floor(v.x / extents.x) );
	int gridy = idMath::Ftoi( idMath::Floor(v.y / extents.y) );

	idBounds bounds;
	bounds.Clear();
	sdInstInfo *inst = re->insts;
	for (int y=-1; y<=1; y++) {
		for (int x=-1; x<=1; x++) {
			idBounds bb2;
			inst->fadeOrigin = inst->inst.origin = idVec3( (x + gridx) * extents.x, (y + gridy) * extents.y, v.z );
			inst->inst.axis.Identity();
			inst->maxVisDist = 0;
			inst->minVisDist = 0.f;
			bb2 = modelbb.Translate( inst->inst.origin );
			bounds.AddBounds( bb2 );
			inst++;
		}
	}
	re->flags.overridenBounds = true;
	re->bounds = bounds;

	if ( renderEntityHandle == -1 ) {
		renderEntityHandle = gameRenderWorld->AddEntityDef( re );
	} else {
		gameRenderWorld->UpdateEntityDef( renderEntityHandle, re );
	}


	if ( !effect.GetRenderEffect().declEffect ) return;

	idVec3 viewOrg;
	renderView_t view;
	if ( sdDemoManager::GetInstance().CalculateRenderView( &view ) ) {
		viewOrg = view.vieworg;
	} else {
		// If we are inside don't run the bacground effect
		idPlayer* player = gameLocal.GetLocalViewPlayer();

		if ( player == NULL ) {
			return;
		}
		viewOrg = player->GetRenderView()->vieworg;
	}

	int area = gameRenderWorld->PointInArea( viewOrg );
	bool runEffect = false;
	if ( area >= 0 ) {
		if ( gameRenderWorld->GetAreaPortalFlags( area ) & ( 1 << PORTAL_OUTSIDE ) ) {
			runEffect = true && !g_skipLocalizedPrecipitation.GetBool();
		}
	}

	// Update the background effect
	if ( runEffect ) {
		effect.GetRenderEffect().origin = viewOrg;
		if ( !effectRunning ) {
			effect.Start( gameLocal.time );
			effectRunning = true;
		} else {
			effect.Update();
		}
	} else {
		effect.StopDetach();
		effectRunning = false;
	}
}
/*
================
hhWeaponAutoCannon::UpdateGUI
================
*/
void hhWeaponAutoCannon::UpdateGUI() {
    if ( GetRenderEntity()->gui[ 0 ] && state != idStr(WP_HOLSTERED) ) {
        GetRenderEntity()->gui[ 0 ]->SetStateFloat( "temperature", GetHeatLevel() );
    }
}