当前位置: 首页>>代码示例>>C++>>正文


C++ float3::Length方法代码示例

本文整理汇总了C++中float3::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ float3::Length方法的具体用法?C++ float3::Length怎么用?C++ float3::Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在float3的用法示例。


在下文中一共展示了float3::Length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CProjectile

CFireProjectile::CFireProjectile(const float3& pos,const float3& speed,CUnit* owner,int emitTtl,float emitRadius,int particleTtl,float particleSize)
: CProjectile(pos,speed,owner),
	ttl(emitTtl),
	emitPos(pos),
	emitRadius(emitRadius),
	particleTime(particleTtl),
	particleSize(particleSize)
{
	drawRadius=emitRadius+particleTime*speed.Length();
	checkCol=false;
	this->pos.y+=particleTime*speed.Length()*0.5;
	ageSpeed=1.0/particleTime;

	alwaysVisible=true;
	castShadow=true;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:16,代码来源:FireProjectile.cpp

示例2: GetCamDistOfGrassBlock

static float GetCamDistOfGrassBlock(const int x, const int y, const bool square = false)
{
	float3 quadCenter = float3(x, 0.f, y) * gSSsq;
	quadCenter.y = CGround::GetHeightReal(quadCenter.x, quadCenter.z, false);
	const float3 dif = camera->GetPos() - quadCenter;
	return (square) ? dif.SqLength() : dif.Length();
}
开发者ID:304471720,项目名称:spring,代码行数:7,代码来源:GrassDrawer.cpp

示例3: FitThroughPoints

/** For reference, see http://realtimecollisiondetection.net/blog/?p=20 . */
Sphere Sphere::FitThroughPoints(const float3 &a, const float3 &b, const float3 &c)
{
	Sphere sphere;

	float3 ab = b-a;
	float3 ac = c-a;

	float s, t;
	bool success = FitSphereThroughPoints(ab, ac, s, t);
	if (!success)
	{
		LOGW("Sphere::FitThroughPoints(a,b,c) failed! The three input points are collinear!");
		sphere.SetDegenerate();
		return sphere;
	}

	const float3 p = s*ab + t*ac;

	// In our translated coordinate space, the origin lies on the sphere, so the distance of p from origin 
	// gives the radius of the sphere.
	sphere.r = p.Length(); 

	// Translate back to original coordinate space.
	sphere.pos = a + p;

	return sphere;
}
开发者ID:jjiezheng,项目名称:MathGeoLib,代码行数:28,代码来源:Sphere.cpp

示例4: CWeaponProjectile

CTorpedoProjectile::CTorpedoProjectile(
		const float3& pos, const float3& speed,
		CUnit* owner,
		float areaOfEffect, float maxSpeed,
		float tracking, int ttl,
		CUnit* target,
		const WeaponDef* weaponDef)
	: CWeaponProjectile(pos, speed, owner, target, ZeroVector, weaponDef, NULL, ttl),
	tracking(tracking),
	maxSpeed(maxSpeed),
	areaOfEffect(areaOfEffect),
	target(target),
	nextBubble(4)
{
	projectileType = WEAPON_TORPEDO_PROJECTILE;
	curSpeed = speed.Length();
	dir = speed / curSpeed;

	if (target) {
		AddDeathDependence(target);
	}

	SetRadius(0.0f);
	drawRadius = maxSpeed * 8;

//	const float3 camDir = (pos - camera->pos).Normalize();
	texx = projectileDrawer->torpedotex->xstart - (projectileDrawer->torpedotex->xend - projectileDrawer->torpedotex->xstart) * 0.5f;
	texy = projectileDrawer->torpedotex->ystart - (projectileDrawer->torpedotex->yend - projectileDrawer->torpedotex->ystart) * 0.5f;
#ifdef TRACE_SYNC
	tracefile << "New projectile: ";
	tracefile << pos.x << " " << pos.y << " " << pos.z << " " << speed.x << " " << speed.y << " " << speed.z << "\n";
#endif

	cegID = gCEG->Load(explGenHandler, cegTag);
}
开发者ID:DarksidedStudios,项目名称:spring,代码行数:35,代码来源:TorpedoProjectile.cpp

示例5: CWeaponProjectile

CLaserProjectile::CLaserProjectile(const float3& pos, const float3& speed,
		CUnit* owner, float length, const float3& color, const float3& color2,
		float intensity, const WeaponDef *weaponDef, int ttl GML_PARG_C)
: CWeaponProjectile(pos,speed,owner,0,ZeroVector,weaponDef,0, true,  ttl GML_PARG_P),
	color(color),
	color2(color2),
	length(length),
	curLength(0),
	stayTime(0),
	intensity(intensity),
	intensityFalloff(weaponDef?intensity*weaponDef->falloffRate:0)
{
	dir=speed;
	dir.Normalize();
	speedf=speed.Length();

	if (weaponDef) SetRadius(weaponDef->collisionSize);
	drawRadius=length;
	if (weaponDef)midtexx = weaponDef->visuals.texture2->xstart + (weaponDef->visuals.texture2->xend-weaponDef->visuals.texture2->xstart)*0.5f;
#ifdef TRACE_SYNC
	tracefile << "New laser: ";
	tracefile << pos.x << " " << pos.y << " " << pos.z << " " << speed.x << " " << speed.y << " " << speed.z << "\n";
#endif

	if (cegTag.size() > 0) {
		ceg.Load(explGenHandler, cegTag);
	}
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:28,代码来源:LaserProjectile.cpp

示例6: DoExplosionDamage

void CGameHelper::DoExplosionDamage(
	CFeature* feature,
	const float3& expPos,
	float expRad,
	const DamageArray& damages,
	const int weaponDefID
) {
	const CollisionVolume* cv = feature->collisionVolume;

	if (cv) {
		const float3 dif = (feature->midPos + cv->GetOffsets()) - expPos;

		float expDist = std::max(dif.Length(), 0.1f);
		float expMod = (expRad - expDist) / expRad;
		float dmgScale = (damages.GetDefaultDamage() + damages.impulseBoost);

		// always do some damage with explosive stuff
		// (DDM wreckage etc. is too big to normally
		// be damaged otherwise, even by BB shells)
		// NOTE: this will also be only approximate
		// for non-spherical volumes
		if ((expRad > SQUARE_SIZE) && (expDist < (cv->GetBoundingRadius() * 1.1f)) && (expMod < 0.1f)) {
			expMod = 0.1f;
		}

		if (expMod > 0.0f) {
			const DamageArray modDamages = damages * expMod;
			const float3& modImpulse = dif * (damages.impulseFactor * expMod / expDist * dmgScale);

			feature->DoDamage(modDamages, modImpulse, NULL, weaponDefID);
		}
	}
}
开发者ID:Tastyfish-Studios,项目名称:Red-Herring-Engine,代码行数:33,代码来源:GameHelper.cpp

示例7: GetCamDistOfGrassBlock

static float GetCamDistOfGrassBlock(const int x, const int y, const bool square = false)
{
	const float qx = x * gSSsq;
	const float qz = y * gSSsq;
	const float3 mid = float3(qx, CGround::GetHeightReal(qx, qz, false), qz);
	const float3 dif = camera->GetPos() - mid;
	return (square) ? dif.SqLength() : dif.Length();
}
开发者ID:amitamitamitamit,项目名称:spring,代码行数:8,代码来源:GrassDrawer.cpp

示例8: CWeaponProjectile

CMissileProjectile::CMissileProjectile(const float3& pos,const float3& speed,CUnit* owner,const DamageArray& damages,float areaOfEffect,float maxSpeed, int ttl,CUnit* target, WeaponDef *weaponDef,float3 targetPos)
: CWeaponProjectile(pos,speed,owner,target,ZeroVector,weaponDef,0),
	damages(damages),
	ttl(ttl),
	maxSpeed(maxSpeed),
	target(target),
	dir(speed),
	oldSmoke(pos),
	age(0),
	drawTrail(true),
	numParts(0),
	areaOfEffect(areaOfEffect),
	decoyTarget(0),
	targPos(targetPos),
	wobbleTime(1),
	wobbleDir(0,0,0),
	wobbleDif(0,0,0),
	isWobbling(weaponDef->wobble>0),
	extraHeightTime(0)
{
	curSpeed=speed.Length();
	dir.Normalize();
	oldDir=dir;
	if(target)
		AddDeathDependence(target);

	SetRadius(0.0);
	if(!weaponDef->visuals.modelName.empty()){
		S3DOModel* model = modelParser->Load3DO(string("objects3d/")+weaponDef->visuals.modelName,1,0);
		if(model){
			SetRadius(model->radius);
		}
	}

	drawRadius=radius+maxSpeed*8;
	ENTER_MIXED;
	float3 camDir=(pos-camera->pos).Normalize();
	if(camera->pos.distance(pos)*0.2+(1-fabs(camDir.dot(dir)))*3000 < 200)
		drawTrail=false;
	ENTER_SYNCED;
	castShadow=true;
#ifdef TRACE_SYNC
	tracefile << "New missile: ";
	tracefile << pos.x << " " << pos.y << " " << pos.z << " " << speed.x << " " << speed.y << " " << speed.z << "\n";
#endif
	if(target)
		target->IncomingMissile(this);

	if(weaponDef->trajectoryHeight>0){
		float dist=pos.distance(targPos);
		extraHeight=dist*weaponDef->trajectoryHeight;
		if(dist<maxSpeed)
			dist=maxSpeed;
		extraHeightTime=(int)(dist/*+pos.distance(targPos+UpVector*dist))*0.5*//maxSpeed);
		extraHeightDecay=extraHeight/extraHeightTime;
	}
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:57,代码来源:MissileProjectile.cpp

示例9:

CFireProjectile::CFireProjectile(const float3& pos, const float3& speed, CUnit* owner, int emitTtl, float emitRadius, int particleTtl, float particleSize):
	//! these are synced, but neither weapon nor piece
	//! (only burning features create instances of them)
	CProjectile(pos, speed, owner, true, false, false),
	ttl(emitTtl),
	emitPos(pos),
	emitRadius(emitRadius),
	particleTime(particleTtl),
	particleSize(particleSize)
{
	drawRadius = emitRadius + particleTime * speed.Length();
	checkCol = false;
	this->pos.y += particleTime * speed.Length() * 0.5f;
	ageSpeed = 1.0f / particleTime;

	alwaysVisible = true;
	castShadow = true;
}
开发者ID:AlexDiede,项目名称:spring,代码行数:18,代码来源:FireProjectile.cpp

示例10: CWeaponProjectile

CFlameProjectile::CFlameProjectile(const float3& pos,const float3& speed,const float3& spread,CUnit* owner,const DamageArray& damages, WeaponDef *weaponDef, int ttl)
: CWeaponProjectile(pos,speed,owner,0,ZeroVector,weaponDef,damages,0),
	spread(spread),
	curTime(0)
{
	invttl=1.0/ttl;

	SetRadius(speed.Length()*0.9);
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:9,代码来源:FlameProjectile.cpp

示例11: Init

void COrbitController::Init(const float3& p, const float3& tar)
{
	CCamera* cam = camera;

	const float l = (tar == ZeroVector)?
		std::max(ground->LineGroundCol(p, p + cam->forward * 1024.0f), 512.0f):
		(p - tar).Length();

	const float3 t = (tar == ZeroVector)? (p + cam->forward * l): tar;
	const float3 v = (t - p);
	const float3 w = (v / v.Length()); // do not normalize v in-place

	const float d = v.Length();
	const float e = RAD2DEG(acos(v.Length2D() / d));
	const float r = RAD2DEG(acos(w.x));

	distance  = cDistance = d;
	elevation = cElevation = e;
	rotation  = cRotation = (v.z > 0.0f)? 180.0f + r: 180.0f - r;
	cen       = t;
}
开发者ID:achoum,项目名称:spring,代码行数:21,代码来源:OrbitController.cpp

示例12: CWeaponProjectile

CStarburstProjectile::CStarburstProjectile(const float3& pos,const float3& speed,CUnit* owner,float3 targetPos,const DamageArray& damages,float areaOfEffect,float maxSpeed,float tracking, int uptime,CUnit* target, WeaponDef *weaponDef, CWeaponProjectile* interceptTarget)
: CWeaponProjectile(pos,speed,owner,target,targetPos,weaponDef,damages,interceptTarget),
	ttl(200),
	maxSpeed(maxSpeed),
	tracking(tracking),
	dir(speed),
	oldSmoke(pos),
	age(0),
	drawTrail(true),
	numParts(0),
	doturn(true),
	curCallback(0),
	numCallback(0),
	missileAge(0),
	areaOfEffect(areaOfEffect)
{
	this->uptime=uptime;
	ttl=(int)min(3000.f,uptime+weaponDef->range/maxSpeed+100);

	maxGoodDif=cos(tracking*0.6);
	curSpeed=speed.Length();
	dir.Normalize();
	oldSmokeDir=dir;

	drawRadius=maxSpeed*8;
	ENTER_MIXED;
	numCallback=new int;
	*numCallback=0;
	float3 camDir=(pos-camera->pos).Normalize();
	if(camera->pos.distance(pos)*0.2+(1-fabs(camDir.dot(dir)))*3000 < 200)
		drawTrail=false;
	ENTER_SYNCED;

	for(int a=0;a<5;++a){
		oldInfos[a]=new OldInfo;
		oldInfos[a]->dir=dir;
		oldInfos[a]->pos=pos;
		oldInfos[a]->speedf=curSpeed;
	}
	castShadow=true;

#ifdef TRACE_SYNC
	tracefile << "New starburst rocket: ";
	tracefile << pos.x << " " << pos.y << " " << pos.z << " " << speed.x << " " << speed.y << " " << speed.z << "\n";
#endif

}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:47,代码来源:StarburstProjectile.cpp

示例13: AddFallingTree

int CAdvTreeDrawer::AddFallingTree(float3 pos, float3 dir, int type)
{
	GML_STDMUTEX_LOCK(tree); // AddFallingTree

	FallingTree ft;

	ft.pos=pos;
	dir.y=0;
	float s=dir.Length();
	if(s>500)
		return 0;
	ft.dir=dir/s;
	ft.speed=std::max(0.01f,s*0.0004f);
	ft.type=type;
	ft.fallPos=0;

	fallingTrees.push_back(ft);
	return 0;
}
开发者ID:DeadnightWarrior,项目名称:spring,代码行数:19,代码来源:AdvTreeDrawer.cpp

示例14: CWeaponProjectile

CLaserProjectile::CLaserProjectile(
    const float3& pos,
    const float3& speed,
    CUnit* owner,
    float length,
    const float3& color,
    const float3& color2,
    float intensity,
    const WeaponDef* weaponDef,
    int ttl):

    CWeaponProjectile(pos, speed, owner, NULL, ZeroVector, weaponDef, NULL, ttl),
    intensity(intensity),
    color(color),
    color2(color2),
    length(length),
    curLength(0.0f),
    intensityFalloff(weaponDef ? (intensity * weaponDef->falloffRate) : 0.0f),
    stayTime(0)
{
    projectileType = WEAPON_LASER_PROJECTILE;

    speedf = speed.Length();
    dir = speed / speedf;

    if (weaponDef) {
        SetRadiusAndHeight(weaponDef->collisionSize, 0.0f);

        midtexx =
            (weaponDef->visuals.texture2->xstart +
             (weaponDef->visuals.texture2->xend - weaponDef->visuals.texture2->xstart) * 0.5f);
    }

    drawRadius = length;

#ifdef TRACE_SYNC
    tracefile << "New laser: ";
    tracefile << pos.x << " " << pos.y << " " << pos.z << " " << speed.x << " " << speed.y << " " << speed.z << "\n";
#endif

    cegID = gCEG->Load(explGenHandler, (weaponDef != NULL)? weaponDef->cegTag: "");
}
开发者ID:rYuuk,项目名称:spring,代码行数:42,代码来源:LaserProjectile.cpp

示例15: InView

bool CCamera::InView(const float3 &p, float radius)
{
	const float3 t = (p - pos);
	const float  l = t.Length();

	if (l < 50.0f) {
		return true;
	}
	else if (l > gu->viewRange) {
		return false;
	}
	
	if ((t.dot(rightside) > radius) ||
	    (t.dot(leftside)  > radius) ||
	    (t.dot(bottom)    > radius) ||
	    (t.dot(top)       > radius)) {
		return false;
	}

	return true;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:21,代码来源:Camera.cpp


注:本文中的float3::Length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。