本文整理汇总了C++中sphere函数的典型用法代码示例。如果您正苦于以下问题:C++ sphere函数的具体用法?C++ sphere怎么用?C++ sphere使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sphere函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: TestForCollisionsAgainstWorld
void CEnvHeadcrabCanister::TestForCollisionsAgainstWorld( const Vector &vecEndPosition )
{
// Splash damage!
// Iterate on all entities in the vicinity.
float flDamageRadius = m_flDamageRadius;
float flDamage = m_flDamage;
CBaseEntity *pEntity;
for ( CEntitySphereQuery sphere( vecEndPosition, flDamageRadius ); ( pEntity = sphere.GetCurrentEntity() ) != NULL; sphere.NextEntity() )
{
if ( pEntity == this )
continue;
if ( !pEntity->IsSolid() )
continue;
// Get distance to object and use it as a scale value.
Vector vecSegment;
VectorSubtract( pEntity->GetAbsOrigin(), vecEndPosition, vecSegment );
float flDistance = VectorNormalize( vecSegment );
float flFactor = 1.0f / ( flDamageRadius * (INNER_RADIUS_FRACTION - 1) );
flFactor *= flFactor;
float flScale = flDistance - flDamageRadius;
flScale *= flScale * flFactor;
if ( flScale > 1.0f )
{
flScale = 1.0f;
}
// Check for a physics object and apply force!
Vector vecForceDir = vecSegment;
IPhysicsObject *pPhysObject = pEntity->VPhysicsGetObject();
if ( pPhysObject )
{
// Send it flying!!!
float flMass = PhysGetEntityMass( pEntity );
vecForceDir *= flMass * 750 * flScale;
pPhysObject->ApplyForceCenter( vecForceDir );
}
if ( pEntity->m_takedamage && ( m_flDamage != 0.0f ) )
{
CTakeDamageInfo info( this, this, flDamage * flScale, DMG_BLAST );
CalculateExplosiveDamageForce( &info, vecSegment, pEntity->GetAbsOrigin() );
pEntity->TakeDamage( info );
}
if ( pEntity->IsPlayer() )
{
if (vecSegment.z < 0.1f)
{
vecSegment.z = 0.1f;
VectorNormalize( vecSegment );
}
float flAmount = SimpleSplineRemapVal( flScale, 0.0f, 1.0f, 250.0f, 1000.0f );
pEntity->ApplyAbsVelocityImpulse( vecSegment * flAmount );
}
}
}
开发者ID:EspyEspurr,项目名称:game,代码行数:60,代码来源:env_headcrabcanister.cpp
示例2: sphere
//--------------------------------------------------------------
void ofApp::update() {
if( bSpacebar ) {
shared_ptr< ofxBulletSphere > sphere( new ofxBulletSphere() );
float trad = fabs(sin( ofGetElapsedTimef() ) * 5);
sphere->create( world.world, ofVec3f( cos( ofGetElapsedTimef()*10.)*trad ,-6, sin(ofGetElapsedTimef()*10)*trad ), 1., 0.75 );
sphere->add();
bulletSpheres.push_back( sphere );
bSpacebar = false;
}
for( int i = 0; i < bulletSpheres.size(); i++ ) {
ofVec3f spos = bulletSpheres[i]->getPosition();
if( spos.y > 5 ) {
bulletSpheres.erase( bulletSpheres.begin() + i );
break;
}
}
if(bAnimated) {
vector< glm::vec3 >& verts = mesh.getVertices();
vector< glm::vec3 >& overts = omesh.getVertices();
for( int i = 0; i < verts.size(); i++ ) {
verts[i].y = ofSignedNoise( verts[i].x*0.025, verts[i].y*0.025 + verts[i].z*0.025, ofGetElapsedTimef() * 0.75 ) * 3;
}
bulletMesh->updateMesh( world.world, mesh );
}
world.update( ofGetLastFrameTime(), 12 );
}
开发者ID:NickHardeman,项目名称:ofxBullet,代码行数:33,代码来源:ofApp.cpp
示例3: on_paint_mesh
void on_paint_mesh(const k3d::mesh& Mesh, const k3d::gl::painter_render_state& RenderState, k3d::iproperty::changed_signal_t& ChangedSignal)
{
const k3d::color color = RenderState.node_selection ? k3d::color(1, 1, 1) : k3d::color(0.8, 0.8, 0.8);
const k3d::color selected_color = RenderState.show_component_selection ? k3d::color(1, 0, 0) : color;
for(k3d::mesh::primitives_t::const_iterator primitive = Mesh.primitives.begin(); primitive != Mesh.primitives.end(); ++primitive)
{
boost::scoped_ptr<k3d::sphere::const_primitive> sphere(k3d::sphere::validate(Mesh, **primitive));
if(!sphere)
continue;
glPolygonOffset(1.0, 1.0);
glEnable(GL_POLYGON_OFFSET_FILL);
glEnable(GL_LIGHTING);
glMatrixMode(GL_MODELVIEW);
for(k3d::uint_t i = 0; i != sphere->matrices.size(); ++i)
{
k3d::gl::material(GL_FRONT_AND_BACK, GL_DIFFUSE, sphere->selections[i] ? selected_color : color);
glPushMatrix();
k3d::gl::push_matrix(sphere->matrices[i]);
draw_solid(RenderState, sphere->radii[i], sphere->z_min[i], sphere->z_max[i], sphere->sweep_angles[i]);
glPopMatrix();
}
}
}
开发者ID:AwesomeDoesIt,项目名称:k3d,代码行数:27,代码来源:sphere_painter.cpp
示例4: sphere
Municao::Municao()
{
sphere();
changeBoundingVolume(Solid::SPHERE);
label(LABEL_MUNICAO);
scale(1.0);
body().gravityScale(0.001);
body().damping(0.0);
light.color(255,180,60);
light.intensity(5.0);
light.attenuation(0.4);
light.quadraticAttenuation(0.01);
visible(false);
disappear();
bala.generate(Particle::GLOW);
bala.setAnimationType(Particle::FIRE);
bala.color(130,70,20);
bala.scale(1.25);
spark.load("media/sprites/spark.tga");
spark.setAnimationType(Particle::FOG);
spark.color(200,100,40);
spark.scale(1.0);
spark.animationMotionOffset(3.5);
spark.stop();
}
开发者ID:filipexts,项目名称:CompGraf_URGE,代码行数:29,代码来源:Municao.cpp
示例5:
double F13::compute(vector<double> x){
int i,k;
double result=0.0;
if(Ovector==NULL)
{
Ovector=createShiftVector(dimension,minX,maxX-1);
Pvector=createPermVector(dimension);
}
for(i=0;i<dimension;i++)
{
anotherz[i]=x[i]-Ovector[i];
}
for(k=1;k<=dimension/(2*nonSeparableGroupSize);k++)
{
result+=rosenbrock(anotherz,nonSeparableGroupSize,k);
}
// printf("Rosenbrock = %1.16E\n", result);
// printf("Sphere = %1.16E\n", sphere(anotherz, dimension, 2));
result+=sphere(anotherz, dimension, 2);
return(result);
}
开发者ID:mikeagn,项目名称:CEC2010SS-LSGO-Benchmarks-CPP,代码行数:26,代码来源:F13.cpp
示例6: on_select_mesh
void on_select_mesh(const k3d::mesh& Mesh, const k3d::gl::painter_render_state& RenderState, const k3d::gl::painter_selection_state& SelectionState, k3d::iproperty::changed_signal_t& ChangedSignal)
{
if(!SelectionState.select_component.count(k3d::selection::SURFACE))
return;
k3d::uint_t primitive_index = 0;
for(k3d::mesh::primitives_t::const_iterator primitive = Mesh.primitives.begin(); primitive != Mesh.primitives.end(); ++primitive, ++primitive_index)
{
boost::scoped_ptr<k3d::sphere::const_primitive> sphere(k3d::sphere::validate(Mesh, **primitive));
if(!sphere)
continue;
k3d::gl::push_selection_token(k3d::selection::PRIMITIVE, primitive_index);
glDisable(GL_LIGHTING);
glMatrixMode(GL_MODELVIEW);
for(k3d::uint_t i = 0; i != sphere->matrices.size(); ++i)
{
k3d::gl::push_selection_token(k3d::selection::SURFACE, i);
glPushMatrix();
k3d::gl::push_matrix(sphere->matrices[i]);
draw_solid(RenderState, sphere->radii[i], sphere->z_min[i], sphere->z_max[i], sphere->sweep_angles[i]);
glPopMatrix();
k3d::gl::pop_selection_token(); // SURFACE
}
k3d::gl::pop_selection_token(); // PRIMITIVE
}
}
开发者ID:AwesomeDoesIt,项目名称:k3d,代码行数:32,代码来源:sphere_painter.cpp
示例7: sphere
void OiGraphix::drawSphere(Sphere* s){
OiGraphixSphere sphere(s->radius,24,24);
sphere.draw((GLfloat)s->xyz.getAt(0),(GLfloat)s->xyz.getAt(1),(GLfloat)s->xyz.getAt(2));
//TODO Verbesserungen darstellen
drawResiduals();
}
开发者ID:cedmayer,项目名称:OpenIndy,代码行数:7,代码来源:oigraphix.cpp
示例8: rootNode
void SpiralScene::setupObjects()
{
int numSpheres = 100;
double sphereScaling = .6;
Angle angleBetweenSpheres = Angle::degrees(25);
double depthBetweenSpheresBase = 1.2;
double depthBetweenSpheresMultiple = 1.10;
int firstSphereDepth = 10;
double radius = 2;
NodePointer rootNode(new TransformNode(getCamera().getTransform()));
MaterialNodePointer material(new MaterialNode(rootNode));
Color white(1, 1, 1);
material->setAmbient(white * .1);
material->setDiffuse(white * .5);
material->setSpecular(white);
material->setShininess(20);
NodePointer firstDepthTranslation(new TranslationNode(0, 0, -firstSphereDepth, material));
NodePointer lastDepthTranslation = firstDepthTranslation;
for (int i = 0; i < numSpheres; i++) {
Angle rotationAngle = angleBetweenSpheres * i;
NodePointer rotation(new RotationNode(rotationAngle, Vector3d::UnitZ(), lastDepthTranslation));
NodePointer radiusTranslation(new TranslationNode(radius, 0, 0, rotation));
NodePointer sphereScalingNode(new ScalingNode(sphereScaling, sphereScaling, sphereScaling, radiusTranslation));
RayObjectPointer sphere(new Sphere(sphereScalingNode));
addObject(sphere);
double depthBetweenSpheres = depthBetweenSpheresBase * pow(depthBetweenSpheresMultiple, i);
lastDepthTranslation = NodePointer(new TranslationNode(0, 0, -depthBetweenSpheres, lastDepthTranslation));
}
}
开发者ID:orangejulius,项目名称:jaytrace,代码行数:33,代码来源:SpiralScene.cpp
示例9: drawLight
void drawLight(void)
{
if (light) {
float Ambient[] = {0.01*ambient ,0.01*ambient ,0.01*ambient ,1.0};
float Diffuse[] = {0.01*diffuse ,0.01*diffuse ,0.01*diffuse ,1.0};
float Specular[] = {0.01*specular,0.01*specular,0.01*specular,1.0};
float Position[] = {lightY,distance*Sin(lightPh),distance*Cos(lightPh),1.0};
glColor3fv(white);
sphere(Position[0],Position[1],Position[2] , 0.1,0);
glEnable(GL_NORMALIZE);
glEnable(GL_LIGHTING);
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0,GL_AMBIENT ,Ambient);
glLightfv(GL_LIGHT0,GL_DIFFUSE ,Diffuse);
glLightfv(GL_LIGHT0,GL_SPECULAR,Specular);
glLightfv(GL_LIGHT0,GL_POSITION,Position);
}
else
glDisable(GL_LIGHTING);
}
开发者ID:gaganthesky,项目名称:TowerDefense_CG,代码行数:31,代码来源:drawExtraStuff.c
示例10: f
float f(Mat m, int n) {
float z = -1.0f;
for (float r = 0.0f; r < 0.8f; r += 0.02f) {
Vec v = { 0.0f, r, 0.0f, 1.0f };
transformPosition(&v, m, v);
z = opUnion(z, sphere(v, transformLength(m, 0.05f * (0.95f - r))));
}
if (n > 0) {
Mat ry, rz, s, t, m2, m3;
rotateZ(&rz, 1.8f);
for (int p = 0; p < 6; p++) {
rotateY(&ry, p * (2 * PI / 6));
mul(&m2, ry, rz);
float ss = 0.45f;
for (float r = 0.2f; r < 0.8f; r += 0.1f) {
scale(&s, ss);
translate(&t, 0.0f, r, 0.0f);
mul(&m3, s, m2);
mul(&m3, t, m3);
mul(&m3, m, m3);
z = opUnion(z, f(m3, n - 1));
ss *= 0.8f;
}
}
}
return z;
}
开发者ID:Lyrics1,项目名称:learn_git,代码行数:30,代码来源:圣诞.c
示例11: initQuadBuffers
MeshLoader::MeshLoader() {
initQuadBuffers();
initCubeBuffers();
initSkyBoxBuffers();
duckVAOC = MeshLoader::loadFromAszFile("res/models/duck.txt");
SolidSphere sphere(1, 12, 24);
initSphereBuffers(sphere.GetVertices(),sphere.numOfVertices);
}
开发者ID:lukaszw896,项目名称:OpenGL-Duck,代码行数:8,代码来源:MeshLoader.cpp
示例12: IndexedSegmentNodeImpl
IndexedSegmentNodeImpl(const _Base it, bool isEnd) :
_Base(it) {
if(!isEnd){
Sphere sphere(*it);
center = sphere.center;
range = sphere.radius;
}
}
开发者ID:kallaballa,项目名称:DebugIndexSegmentTree,代码行数:8,代码来源:TestKDTree.hpp
示例13: TEST
TEST(SphericalBoundary, inside) {
SphericalBoundary sphere(Vector3d(0, 0, 0), 10);
Candidate c;
c.current.setPosition(Vector3d(9, 0, 0));
sphere.process(&c);
EXPECT_TRUE(c.isActive());
EXPECT_FALSE(c.hasProperty("Rejected"));
}
开发者ID:rafaelab,项目名称:CRPropa3,代码行数:8,代码来源:testBreakCondition.cpp
示例14: getCenter
Sphere AAB::getBoundingSphere() const
{
Vector3 center = getCenter();
Vector3 extent = getExtent();
float radius = (max - center).length();
Sphere sphere(center, radius);
return sphere;
}
开发者ID:KrasusC,项目名称:OppositeRenderer,代码行数:8,代码来源:AAB.cpp
示例15: sphere
sphere sphere::operator +(const sphere& other) const
{
glm::vec4 center = (c + other.getCenter()) * 0.5f;
float radius = glm::distance(c, center) + glm::max(r, other.getRadius());
return sphere(center, radius);
}
开发者ID:EddyGun,项目名称:Vulkan,代码行数:8,代码来源:sphere.cpp
示例16: sphere
void MainWindow::on_sphereButton_released()
{
DialogSphere sphere(this);
if(sphere.exec())
ui->glwidget->scene.addSphere( sphere.getX(), sphere.getY(), sphere.getZ(), sphere.getR(), sphere.getDisc() );
ui->glwidget->updateGL();
}
开发者ID:Quixotic7,项目名称:brep,代码行数:8,代码来源:mainwindow.cpp
示例17: ResetSequence
void CASW_Boomer_Blob::CheckNearbyTargets( )
{
// see if an alien is nearby
if ( gpGlobals->curtime >= m_fEarliestAOEDetonationTime )
{
if ( !m_bModelOpening && gpGlobals->curtime >= (m_fDetonateTime - ASW_BOOMER_WARN_DELAY) )
{
// we are one second from detonating, commit to detonating and start the opening sequence
// regardless of anyone nearby
m_bModelOpening = true;
ResetSequence( LookupSequence( "MortarBugProjectile_Opening" ) );
CEffectData data;
data.m_vOrigin = GetAbsOrigin();
CPASFilter filter( data.m_vOrigin );
filter.SetIgnorePredictionCull(true);
DispatchParticleEffect( "boomer_grenade_open", PATTACH_ABSORIGIN_FOLLOW, this, -1, false, -1, &filter );
}
// if we exceeded the detonation time, just detonate
if ( gpGlobals->curtime >= m_fDetonateTime )
{
Detonate();
return;
}
// if the model is opening, do the animation advance
if ( m_bModelOpening )
{
StudioFrameAdvance();
SetNextThink( gpGlobals->curtime );
return;
}
float flRadius = asw_boomer_blob_radius_check_scale.GetFloat() * m_DmgRadius;
Vector vecSrc = GetAbsOrigin();
CBaseEntity *pEntity = NULL;
for ( CEntitySphereQuery sphere( vecSrc, flRadius ); ( pEntity = sphere.GetCurrentEntity() ) != NULL; sphere.NextEntity() )
{
if ( !pEntity || !pEntity->IsPlayer() )
continue;
// give them a 2 second warning before detonation
m_fDetonateTime = MIN( m_fDetonateTime, m_fDetonateTime + ASW_BOOMER_WARN_DELAY );
}
}
if ( m_fDetonateTime <= gpGlobals->curtime + asw_boomer_blob_radius_check_interval.GetFloat() )
{
SetThink( &CASW_Boomer_Blob::Detonate );
SetNextThink( m_fDetonateTime );
}
else
{
SetThink( &CASW_Boomer_Blob::CheckNearbyTargets );
SetNextThink( gpGlobals->curtime + asw_boomer_blob_radius_check_interval.GetFloat() );
}
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:58,代码来源:asw_boomer_blob.cpp
示例18: display
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glLoadIdentity();
//view angle
if (mode == 0) //rotation for ortho mode
{
glRotatef(ph, 1,0,0);
glRotatef(th, 0,1,0);
glScaled(0.4,0.4,0.4);
}
else if (mode == 1) //rotation for perspective mode
{
ex = Sin(-th)*Cos(ph)*8;
ey = Sin(ph)*8;
ez = Cos(-th)*Cos(ph)*8;
gluLookAt(ex,ey,ez , 0,0,0 , 0,Cos(ph),0);
//glScaled(0.3,0.3,0.3);
}
else //mode == 2 // rotation and movement for FP mode
{ // occur in keyboard & special
vx = ex - Sin(th)*Cos(ph); // here we simply update
vy = ey - Sin(ph); // location of view target
vz = ez - Cos(th)*Cos(ph);
gluLookAt(ex,ey,ez , vx,vy,vz , 0,Cos(ph),0);
}
sphere(0, 0, 0, 1.5*r, 0.5); //Jupiter
glPushMatrix();
glRotated(r/2, 0,1,0);
cube(1, 0, 0, r, 0.25); //IO
glPopMatrix();
glPushMatrix();
glRotated(r/4, 0,1,0);
octahedron(-2, 0, 0, 4.0/3.0*r, 0.25); //Europa
glPopMatrix();
glPushMatrix();
glRotated(r/8, 0,1,0);
dodecahedron(3, 0, 0, -1.125*r, 0.25); //Ganymede
glPopMatrix();
glPushMatrix();
glRotated(r/18.4, 0,1,0);
icosahedron(4, 0, 0, 0.75*r, 0.25); //Callisto
glPopMatrix();
r = glutGet(GLUT_ELAPSED_TIME)*rate;
r = fmod(r, 360*24*18.4);
glFlush();
glutSwapBuffers();
}
开发者ID:jchan1e,项目名称:graphics,代码行数:58,代码来源:scene.c
示例19: ghost
static void ghost(double x,double y,double z, double r, int rotate, int col)
{
// Save transformation
glPushMatrix();
// Offset and scale
glTranslated(x,y,z);
if (rotate != 0){
glRotated(rotate,0,1,0);
}
glScaled(r,r,r);
//Draw Body
sphere(x,y,z,r,rotate,col);
//draw body
glPushMatrix();
glTranslated(x,y,z);
glRotated(90,1,0,0);
if (rotate != 0){
glRotated(rotate,0,1,0);
}
glScaled(r,r,r);
cylinder(r);
// Draw eyes
// offset for right eye
glPushMatrix();
glPolygonOffset(0,0);
glTranslated(x+(r/2),y,z+r);
glScaled(r/3,r/3,r/3);
// right eye
sphere(x,y,z,r,rotate,4);
// offset for left eye
glPushMatrix();
glTranslated(x-(r/2),y,z+r);
glScaled(r/3,r/3,r/3);
//left eye
sphere(x,y,z,r,rotate,4);
}
开发者ID:denzelr,项目名称:Pacman,代码行数:45,代码来源:pacman.c
示例20: cb2sph
int cb2sph(float *cube, Vec3i volsize, int ri, Vec3i origin,
int nnz0, int *ptrs, int *cord, float *sphere)
{
int xs, ys, zs, xx, yy, zz, rs, r2;
int ix, iy, iz, jnz, nnz, nrays;
int ftm = 0, status = 0;
int xcent = (int)origin[0];
int ycent = (int)origin[1];
int zcent = (int)origin[2];
int nx = (int)volsize[0];
int ny = (int)volsize[1];
int nz = (int)volsize[2];
r2 = ri*ri;
nnz = 0;
nrays = 0;
ptrs(1) = 1;
for (ix = 1; ix <= nx; ix++) {
xs = ix-xcent;
xx = xs*xs;
for ( iy = 1; iy <= ny; iy++ ) {
ys = iy-ycent;
yy = ys*ys;
jnz = 0;
ftm = 1;
// not the most efficient implementation
for (iz = 1; iz <= nz; iz++) {
zs = iz-zcent;
zz = zs*zs;
rs = xx + yy + zz;
if (rs <= r2) {
jnz++;
nnz++;
sphere(nnz) = cube(iz, iy, ix);
// record the coordinates of the first nonzero ===
if (ftm) {
nrays++;
cord(1,nrays) = iz;
cord(2,nrays) = iy;
cord(3,nrays) = ix;
ftm = 0;
}
}
} // end for (iz..)
if (jnz > 0) {
ptrs(nrays+1) = ptrs(nrays) + jnz;
} // endif (jnz)
} // end for iy
} // end for ix
if (nnz != nnz0) status = -1;
return status;
}
开发者ID:C-CINA,项目名称:2dx,代码行数:57,代码来源:project3d.cpp
注:本文中的sphere函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论