本文整理汇总了C++中VC3类的典型用法代码示例。如果您正苦于以下问题:C++ VC3类的具体用法?C++ VC3怎么用?C++ VC3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VC3类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getRotation
bool CollisionVolume::testCollision(const VC3 &objectPosition, const VC3 &angles, CollisionData &collisionData, float epsilon)
{
QUAT rotation = getRotation(angles);
//rotation.MakeFromAngles(0, -yRotation, 0);
Matrix tm;
tm.CreateRotationMatrix(rotation);
// Everything's relative etc
VC3 rayOrigin = tm.GetTransformedVector(collisionData.rayOrigin - objectPosition) + objectPosition;
VC3 rayDirection = tm.GetWithoutTranslation().GetTransformedVector(collisionData.rayDirection);
if(!data->possibleCollision(objectPosition, collisionData))
return false;
if(!data->accurateCollision(objectPosition, collisionData, rayOrigin, rayDirection))
return false;
float collisionDistance = objectPosition.GetRangeTo(collisionData.rayOrigin);
VC3 pos = tm.GetInverse().GetTransformedVector(collisionData.collisionPosition - objectPosition) + objectPosition;
if(collisionData.hasCollision)
if(collisionDistance > pos.GetRangeTo(collisionData.rayOrigin))
return false;
collisionData.rayLength = collisionDistance;
collisionData.hasCollision = true;
collisionData.collisionPosition = objectPosition;
collisionData.objectData = data->data;
return true;
}
开发者ID:DeejStar,项目名称:Jack-Claw,代码行数:31,代码来源:collision_model.cpp
示例2: SharedModel
SharedModel(shared_ptr<IStorm3D_Model> model_, shared_ptr<IStorm3D_Model> fadeModel_, const std::string &bones_, const std::string &idleAnimation_)
: model(model_),
fadeModel(fadeModel_),
bones(bones_),
idleAnimation(idleAnimation_),
radius(0),
radius2d(0)
{
boost::scoped_ptr<Iterator<IStorm3D_Model_Object *> > objectIterator(model->ITObject->Begin());
for(; !objectIterator->IsEnd(); objectIterator->Next())
{
IStorm3D_Model_Object *object = objectIterator->GetCurrent();
if(!object)
continue;
IStorm3D_Mesh *mesh = object->GetMesh();
if(!mesh)
continue;
VC3 objectPosition = object->GetPosition();
float objectDistance = objectPosition.GetLength();
float distance = objectDistance + mesh->GetRadius();
if(distance > radius)
radius = distance;
float meshRadius = mesh->GetRadius();
if(meshRadius + objectDistance > radius2d)
radius2d = meshRadius + objectDistance;
}
if(!bones.empty())
model->LoadBones(bones.c_str());
}
开发者ID:DeejStar,项目名称:Jack-Claw,代码行数:33,代码来源:storm3d_terrain_groups.cpp
示例3: D3DXMatrixLookAtLH
/*!
\param screen_position screen position
\param position_ position
\param direction_ direction
*/
void Storm3D_Scene::GetEyeVectors(const VC2I &screen_position, Vector &position_, Vector &direction_)
{
static const float NEAR_Z = 2.f;
D3DXMATRIX pProjection;
D3DXMATRIX pView;
VC3 camera_up = camera.GetUpVec();
VC3 camera_position = camera.GetPosition();
VC3 camera_target = camera.GetTarget();
D3DXMatrixLookAtLH(pView, camera_position, camera_target, camera_up);
//RECT windowSize = { 0 };
//GetClientRect(Storm3D2->window_handle, &windowSize);
igios_unimplemented();
Storm3D_SurfaceInfo ss = Storm3D2->GetScreenSize();
float aspect=(float) ss.width / (float) ss.height;
float fov = camera.GetFieldOfView();
float vis_range = camera.GetVisibilityRange();
VC3 pV;
D3DXMatrixPerspectiveFovLH(pProjection,fov,aspect,1.0f,vis_range);
pV.x = 1.0f;
pV.y = 1.0f;
pV.z = 1.0f;
//pV.x = ( ( ( 2.0f * (float)screen_position.x ) / windowSize.right ) - 1 ) / pProjection._11;
//pV.y = -( ( ( 2.0f * (float)screen_position.y ) / windowSize.bottom ) - 1 ) / pProjection._22;
//pV.z = 1.0f;
D3DXMATRIX m;
D3DXMatrixInverse(m, NULL, pView);
VC3 vPickRayDir;
VC3 vPickRayOrig;
vPickRayDir.x = pV.x*m._11 + pV.y*m._21 + pV.z*m._31;
vPickRayDir.y = pV.x*m._12 + pV.y*m._22 + pV.z*m._32;
vPickRayDir.z = pV.x*m._13 + pV.y*m._23 + pV.z*m._33;
vPickRayDir = vPickRayDir.GetNormalized();
vPickRayOrig.x = m._41;
vPickRayOrig.y = m._42;
vPickRayOrig.z = m._43;
vPickRayOrig+=vPickRayDir*NEAR_Z;
direction_.x = vPickRayDir.x;
direction_.y = vPickRayDir.y;
direction_.z = vPickRayDir.z;
position_.x = vPickRayOrig.x;
position_.y = vPickRayOrig.y;
position_.z = vPickRayOrig.z;
}
开发者ID:sopyer,项目名称:Shadowgrounds,代码行数:60,代码来源:Storm3D_Scene.cpp
示例4: upvec
/*!
\param x
\param y
\param dir
\param origin
\param near_z
*/
void Storm3D_Camera::getRayVector(int x, int y, VC3 &dir, VC3 &origin, float near_z)
{
D3DXMATRIX pProjection;
D3DXMATRIX pView;
D3DXVECTOR3 upvec(this->upvec.x, this->upvec.y, this->upvec.z);
D3DXVECTOR3 position(this->position.x, this->position.y, this->position.z);
D3DXVECTOR3 target(this->target.x, this->target.y, this->target.z);
D3DXMatrixLookAtLH(&pView, &position, &target, &upvec);
float fov = this->GetFieldOfView();
Storm3D_SurfaceInfo ss = Storm3D2->GetScreenSize();
float aspect=(float) ss.width / (float) ss.height;
float vis_range = this->GetVisibilityRange();
VC3 pV;
D3DXMatrixPerspectiveFovLH(&pProjection, fov, aspect, 1.0f, vis_range);
pV.x = ( ( ( 2.0f * (float)x * ss.width / 1024 ) / ss.width ) - 1 ) / pProjection._11;
pV.y = ( ( ( 2.0f * (float)y * ss.height / 768 ) / ss.height ) - 1 ) / pProjection._22;
pV.z = 1.0f;
D3DXMATRIX m;
D3DXMatrixInverse(&m, NULL, &pView);
VC3 vPickRayDir;
VC3 vPickRayOrig;
vPickRayDir.x = pV.x * m._11 + pV.y * m._21 + pV.z * m._31;
vPickRayDir.y = pV.x * m._12 + pV.y * m._22 + pV.z * m._32;
vPickRayDir.z = pV.x * m._13 + pV.y * m._23 + pV.z * m._33;
vPickRayDir.Normalize();
vPickRayOrig.x = m._41;
vPickRayOrig.y = m._42;
vPickRayOrig.z = m._43;
vPickRayOrig += vPickRayDir * near_z;
dir.x = vPickRayDir.x;
dir.y = vPickRayDir.y;
dir.z = vPickRayDir.z;
origin.x = vPickRayOrig.x;
origin.y = vPickRayOrig.y;
origin.z = vPickRayOrig.z;
}
开发者ID:DeejStar,项目名称:Jack-Claw,代码行数:54,代码来源:Storm3D_Camera.cpp
示例5: scalevec
void VisualEffect::moveBetween(const VC3 &position_, const VC3 &endPosition, const VC3 &rotation, float alpha, float scale)
{
if (visualObject == NULL)
return;
if (effectType->getType() == VisualEffectType::VISUALEFFECT_TYPE_RAY)
{
this->position = (position_ + endPosition) / 2;
VC3 diffVec = endPosition - position_;
float raylen = diffVec.GetLength();
VC3 scalevec(1*scale,1*scale,raylen);
visualObject->setScale(scalevec);
visualObject->setVisibilityFactor(alpha);
}
visualObject->setPosition(this->position);
visualObject->setRotation(rotation.x, rotation.y, rotation.z);
}
开发者ID:sopyer,项目名称:Shadowgrounds,代码行数:17,代码来源:VisualEffect.cpp
示例6: calcForce
void GravityPointParticleForce::calcForce(Vector& force, const Vector& pos, const Vector& vel) {
VC3 diff = pos - m_point;
VC3 diffNorm = diff.GetNormalized();
float diffLenSq = diff.GetSquareLength();
if (fabsf(diffLenSq) < 0.01f)
{
force.x = 0.0f;
force.y = 0.0f;
force.z = 0.0f;
} else {
// realistic gravity (bad)
//force = -diffNorm * 0.001f * m_gravity / diffLenSq;
// unrealisic gravity (better)
float diffLen = sqrtf(diffLenSq);
force = -diffNorm * 0.001f * m_gravity / diffLen;
}
}
开发者ID:DeejStar,项目名称:Jack-Claw,代码行数:17,代码来源:particleforces.cpp
示例7: physicsExplosion
void ParticlePhysics::physicsExplosion(const VC3 &explosionPosition, float forceFactor, float radius)
{
// added support for radius parameter --jpk
// TODO: this implementation does not take radius into account when calculating forces... (probably should)
float radiusSq = radius * radius;
for(PhysicsActorList::iterator it = data->physicsActorList.begin(); it != data->physicsActorList.end(); ++it)
{
PhysicsActor *actor = *it;
if(!actor)
continue;
VC3 velocity;
if(actor->actor)
actor->actor->getMassCenterPosition(velocity);
else
velocity = actor->position;
velocity -= explosionPosition;
float len = velocity.GetSquareLength();
if(len > radiusSq)
continue;
len = sqrtf(len);
velocity.y *= 1.3f;
velocity.y += 1.0f;
if(len > 0.01f)
{
velocity /= len;
if(len < 1.5f)
len = 1.5f;
velocity /= len;
}
else
velocity.y = 1.f;
velocity *= 7.5f * forceFactor;
//actor->sleepCounter = 1;
actor->force += velocity;
actor->forceUpdate = true;
}
}
开发者ID:DeejStar,项目名称:Shadowgrounds-Redux,代码行数:45,代码来源:ParticlePhysics.cpp
示例8: run
void ProgressBar::run(const VC3 &playerPosition, float playerAngle,
bool continueKeyPressed, bool interruptKeyPressed)
{
if (isProgressing())
{
// has player moved/rotated too much to interrupt the progress
bool playerInterrupted = interruptKeyPressed;
if (!continueKeyPressed)
playerInterrupted = true;
VC3 moved = playerPosition - this->progressPosition;
if (moved.GetSquareLength() > PROGRESSBAR_PLAYER_MOVE_TRESHOLD*PROGRESSBAR_PLAYER_MOVE_TRESHOLD)
playerInterrupted = true;
float rotAngle = util::AngleRotationCalculator::getFactoredRotationForAngles(playerAngle, this->progressAngle, 0.0f);
if (fabs(rotAngle) > PROGRESSBAR_PLAYER_ROTATE_TRESHOLD)
playerInterrupted = true;
if (playerInterrupted)
{
progressing = false;
triggerInterrupted = true;
visibilityLeftCounter = PROGRESSBAR_VISIBLE_AFTER_STOP;
}
if (!isDone())
{
timeDone++;
} else {
progressing = false;
visibilityLeftCounter = PROGRESSBAR_VISIBLE_AFTER_STOP;
}
} else {
if (visibilityLeftCounter > 0)
{
visibilityLeftCounter--;
if (visibilityLeftCounter == 0)
{
visible = false;
}
}
}
}
开发者ID:DeejStar,项目名称:Jack-Claw,代码行数:44,代码来源:ProgressBar.cpp
示例9: SphereCollision
bool SphereCollision(const VC3 &pos, float radius, Storm3D_CollisionInfo &info, bool accurate)
{
if(pos.GetRangeTo(position) < radius + getRadius())
{
info.hit = true;
return true;
}
return false;
}
开发者ID:sopyer,项目名称:Shadowgrounds,代码行数:10,代码来源:storm3d_terrain_decalsystem.cpp
示例10: UpdateVisPlanes
Frustum Storm3D_Camera::getFrustum() const
{
if(!forcedOrthogonalProjection)
{
if(visplane_update_needed)
UpdateVisPlanes();
Frustum result(pnormals, position, vis_range);
return result;
}
else
{
Frustum ret;
VC3 nor = target - position;
nor.Normalize ();
VC3 pn[5] = { nor, nor, nor, nor, nor };
return Frustum(pn, position, 10000.0f);
}
}
开发者ID:DeejStar,项目名称:Shadowgrounds-Redux,代码行数:19,代码来源:Storm3D_Camera.cpp
示例11: SphereCollision
void CollisionFace::SphereCollision(const VC3 &position, float radius, Storm3D_CollisionInfo &colinfo, bool accurate)
{
VC3 closest;
getClosestPoint(position, vertex0, vertex1, vertex2, closest);
float sqRange = closest.GetSquareRangeTo(position);
if(sqRange < radius * radius && sqRange < colinfo.range * colinfo.range)
{
colinfo.hit = true;
colinfo.range = sqrtf(sqRange);
colinfo.position = closest;
colinfo.plane_normal = plane.planenormal;
colinfo.inside_amount = radius - colinfo.range;
float planeRange = plane.GetPointRange(position);
if(planeRange < 0)
colinfo.plane_normal = -colinfo.plane_normal;
}
}
开发者ID:DeejStar,项目名称:Jack-Claw,代码行数:19,代码来源:Storm3D_Mesh_CollisionTable.cpp
示例12: getAmount
float getAmount(const VC3 &pos, float angle, const IStorm3D_Terrain &terrain, float rayHeight) const
{
float fovRadians = fov * (3.1415927f / 180.f);
int index = int(RAY_AMOUNT * (angle + fovRadians) / (2.f * fovRadians));
assert(index >= 0 && index < RAY_AMOUNT);
float distance = pos.GetRangeTo(position);
if(!lengthOk[index])
{
float rayAngle = -fovRadians + float(index) * ((2 * fovRadians) / (RAY_AMOUNT - 1));
VC3 rayDir = direction;
float x = rayDir.x;
float z = rayDir.z;
rayDir.x = x * cosf(rayAngle) + z * sinf(rayAngle);
rayDir.y = 0;
rayDir.z = -x * sinf(rayAngle) + z * cosf(rayAngle);
rayDir.Normalize();
Storm3D_CollisionInfo cInfo;
ObstacleCollisionInfo oInfo;
terrain.rayTrace(position + VC3(0,rayHeight,0) + (rayDir * .5f), rayDir, range, cInfo, oInfo, true, true);
if(oInfo.hit && oInfo.hitAmount > 0)
length[index] = oInfo.ranges[0];
else if(cInfo.hit)
length[index] = cInfo.range;
else
length[index] = range;
lengthOk[index] = true;
}
if(distance > length[index])
return 0;
return 1.f - distance / range;
}
开发者ID:DeejStar,项目名称:Shadowgrounds-Redux,代码行数:39,代码来源:SpotLightCalculator.cpp
示例13: VC3
void PointArrayParticleSystem::setParticleVelocity(Vector& vel, const Vector& dir, float speed, const GenParticleSystemEditables& eds)
{
if(m_parray.get()==NULL)
return;
bool forceDirection = !use_explosion && (eds.launchDirectionType == GenParticleSystemEditables::DIRECTION_EXPLOSION || eds.launchDirectionType == GenParticleSystemEditables::DIRECTION_NEGATIVE_EXPLOSION);
if(m_eds->useNormalsAsDirection || forceDirection)
{
if(m_eds->useBinormalsAsDirection)
{
//VC3 up = VC3(0,1,0);
VC3 up = VC3((rand() % 1000) / 1000.0f, (rand() % 1000) / 1000.0f, (rand() % 1000) / 1000.0f);
VC3 binormal = up.GetCrossWith(m_parray->normals[m_index]);
vel = binormal * speed;
m_rotation.RotateVector(vel);
} else {
vel = m_parray->normals[m_index] * speed;
m_rotation.RotateVector(vel);
}
}
else
vel = dir * speed;
}
开发者ID:DeejStar,项目名称:Shadowgrounds-Redux,代码行数:24,代码来源:pointarrayparticlesystem.cpp
示例14: VC3
bool LineAreaChecker::isPointInsideLineArea(const VC3 &point,
const VC3 &lineStart, const VC3 &lineEnd, float lineWidth)
{
VC3 projPos = lineEnd - lineStart;
float projPosLenSq = projPos.GetSquareLength();
VC3 projPosNorm = VC3(0,0,0);
if (projPosLenSq > 0.00001f)
{
projPosNorm = projPos.GetNormalized();
}
VC3 chkpos = point - lineStart;
float chkposLen = chkpos.GetLength();
VC3 hitAndUnitDiff = chkpos - projPos;
float hitAndUnitDiffLenSq = hitAndUnitDiff.GetSquareLength();
float lineRadiusSq = (float)(lineWidth * lineWidth);
if (hitAndUnitDiffLenSq < lineRadiusSq)
{
return true;
}
if (chkposLen * chkposLen < projPosLenSq)
{
VC3 pipedPos = projPosNorm * chkposLen;
VC3 posdiff = chkpos - pipedPos;
if (posdiff.GetSquareLength() < lineRadiusSq)
{
return true;
}
}
return false;
}
开发者ID:DeejStar,项目名称:Jack-Claw,代码行数:37,代码来源:LineAreaChecker.cpp
示例15: getLightAmount
float SpotLightCalculator::getLightAmount(const VC3 &position, const IStorm3D_Terrain &terrain, float rayHeight) const
{
float squareRange = position.GetSquareRangeTo(data->position);
if(squareRange > data->squareRange)
return 0;
VC2 pdir(position.x - data->position.x, position.z - data->position.z);
VC2 sdir(data->direction.x, data->direction.z);
float pAngle = pdir.CalculateAngle();
float sAngle = sdir.CalculateAngle();
float diff = pAngle - sAngle;
//assert(diff
if(diff < -3.1415f)
diff += 3.1415f * 2;
else if(diff > 3.1415f)
diff -= 3.1415f * 2;
if(fabsf(diff) / 3.1415f * 180.f > data->fov)
return 0;
return data->getAmount(position, -diff, terrain, rayHeight);
}
开发者ID:DeejStar,项目名称:Shadowgrounds-Redux,代码行数:24,代码来源:SpotLightCalculator.cpp
示例16: switch
void PositionScripting::process(util::ScriptProcess *sp,
int command, int intData, char *stringData, ScriptLastValueType *lastValue,
GameScriptData *gsd, Game *game)
{
switch(command)
{
case GS_CMD_SETPOSITION:
{
VC3 tmp(0,0,0);
if (gs_coordinate_param(game->gameMap, stringData, &tmp))
{
float x = tmp.x;
float y = tmp.z;
game->gameMap->keepWellInScaledBoundaries(&x, &y);
gsd->position = VC3(
x, game->gameMap->getScaledHeightAt(x,y), y);
} else {
sp->error("PositionScripting::process - Missing or bad setPosition parameter.");
}
}
break;
case GS_CMD_POSITIONRANDOMOFFSET:
if (intData > 0)
{
int o1 = (game->gameRandom->nextInt() % (intData * 20 + 10)) - intData*10;
int o2 = (game->gameRandom->nextInt() % (intData * 20 + 10)) - intData*10;
int o3 = (game->gameRandom->nextInt() % (intData * 20 + 10)) - intData*10;
gsd->position.x += (float)o1 * 0.1f;
gsd->position.y += (float)o2 * 0.1f;
gsd->position.z += (float)o3 * 0.1f;
} else {
sp->warning("PositionScripting::process - positionRandomOffset with zero parameter.");
lastValue = 0;
}
break;
case GS_CMD_MOVEPOSITIONZ:
gsd->position.z += (float)intData / 100.0f;
break;
case GS_CMD_MOVEPOSITIONX:
gsd->position.x += (float)intData / 100.0f;
break;
case GS_CMD_MOVEPOSITIONZFLOAT:
{
float floatData = *((float *)(&intData));
gsd->position.z += floatData;
}
break;
case GS_CMD_MOVEPOSITIONXFLOAT:
{
float floatData = *((float *)(&intData));
gsd->position.x += floatData;
}
break;
case GS_CMD_GETPOSITIONX:
*lastValue = (int)gsd->position.x;
break;
case GS_CMD_GETPOSITIONZ:
*lastValue = (int)gsd->position.z;
break;
case GS_CMD_GETPOSITIONHEIGHT:
*lastValue = (int)gsd->position.y;
break;
case GS_CMD_GETACCURATEPOSITIONX:
*lastValue = (int)(gsd->position.x * 1000.0f);
break;
case GS_CMD_GETACCURATEPOSITIONZ:
*lastValue = (int)(gsd->position.z * 1000.0f);
break;
case GS_CMD_SETPOSITIONHEIGHT:
if (stringData != NULL)
{
gsd->position.y = (float)atof(stringData);
} else {
sp->error("PositionScripting::process - Missing setPositionHeight parameter.");
}
break;
case GS_CMD_SETPOSITIONHEIGHTONGROUND:
{
float x = gsd->position.x;
float y = gsd->position.z;
game->gameMap->keepWellInScaledBoundaries(&x, &y);
gsd->position = VC3(
x, game->gameMap->getScaledHeightAt(x,y), y);
}
break;
case GS_CMD_POSITIONACCURATERANDOMOFFSET:
if (intData > 0)
//.........这里部分代码省略.........
开发者ID:DeejStar,项目名称:Jack-Claw,代码行数:101,代码来源:PositionScripting.cpp
示例17: pos
void PhysicsLib::updateVisualization(const VC3 &cameraPosition, float range, bool forceUpdate)
{
bool visualizeCollisionShapes = data->featureMap[PhysicsLib::VISUALIZE_COLLISION_SHAPES];
bool visualizeDynamic = data->featureMap[PhysicsLib::VISUALIZE_DYNAMIC];
bool visualizeStatic = data->featureMap[PhysicsLib::VISUALIZE_STATIC];
bool visualizeCollisionContacts = data->featureMap[PhysicsLib::VISUALIZE_COLLISION_CONTACTS];
bool visualizeFluids = data->featureMap[PhysicsLib::VISUALIZE_FLUIDS];
bool visualizeJoints = data->featureMap[PhysicsLib::VISUALIZE_JOINTS];
bool visualizeCCD = data->featureMap[PhysicsLib::VISUALIZE_CCD];
if (forceUpdate
|| visualizeCollisionShapes
|| visualizeDynamic
|| visualizeStatic
|| visualizeCollisionContacts
|| visualizeFluids
|| visualizeJoints
|| visualizeCCD)
{
// (do the update)
} else {
// do not unnecessarily do this stuff!
return;
}
float rangeSq = range * range;
int actorAmount = data->scene->getNbActors();
NxActor **actorArray = data->scene->getActors();
if(visualizeCollisionShapes || visualizeStatic || visualizeCollisionContacts)
data->sdk->setParameter(NX_VISUALIZE_COLLISION_SHAPES, 1);
else
data->sdk->setParameter(NX_VISUALIZE_COLLISION_SHAPES, 0);
if(visualizeDynamic)
data->sdk->setParameter(NX_VISUALIZE_BODY_MASS_AXES, 1);
else
data->sdk->setParameter(NX_VISUALIZE_BODY_MASS_AXES, 0);
data->sdk->setParameter(NX_VISUALIZE_CONTACT_NORMAL, visualizeCollisionContacts);
data->sdk->setParameter(NX_VISUALIZE_CONTACT_FORCE, visualizeCollisionContacts);
data->sdk->setParameter(NX_VISUALIZE_CONTACT_POINT, visualizeCollisionContacts);
data->sdk->setParameter(NX_VISUALIZE_COLLISION_SKELETONS, visualizeCCD);
for(int i = 0; i < actorAmount; ++i)
{
NxActor *actor = actorArray[i];
if(!actor)
continue;
NxVec3 nxpos = actor->getGlobalPosition();
VC3 pos(nxpos.x, nxpos.y, nxpos.z);
VC3 diff = (pos - cameraPosition);
diff.y = 0; // ignore height
bool inRange = false;
if (diff.GetSquareLength() < rangeSq)
inRange = true;
if(actor->isDynamic())
{
//if(visualizeDynamic && inRange)
if(visualizeDynamic)
actor->raiseBodyFlag(NX_BF_VISUALIZATION);
else
actor->clearBodyFlag(NX_BF_VISUALIZATION);
}
int shapeAmount = actor->getNbShapes();
NxShape *const*shapes = actor->getShapes();
while(shapeAmount--)
{
NxShape *shape = shapes[shapeAmount];
if(actor->isDynamic())
{
//if(visualizeCollisionShapes && inRange)
if(visualizeCollisionShapes)
shape->setFlag(NX_SF_VISUALIZATION, true);
else
shape->setFlag(NX_SF_VISUALIZATION, false);
}
else
{
if(visualizeStatic && !shape->isHeightField() && inRange)
shape->setFlag(NX_SF_VISUALIZATION, true);
else
shape->setFlag(NX_SF_VISUALIZATION, false);
}
}
}
}
开发者ID:sopyer,项目名称:Shadowgrounds,代码行数:95,代码来源:physics_lib.cpp
示例18: LinkedListIterator
bool ReconChecker::isReconAvailableAtPosition(Game *game, int player, const VC3 &position)
{
LinkedList *ulist = game->units->getAllUnits();
LinkedListIterator iter = LinkedListIterator(ulist);
while (iter.iterateAvailable())
{
Unit *u = (Unit *)iter.iterateNext();
// unit is friendly towards player?
// (but player does not need to be friendly towards the unit ;)
if (u->isActive() && !u->isDestroyed()
&& !game->isHostile(u->getOwner(), player)
&& u->getReconValue() > 0
&& u->getMoveState() != Unit::UNIT_MOVE_STATE_UNCONSCIOUS)
{
VC3 rayStartPosition = u->getPosition() + VC3(0, 2.0f, 0);
VC3 target = position;
float terrainHeight = game->gameMap->getScaledHeightAt(target.x, target.z);
if (target.y < terrainHeight + 2.0f) target.y = terrainHeight + 2.0f;
VC3 dir = target - rayStartPosition;
float dirLen = dir.GetLength();
dir.Normalize();
if (dirLen > u->getUnitType()->getVisionRange() + 2.0f)
{
continue;
}
// TEMP!
// ignore all small own units (1.5m)...
// except the one we're trying to hit
LinkedList *oul = game->units->getOwnedUnits(u->getOwner());
LinkedListIterator iter = LinkedListIterator(oul);
while (iter.iterateAvailable())
{
Unit *ou = (Unit *)iter.iterateNext();
if (ou != u && ou->getUnitType()->getSize() <= 1.5f)
ou->getVisualObject()->setCollidable(false);
}
// disable collision check for this unit
u->getVisualObject()->setCollidable(false);
GameCollisionInfo cinfo;
game->getGameScene()->rayTrace(rayStartPosition, dir, (float)dirLen, cinfo, false, true);
// collision check back
u->getVisualObject()->setCollidable(true);
// TEMP!
// restore them all...
oul = game->units->getOwnedUnits(u->getOwner());
iter = LinkedListIterator(oul);
while (iter.iterateAvailable())
{
Unit *ou = (Unit *)iter.iterateNext();
if (ou != u && ou->getUnitType()->getSize() <= 1.5f)
ou->getVisualObject()->setCollidable(true);
}
if (cinfo.hit)
{
// 4 meters max dist.
if (cinfo.range >= dirLen - 4.0f)
{
return true;
}
} else {
return true;
}
}
}
return false;
}
开发者ID:DeejStar,项目名称:Jack-Claw,代码行数:75,代码来源:ReconChecker.cpp
示例19: assert
void VisualEffect::init(IPointableObject *object, IPointableObject *origin,
const VC3 &position, const VC3 &endPosition, const VC3 &rotation,
int muzzleFlashBarrelNumber)
{
// make sure this is called only once.
assert(visualObject == NULL);
// set the object we want to follow...
if (effectType->getFollow() == VisualEffectType::VISUALEFFECT_FOLLOW_NONE)
{
follow = NULL;
} else {
if (effectType->getFollow() == VisualEffectType::VISUALEFFECT_FOLLOW_OBJECT)
{
follow = object;
} else {
follow = origin;
}
}
// visual object...
visualObject = effectType->getNewVisualObject();
if (effectType->getType() == VisualEffectType::VISUALEFFECT_TYPE_MUZZLEFLASH)
{
// special case: muzzleflash
if (visualObject != NULL && follow != NULL)
{
Muzzleflasher::createMuzzleflash(follow, visualObject, muzzleFlashBarrelNumber);
visualObject->setInScene(false);
} else {
//Logger::getInstance()->error("VisualEffect::init - Null visualObject or follow unit for muzzleflash.");
}
this->position = position;
return;
}
if (effectType->getType() == VisualEffectType::VISUALEFFECT_TYPE_EJECT)
{
this->position = position;
return;
}
// normal and ray visualeffects...
visualObject->setCollidable(false);
visualObject->setInScene(true);
// set position, rotation and scale based on type and the
// given parameters...
if (effectType->getType() == VisualEffectType::VISUALEFFECT_TYPE_NORMAL)
{
this->position = position;
}
if (effectType->getType() == VisualEffectType::VISUALEFFECT_TYPE_RAY)
{
this->position = (position + endPosition) / 2;
VC3 diffVec = endPosition - position;
float raylen = diffVec.GetLength();
VC3 scale(1,1,raylen);
visualObject->setScale(scale);
}
if (effectType->getType() == VisualEffectType::VISUALEFFECT_TYPE_NORMAL)
{
this->position = position;
}
visualObject->setPosition(this->position);
visualObject->setRotation(rotation.x, rotation.y, rotation.z);
}
开发者ID:sopyer,项目名称:Shadowgrounds,代码行数:72,代码来源:VisualEffect.cpp
示例20: assert
void PhysicsContactSoundManager::physicsContact(const PhysicsContact &contact)
{
// WARNING: unsafe IGamePhysicsObject -> AbstractPhysicsObject casts!
AbstractPhysicsObject *o1 = (AbstractPhysicsObject *)contact.obj1;
AbstractPhysicsObject *o2 = (AbstractPhysicsObject *)contact.obj2;
//assert(o1 != NULL);
//assert(o2 != NULL);
assert(contact.physicsObject1);
assert(contact.physicsObject2);
#ifdef PHYSICS_PHYSX
int sm1 = contact.physicsObject1->getIntData();
int sm2 = contact.physicsObject2->getIntData();
// int claw_material = impl->soundmp->getMaterialIndexByName( "claw" );
// int claw_body_material = impl->soundmp->getMaterialIndexByName( "claw_body" );
if(sm1 == SOUNDMATERIALPARSER_NO_SOUND_INDEX || sm2 == SOUNDMATERIALPARSER_NO_SOUND_INDEX)
{
return;
}
#else
if (o1->getSoundMaterial() == SOUNDMATERIALPARSER_NO_SOUND_INDEX
|| o2->getSoundMaterial() == SOUNDMATERIALPARSER_NO_SOUND_INDEX)
{
return;
}
#endif
const util::SoundMaterialParser::SoundMaterialList &smlist = impl->soundmp->getSoundMaterials();
for (int i = 0; i < 2; i++)
{
AbstractPhysicsObject *o = o1;
if (i == 1)
{
o = o2;
}
#ifdef PHYSICS_PHYSX
int smindex = sm1;
if (i == 1)
{
smindex = sm2;
}
assert(smindex >= 0 && smindex < (int)smlist.size());
#else
int smindex = o->getSoundMaterial();
#endif
bool makeSound = false;
VC3 soundpos;
if(o)
{
/*
// debug logging
if( contact.contactForceLen > 1.0f && smlist[smindex].sounds.empty() == false )
{
VC3 accel = o->getAcceleration();
VC3 angaccel = o->getAngularAcceleration();
std::stringstream ss;
ss << contact.contactForceLen << ", " << accel.GetLength() << ", " << angaccel.GetLength() << std::endl;
Logger::getInstance()->error( ss.str().c_str() );
}
*/
if(contact.contactForceLen >= smlist[smindex].requiredForce)
{
// TODO: use contact position instead of object's position.
soundpos = o->getPosition();
VC3 accel = o->getAcceleration();
VC3 angaccel = o->getAngularAcceleration();
if (accel.GetSquareLength() >= smlist[smindex].requiredAcceleration * smlist[smindex].requiredAcceleration
|| angaccel.GetSquareLength() >= smlist[smindex].requiredAngularAcceleration * smlist[smindex].requiredAngularAcceleration)
{
makeSound = true;
/*
std::vector<std::string> soundlist = smlist[smindex].sounds;
if (soundlist.size() > 0)
{
// TODO: some better pseudo-random logic here maybe...
int sndnum = rand() % soundlist.size();
const char *soundfile = soundlist[sndnum].c_str();
float volumeFactor = 1.0f;
if (smlist[smindex].requiredForce > 0.0f)
{
// 40% - 100% volume factor (100% required force - 200% required force)
volumeFactor = (contact.contactForceLen / smlist[smindex].requiredForce) - 1.0f;
volumeFactor *= 0.6f;
volumeFactor += 0.4f;
if (volumeFactor > 1.0f)
volumeFactor = 1.0f;
//.........这里部分代码省略.........
开发者ID:DeejStar,项目名称:Shadowgrounds-Redux,代码行数:101,代码来源:PhysicsContactSoundManager.cpp
注:本文中的VC3类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论