//---------------------------------------- void ofLight::setup() { if(glIndex==-1){ bool bLightFound = false; // search for the first free block for(int i=0; i<OF_MAX_LIGHTS; i++) { if(getActiveLights()[i] == false) { glIndex = i; retain(glIndex); bLightFound = true; break; } } if( !bLightFound ){ ofLog(OF_LOG_ERROR, "ofLight : Trying to create too many lights: " + ofToString(glIndex)); } if(bLightFound) { // run this the first time, since it was not found before // onPositionChanged(); setAmbientColor( getAmbientColor() ); setDiffuseColor( getDiffuseColor() ); setSpecularColor( getSpecularColor() ); setAttenuation( getAttenuationConstant(), getAttenuationLinear(), getAttenuationQuadratic() ); if(getIsSpotlight()) { setSpotlightCutOff(getSpotlightCutOff()); setSpotConcentration(getSpotConcentration()); } if(getIsSpotlight() || getIsDirectional()) { onOrientationChanged(); } } } }
int main(void){ _delay_ms(100); // startup delay init(); // initializations for Arduino.h Tlc.init(); // initialize the TLC chip initGPIO(); // initialize GPIO and pull-ups _delay_ms(100); // GPIO stability delay initTimers(); // initialize timer0 (CTC, T~100us) initPCINT(); // initialize pin change interrupts (2:0) // Temporary idea: Determine the bottom/back LED, send it to rgbUtil so that // it knows which led to cycle to next setBottomLED(0); setAmbientColor(0, 0, 0 ); Serial.begin(9600); //Infinitely cycle an LED around the loop while (1) { if (dt_us > 3000000) stopped(); _delay_ms(75); } return 0; }
void CC3PODLight::initAtIndex( GLint aPODIndex, CC3PODResource* aPODRez ) { super::initAtIndex( aPODIndex, aPODRez ); // Get the light content if (getPodContentIndex() >= 0) { SPODLight* psl = (SPODLight*)aPODRez->getLightPODStructAtIndex(getPodContentIndex()); //LogRez(@"Setting %@ parameters from %@", [self class], NSStringFromSPODLight(psl)); setPodTargetIndex( psl->nIdxTarget ); setAmbientColor( kCC3DefaultLightColorAmbient ); setDiffuseColor( ccc4f(psl->pfColour[0], psl->pfColour[1], psl->pfColour[2], 1.0) ); setSpecularColor( kCC3DefaultLightColorSpecular ); setAttenuation( CC3AttenuationCoefficientsMake(psl->fConstantAttenuation, psl->fLinearAttenuation, psl->fQuadraticAttenuation) ); switch (psl->eType) { case ePODDirectional: setIsDirectionalOnly( true ); break; case ePODPoint: setIsDirectionalOnly( false ); break; case ePODSpot: setIsDirectionalOnly( false ); setSpotCutoffAngle( CC3RadToDeg(psl->fFalloffAngle) ); setSpotExponent( psl->fFalloffExponent ); break; default: break; } } }
void claw(float h) { setDiffuseColor( 0.25, 0.25, 0.85 ); setAmbientColor( 0.25, 0.25, 0.85 ); glBegin( GL_TRIANGLES ); glNormal3d( 0.0, 0.0, 1.0); // +z side glVertex3d( 0.5, 0.0, 0.5); glVertex3d(-0.5, 0.0, 0.5); glVertex3d( 0.5, h, 0.5); glNormal3d( 0.0, 0.0, -1.0); // -z side glVertex3d( 0.5, 0.0, -0.5); glVertex3d(-0.5, 0.0, -0.5); glVertex3d( 0.5, h, -0.5); glEnd(); glBegin( GL_QUADS ); glNormal3d( 1.0, 0.0, 0.0); // +x side glVertex3d( 0.5, 0.0,-0.5); glVertex3d( 0.5, 0.0, 0.5); glVertex3d( 0.5, h, 0.5); glVertex3d( 0.5, h,-0.5); glNormal3d( 0.0,-1.0, 0.0); // -y side glVertex3d( 0.5, 0.0, 0.5); glVertex3d( 0.5, 0.0,-0.5); glVertex3d(-0.5, 0.0,-0.5); glVertex3d(-0.5, 0.0, 0.5); glEnd(); }
/* * Create a directional light with light num and init */ DirectionalLight::DirectionalLight(int lightNum, Vector4 ambient, Vector4 diffuse, Vector4 specular) { lightNumber = lightNum; init(); setAmbientColor(ambient); setDiffuseColor(diffuse); setSpecularColor(specular); }
void upper_arm(float h) { // draw the upper arm setDiffuseColor( 0.85, 0.75, 0.25 ); setAmbientColor( 0.95, 0.75, 0.25 ); glPushMatrix(); glScalef( 1.0, 1.0, 0.7 ); y_box(h); glPopMatrix(); }
Render::Render(DriverType driver) : m_driver (driver), m_deferredVBUnlock (true) { m_pixelCenterOffset = 0; setAmbientColor(Colour(0.25f,0.25f,0.25f,1)); setClearColor(Colour(0.52f,0.6f,0.7f,1)); strncpy_s(m_deviceName, sizeof(m_deviceName), "UNKNOWN", sizeof(m_deviceName)); }
//---------------------------------------- ofLight::ofLight() :data(new Data){ setAmbientColor(ofColor(0,0,0)); setDiffuseColor(ofColor(255,255,255)); setSpecularColor(ofColor(255,255,255)); setPointLight(); // assume default attenuation factors // setAttenuation(1.f,0.f,0.f); }
SpotLight::SpotLight(int lightNum, double cuttoffAngle, double falloffParam, Vector4 ambient, Vector4 diffuse, Vector4 specular) { lightNumber = lightNum; init(); beamWidth = cuttoffAngle; falloff = falloffParam; setAmbientColor(ambient); setDiffuseColor(diffuse); setSpecularColor(specular); }
void CC3PODLight::initAtIndex( GLint aPODIndex, CC3PODResource* aPODRez ) { init(); setPodIndex( aPODIndex ); SPODNode* psn = (SPODNode*)getNodePODStructAtIndex( aPODIndex, aPODRez ); //LogRez(@"Creating %@ at index %i from: %@", [self class], aPODIndex, NSStringFromSPODNode(psn)); setName( psn->pszName ); setPodContentIndex( psn->nIdx ); setPodParentIndex( psn->nIdxParent ); if ( psn->pfAnimPosition ) setLocation( *(CC3Vector*)psn->pfAnimPosition ); if ( psn->pfAnimRotation ) setQuaternion( *(CC3Quaternion*)psn->pfAnimRotation ); if ( psn->pfAnimScale ) setScale( *(CC3Vector*)psn->pfAnimScale ); if ( CC3PODNodeAnimation::sPODNodeDoesContainAnimation((PODStructPtr)psn) ) setAnimation( CC3PODNodeAnimation::animationFromSPODNode( (PODStructPtr)psn, aPODRez->getAnimationFrameCount() ) ); else if (aPODRez->shouldFreezeInanimateNodes()) setAnimation( CC3FrozenNodeAnimation::animationFromNodeState( this ) ); // Get the light content if (getPodContentIndex() >= 0) { SPODLight* psl = (SPODLight*)aPODRez->getLightPODStructAtIndex(getPodContentIndex()); //LogRez(@"Setting %@ parameters from %@", [self class], NSStringFromSPODLight(psl)); setPodTargetIndex( psl->nIdxTarget ); setAmbientColor( kCC3DefaultLightColorAmbient ); setDiffuseColor( ccc4f(psl->pfColour[0], psl->pfColour[1], psl->pfColour[2], 1.0) ); setSpecularColor( kCC3DefaultLightColorSpecular ); setAttenuation( CC3AttenuationCoefficientsMake(psl->fConstantAttenuation, psl->fLinearAttenuation, psl->fQuadraticAttenuation) ); switch (psl->eType) { case ePODDirectional: setIsDirectionalOnly( true ); break; case ePODPoint: setIsDirectionalOnly( false ); break; case ePODSpot: setIsDirectionalOnly( false ); setSpotCutoffAngle( CC3RadToDeg(psl->fFalloffAngle) ); setSpotExponent( psl->fFalloffExponent ); break; default: break; } } }
//---------------------------------------- ofLight::ofLight(){ glIndex = -1; isEnabled = false; setAmbientColor(ofColor(0,0,0)); setDiffuseColor(ofColor(255,255,255)); setSpecularColor(ofColor(255,255,255)); setPointLight(); // assume default attenuation factors // setAttenuation(1.f,0.f,0.f); }
Material::Material() { mShaderProgram = NULL; setAmbientColor(); setDiffuseColor(); setEmissiveColor(); setSpecularColor(); mUniformsInitialized = false; for (unsigned int i = 0; i < MATERIAL_COMPONENT_COUNT; ++i) { mMaterialComponentEnabled[i] = false; } }
void VClouds::create() { remove(); mVolCloudsMaterial = static_cast<Ogre::MaterialPtr>( Ogre::MaterialManager::getSingleton().getByName("SkyX_VolClouds")); mVolCloudsLightningMaterial = static_cast<Ogre::MaterialPtr>( Ogre::MaterialManager::getSingleton().getByName( "SkyX_VolClouds_Lightning")); if (mVolCloudsMaterial.isNull() || mVolCloudsLightningMaterial.isNull()) { SkyXLOG("Error while creating SkyX::VClouds::VClouds," "materials are not found"); return; } // Data manager mDataManager->create(128, 128, 20); // Geometry manager mGeometryManager->create(mGeometrySettings.Height, mGeometrySettings.Radius, mGeometrySettings.Alpha, mGeometrySettings.Beta, mGeometrySettings.NumberOfBlocks, mGeometrySettings.Na, mGeometrySettings.Nb, mGeometrySettings.Nc); mGeometryManager->getSceneNode()->setVisible(mVisible); mVolCloudsMaterial ->getTechnique(0)->getPass(0)->getVertexProgramParameters()-> setNamedConstant("uRadius", mGeometrySettings.Radius); mVolCloudsLightningMaterial-> getTechnique(0)->getPass(0)->getVertexProgramParameters()-> setNamedConstant("uRadius", mGeometrySettings.Radius); // Lightning manager mLightningManager->create(); mCreated = true; // Update material parameters setSunColor(mSunColor); setAmbientColor(mAmbientColor); setLightResponse(mLightResponse); setAmbientFactors(mAmbientFactors); // Set current wheater setWheater(mWheater.x, mWheater.y, mDelayedResponse); }
void rotation_base(float h) { setDiffuseColor( 0.85, 0.75, 0.25 ); setAmbientColor( 0.95, 0.75, 0.25 ); glPushMatrix(); glPushMatrix(); glScalef(4.0, h, 4.0); y_box(1.0f); // the rotation base glPopMatrix(); setDiffuseColor( 0.15, 0.15, 0.65 ); setAmbientColor( 0.15, 0.15, 0.65 ); glPushMatrix(); glTranslatef(-0.5, h, -0.6); glScalef(2.0, h, 1.6); y_box(1.0f); // the console glPopMatrix(); setDiffuseColor( 0.65, 0.65, 0.65 ); setAmbientColor( 0.65, 0.65, 0.65 ); glPushMatrix(); glTranslatef( 0.5, h, 0.6 ); glRotatef( -90.0, 1.0, 0.0, 0.0 ); drawCylinder( h, 0.05, 0.05 ); // the pipe glPopMatrix(); glPopMatrix(); }
KX_WorldInfo::KX_WorldInfo(Scene *blenderscene, World *blenderworld) { if (blenderworld) { m_name = blenderworld->id.name + 2; m_do_color_management = BKE_scene_check_color_management_enabled(blenderscene); m_hasworld = true; m_hasmist = ((blenderworld->mode) & WO_MIST ? true : false); m_misttype = blenderworld->mistype; m_miststart = blenderworld->miststa; m_mistdistance = blenderworld->mistdist; m_mistintensity = blenderworld->misi; setMistColor(blenderworld->horr, blenderworld->horg, blenderworld->horb); setBackColor(blenderworld->horr, blenderworld->horg, blenderworld->horb); setAmbientColor(blenderworld->ambr, blenderworld->ambg, blenderworld->ambb); } else { m_hasworld = false; } }
//---------------------------------------- void ofLight::setup() { if(data->glIndex==-1){ bool bLightFound = false; // search for the first free block for(size_t i=0; i<ofLightsData().size(); i++) { if(ofLightsData()[i].expired()) { data->glIndex = i; data->isEnabled = true; ofLightsData()[i] = data; bLightFound = true; break; } } if(!bLightFound && ofIsGLProgrammableRenderer()){ ofLightsData().push_back(data); data->glIndex = ofLightsData().size() - 1; data->isEnabled = true; bLightFound = true; } if( bLightFound ){ // run this the first time, since it was not found before // onPositionChanged(); setAmbientColor( getAmbientColor() ); setDiffuseColor( getDiffuseColor() ); setSpecularColor( getSpecularColor() ); setAttenuation( getAttenuationConstant(), getAttenuationLinear(), getAttenuationQuadratic() ); if(getIsSpotlight()) { setSpotlightCutOff(getSpotlightCutOff()); setSpotConcentration(getSpotConcentration()); } if(getIsSpotlight() || getIsDirectional()) { onOrientationChanged(); } }else{ ofLogError("ofLight") << "setup(): couldn't get active GL light, maximum number of "<< ofLightsData().size() << " reached"; } } }
void base(float h) { setDiffuseColor( 0.25, 0.25, 0.25 ); setAmbientColor( 0.25, 0.25, 0.25 ); glPushMatrix(); glPushMatrix(); glTranslatef(1.0, h / 2.0, 0.75); drawCylinder(0.25, h / 2.0, h / 2.0); glPopMatrix(); glPushMatrix(); glTranslatef(1.0, h / 2.0, -1.0); drawCylinder(0.25, h / 2.0, h / 2.0); glPopMatrix(); glPushMatrix(); glTranslatef(-1.0, h / 2.0, 0.75); drawCylinder(0.25, h / 2.0, h / 2.0); glPopMatrix(); glPushMatrix(); glTranslatef(-1.0, h / 2.0, -1.0); drawCylinder(0.25, h / 2.0, h / 2.0); glPopMatrix(); glScalef(4.0f, h, 4.0f); y_box(1.0f); glPopMatrix(); }
void lower_arm(float h) { // draw the lower arm setDiffuseColor( 0.85, 0.75, 0.25 ); setAmbientColor( 0.95, 0.75, 0.25 ); y_box(h); }
void ofMaterial::setColors(ofFloatColor oDiffuse, ofFloatColor oAmbient, ofFloatColor oSpecular, ofFloatColor oEmissive) { setDiffuseColor(oDiffuse); setAmbientColor(oAmbient); setSpecularColor(oSpecular); setEmissiveColor(oEmissive); }
Phong::Phong(const Flags flags): transformationMatrixUniform(0), projectionMatrixUniform(1), normalMatrixUniform(2), lightUniform(3), diffuseColorUniform(4), ambientColorUniform(5), specularColorUniform(6), lightColorUniform(7), shininessUniform(8), _flags(flags) { #ifdef MAGNUM_BUILD_STATIC /* Import resources on static build, if not already */ if(!Utility::Resource::hasGroup("MagnumShaders")) importShaderResources(); #endif Utility::Resource rs("MagnumShaders"); #ifndef MAGNUM_TARGET_GLES const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); #else const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200}); #endif Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex); Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment); vert.addSource(flags ? "#define TEXTURED\n" : "") .addSource(rs.get("generic.glsl")) .addSource(rs.get("Phong.vert")); frag.addSource(flags & Flag::AmbientTexture ? "#define AMBIENT_TEXTURE\n" : "") .addSource(flags & Flag::DiffuseTexture ? "#define DIFFUSE_TEXTURE\n" : "") .addSource(flags & Flag::SpecularTexture ? "#define SPECULAR_TEXTURE\n" : "") .addSource(rs.get("Phong.frag")); CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); attachShaders({vert, frag}); #ifndef MAGNUM_TARGET_GLES if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version)) #else if(!Context::current().isVersionSupported(Version::GLES300)) #endif { bindAttributeLocation(Position::Location, "position"); bindAttributeLocation(Normal::Location, "normal"); if(flags) bindAttributeLocation(TextureCoordinates::Location, "textureCoordinates"); } CORRADE_INTERNAL_ASSERT_OUTPUT(link()); #ifndef MAGNUM_TARGET_GLES if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version)) #endif { transformationMatrixUniform = uniformLocation("transformationMatrix"); projectionMatrixUniform = uniformLocation("projectionMatrix"); normalMatrixUniform = uniformLocation("normalMatrix"); lightUniform = uniformLocation("light"); ambientColorUniform = uniformLocation("ambientColor"); diffuseColorUniform = uniformLocation("diffuseColor"); specularColorUniform = uniformLocation("specularColor"); lightColorUniform = uniformLocation("lightColor"); shininessUniform = uniformLocation("shininess"); } #ifndef MAGNUM_TARGET_GLES if(flags && !Context::current().isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>(version)) #endif { if(flags & Flag::AmbientTexture) setUniform(uniformLocation("ambientTexture"), AmbientTextureLayer); if(flags & Flag::DiffuseTexture) setUniform(uniformLocation("diffuseTexture"), DiffuseTextureLayer); if(flags & Flag::SpecularTexture) setUniform(uniformLocation("specularTexture"), SpecularTextureLayer); } /* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */ #ifdef MAGNUM_TARGET_GLES /* Default to fully opaque white so we can see the textures */ if(flags & Flag::AmbientTexture) setAmbientColor(Color4{1.0f}); else setAmbientColor(Color4{0.0f, 1.0f}); if(flags & Flag::DiffuseTexture) setDiffuseColor(Color4{1.0f}); setSpecularColor(Color4{1.0f}); setLightColor(Color4{.0f}); setShininess(80.0f); #endif }
// We are going to override (is that the right word?) the draw() // method of ModelerView to draw out SampleModel void SampleModel::draw() { // This call takes care of a lot of the nasty projection // matrix stuff. Unless you want to fudge directly with the // projection matrix, don't bother with this ... ModelerView::draw(); /************************************************* ** ** NOW SAVE THE CURRENT MODELVIEW MATRIX ** ** At this point in execution, the MODELVIEW matrix contains ** ONLY the camera transformation. We need to save this camera ** transformation so that we can use it later (for reasons ** explained below). ** *****************************************************/ cameraMatrix = getModelViewMatrix(); // draw the sample model setAmbientColor(.1f, .1f, .1f); //glPushMatrix(); //glPopMatrix(); glPushMatrix(); // push identity glTranslated(VAL(XPOS), VAL(YPOS), VAL(ZPOS)); // values set by the sliders if (VAL(NINJATURTLE)) setDiffuseColor(COLOR_GREEN); else setDiffuseColor(.940f, .816f, .811f); if (animate) glRotated(animHeadAngle, 0.0, 1.0, 0.0); if (VAL(EYEBANDANA)) drawEyeBandana(); if (!VAL(NINJATURTLE)) setDiffuseColor(.940f, .816f, .811f); drawHead(); if (!VAL(NINJATURTLE)) { setDiffuseColor(0, 0, 0); drawFace(); setDiffuseColor(.940f, .816f, .811f); drawNeck(); } drawUpperTorso(); drawLowerTorso(); if (!VAL(NINJATURTLE)) setDiffuseColor(.940f, .816f, .811f); drawRightHandJoint(); glPushMatrix(); if (animate) glRotated(animUpperArmAngle, 1.0, 0, 0); drawUpperRightHand(); drawLowerRightHand(); drawRightHand(); glPopMatrix(); drawLeftHandJoint(); glPushMatrix(); if (animate) glRotated(-animUpperArmAngle, 1.0, 0, 0); drawUpperLeftHand(); drawLowerLeftHand(); drawLeftHand(); glPopMatrix(); drawRightLegJoint(); drawLeftLegJoint(); drawUpperRightLeg(); drawLowerRightLeg(); drawRightFoot(); drawUpperLeftLeg(); drawLowerLeftLeg(); drawLeftFoot(); if (VAL(NINJATURTLE)) drawShell(); else drawTail(); // handle the positioning and hierachical modeling of the tail if (VAL(METABALLSKIN)) { MetaBalls mb; mb.setUpGrid(); mb.setUpMetaballs(); mb.evalScalarField(); mb.draw(); } glPopMatrix(); /*********************************************** ** ** NOW WE WILL ACTUALLY BEGIN DRAWING THE MODEL ** ** Draw your model up to the node where you would like ** particles to spawn from. ** ** FYI: As you call glRotate, glScale, or glTranslate, ** OpenGL is multiplying new transformations into the ** MODELVIEW matrix. ** ********************************************/ // If particle system exists, draw it ParticleSystem *ps = ModelerApplication::Instance()->GetParticleSystem(); if (ps != NULL) { ps->computeForcesAndUpdateParticles(t); ps->drawParticles(t, m_camera); } /************************************************* ** ** NOW DO ANY CLOSING CODE ** ** Don't forget that animator requires you to call ** endDraw(). ** **************************************************/ endDraw(); }
void Ariou::draw() { ModelerView::draw(); ModelerApplication::Instance()->Swing(LEFT_UPPER_ARM_ROTATE_X, 3.1); //ModelerApplication::Instance()->Swing(LEFT_UPPER_ARM_ROTATE_Y, 2.5); ModelerApplication::Instance()->Swing(HEAD_ROTATE, 1); ModelerApplication::Instance()->Swing(RIGHT_UPPER_ARM_ROTATE_X, 1.1); ModelerApplication::Instance()->Swing(RIGHT_UPPER_ARM_ROTATE_Y, 4.5); ModelerApplication::Instance()->Swing(LEFT_LEG_ROTATE_X, 6.1); ModelerApplication::Instance()->Swing(RIGHT_LEG_ROTATE_X, 6.1); ModelerApplication::Instance()->Swing(LS_DEPTH, 0.02); ModelerApplication::Instance()->Swing(LS_ANGLE, 0.15); setAmbientColor(.1f, .1f, .1f); setDiffuseColor(COLOR_RED); glPushMatrix(); glScaled(VAL(FLOOR_SIZE), VAL(FLOOR_SIZE), VAL(FLOOR_SIZE)); drawSierpinskiTriangle(0, 0, 1, 0.86602540378443864676372317075293618347140262690519, 0, -0.5, -0.86602540378443864676372317075293618347140262690519, 0, -0.5, VAL(FLOOR_DEPTH)); glTranslated(0, -0.05, 0); setDiffuseColor(COLOR_WHITE); drawPolygon(16, 2); glPopMatrix(); glPushMatrix(); /* GLfloat maambient[] = { 0.79225f, 0.79225f, 0.79225f, 1.0f }; GLfloat madiffuse[] = { 0.50754f, 0.50754f, 0.50754f, 1.0f }; GLfloat maspecular[] = { 0.508273f, 0.508273f, 0.508273f, 0.508273f }; GLfloat shininess = 51.2f; GLfloat maemi[] = { 0.0f, 0.0f, 0.0f, 1.0f }; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, maambient); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, madiffuse); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, maspecular); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, maemi); */ glTranslated(VAL(XPOS), VAL(YPOS), VAL(ZPOS)); glScaled(VAL(XSCALE), VAL(YSCALE), VAL(ZSCALE)); glRotated(VAL(ROTATE), 0, 1, 0); setDiffuseColor(COLOR_YELLOW); // Torus if (VAL(DETAIL_LEVEL) > 1) { glPushMatrix(); glTranslated(.0f, 6, .0f); drawTorus(VAL(TORUS_R), VAL(TORUS_r)); glPopMatrix(); } //head glPushMatrix(); glTranslated(0, VAL(LEG_LENGTH) + 0.05 + VAL(HEIGHT) + 0.05 + VAL(HEAD_SIZE), 0); glRotated(VAL(HEAD_ROTATE), 0.0, 1.0, 0.0); drawSphere(VAL(HEAD_SIZE)); if (VAL(DETAIL_LEVEL) > 2) { // Nose drawRoundCylinder(VAL(HEAD_SIZE) * 1.1, 0.2, 0.2); // Ear glPushMatrix(); glTranslated(0.9 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 1.1 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 0); glRotated(-20, 0, 0, 1); drawPyramid(VAL(EAR_SIZE)); glPopMatrix(); glPushMatrix(); glTranslated(-0.9 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 1.1 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 0); glRotated(20, 0, 0, 1); drawPyramid(VAL(EAR_SIZE)); glPopMatrix(); // Eyes glPushMatrix(); setDiffuseColor(COLOR_RED); glTranslated(-0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, 0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, VAL(HEAD_SIZE) - 0.9); drawRoundCylinder( 0.9, 0.2, 0.2); glPopMatrix(); glPushMatrix(); setDiffuseColor(COLOR_RED); glTranslated( 0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, 0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, VAL(HEAD_SIZE) - 0.9); drawRoundCylinder( 0.9, 0.2, 0.2); glPopMatrix(); } glPopMatrix(); if (VAL(DETAIL_LEVEL) > 1) { //body // a.k.a. torso/trunk glPushMatrix(); setDiffuseColor(COLOR_YELLOW); glTranslated(0, 0.05 + VAL(LEG_LENGTH), 0); glRotated(-90, 1.0, 0.0, 0.0); drawRoundCylinder(VAL(HEIGHT), 0.7, 0.6); glPushMatrix(); glTranslated(-0.8, 0, VAL(HEIGHT) - 0.4); glRotated(90, 0, 1, 0); // the shoulder if (VAL(DETAIL_LEVEL) > 2) { drawRoundCylinder(1.6, 0.2, 0.2); } glPopMatrix(); // the waist if (VAL(DETAIL_LEVEL) > 3) { glPushMatrix(); glTranslated(0, 0, 0.5); glRotated(90, 1, 0, 0); drawTorus(0.7, 0.08); glPopMatrix(); } glPopMatrix(); if (VAL(DETAIL_LEVEL) > 2) { //right arm glPushMatrix(); glTranslated(-0.7 - 0.20, VAL(LEG_LENGTH) + 0.05 + VAL(HEIGHT) * 0.9f, 0); glTranslated(0.15, 0, 0); glRotated(VAL(RIGHT_UPPER_ARM_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(RIGHT_UPPER_ARM_ROTATE_Y), 0.0, 1.0, 0.0); glTranslated(-0.15, 0, 0); drawRoundCylinder(VAL(UPPER_ARM_LENGTH), 0.22, 0.15); // lower arm glTranslated(0, 0, VAL(UPPER_ARM_LENGTH) - 0.1); glRotated(VAL(RIGHT_LOWER_ARM_ROTATE) - 180, 1, 0, 0); drawRoundCylinder(VAL(LOWER_ARM_LENGTH), 0.15, 0.20); // hand glPushMatrix(); glTranslated(-0.03, -0.15, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(VAL(RIGHT_HAND_ANGLE), 0, 1, 0); drawCylinder(0.8, 0.15, 0.0001); glPopMatrix(); glPushMatrix(); glTranslated(0.03, -0.15, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(-VAL(RIGHT_HAND_ANGLE), 0, 1, 0); drawCylinder(0.8, 0.15, 0.0001); glPopMatrix(); glPopMatrix(); //left arm glPushMatrix(); glTranslated(0.7 + 0.20, VAL(LEG_LENGTH) + 0.05 + VAL(HEIGHT) * 0.9f, 0); glTranslated(-0.15, 0, 0); glRotated(VAL(LEFT_UPPER_ARM_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(LEFT_UPPER_ARM_ROTATE_Y), 0.0, 1.0, 0.0); glTranslated(0.15, 0, 0); drawRoundCylinder(VAL(UPPER_ARM_LENGTH), 0.22, 0.15); glTranslated(0, 0, VAL(UPPER_ARM_LENGTH) - 0.1); glRotated(VAL(LEFT_LOWER_ARM_ROTATE) - 180, 1, 0, 0); drawRoundCylinder(VAL(LOWER_ARM_LENGTH), 0.15, 0.20); // hand glPushMatrix(); glTranslated(-0.03, 0, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(VAL(LEFT_HAND_ANGLE), 0, 1, 0); drawBox(0.03, 0.25, 0.5); glPopMatrix(); glPushMatrix(); glTranslated(0.03, 0, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(-VAL(LEFT_HAND_ANGLE), 0, 1, 0); drawBox(0.03, 0.25, 0.5); if (VAL(DETAIL_LEVEL) > 3) { glRotated(90, 0, 0, 1); drawCylinder(5, 0.02, 0.02); if (VAL(DETAIL_LEVEL) > 4) { glTranslated(0, 0, 4); LS ls("X", VAL(LS_DEPTH), VAL(LS_ANGLE)); ls.expand(0); glPushMatrix(); setDiffuseColor(COLOR_GREEN); glTranslated(0, -0.5, 1); glPushMatrix(); glRotated(90, 1.0, 0.0, 0.0); ls.drawLS(); glPopMatrix(); glPopMatrix(); } } glPopMatrix(); glPopMatrix(); } //right leg glPushMatrix(); setDiffuseColor(COLOR_YELLOW); glTranslated(-0.5, VAL(LEG_LENGTH), 0); glRotated(VAL(RIGHT_LEG_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(RIGHT_LEG_ROTATE_Y), 0.0, 1.0, 0.0); drawRoundCylinder(VAL(LEG_LENGTH) - 0.15, 0.3, 0.4); glTranslated(0, 0, VAL(LEG_LENGTH) * 0.85f); glRotated(70, 1, 0, 0); drawTorus(VAL(FEET_SIZE), VAL(FEET_SIZE) / 4); glPopMatrix(); //left leg glPushMatrix(); glTranslated(0.5, VAL(LEG_LENGTH), 0); glRotated(VAL(LEFT_LEG_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(LEFT_LEG_ROTATE_Y), 0.0, 1.0, 0.0); drawRoundCylinder(VAL(LEG_LENGTH) - 0.15, 0.3, 0.4); glTranslated(0, 0, VAL(LEG_LENGTH) * 0.85f); glRotated(70, 1, 0, 0); drawTorus(VAL(FEET_SIZE), VAL(FEET_SIZE) / 4); glPopMatrix(); } glPopMatrix(); }
void PMFinish::restoreMemento( PMMemento* s ) { PMMementoDataIterator it( s ); PMMementoData* data; for( ; it.current( ); ++it ) { data = it.current( ); if( data->objectType( ) == s_pMetaObject ) { switch( data->valueID( ) ) { case PMAmbientColorID: setAmbientColor( data->colorData( ) ); break; case PMDiffuseID: setDiffuse( data->doubleData( ) ); break; case PMBrillianceID: setBrilliance( data->doubleData( ) ); break; case PMCrandID: setCrand( data->doubleData( ) ); break; case PMConserveEnergyID: setConserveEnergy( data->boolData( ) ); case PMPhongID: setPhong( data->doubleData( ) ); break; case PMPhongSizeID: setPhongSize( data->doubleData( ) ); break; case PMMetallicID: setMetallic( data->doubleData( ) ); break; case PMSpecularID: setSpecular( data->doubleData( ) ); break; case PMRoughnessID: setRoughness( data->doubleData( ) ); break; case PMIridID: setIrid( data->boolData( ) ); break; case PMIridAmountID: setIridAmount( data->doubleData( ) ); break; case PMIridThicknessID: setIridThickness( data->doubleData( ) ); break; case PMIridTurbulenceID: setIridTurbulence( data->doubleData( ) ); break; case PMReflectionColorID: setReflectionColor( data->colorData( ) ); break; case PMReflectionMinColorID: setReflectionMinColor( data->colorData( ) ); break; case PMReflectionFresnelID: setReflectionFresnel( data->boolData( ) ); break; case PMReflectionFalloffID: setReflectionFalloff( data->doubleData( ) ); break; case PMReflectionExponentID: setReflectionExponent( data->doubleData( ) ); break; case PMReflectionMetallicID: setReflectionMetallic( data->doubleData( ) ); break; case PMEnableAmbientID: enableAmbient( data->boolData( ) ); break; case PMEnablePhongID: enablePhong( data->boolData( ) ); break; case PMEnablePhongSizeID: enablePhongSize( data->boolData( ) ); break; case PMEnableDiffuseID: enableDiffuse( data->boolData( ) ); break; case PMEnableBrillianceID: enableBrilliance( data->boolData( ) ); break; case PMEnableCrandID: enableCrand( data->boolData( ) ); break; case PMEnableSpecularID: enableSpecular( data->boolData( ) ); break; case PMEnableRoughnessID: enableRoughness( data->boolData( ) ); break; case PMEnableMetallicID: enableMetallic( data->boolData( ) ); break; case PMEnableReflectionID: enableReflection( data->boolData( ) ); break; case PMEnableReflectionMinID: enableReflectionMin( data->boolData( ) ); break; case PMEnableRefFalloffID: enableRefFalloff( data->boolData( ) ); break; case PMEnableRefExponentID: enableRefExponent( data->boolData( ) ); break; case PMEnableRefMetallicID: enableRefMetallic( data->boolData( ) ); break; default: kdError( PMArea ) << "Wrong ID in PMFinish::restoreMemento\n"; break; } } } Base::restoreMemento( s ); }
void BasicAmbientMethod::copyFrom(ShadingMethodBase* method) { BasicAmbientMethod* basicAmbientMethod = (BasicAmbientMethod*)method; setAmbient(basicAmbientMethod->getAmbient()); setAmbientColor(basicAmbientMethod->getAmbientColor()); }
// We are going to override (is that the right word?) the draw() // method of ModelerView to draw out SampleModel void SampleModel::draw() { // This call takes care of a lot of the nasty projection // matrix stuff. Unless you want to fudge directly with the // projection matrix, don't bother with this ... ModelerView::draw(); // draw the floor setAmbientColor(.1f,.1f,.1f); setDiffuseColor(1, 1, 1); //drawSphere(6.0); // drawTwoBalls(); drawWeb(9, 15); setDiffuseColor(0.5f, 0.4f, 0.4f); #define DETAIL (VAL(LEVEL_OF_DETAIL)) if (currMood != VAL(MOOD)) { setMood(); currMood = VAL(MOOD); } if (VAL(ANIMATE)) { animate(); } // whole glPushMatrix(); glTranslated(VAL(XPOS), VAL(YPOS), VAL(ZPOS)); glTranslated(0, 1.5, 0); glRotated(VAL(SPIDER_ROTATE_Z), 0, 0, 1); if (DETAIL >= 1) { // belly glPushMatrix(); glTranslated(1.5, 0, 0); glScaled(1.1, 0.7, 0.8); drawSphere(1.2); // spinneret if (DETAIL >= 2) { glPushMatrix(); glTranslated(1.1, 0, 0); glRotated(VAL(SPINNERET_ROTATE_Y), 0, 1, 0); // 90 glRotated(VAL(SPINNERET_ROTATE_X), 1, 0, 0); // 0 drawCylinder(0.3, 0.2, 0); glPopMatrix(); } glPopMatrix(); } if (DETAIL >= 1) { // body if (DETAIL >= 2) { glPushMatrix(); glRotated(VAL(BODY_ROTATE_Z), 0, 0, 1); glPushMatrix(); glScaled(1.3, 1, 1); drawSphere(0.5); glPopMatrix(); // legs if (DETAIL >= 3) { // left legs glPushMatrix(); glTranslated(0, 0, 0.3); if (DETAIL >= 4) { // left 1 glPushMatrix(); glRotated(VAL(LEFT_LEG_1_1_ROTATE_Y), 0, 1, 0); // -60 glRotated(VAL(LEFT_LEG_1_1_ROTATE_X), 1, 0, 0); // -30 drawCylinder(2, 0.1, 0.1); if (DETAIL >= 5) { glPushMatrix(); glTranslated(0, 0, 2); glRotated(VAL(LEFT_LEG_1_2_ROTATE_Y), 0, 1, 0); // -40 glRotated(VAL(LEFT_LEG_1_2_ROTATE_X), 1, 0, 0); // 50 drawCylinder(2, 0.1, 0.1); if (DETAIL >= 6) { glPushMatrix(); glTranslated(0, 0, 2); glRotated(VAL(LEFT_LEG_1_3_ROTATE_Y), 0, 1, 0); // -20 glRotated(VAL(LEFT_LEG_1_3_ROTATE_X), 1, 0, 0); // 20 drawCylinder(2, 0.1, 0); // drawSphere(0.2); glPopMatrix(); } glPopMatrix(); } glPopMatrix(); // left 2 glPushMatrix(); glRotated(VAL(LEFT_LEG_2_1_ROTATE_Y), 0, 1, 0); // -30 glRotated(VAL(LEFT_LEG_2_1_ROTATE_X), 1, 0, 0); // -25 drawCylinder(1.5, 0.1, 0.1); if (DETAIL >= 5) { glPushMatrix(); glTranslated(0, 0, 1.5); glRotated(VAL(LEFT_LEG_2_2_ROTATE_Y), 0, 1, 0); // -30 glRotated(VAL(LEFT_LEG_2_2_ROTATE_X), 1, 0, 0); // 40 drawCylinder(1.5, 0.1, 0.1); if (DETAIL >= 6) { glPushMatrix(); glTranslated(0, 0, 1.5); glRotated(VAL(LEFT_LEG_2_3_ROTATE_Y), 0, 1, 0); // -20 glRotated(VAL(LEFT_LEG_2_3_ROTATE_X), 1, 0, 0); // 30 drawCylinder(1.5, 0.1, 0); glPopMatrix(); } glPopMatrix(); } glPopMatrix(); // left 3 glPushMatrix(); glRotated(VAL(LEFT_LEG_3_1_ROTATE_Y), 0, 1, 0); // 20 glRotated(VAL(LEFT_LEG_3_1_ROTATE_X), 1, 0, 0); // -30 drawCylinder(1.5, 0.1, 0.1); if (DETAIL >= 5) { glPushMatrix(); glTranslated(0, 0, 1.5); glRotated(VAL(LEFT_LEG_3_2_ROTATE_Y), 0, 1, 0); // 20 glRotated(VAL(LEFT_LEG_3_2_ROTATE_X), 1, 0, 0); // 50 drawCylinder(1.5, 0.1, 0.1); if (DETAIL >= 6) { glPushMatrix(); glTranslated(0, 0, 1.5); glRotated(VAL(LEFT_LEG_3_3_ROTATE_Y), 0, 1, 0); // 20 glRotated(VAL(LEFT_LEG_3_3_ROTATE_X), 1, 0, 0); // 40 drawCylinder(1.5, 0.1, 0); glPopMatrix(); } glPopMatrix(); } glPopMatrix(); // left 4 glPushMatrix(); glRotated(VAL(LEFT_LEG_4_1_ROTATE_Y), 0, 1, 0); // 60 glRotated(VAL(LEFT_LEG_4_1_ROTATE_X), 1, 0, 0); // -20 drawCylinder(2, 0.1, 0.1); if (DETAIL >= 5) { glPushMatrix(); glTranslated(0, 0, 2); glRotated(VAL(LEFT_LEG_4_2_ROTATE_Y), 0, 1, 0); // 20 glRotated(VAL(LEFT_LEG_4_2_ROTATE_X), 1, 0, 0); // 40 drawCylinder(2, 0.1, 0.1); if (DETAIL >= 6) { glPushMatrix(); glTranslated(0, 0, 2); glRotated(VAL(LEFT_LEG_4_3_ROTATE_Y), 0, 1, 0); // 20 glRotated(VAL(LEFT_LEG_4_3_ROTATE_X), 1, 0, 0); // 20 drawCylinder(2, 0.1, 0); glPopMatrix(); } glPopMatrix(); } glPopMatrix(); } glPopMatrix(); // right legs glPushMatrix(); glTranslated(0, 0, -0.3); if (DETAIL >= 4) { // right 1 glPushMatrix(); glRotated(VAL(RIGHT_LEG_1_1_ROTATE_Y), 0, 1, 0); // -60 glRotated(VAL(RIGHT_LEG_1_1_ROTATE_X), 1, 0, 0); // -30 drawCylinder(2, 0.1, 0.1); if (DETAIL >= 5) { glPushMatrix(); glTranslated(0, 0, 2); glRotated(VAL(RIGHT_LEG_1_2_ROTATE_Y), 0, 1, 0); // -40 glRotated(VAL(RIGHT_LEG_1_2_ROTATE_X), 1, 0, 0); // 50 drawCylinder(2, 0.1, 0.1); if (DETAIL >= 6) { glPushMatrix(); glTranslated(0, 0, 2); glRotated(VAL(RIGHT_LEG_1_3_ROTATE_Y), 0, 1, 0); // -20 glRotated(VAL(RIGHT_LEG_1_3_ROTATE_X), 1, 0, 0); // 20 drawCylinder(2, 0.1, 0); glPopMatrix(); } glPopMatrix(); } glPopMatrix(); // right 2 glPushMatrix(); glRotated(VAL(RIGHT_LEG_2_1_ROTATE_Y), 0, 1, 0); // -30 glRotated(VAL(RIGHT_LEG_2_1_ROTATE_X), 1, 0, 0); // -25 drawCylinder(1.5, 0.1, 0.1); if (DETAIL >= 5) { glPushMatrix(); glTranslated(0, 0, 1.5); glRotated(VAL(RIGHT_LEG_2_2_ROTATE_Y), 0, 1, 0); // -30 glRotated(VAL(RIGHT_LEG_2_2_ROTATE_X), 1, 0, 0); // 40 drawCylinder(1.5, 0.1, 0.1); if (DETAIL >= 6) { glPushMatrix(); glTranslated(0, 0, 1.5); glRotated(VAL(RIGHT_LEG_2_3_ROTATE_Y), 0, 1, 0); // -20 glRotated(VAL(RIGHT_LEG_2_3_ROTATE_X), 1, 0, 0); // 30 drawCylinder(1.5, 0.1, 0); glPopMatrix(); } glPopMatrix(); } glPopMatrix(); // right 3 glPushMatrix(); glRotated(VAL(RIGHT_LEG_3_1_ROTATE_Y), 0, 1, 0); // 20 glRotated(VAL(RIGHT_LEG_3_1_ROTATE_X), 1, 0, 0); // -30 drawCylinder(1.5, 0.1, 0.1); if (DETAIL >= 5) { glPushMatrix(); glTranslated(0, 0, 1.5); glRotated(VAL(RIGHT_LEG_3_2_ROTATE_Y), 0, 1, 0); // 20 glRotated(VAL(RIGHT_LEG_3_2_ROTATE_X), 1, 0, 0); // 50 drawCylinder(1.5, 0.1, 0.1); if (DETAIL >= 6) { glPushMatrix(); glTranslated(0, 0, 1.5); glRotated(VAL(RIGHT_LEG_3_3_ROTATE_Y), 0, 1, 0); // 20 glRotated(VAL(RIGHT_LEG_3_3_ROTATE_X), 1, 0, 0); // 40 drawCylinder(1.5, 0.1, 0); glPopMatrix(); } glPopMatrix(); } glPopMatrix(); // right 4 glPushMatrix(); glRotated(VAL(RIGHT_LEG_4_1_ROTATE_Y), 0, 1, 0); // 60 glRotated(VAL(RIGHT_LEG_4_1_ROTATE_X), 1, 0, 0); // -20 drawCylinder(2, 0.1, 0.1); if (DETAIL >= 5) { glPushMatrix(); glTranslated(0, 0, 2); glRotated(VAL(RIGHT_LEG_4_2_ROTATE_Y), 0, 1, 0); // 20 glRotated(VAL(RIGHT_LEG_4_2_ROTATE_X), 1, 0, 0); // 40 drawCylinder(2, 0.1, 0.1); if (DETAIL >= 6) { glPushMatrix(); glTranslated(0, 0, 2); glRotated(VAL(RIGHT_LEG_4_3_ROTATE_Y), 0, 1, 0); // 20 glRotated(VAL(RIGHT_LEG_4_3_ROTATE_X), 1, 0, 0); // 20 drawCylinder(2, 0.1, 0); glPopMatrix(); } glPopMatrix(); } glPopMatrix(); } glPopMatrix(); } if (DETAIL >= 3) { // head glPushMatrix(); glTranslated(-0.6, 0, 0); drawSphere(0.5); if (DETAIL >= 4) { // left tooth glPushMatrix(); glTranslated(-0.3, 0, 0.2); glRotated(VAL(LEFT_TOOTH_ROTATE_Y), 0, 1, 0); drawCylinder(0.25, 0.25, 0.05); glPopMatrix(); // right tooth glPushMatrix(); glTranslated(-0.3, 0, -0.2); glRotated(VAL(RIGHT_TOOTH_ROTATE_Y), 0, 1, 0); drawCylinder(0.25, 0.25, 0.05); glPopMatrix(); // left antenna glPushMatrix(); glTranslated(-0.3, 0, 0.4); glRotated(VAL(LEFT_ANTENNA_ROTATE_Y), 0, 1, 0); // -75 glRotated(VAL(LEFT_ANTENNA_ROTATE_X), 1, 0, 0); // -30 drawCylinder(1, 0.1, 0.1); if (DETAIL >= 5) { glPushMatrix(); glTranslated(0, 0, 1); glRotated(VAL(LEFT_ANTENNA_UPPER_ROTATE_Y), 0, 1, 0); // -30 glRotated(VAL(LEFT_ANTENNA_UPPER_ROTATE_X), 1, 0, 0); // 45 drawCylinder(0.7, 0.1, 0); glPopMatrix(); } glPopMatrix(); // right antenna glPushMatrix(); glTranslated(-0.3, 0, -0.4); glRotated(VAL(RIGHT_ANTENNA_ROTATE_Y), 0, 1, 0); glRotated(VAL(RIGHT_ANTENNA_ROTATE_X), 1, 0, 0); drawCylinder(1, 0.1, 0.1); if (DETAIL >= 5) { glPushMatrix(); glTranslated(0, 0, 1); glRotated(VAL(RIGHT_ANTENNA_UPPER_ROTATE_Y), 0, 1, 0); glRotated(VAL(RIGHT_ANTENNA_UPPER_ROTATE_X), 1, 0, 0); drawCylinder(0.7, 0.1, 0); glPopMatrix(); } glPopMatrix(); } glPopMatrix(); } glPopMatrix(); } } glPopMatrix(); }
//---------------------------------------- void ofLight::setAmbientColor(float r, float g, float b, float a) { setAmbientColor(r, g, b, a); }