本文整理汇总了C++中Sphere函数的典型用法代码示例。如果您正苦于以下问题:C++ Sphere函数的具体用法?C++ Sphere怎么用?C++ Sphere使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sphere函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: glClearColor
void Scene::display() {
// Set lighting
light.setLighting();
// Set background color
glClearColor(backgroundColor[0],
backgroundColor[1],
backgroundColor[2],
backgroundColor[3]);
glColor3f(1,1,1);
if (drawAxesOn) drawAxes(-(worldX/2)-5, -(worldY/2)-5, -(worldZ/2)-5);
// Draw real time scene
/*
Thing thing;
unsigned long nObjects = model.get_num_objects();
Vec3 * p = 0;
Vec3 * r = 0;
double * a = 0;
for (unsigned long i=0; i<nObjects; i++) {
model.get_next_object_state(&p,&r,&a);
if (p != 0) {
thing.Cube(p->x, p->y, p->z,
0.4,0.4,0.4,
*a,p->x,p->y,p->z);
}
else { std::cout << "its zero" << std::endl;}
}
*/
// Draw box bounding the world
WireframeCube(0,0,0,
worldX,worldY, worldZ,
0,0,0,0);
// Draw recorded scene
double radius = 1.0;
FrameState * frame = reader.get_next_frame();
if (frame != 0) {
unsigned long nObjects = frame->get_num_objects();
for (unsigned long i=0; i<nObjects; i++) {
Object * o = frame->get_object(i);
if (o != 0) {
// Set color based on id
int origin = o->getID() >> 28;
glColor3f(colors[origin].x, colors[origin].y, colors[origin].z);
// Draw an object from the animation record file
//Cube(o->x(), o->y(), o->z(),
// 0.4,0.4,0.4,
// o->a_r(),o->x_r(),o->y_r(),o->z_r());
Sphere(o->x(), o->y(), o->z(), radius);
}
}
示例2: TEST
TEST(IntersectTest, IntersectPTest) {
Sphere sphere = Sphere(vec3(1,0,0), 1);
Ray ray = Ray(vec3(-1,0,0), vec3(0,1,0), 0, 0, 100);
EXPECT_FALSE(sphere.intersectP(ray));
Ray ray2 = Ray(vec3(0,0,0), vec3(0,1,0), 0, 0, 100);
EXPECT_TRUE(sphere.intersectP(ray2));
}
示例3: vec3
void RayTracer::initVariables()
{
// Camera
CameraPositionPoint = vec3(0, 0, 0);
CameraDirection = vec3(0, 0, -1);
View_Plane = ViewPlane(-0.1, 0.1, -0.1, 0.1, 0.1);
// World
WorldDirection_u = vec3(1, 0, 0);
WorldDirection_v = vec3(0, 1, 0);
WorldDirection_w = vec3(0, 0, 1);
// Object
sphere01 = Sphere(vec3(-4, 0, -7), 1);
sphere02 = Sphere(vec3(0, 0, -7), 2);
sphere03 = Sphere(vec3(4, 0, -7), 1);
// HorozonPlane = pla
}
示例4: dynLightCreate
void FireFieldSpell::Update() {
pPSStream.Update(g_framedelay);
pPSStream1.Update(g_framedelay);
EERIE_LIGHT * el = dynLightCreate(m_light);
if(el) {
el->pos = m_pos + Vec3f(0.f, -120.f, 0.f);
el->intensity = 4.6f;
el->fallstart = Random::getf(150.f, 180.f);
el->fallend = Random::getf(290.f, 320.f);
el->rgb = Color3f(1.f, 0.8f, 0.6f) + Color3f(Random::getf(-0.1f, 0.f), 0.f, 0.f);
el->duration = ArxDurationMs(600);
el->extras=0;
}
if(VisibleSphere(Sphere(m_pos - Vec3f(0.f, 120.f, 0.f), 350.f))) {
pPSStream.Render();
pPSStream1.Render();
float fDiff = g_framedelay / 8.f;
int nTime = checked_range_cast<int>(fDiff);
for(long nn=0;nn<=nTime+1;nn++) {
PARTICLE_DEF * pd = createParticle();
if(!pd) {
break;
}
float t = Random::getf() * (glm::pi<float>() * 2.f) - glm::pi<float>();
float ts = std::sin(t);
float tc = std::cos(t);
pd->ov = m_pos + Vec3f(120.f * ts, 15.f * ts, 120.f * tc) * randomVec();
pd->move = Vec3f(2.f, 1.f, 2.f) + Vec3f(-4.f, -8.f, -4.f) * randomVec3f();
pd->siz = 7.f;
pd->tolive = Random::getu(500, 1500);
pd->tc = fire2;
pd->m_flags = ROTATING | FIRE_TO_SMOKE;
pd->m_rotation = Random::getf(-0.1f, 0.1f);
pd->scale = Vec3f(-8.f);
PARTICLE_DEF * pd2 = createParticle();
if(!pd2) {
break;
}
*pd2 = *pd;
pd2->delay = Random::getu(60, 210);
}
}
}
示例5: setSphere
void Extent::loadSphere( Iff & iff )
{
iff.enterChunk(TAG_SPHR);
Vector center = iff.read_floatVector();
real radius = iff.read_float();
setSphere( Sphere(center,radius) );
iff.exitChunk(TAG_SPHR);
}
示例6: Sphere
EClipStatus CSensorVision::GetBoxClipStatus(CActor* pActor, const bbox3& Box) const
{
//???check FOV too?
sphere Sphere(pActor->Position, Radius);
switch (Sphere.clipstatus(Box))
{
case sphere::Inside: return Inside;
case sphere::Clipped: return Clipped;
case sphere::Outside:
default: return Outside;
}
}
示例7: test
void test(){
Sphere s = Sphere((vec3) {0.,0.,0}, 5., (Color) {100, 100, 100});
Intersection i = s.intersects((vec3) {0,0,-10}, (vec3) {0,0,1});
assertEqual(i.distance, 5., "Intersection distance");
assertEqual(i.point, (vec3) {0,0,-5}, "Intersection point");
assertEqual(i.normal, (vec3) {0,0,-1}, "Intersection normal");
assertEqual(i.obj, &s, "Intersection object");
}
示例8: CHECK_NOT_NULL
std::shared_ptr<RuntimeGameObject> RuntimeGameObject::Create(_In_ const std::shared_ptr<RuntimeGameWorld>& world, _In_ const std::map<std::wstring, std::wstring>& properties)
{
CHECK_NOT_NULL(g_gameObjectFactory);
// Get details from the gameplay module
GameObjectCreateParameters parameters = g_gameObjectFactory(world, properties);
// Create base object with those parameters
std::shared_ptr<RuntimeGameObject> object(GDKNEW RuntimeGameObject(world, parameters));
// stash away these initial properties for later
object->_initialProperties = properties;
// do we have rigid body info? (requires a collision primitive)
if (parameters.collisionPrimitive)
{
RigidBodyCreateParameters rigidBodyParams(parameters.position, 100.0f, parameters.collisionPrimitive.get());
rigidBodyParams.type = PhysicsBodyTypeToRigidBodyType(parameters.physicsType);
rigidBodyParams.gravityScale = (parameters.floating) ? 0.0f : 1.0f;
object->_body = world->GetPhysicsWorld()->CreateBody(object, rigidBodyParams);
}
// if we're in the editor, let's create the picking mesh & sphere
if (world->IsEditing())
{
std::vector<Triangle> triangles;
Matrix identity = Matrix::Identity();
auto& visuals = object->GetVisualInfos();
if (visuals.size())
{
for (auto i = 0; i < visuals.size(); ++i)
{
Collision::TriangleListFromGeometry(Content::LoadGeometryContent(visuals[i].geometry), identity, 0, triangles);
}
object->_triangleMesh = CollisionPrimitive::Create(TriangleMesh(SpacePartitionType::AabbTree, triangles));
// loose sphere around the AABB. Not a best fit, but fast to compute and "good enough" as a pre-test
Vector3 aabbMin, aabbMax;
GetAabbForPrimitive(object->_triangleMesh.get(), &aabbMin, &aabbMax);
object->_sphere = CollisionPrimitive::Create(Sphere((aabbMin + aabbMax) * 0.5f, (aabbMax - aabbMin).Length() * 0.5f));
}
}
// Bind the object and controller, if one was provided
if (parameters.controller)
{
parameters.controller->OnCreate(object);
}
return object;
}
示例9: switch
void Light::ProcessRayQuery(const RayOctreeQuery& query, PODVector<RayQueryResult>& results)
{
// Do not record a raycast result for a directional light, as it would block all other results
if (lightType_ == LIGHT_DIRECTIONAL)
return;
float distance = query.maxDistance_;
switch (query.level_)
{
case RAY_AABB:
Drawable::ProcessRayQuery(query, results);
return;
case RAY_OBB:
{
Matrix3x4 inverse(node_->GetWorldTransform().Inverse());
Ray localRay = query.ray_.Transformed(inverse);
distance = localRay.HitDistance(GetWorldBoundingBox().Transformed(inverse));
if (distance >= query.maxDistance_)
return;
}
break;
case RAY_TRIANGLE:
if (lightType_ == LIGHT_SPOT)
{
distance = query.ray_.HitDistance(GetFrustum());
if (distance >= query.maxDistance_)
return;
}
else
{
distance = query.ray_.HitDistance(Sphere(node_->GetWorldPosition(), range_));
if (distance >= query.maxDistance_)
return;
}
break;
case RAY_TRIANGLE_UV:
LOGWARNING("RAY_TRIANGLE_UV query level is not supported for Light component");
return;
}
// If the code reaches here then we have a hit
RayQueryResult result;
result.position_ = query.ray_.origin_ + distance * query.ray_.direction_;
result.normal_ = -query.ray_.direction_;
result.distance_ = distance;
result.drawable_ = this;
result.node_ = node_;
result.subObject_ = M_MAX_UNSIGNED;
results.Push(result);
}
示例10: AABB
//------------------------------------------------------------------------
void CVehicleDamageBehaviorBurn::Update(const float deltaTime)
{
m_timeCounter -= deltaTime;
if (m_timeCounter <= 0.0f)
{
CGameRules *pGameRules = g_pGame->GetGameRules();
if (pGameRules && gEnv->bServer)
{
Vec3 worldPos;
if (m_pHelper)
worldPos = m_pHelper->GetWorldTM().GetTranslation();
else
worldPos = m_pVehicle->GetEntity()->GetWorldTM().GetTranslation();
SEntityProximityQuery query;
query.box = AABB(worldPos-Vec3(m_radius), worldPos+Vec3(m_radius));
gEnv->pEntitySystem->QueryProximity(query);
IEntity* pEntity = 0;
for (int i = 0; i < query.nCount; ++i)
{
if ((pEntity = query.pEntities[i]) && pEntity->GetPhysics())
{
float damage = (pEntity->GetId() == m_pVehicle->GetEntityId()) ? m_selfDamage : m_damage;
// SNH: need to check vertical distance here as the QueryProximity() call seems to work in 2d only
Vec3 pos = pEntity->GetWorldPos();
if(abs(pos.z - worldPos.z) < m_radius)
{
if (damage > 0.f)
{
HitInfo hitInfo(m_shooterId, pEntity->GetId(), m_pVehicle->GetEntityId(), -1, m_radius);
hitInfo.damage = damage;
hitInfo.pos = worldPos;
hitInfo.type = pGameRules->GetHitTypeId("fire");
pGameRules->ServerHit(hitInfo);
}
}
}
}
if (gEnv->pAISystem)
gEnv->pAISystem->RegisterDamageRegion(this, Sphere(worldPos, m_radius));
}
m_timeCounter = m_interval;
}
m_pVehicle->NeedsUpdate();
}
示例11: sph
void sph(double angle)
{
GLfloat blue_mat[] = { 1, 1, 0, 1 };
glPushMatrix();
glTranslatef(0.75, 0.0, 0);
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue_mat );
Sphere(1.0, 20, 20);
glPopMatrix();
glFinish();
}
示例12: S
// Berechne die kleinste einschliessende Kugel fuer n Punkte, wobei
// die Punkte q1,q2 und q3 auf dem Rand der gesuchten Kugel liegen
Sphere Sphere::ses3(int n, std::vector<Vector3d>& p,Vector3d& q1,Vector3d& q2,Vector3d& q3) {
Sphere S(q1,q2,q3);
///ADD YOUR CODE HERE!
for(int i=0;i<n;i++){
if((p[i]-S.center).length()>S.radius)
S=Sphere(q1,q2,q3,p[i]);
}
return S;
}
示例13: srand
bool CScreensaverCyclone::Start()
{
int i, j;
std::string fraqShader = kodi::GetAddonPath("resources/shaders/frag.glsl");
std::string vertShader = kodi::GetAddonPath("resources/shaders/vert.glsl");
if (!LoadShaderFiles(vertShader, fraqShader) || !CompileAndLink())
return false;
gCycloneSettings.Load();
srand((unsigned)time(nullptr));
// Window initialization
glViewport(X(), Y(), Width(), Height());
glEnable(GL_DEPTH_TEST);
glFrontFace(GL_CCW);
glEnable(GL_CULL_FACE);
glClearColor(0.0, 0.0, 0.0, 1.0);
m_modelMat = glm::mat4(1.0f);
m_projMat = glm::perspective(glm::radians(80.0f), (GLfloat)Height() / (GLfloat)Width(), 50.0f, 3000.0f);
if (!rsRandi(500)) // Easter egg view
{
m_projMat = glm::rotate(m_projMat, glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f));
m_projMat = glm::translate(m_projMat, glm::vec3(0.0f, -(WIDTH * 2), 0.0f));
}
else // Normal view
m_projMat = glm::translate(m_projMat, glm::vec3(0.0f, 0.0f, -(WIDTH * 2)));
Sphere(float(gCycloneSettings.dSize) / 4.0f, 3, 2);
m_lightingEnabled = 1;
// Initialize cyclones and their particles
for (i = 0; i < 13; i++)
m_fact[i] = float(factorial(i));
m_cyclones = new CCyclone*[gCycloneSettings.dCyclones];
m_particles = new CParticle*[gCycloneSettings.dParticles * gCycloneSettings.dCyclones];
for (i = 0; i < gCycloneSettings.dCyclones; i++)
{
m_cyclones[i] = new CCyclone;
for (j=i*gCycloneSettings.dParticles; j<((i+1)*gCycloneSettings.dParticles); j++)
m_particles[j] = new CParticle(m_cyclones[i]);
}
glGenBuffers(1, &m_vertexVBO);
glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO);
m_lastTime = kodi::time::GetTimeSec<double>();
m_startOK = true;
return true;
}
示例14: Sphere
//================================================================================================//
void BrainCell::Spawn(Vec2 pos)
{
IsActive = true;
oPos = Pos = pos;
frame = 0;
fStartLife = fLife = 3;
mSphere = Sphere(20,pos+Vec2(32,32));
iTakeDamageTicks = 0;
iAttackTicks = 0;
pulsate = 0;
}
示例15: Sphere
// Berechne die kleinste einschliessende Kugel fuer n Punkte,
Sphere Sphere::ses0(int n,std::vector<Vector3d>& p) {
Sphere S = Sphere(p[0]);
for(int i=1;i<n;i++){
if((p[i]-S.center).length()>S.radius){
S=ses1(i,p,p[i]);
}
}
///ADD YOUR CODE HERE!
return S;
}