Ejemplo n.º 1
0
/* Display callback */
void 
cbDisplay(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glLoadIdentity();
    gluLookAt(7 * cos(theta), 7 * sin(theta), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0);

    glTranslatef(0.25, 0.25, 0.25);
    sphereColor(brown);
    glutSolidSphere(1.0, 64, 64);

    glTranslatef(0.75, -1.25, -0.75);
    sphereColor(red);
    glutSolidSphere(0.667, 32, 32);

    glTranslatef(-0.25, 2.5, 1.25);
    sphereColor(violet);
    glutSolidSphere(0.5, 32, 32);

    glTranslatef(0.5, 0.0, -1.5);
    sphereColor(gray);
    glutSolidSphere(0.667, 32, 32);

    glutSwapBuffers();
}
Ejemplo n.º 2
0
void Sphere3DOverlay::render(RenderArgs* args) {
    if (!_renderVisible) {
        return; // do nothing if we're not visible
    }

    float alpha = getAlpha();
    xColor color = getColor();
    const float MAX_COLOR = 255.0f;
    glm::vec4 sphereColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);

    auto batch = args->_batch;

    if (batch) {
        batch->setModelTransform(getRenderTransform());

        auto geometryCache = DependencyManager::get<GeometryCache>();
        auto shapePipeline = args->_shapePipeline;
        if (!shapePipeline) {
            shapePipeline = _isSolid ? geometryCache->getOpaqueShapePipeline() : geometryCache->getWireShapePipeline();
        }

        if (_isSolid) {
            geometryCache->renderSolidSphereInstance(args, *batch, sphereColor, shapePipeline);
        } else {
            geometryCache->renderWireSphereInstance(args, *batch, sphereColor, shapePipeline);
        }
    }
}
Ejemplo n.º 3
0
void Sphere3DOverlay::render(RenderArgs* args) {
    if (!_visible) {
        return; // do nothing if we're not visible
    }

    const int SLICES = 15;
    float alpha = getAlpha();
    xColor color = getColor();
    const float MAX_COLOR = 255.0f;
    glm::vec4 sphereColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);

    auto batch = args->_batch;

    if (batch) {
        Transform transform;
        transform.setTranslation(_position);
        transform.setRotation(_rotation);
        transform.setScale(_dimensions);

        batch->setModelTransform(transform);
        DependencyManager::get<GeometryCache>()->renderSphere(*batch, 1.0f, SLICES, SLICES, sphereColor, _isSolid);
    } else {
        glDisable(GL_LIGHTING);
        
        glm::vec3 position = getPosition();
        glm::vec3 center = getCenter();
        glm::vec3 dimensions = getDimensions();
        glm::quat rotation = getRotation();

        float glowLevel = getGlowLevel();
        Glower* glower = NULL;
        if (glowLevel > 0.0f) {
            glower = new Glower(glowLevel);
        }

        glPushMatrix();
            glTranslatef(position.x, position.y, position.z);
            glm::vec3 axis = glm::axis(rotation);
            glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
            glPushMatrix();
                glm::vec3 positionToCenter = center - position;
                glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
                glScalef(dimensions.x, dimensions.y, dimensions.z);
                DependencyManager::get<GeometryCache>()->renderSphere(1.0f, SLICES, SLICES, sphereColor, _isSolid);
            glPopMatrix();
        glPopMatrix();
        
        if (glower) {
            delete glower;
        }
    }

}
Ejemplo n.º 4
0
void DecalManager::renderDecalSpheres()
{
   if ( mData && Con::getBoolVariable( "$renderSpheres" ) )
   {
      PROFILE_SCOPE( DecalManager_renderDecalSpheres );

      const Vector<DecalSphere*> &grid = mData->getGrid();

      GFXDrawUtil *drawUtil = GFX->getDrawUtil();
      ColorI sphereLineColor( 0, 255, 0, 25 );
      ColorI sphereColor( 0, 0, 255, 30 );

      GFXStateBlockDesc desc;
      desc.setBlend( true );
      desc.setZReadWrite( true, false );

      for ( U32 i = 0; i < grid.size(); i++ )
      {
         DecalSphere *decalSphere = grid[i];
         const SphereF &worldSphere = decalSphere->mWorldSphere;
         drawUtil->drawSphere( desc, worldSphere.radius, worldSphere.center, sphereColor );
      }
   }
}
Ejemplo n.º 5
0
void init() {
	SetRandSeed((unsigned int)time(0));
	int nSample=2500;
	matSampler=new MultiJittered(nSample,1024,1);

	emiMat=new Emissive();
	emiMat->ls=40.0;
	planeMat=new Matte();
	planeMat->diffuseBRDF->setSampler(matSampler);
	COLOR3D color(0.9,0.9,0.9);
	planeMat->setCd(color);
	planeMat->setKd(0.75);
	redMat=new Matte();
	redMat->diffuseBRDF->setSampler(matSampler);
	color.g=0.1; color.b=0.1;
	redMat->setCd(color);
	redMat->setKd(0.75);
	greenMat=new Matte();
	greenMat->diffuseBRDF->setSampler(matSampler);
	color.r=0.1; color.g=0.9; color.b=0.1;
	greenMat->setCd(color);
	greenMat->setKd(0.75);
	sphereMat=new Matte();
	sphereMat->diffuseBRDF->setSampler(matSampler);
	COLOR3D sphereColor(0.9,0.9,0.2);
	sphereMat->setCd(sphereColor);
	sphereMat->setKd(0.75);

	InitWorld();
	world->nSamples=nSample;
	world->maxDepth=5;
	RayCast* tracer=new RayCast();
	world->setTracer(tracer);
	delete tracer;

	VECTOR3D eye(0,-50,400),dir(0,0,-1);
	camera=new Camera(eye,dir,0);

	VECTOR3D pos(-50,250,0),va(0,0,-100),vb(100,0,0);

	Rect* lightRec=new Rect(pos,va,vb);
	lightRec->setMaterial(emiMat);
	lightRec->setSampler(matSampler);
	world->addObject(lightRec);

	AreaLight* light=new AreaLight();
	light->setObject(lightRec);
	world->addLight(light);

	pos.x=-200; pos.y=-200; pos.z=-200; va.z=350,vb.x=400;
	Rect* ground=new Rect(pos,va,vb);
	ground->setMaterial(planeMat);
	world->addObject(ground);

	pos.x=-200; pos.y=250; pos.z=150; va.z=-350,vb.x=400;
	Rect* top=new Rect(pos,va,vb);
	top->setMaterial(planeMat);
	world->addObject(top);

	pos.x=-200; pos.y=-200; pos.z=-200; va.x=400; va.y=0; va.z=0; vb.x=0; vb.y=450; vb.z=0;
	Rect* far=new Rect(pos,va,vb);
	far->setMaterial(planeMat);
	world->addObject(far);

	pos.x=-200; pos.y=-200; pos.z=150; va.x=0; va.y=0; va.z=-350; vb.x=0; vb.y=450; vb.z=0;
	Rect* left=new Rect(pos,va,vb);
	left->setMaterial(redMat);
	world->addObject(left);

	pos.x=200; pos.y=-200; pos.z=-200; va.x=0; va.y=0; va.z=350; vb.x=0; vb.y=450; vb.z=0;
	Rect* right=new Rect(pos,va,vb);
	right->setMaterial(greenMat);
	world->addObject(right);

	pos.x=100; pos.y=-150; pos.z=-50;
	Sphere* sphere=new Sphere(pos,50);
	sphere->setMaterial(sphereMat);
	world->addObject(sphere);
}