示例#1
0
float CCurse::Render() {
	
	GRenderer->SetCulling(Renderer::CullCW);
	GRenderer->SetRenderState(Renderer::DepthWrite, true);
	GRenderer->SetRenderState(Renderer::AlphaBlending, false);
	
	if(svoodoo) {
		Anglef stiteangle = Anglef(fRot, 0, 0);
		Vec3f stitepos = eTarget;
		Vec3f stitescale = Vec3f::ONE;
		Color3f stitecolor = Color3f::white;
		DrawEERIEObjEx(svoodoo , &stiteangle, &stitepos, &stitescale, &stitecolor);
	}
	
	for(int i = 0; i < 4; i++) {
		
		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}
		
		pd->ov = eTarget;
		pd->move = Vec3f(2.f * frand2(), rnd() * -10.f - 10.f, 2.f * frand2());
		pd->siz = 0.015f;
		pd->tolive = Random::get(1000, 1600);
		pd->tc = tex_p1;
		pd->special = ROTATING | MODULATE_ROTATION | DISSIPATING | SUBSTRACT | GRAVITY;
		pd->fparam = 0.0000001f;
	}
	
	return 1;
}
示例#2
0
void CCurse::Render() {
	
	RenderMaterial mat;
	mat.setCulling(Renderer::CullCW);
	mat.setDepthTest(true);
	mat.setBlendType(RenderMaterial::Opaque);
	
		Anglef stiteangle = Anglef(0, fRot, 0);
		Vec3f stitepos = eTarget;
		Vec3f stitescale = Vec3f_ONE;
		Color3f stitecolor = Color3f::white;
		Draw3DObject(svoodoo, stiteangle, stitepos, stitescale, stitecolor, mat);
	
	for(int i = 0; i < 4; i++) {
		
		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}
		
		pd->ov = eTarget;
		pd->move = Vec3f(2.f * frand2(), rnd() * -10.f - 10.f, 2.f * frand2());
		pd->siz = 0.015f;
		pd->tolive = Random::get(1000, 1600);
		pd->tc = tex_p1;
		pd->special = ROTATING | MODULATE_ROTATION | DISSIPATING | SUBSTRACT | GRAVITY;
		pd->fparam = 0.0000001f;
	}
}
示例#3
0
void CRepelUndead::Render() {
	
	if(ulCurrentTime >= ulDuration)
		return;
	
	RenderMaterial mat;
	mat.setDepthTest(true);
	mat.setBlendType(RenderMaterial::Additive);
	
	Anglef  eObjAngle;

	eObjAngle.setPitch(m_yaw);
	eObjAngle.setYaw(0);
	eObjAngle.setRoll(0);

	float vv = 1.f + (std::sin(arxtime.get_updated() * ( 1.0f / 1000 ))); 
	vv *= ( 1.0f / 2 );
	vv += 1.1f;
	
	Draw3DObject(ssol, eObjAngle, eSrc + Vec3f(0.f, -5.f, 0.f), Vec3f(vv), Color3f(0.6f, 0.6f, 0.8f), mat);
	
	vv *= 100.f;
	
	for(int n = 0; n < 4; n++) {
		
		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}
		
		float dx = -std::sin(frand2() * 360.f) * vv;
		float dz =  std::cos(frand2() * 360.f) * vv;
		pd->ov = eSrc + Vec3f(dx, 0.f, dz);
		pd->move = Vec3f(0.8f * frand2(), -4.f * rnd(), 0.8f * frand2());
		pd->scale = Vec3f(-0.1f);
		pd->tolive = Random::get(2600, 3200);
		pd->tc = tex_p2;
		pd->siz = 0.3f;
		pd->rgb = Color3f(.4f, .4f, .6f);
	}
	
	if(!lightHandleIsValid(lLightId)) {
		lLightId = GetFreeDynLight();
	}
	
	if(lightHandleIsValid(lLightId)) {
		EERIE_LIGHT * light = lightHandleGet(lLightId);
		
		light->intensity = 2.3f;
		light->fallend = 350.f;
		light->fallstart = 150.f;
		light->rgb = Color3f(0.8f, 0.8f, 1.f);
		light->pos = eSrc + Vec3f(0.f, -50.f, 0.f);
		light->duration = 200;
		light->time_creation = (unsigned long)(arxtime);
	}
}
示例#4
0
void CMultiMagicMissile::Create(Vec3f aePos, float afAlpha, float afBeta)
{
	
	long lMax = 0;
	
	for(size_t i = 0; i < pTab.size(); i++) {
		Anglef angles(afAlpha, afBeta, 0.f);
		
		if(i > 0) {
			angles.setYaw(angles.getYaw() + frand2() * 4.0f);
			angles.setPitch(angles.getPitch() + frand2() * 6.0f);
		}
		
		pTab[i]->Create(aePos, angles);  
		
		float fTime = ulDuration + frand2() * 1000.0f;
		long lTime = checked_range_cast<long>(fTime);
		
		lTime		= std::max(1000L, lTime);
		lMax		= std::max(lMax, lTime);
		
		CMagicMissile * pMM = (CMagicMissile *)pTab[i];
		
		pMM->SetDuration(lTime);
		
		if(m_mrCheat) {
			pMM->SetColor(Color3f(0.9f, 0.2f, 0.5f));
		} else {
			pMM->SetColor(Color3f(0.9f + rnd() * 0.1f, 0.9f + rnd() * 0.1f, 0.7f + rnd() * 0.3f));
		}
		
		pTab[i]->lLightId = GetFreeDynLight();
		
		if(lightHandleIsValid(pTab[i]->lLightId)) {
			EERIE_LIGHT * el = lightHandleGet(pTab[i]->lLightId);
			
			el->intensity	= 0.7f + 2.3f;
			el->fallend		= 190.f;
			el->fallstart	= 80.f;
			
			if(m_mrCheat) {
				el->rgb.r = 1;
				el->rgb.g = 0.3f;
				el->rgb.b = 0.8f;
			} else {
				el->rgb.r = 0;
				el->rgb.g = 0;
				el->rgb.b = 1;
			}
			
			el->pos	 = pMM->eSrc;
			el->duration = 300;
		}
	}
	
	SetDuration(lMax + 1000);
}
示例#5
0
void CRiseDead::Split(Vec3f * v, int a, int b, float yo)
{
	if(a != b) {
		int i = (int)((a + b) * 0.5f);

		if(i != a && i != b) {
			v[i].x = (v[a].x + v[b].x) * 0.5f + yo * frand2() * fBetaRadCos;
			v[i].y = v[0].y;// + (i+1)*5;
			v[i].z = (v[a].z + v[b].z) * 0.5f + yo * frand2() * fBetaRadSin;
			Split(v, a, i, yo * 0.8f);
			Split(v, i, b, yo * 0.8f);
		}
	}
}
示例#6
0
void CSummonCreature::Split(Vec3f * v, int a, int b, float yo)
{
	if(a != b) {
		int i = (int)((a + b) * 0.5f);

		if((i != a) && (i != b)) {
			v[i].x = (v[a].x + v[b].x) * 0.5f + yo * frand2() * (sizeF * 0.005f) * fBetaRadCos;
			v[i].y = v[0].y + (i + 1) * 5;
			v[i].z = (v[a].z + v[b].z) * 0.5f + yo * frand2() * (sizeF * 0.005f) * fBetaRadSin;
			Split(v, a, i, yo * 0.8f);
			Split(v, i, b, yo * 0.8f);
		}
	}
}
示例#7
0
//-----------------------------------------------------------------------------
//							PORTALS
//-----------------------------------------------------------------------------
void Split(Vec3f * v, int a, int b, float yo)
{
	if(a != b) {
		int i = (int)((a + b) * 0.5f);

		if(i != a && i != b) {
			v[i].x = (v[a].x + v[b].x) * 0.5f + yo * frand2(); 
			v[i].y = (v[a].y + v[b].y) * 0.5f; 
			v[i].z = (v[a].z + v[b].z) * 0.5f + yo * frand2();
			Split(v, a, i, yo * 0.7f);
			Split(v, i, b, yo * 0.7f);
		}
	}
}
示例#8
0
void LFDNoise1_ar::m_signal(int n, t_sample *const *in, 
			    t_sample *const *out)
{
    t_sample *nout = *out;

    float prevLevel = m_prevlevel;
    float nextLevel = m_nextlevel;
    float phase = m_phase;
    
    RGET;

    if (m_ar)
    {
	t_sample *nin = *in;
	float smpdur = m_smpdur;
	for (int i = 0; i!= n; ++i)
	{
	    phase -= ZXP(nin) * smpdur;
	    if (phase <= 0) 
	    {
		phase = sc_wrap(phase, 0.f, 1.f);
		prevLevel = nextLevel;
		nextLevel = frand2(s1,s2,s3);
	    }
	    ZXP(nout) = nextLevel + ( phase * (prevLevel - nextLevel) );
	}
    }
    else 
    {
	float dphase = m_smpdur * m_freq;
	for (int i = 0; i!= n; ++i)
	{
	    phase -= dphase;
	    if (phase <= 0) 
	    {
		phase = sc_wrap(phase, 0.f, 1.f);
		prevLevel = nextLevel;
		nextLevel = frand2(s1,s2,s3);
	    }
	    ZXP(nout) = nextLevel + ( phase * (prevLevel - nextLevel) );
	}
    }

    m_prevlevel = prevLevel;
    m_nextlevel = nextLevel;
    m_phase = phase;
    
    RPUT;
}
示例#9
0
void CRuneOfGuarding::Render()
{
	Vec3f pos = eSrc + Vec3f(0.f, -20.f, 0.f);
	
	RenderMaterial mat;
	mat.setDepthTest(true);
	mat.setBlendType(RenderMaterial::Additive);
	
	Anglef stiteangle;
	Color3f stitecolor;
	
	float stiteangleb = float(ulCurrentTime) * 0.01f;
	stiteangle.setYaw(0);
	stiteangle.setRoll(0);
	
	stiteangle.setPitch(stiteangleb * 0.1f);
	stitecolor = Color3f(0.4f, 0.4f, 0.6f);
	float scale = std::sin(ulCurrentTime * 0.015f);
	Vec3f stitescale = Vec3f(1.f, -0.1f, 1.f);
	
	Draw3DObject(slight, stiteangle, pos, stitescale, stitecolor, mat);
	
	stiteangle.setPitch(stiteangleb);
	stitecolor = Color3f(0.6f, 0.f, 0.f);
	stitescale = Vec3f(2.f) * (1.f + 0.01f * scale);
	
	Draw3DObject(ssol, stiteangle, pos, stitescale, stitecolor, mat);
	
	stitecolor = Color3f(0.6f, 0.3f, 0.45f);
	stitescale = Vec3f(1.8f) * (1.f + 0.02f * scale);
	
	Draw3DObject(srune, stiteangle, pos, stitescale, stitecolor, mat);
	
	for(int n = 0; n < 4; n++) {
		
		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}
		
		pd->ov = pos + (Vec3f(40.f, 0.f, 40.f) * Vec3f(frand2(), 0.f, frand2()));
		pd->move = Vec3f(0.8f, -4.f, 0.8f) * Vec3f(frand2(), rnd(), frand2());
		pd->scale = Vec3f(-0.1f);
		pd->tolive = Random::get(2600, 3200);
		pd->tc = tex_p2;
		pd->siz = 0.3f;
		pd->rgb = Color3f(.4f, .4f, .6f);
	}
}
示例#10
0
static unsigned int nrand(unsigned int nLimit)
{
  unsigned long result;
  double_t ratio;

  /* Loop to be sure a legal random number is generated */

  do
    {
      /* Get a random integer in the requested range */

#if (CONFIG_LIB_RAND_ORDER == 1)
      ratio = frand1();
#elif (CONFIG_LIB_RAND_ORDER == 2)
      ratio = frand2();
#else /* if (CONFIG_LIB_RAND_ORDER > 2) */
      ratio = frand3();
#endif

      /* Then, produce the return-able value */

      result = (unsigned long)(((double_t)nLimit) * ratio);
    }
  while (result >= (unsigned long)nLimit);

  return (unsigned int)result;
}
示例#11
0
void Split(Vec3f * v, int a, int b, float fX, float fMulX, float fY, float fMulY, float fZ, float fMulZ)
{
	if (a != b)
	{
		int i = (int)((a + b) * 0.5f);

		if ((i != a) && (i != b))
		{
			v[i].x = (v[a].x + v[b].x) * 0.5f + fX * frand2();
			v[i].y = (v[a].y + v[b].y) * 0.5f + fY * frand2(); 
			v[i].z = (v[a].z + v[b].z) * 0.5f + fZ * frand2(); 
			Split(v, a, i, fX, fMulX, fY, fMulY, fZ, fMulZ);
			Split(v, i, b, fX, fMulX, fY, fMulY, fZ, fMulZ);
		}
	}
}
示例#12
0
void CMultiPoisonProjectile::Create(Vec3f srcPos, float afBeta) {
	
	long lMax = 0;

	for(size_t i = 0; i < m_projectiles.size(); i++) {
		CPoisonProjectile * projectile = m_projectiles[i];
		
		projectile->Create(srcPos, afBeta + frand2() * 10.0f);
		long lTime = ulDuration + Random::get(0, 5000);
		projectile->SetDuration(lTime);
		lMax = std::max(lMax, lTime);

		projectile->lLightId = GetFreeDynLight();

		if(lightHandleIsValid(projectile->lLightId)) {
			EERIE_LIGHT * light = lightHandleGet(projectile->lLightId);
			
			light->intensity		= 2.3f;
			light->fallend		= 250.f;
			light->fallstart		= 150.f;
			light->rgb = Color3f::green;
			light->pos = projectile->eSrc;
			light->time_creation	= (unsigned long)(arxtime);
			light->duration		= 200;
		}
	}

	SetDuration(lMax + 1000);
}
示例#13
0
//-----------------------------------------------------------------------------
void Split(TexturedVertex * v, int a, int b, float yo, float fMul)
{
	if (a != b)
	{
		int i = (int)((a + b) * 0.5f);

		if ((i != a) && (i != b))
		{
			v[i].p.x = (v[a].p.x + v[b].p.x) * 0.5f + yo * frand2(); 
			v[i].p.y = (v[a].p.y + v[b].p.y) * 0.5f + yo * frand2(); 
			v[i].p.z = (v[a].p.z + v[b].p.z) * 0.5f + yo * frand2(); 
			Split(v, a, i, yo * fMul);
			Split(v, i, b, yo * fMul);
		}
	}
}
示例#14
0
void CNegateMagic::Render() {
	
	int i = 0;
	
	Vec3f stitepos = eSrc - Vec3f(0.f, 10.f, 0.f);

	if(ulCurrentTime >= ulDuration)
		return;
	
	RenderMaterial mat;
	mat.setLayer(RenderMaterial::Decal);
	mat.setDepthTest(true);
	mat.setTexture(tex_sol);
	mat.setBlendType(RenderMaterial::Additive);
	
	for(i = 0; i < 360; i++) {
		float t = rnd();
		if(t < 0.04f) {
			
			PARTICLE_DEF * pd = createParticle();
			if(!pd) {
				break;
			}
			
			pd->ov = stitepos + Vec3f(frand2() * 150.f, 0.f, frand2() * 150.f);
			pd->move = Vec3f(0.f, -3.0f * rnd(), 0.f);
			pd->siz = 0.3f;
			pd->tolive = Random::get(2000, 4000);
			pd->tc = tex_p2;
			pd->special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING
			              | SUBSTRACT;
			pd->fparam = 0.0000001f;
		}
	}
	
	Anglef stiteangle(0.f, -(float) ulCurrentTime * 0.02f, 0.f);
	Color3f stitecolor = Color3f::gray(.4f);
	float scalediff = std::sin(ulCurrentTime * 0.004f);
	Vec3f stitescale = Vec3f(3.f + 0.5f * scalediff);
	Draw3DObject(ssol, stiteangle, stitepos, stitescale, stitecolor, mat);
	
	stitecolor = Color3f(.5f, 0.f, .5f);
	stitescale = Vec3f(3.1f + 0.2f * scalediff);
	Draw3DObject(ssol, stiteangle, stitepos, stitescale, stitecolor, mat);
}
void LFDNoise3_Ctor(LFDNoise3* unit)
{
	if (INRATE(0) == calc_FullRate) {
		SETCALC(LFDNoise3_next);
	} else {
		SETCALC(LFDNoise3_next_k);
	}

	RGET
	unit->mPhase = 0.f;
	unit->mLevelA = frand2(s1, s2, s3) * 0.8f;	// limits max interpol. overshoot to 1.
	unit->mLevelB = frand2(s1, s2, s3) * 0.8f;
	unit->mLevelC = frand2(s1, s2, s3) * 0.8f;
	unit->mLevelD = frand2(s1, s2, s3) * 0.8f;
	RPUT

	LFDNoise3_next(unit, 1);
}
示例#16
0
文件: battle.c 项目: scumola/GalaxyNG
int
shoot(group *attacker, group *defender)
{
  double          defense;

  assert(attacker->type->weapons > 0);
  defense = defender->defense;
  return ((defense > 0) ?
          ((attacker->attack / defense) > pow(4.0, frand2())) : 1);
}
示例#17
0
Particle::Particle()
{
	p3Pos.x = frand2() * 5;
	p3Pos.y = frand2() * 5;
	p3Pos.z = frand2() * 5;

	p3Velocity.x = frand2() * 10;
	p3Velocity.y = frand2() * 10;
	p3Velocity.z = frand2() * 10;

	float frnd = 2000 + rnd() * 3000;
	ulTTL = checked_range_cast<long>(frnd);
	fOneOnTTL = 1.0f / (float) ulTTL;
	ulTime		=	0;


	fSizeStart = 1;
	fSizeEnd = 1;
	fColorStart[0] = 1;
	fColorStart[1] = 1;
	fColorStart[2] = 1;
	fColorStart[3] = 0.5f;
	fColorEnd[0] = 1;
	fColorEnd[1] = 1;
	fColorEnd[2] = 1;
	fColorEnd[3] = 0.1f;

	iTexTime = 0;
	iTexNum = 0;
}
示例#18
0
t_int *lfnoise_perform(t_int *w){
    t_lfnoise       *x      = (t_lfnoise *) w[1];	
    t_float         *out    = (t_float *)       w[3];
	int             remain  = (int)  w[4];
    
    t_float         freq    = x->m_connected ? (*(t_float *)(w[2])) : x->m_freq;
    float           level   = x->m_level;
	float           slope   = x->m_slope;
    float           curve   = x->m_curve;
    int32            counter = x->m_counter;
    
    
    if (x->ob.z_disabled) return w + 5;
    
	
	RGET
    
	do {
		if (counter<=0) {
			float value = x->m_nextvalue;
			x->m_nextvalue = frand2(s1,s2,s3);
			level = x->m_nextmidpt;
			x->m_nextmidpt = (x->m_nextvalue + value) * 0.5;
            
			counter = (int32)(x->m_sr / sc_max(freq, 0.001f));
			counter = sc_max(2, counter);
			float fseglen = (float)counter;
			curve = 2.f * (x->m_nextmidpt - level - fseglen * slope) / (fseglen * fseglen + fseglen);
		}
        
		int nsmps = sc_min(remain, counter);
		remain -= nsmps;
		counter -= nsmps;
        
        while (nsmps--) {
            *out++ = level;
            slope += curve;
			level += slope;
        }

	} while (remain);

	x->m_level  = level;
	x->m_slope  = slope;
    x->m_curve  = curve;
	x->m_counter= counter;
	
    RPUT
    
	return w + 5;
}
示例#19
0
void CurseSpell::Update(float timeDelta) {
	
	fRot += timeDelta * 0.25f;
	
	Vec3f target = Vec3f_ZERO;
	if(ValidIONum(m_target)) {
		target = entities[m_target]->pos;

		if(m_target == PlayerEntityHandle)
			target.y -= 200.f;
		else
			target.y += entities[m_target]->physics.cyl.height - 30.f;
	}
	m_pos = target;
	
	RenderMaterial mat;
	mat.setCulling(Renderer::CullCW);
	mat.setDepthTest(true);
	mat.setBlendType(RenderMaterial::Opaque);
	
	Draw3DObject(svoodoo, Anglef(0, fRot, 0), m_pos, Vec3f_ONE, Color3f::white, mat);
	
	for(int i = 0; i < 4; i++) {
		
		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}
		
		pd->ov = m_pos;
		pd->move = Vec3f(2.f * frand2(), rnd() * -10.f - 10.f, 2.f * frand2());
		pd->siz = 0.015f;
		pd->tolive = Random::get(1000, 1600);
		pd->tc = tex_p1;
		pd->special = ROTATING | MODULATE_ROTATION | DISSIPATING | SUBSTRACT | GRAVITY;
		pd->fparam = 0.0000001f;
	}
}
示例#20
0
void WhiteNoise_ar::m_signal(int n, t_sample *const *in, 
			       t_sample *const *out)
{
    t_sample *nout = *out;

    RGET;

    for (int i = 0; i!= n;++i)
    {
	(*(nout)++) = frand2(s1, s2, s3);
    }

    RPUT
}
示例#21
0
//-----------------------------------------------------------------------------
// render the space time tearing
void CRiseDead::Render()
{
	if(ulCurrentTime >= (ulDurationIntro + ulDurationRender + ulDurationOuttro))
		return;
	
	if(fTexWrap >= 1.0f)
		fTexWrap -= 1.0f;

	//-------------------------------------------------------------------------
	// render intro (opening + rays)
	if(ulCurrentTime < ulDurationIntro) {
		if(ulCurrentTime < ulDurationIntro * 0.666f) {
			fSizeIntro = (end + 2) * fOneOnDurationIntro * (1.5f) * ulCurrentTime;
			sizeF = 1;
		} else {
			if(bIntro != false)
				bIntro = false;

			sizeF = (iSize) * (fOneOnDurationIntro * 3) * (ulCurrentTime - ulDurationIntro * 0.666f);
		}
	}
	// do nothing just render
	else if (ulCurrentTime < (ulDurationIntro + ulDurationRender))
	{
	}
	// close it all
	else if (ulCurrentTime < (ulDurationIntro + ulDurationRender + ulDurationOuttro))
	{
		//if (sizeF > 0)
		{
			sizeF = iSize - (iSize) * fOneOnDurationOuttro * (ulCurrentTime - (ulDurationIntro + ulDurationRender));
		}
	}
	
	//cailloux
	if(this->timestone <= 0) {
		this->timestone = Random::get(50, 150);
		Vec3f	pos;
		float r = 80.f * frand2();
		pos.x = this->eSrc.x + r;
		pos.y = this->eSrc.y;
		pos.z = this->eSrc.z + r;
		this->AddStone(&pos);
	}
	
	RenderFissure();
	
	this->DrawStone();
}
void LFDNoise0_next(LFDNoise0 *unit, int inNumSamples)
{
	float *out = ZOUT(0);
	float *freq = ZIN(0);
	float level = unit->mLevel;
	float phase = unit->mPhase;
	float smpdur = SAMPLEDUR;
	RGET

	LOOP1(inNumSamples,
		phase -= ZXP(freq) * smpdur;
		if (phase < 0) {
			phase = sc_wrap(phase, 0.f, 1.f);
			level = frand2(s1,s2,s3);
		}
		ZXP(out) = level;
	)
示例#23
0
void LFDNoise0_next_k(LFDNoise0 *unit, int inNumSamples)
{
    float *out = ZOUT(0);
    float freq = ZIN0(0);
    float level = unit->mLevel;
    float phase = unit->mPhase;
    float smpdur = SAMPLEDUR;
    float dphase = smpdur * freq;

    RGET

    LOOP(inNumSamples,
         phase -= dphase;
    if (phase <= 0) {
    phase = sc_wrap(phase, 0.f, 1.f);
        level = frand2(s1,s2,s3);
    }
    ZXP(out) = level;
        )
void LFDNoise1_next(LFDNoise1 *unit, int inNumSamples)
{
	float *out = ZOUT(0);
	float *freq = ZIN(0);
	float prevLevel = unit->mPrevLevel;
	float nextLevel = unit->mNextLevel;
	float phase = unit->mPhase;
	float smpdur = SAMPLEDUR;

	RGET

	LOOP1(inNumSamples,
		phase -= ZXP(freq) * smpdur;
		if (phase < 0) {
			phase = sc_wrap(phase, 0.f, 1.f);
			prevLevel = nextLevel;
			nextLevel = frand2(s1,s2,s3);
		}
		ZXP(out) = nextLevel + ( phase * (prevLevel - nextLevel) );
	)
示例#25
0
文件: LFNoise1.cpp 项目: Angeldude/pd
void LFNoise1_ar::m_signal(int n, t_sample *const *in, 
			       t_sample *const *out)
{
    t_sample *nout = *out;

    float level = m_level;
    int32 counter = m_counter;
    float slope = m_slope;
    
    RGET;

    int remain = n;
    do
    {
	if (counter<=0) 
	{
	    counter = (int)(m_sr / sc_max(m_freq, .001f));
	    counter = sc_max(1, counter);
	    float nextlevel = frand2(s1,s2,s3);
	    slope = (nextlevel - level) / counter;
	}
	int nsmps = sc_min(remain, counter);
	remain -= nsmps;
	counter -= nsmps;
	
	for (int i = 0; i!= nsmps;++i)
	{
	    (*(nout)++)=level;
	    level+=slope;
	}
    }
    while(remain);

    m_level = level;
    m_counter = counter;
    m_slope = slope;
    
    RPUT;
}
示例#26
0
Particle::Particle()
	: p3Pos(frand2() * 5, frand2() * 5, frand2() * 5),
	  p3Velocity(frand2() * 10, frand2() * 10, frand2() * 10),
	  ulTime(0), fSize(1.f), fSizeStart(1.f), fSizeEnd(1.f),
	  iTexTime(0), iTexNum(0) {
	
	ulTTL = checked_range_cast<long>(2000 + rnd() * 3000);
	fOneOnTTL = 1.0f / float(ulTTL);
	
	fColorStart[0] = 1;
	fColorStart[1] = 1;
	fColorStart[2] = 1;
	fColorStart[3] = 0.5f;
	fColorEnd[0] = 1;
	fColorEnd[1] = 1;
	fColorEnd[2] = 1;
	fColorEnd[3] = 0.1f;
}
void LFDNoise3_next_k(LFDNoise3 *unit, int inNumSamples)
{
	float *out = ZOUT(0);
	float freq = ZIN0(0);
	float a = unit->mLevelA;
	float b = unit->mLevelB;
	float c = unit->mLevelC;
	float d = unit->mLevelD;
	float phase = unit->mPhase;
	float dphase = freq * SAMPLEDUR;

	RGET

	LOOP1(inNumSamples,
		phase -= dphase;
		if (phase < 0) {
			phase = sc_wrap(phase, 0.f, 1.f);
			a = b;
			b = c;
			c = d;
			d = frand2(s1,s2,s3) * 0.8f;	// limits max interpol. overshoot to 1.
		}
		ZXP(out) = cubicinterp(1.f - phase, a, b, c, d);
	)
示例#28
0
void IceFieldSpell::Launch()
{
	spells.endByCaster(m_caster, SPELL_ICE_FIELD);
	
	ARX_SOUND_PlaySFX(SND_SPELL_ICE_FIELD);
	
	m_duration = (m_launchDuration > -1) ? m_launchDuration : 100000;
	m_hasDuration = true;
	m_fManaCostPerSecond = 2.8f;
	m_light = LightHandle::Invalid;
	
	Vec3f target;
	float beta = 0.f;
	bool displace = false;
	if(m_caster == PlayerEntityHandle) {
		target = player.basePosition();
		beta = player.angle.getPitch();
		displace = true;
	} else {
		if(ValidIONum(m_caster)) {
			Entity * io = entities[m_caster];
			target = io->pos;
			beta = io->angle.getPitch();
			displace = (io->ioflags & IO_NPC) == IO_NPC;
		} else {
			ARX_DEAD_CODE();
		}
	}
	if(displace) {
		target += angleToVectorXZ(beta) * 250.f;
	}
	
	m_pos = target;
	
	DamageParameters damage;
	damage.radius = 150.f;
	damage.damages = 10.f;
	damage.area = DAMAGE_FULL;
	damage.duration = 100000000;
	damage.source = m_caster;
	damage.flags = 0;
	damage.type = DAMAGE_TYPE_MAGICAL | DAMAGE_TYPE_COLD | DAMAGE_TYPE_FIELD;
	damage.pos = target;
	m_damage = DamageCreate(damage);
	
	tex_p1 = TextureContainer::Load("graph/obj3d/textures/(fx)_tsu_blueting");
	tex_p2 = TextureContainer::Load("graph/obj3d/textures/(fx)_tsu_bluepouf");
	
	for(int i = 0; i < iMax; i++) {
		float t = rnd();

		if (t < 0.5f)
			tType[i] = 0;
		else
			tType[i] = 1;
		
		tSize[i] = Vec3f_ZERO;
		tSizeMax[i] = Vec3f(rnd(), rnd(), rnd()) + Vec3f(0.f, 0.2f, 0.f);
		
		Vec3f minPos;
		if(tType[i] == 0) {
			minPos = Vec3f(1.2f, 1, 1.2f);
		} else {
			minPos = Vec3f(0.4f, 0.3f, 0.4f);
		}
		
		tSizeMax[i] = glm::max(tSizeMax[i], minPos);
		
		if(tType[i] == 0) {
			tPos[i].x = m_pos.x + frand2() * 80;
			tPos[i].y = m_pos.y;
			tPos[i].z = m_pos.z + frand2() * 80;
		} else {
			tPos[i].x = m_pos.x + frand2() * 120;
			tPos[i].y = m_pos.y;
			tPos[i].z = m_pos.z + frand2() * 120;
		}
	}
	
	m_snd_loop = ARX_SOUND_PlaySFX(SND_SPELL_ICE_FIELD_LOOP, &target, 1.f, ARX_SOUND_PLAY_LOOPED);
}
示例#29
0
//---------------------------------------------------------------------
float CBless::Render()
{
	int i = 0;

	float x = eSrc.x;
	float y = eSrc.y - 5;
	float z = eSrc.z;

	if (ulCurrentTime >= ulDuration)
	{
		return 0.f;
	}

	GRenderer->SetCulling(Renderer::CullNone);
	GRenderer->SetRenderState(Renderer::DepthWrite, false);
	GRenderer->SetRenderState(Renderer::AlphaBlending, true);

	TexturedVertex v[4];
	TexturedVertex v3[4];

	float ff = ((float)spells[spellinstance].caster_level + 10) * 6.f;
	float fBetaRadCos = (float) cos(radians(MAKEANGLE(player.angle.b))) * ff;
	float fBetaRadSin = (float) sin(radians(MAKEANGLE(player.angle.b))) * ff;

	ColorBGRA color = Color::white.toBGR();

	v[0].p.x = x - fBetaRadCos - fBetaRadSin;
	v[0].p.y = y;
	v[0].p.z = z - fBetaRadSin + fBetaRadCos;
	v[1].p.x = x + fBetaRadCos - fBetaRadSin;
	v[1].p.y = y;
	v[1].p.z = z + fBetaRadSin + fBetaRadCos;
	v[2].p.x = x - fBetaRadCos + fBetaRadSin;
	v[2].p.y = y;
	v[2].p.z = z - fBetaRadSin - fBetaRadCos;
	v[3].p.x = x + fBetaRadCos + fBetaRadSin;
	v[3].p.y = y;
	v[3].p.z = z + fBetaRadSin - fBetaRadCos;
	
	v3[0].color = color;
	v3[1].color = color;
	v3[2].color = color;
	v3[3].color = color;
	
	GRenderer->SetTexture(0, tex_sol);
	
	v3[0].uv = Vec2f::ZERO;
	v3[1].uv = Vec2f::X_AXIS;
	v3[2].uv = Vec2f::Y_AXIS;
	v3[3].uv = Vec2f::ONE;
	
	EE_RT2(&v[0], &v3[0]);
	EE_RT2(&v[1], &v3[1]);
	EE_RT2(&v[2], &v3[2]);
	EE_RT2(&v[3], &v3[3]);
	ARX_DrawPrimitive(&v3[0], &v3[1], &v3[2]);
	ARX_DrawPrimitive(&v3[1], &v3[2], &v3[3]);
	
	GRenderer->SetRenderState(Renderer::AlphaBlending, false);
	
	for(i = 0; i < 12; i++) {
		
		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}
		
		pd->ov = eSrc - Vec3f(0.f, 20.f, 0.f);
		pd->move = Vec3f(3.f * frand2(), rnd() * 0.5f, 3.f * frand2());
		pd->siz = 0.005f;
		pd->tolive = Random::get(1000, 2000);
		pd->tc = tex_p1;
		pd->special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
		pd->fparam = 0.0000001f;
		pd->rgb = Color3f(0.7f, 0.6f, 0.2f);
	}
	
	GRenderer->SetCulling(Renderer::CullNone);
	GRenderer->SetRenderState(Renderer::DepthWrite, false);
	GRenderer->SetRenderState(Renderer::AlphaBlending, true);
	
	return 1;
}
示例#30
0
void CLightning::BuildS(LIGHTNING * pLInfo)
{
	Vec3f astart = pLInfo->eStart;
	Vec3f avect = pLInfo->eVect;

	if(pLInfo->anb > 0 && m_nbtotal < (MAX_NODES - 1)) {
		m_nbtotal++;
		int moi = m_nbtotal;

		if(pLInfo->abFollow) {
			avect = glm::normalize(m_eDest - pLInfo->eStart);
		}

		Vec3f fAngle;
		fAngle.x = frand2() * (pLInfo->fAngleMax.x - pLInfo->fAngleMin.x) + pLInfo->fAngleMin.x;
		fAngle.y = frand2() * (pLInfo->fAngleMax.y - pLInfo->fAngleMin.y) + pLInfo->fAngleMin.y;
		fAngle.z = frand2() * (pLInfo->fAngleMax.z - pLInfo->fAngleMin.z) + pLInfo->fAngleMin.z;

		Vec3f av;
		av.x = glm::cos(glm::acos(avect.x) - glm::radians(fAngle.x));
		av.y = glm::sin(glm::asin(avect.y) - glm::radians(fAngle.y));
		av.z = glm::tan(glm::atan(avect.z) - glm::radians(fAngle.z));
		av = glm::normalize(av);
		avect = av;

		float ts = rnd();
		av *= ts * (m_fLengthMax - m_fLengthMin) * pLInfo->anb * m_invNbSegments + m_fLengthMin;

		astart += av;
		pLInfo->eStart = astart;
		
		m_cnodetab[m_nbtotal].pos = pLInfo->eStart;
		m_cnodetab[m_nbtotal].size = m_cnodetab[0].size * pLInfo->anb * m_invNbSegments;
		m_cnodetab[m_nbtotal].parent = pLInfo->aParent;
		
		int anb = pLInfo->anb;
		int anbrec = pLInfo->anbrec;

		float p = rnd();

		if(p <= 0.15 && pLInfo->anbrec < 7) {
			float m = rnd();

			if(pLInfo->abFollow) {
				pLInfo->eStart = astart;
				pLInfo->eVect = avect;
				pLInfo->abFollow = false;
				pLInfo->anb =  anb - (int)(10 * (1 - m));
				pLInfo->anbrec = anbrec + (int)(2 * m);
				pLInfo->aParent = moi;
				pLInfo->fAngleMin = m_fAngleMin;
				pLInfo->fAngleMax = m_fAngleMax;
				
				BuildS(pLInfo);

				pLInfo->eStart = astart;
				pLInfo->eVect = avect;
				pLInfo->abFollow = true;
				pLInfo->anb = anb - (int)(10 * m);
				pLInfo->anbrec = anbrec + (int)(2 * m);
				pLInfo->aParent = moi;
				pLInfo->fAngleMin = m_fAngleMin;
				pLInfo->fAngleMax = m_fAngleMax;
				
				BuildS(pLInfo);
			} else {
				pLInfo->abFollow = false;
				pLInfo->eStart = astart;
				pLInfo->eVect = avect;
				pLInfo->anb = anb - (int)(10 * (1 - m));
				pLInfo->anbrec = anbrec + (int)(2 * m);
				pLInfo->aParent = moi;
				pLInfo->fAngleMin = m_fAngleMin;
				pLInfo->fAngleMax = m_fAngleMax;
				
				BuildS(pLInfo);

				pLInfo->abFollow = false;
				pLInfo->eStart = astart;
				pLInfo->eVect = avect;
				pLInfo->anb = anb - (int)(10 * m);
				pLInfo->anbrec = anbrec + (int)(2 * m);
				pLInfo->aParent = moi;
				pLInfo->fAngleMin = m_fAngleMin;
				pLInfo->fAngleMax = m_fAngleMax;
				
				BuildS(pLInfo);
			}
		} else {
			if(rnd() <= 0.10) {
				pLInfo->abFollow = true;
			}

			pLInfo->eStart = astart;
			pLInfo->eVect = avect;
			pLInfo->anb = anb - 1;
			pLInfo->anbrec = anbrec;
			pLInfo->aParent = moi;
			pLInfo->fAngleMin = m_fAngleMin;
			pLInfo->fAngleMax = m_fAngleMax;
			
			BuildS(pLInfo);
		}
	}
}