//------------------------------------------------------------- // VtxFogTabs::getObjAttributes() when switched in //------------------------------------------------------------- void VtxFogTabs::getObjAttributes(){ if(!update_needed) return; TNfog *tnode=fog(); TNarg *arg=(TNarg*)tnode->left; //m_density_expr->setValue("1.0"); if(arg){ // height expr m_density_expr->setValue(arg); } Planetoid *orb=getOrbital(); m_hmin_sldr->setValue(orb->fog_min/FEET); m_hmax_sldr->setValue((orb->fog_max-orb->fog_min)/FEET); m_vmin_sldr->setValue(orb->fog_vmin/FEET); m_vmax_sldr->setValue((orb->fog_vmax-orb->fog_vmin)/FEET); Color color=orb->fog_color; color.set_alpha(orb->fog_value); m_fog_color->setColor(color); // m_fog_color.SetColor(orb->fog_color); // m_fog_value=(int)(orb->fog_value*100); update_needed=false; }
Refraction() { unsigned int rttSize = Settings::Manager::getInt("rtt size", "Water"); setRenderOrder(osg::Camera::PRE_RENDER); setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); setReferenceFrame(osg::Camera::RELATIVE_RF); setSmallFeatureCullingPixelSize(Settings::Manager::getInt("small feature culling pixel size", "Water")); setName("RefractionCamera"); setCullMask(Mask_Effect|Mask_Scene|Mask_Terrain|Mask_Actor|Mask_ParticleSystem|Mask_Sky|Mask_Sun|Mask_Player|Mask_Lighting); setNodeMask(Mask_RenderToTexture); setViewport(0, 0, rttSize, rttSize); // No need for Update traversal since the scene is already updated as part of the main scene graph // A double update would mess with the light collection (in addition to being plain redundant) setUpdateCallback(new NoTraverseCallback); // No need for fog here, we are already applying fog on the water surface itself as well as underwater fog // assign large value to effectively turn off fog // shaders don't respect glDisable(GL_FOG) osg::ref_ptr<osg::Fog> fog (new osg::Fog); fog->setStart(10000000); fog->setEnd(10000000); getOrCreateStateSet()->setAttributeAndModes(fog, osg::StateAttribute::OFF|osg::StateAttribute::OVERRIDE); mClipCullNode = new ClipCullNode; addChild(mClipCullNode); mRefractionTexture = new osg::Texture2D; mRefractionTexture->setTextureSize(rttSize, rttSize); mRefractionTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); mRefractionTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); mRefractionTexture->setInternalFormat(GL_RGB); mRefractionTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR); mRefractionTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR); attach(osg::Camera::COLOR_BUFFER, mRefractionTexture); mRefractionDepthTexture = new osg::Texture2D; mRefractionDepthTexture->setSourceFormat(GL_DEPTH_COMPONENT); mRefractionDepthTexture->setInternalFormat(GL_DEPTH_COMPONENT24); mRefractionDepthTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); mRefractionDepthTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); mRefractionDepthTexture->setSourceType(GL_UNSIGNED_INT); mRefractionDepthTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR); mRefractionDepthTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR); attach(osg::Camera::DEPTH_BUFFER, mRefractionDepthTexture); }
//static void LLDrawPoolBump::renderBump(U32 pass) { if (!gPipeline.hasRenderBatches(pass)) { return; } LLFastTimer ftm(FTM_RENDER_BUMP); LLGLDisable fog(GL_FOG); LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_LEQUAL); LLGLEnable blend(GL_BLEND); glColor4f(1,1,1,1); /// Get rid of z-fighting with non-bump pass. LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1.0f, -1.0f); renderBump(pass, sVertexMask); }
ParticleBasicMaterial::ParticleBasicMaterial() : Material(kParticleBasicMaterial) { // equivalent to three.js setMaterialShaders initUniforms(uniforms); vertexShader(ParticleBasicMaterial::kVertexShader); fragmentShader(ParticleBasicMaterial::kFragmentShader); color() = Color( 0xffffff ); // map = null; size() = 1.0f; sizeAttenuation() = true; vertexColors() = false; fog() = true; }
void draw_line(t_env *e, int x) { int height; int i; i = 0; if (e->dist_ray <= 0) { e->dist_ray = 0.01; e->side = 0x0000ff; } fog(e); height = 277 / e->dist_ray; while (i < (double)WIN_Y / 2.0 - (double)height / 2.0) get_pixel_color(e, x, i++); while (i < (double)WIN_Y / 2.0 + (double)height / 2.0) pixel_put(e, x, i++, e->fog); while (i < WIN_Y - 1) { pixel_put(e, x, i, find_ground_color(e, i, x)); i++; } }
//------------------------------------------------------------- // VtxFogTabs::setObjAttributes() when switched out //------------------------------------------------------------- void VtxFogTabs::setObjAttributes(){ update_needed=true; TNfog *tnode=fog(); Planetoid *orb=getOrbital(); orb->fog_vmin=m_vmin_sldr->getValue()*FEET; orb->fog_vmax=(m_vmax_sldr->getValue()+m_vmin_sldr->getValue())*FEET; orb->fog_min=m_hmin_sldr->getValue()*FEET; orb->fog_max=(m_hmax_sldr->getValue()+m_hmin_sldr->getValue())*FEET; Color color=m_fog_color->getColor(); double fog_value=m_fog_color->getValue(); color.set_alpha(fog_value); orb->fog_color=color; orb->fog_value=fog_value; wxString str="fog("; wxString expr=m_density_expr->getText(); if(expr.length()==0) expr="1"; str+=expr; str+=")"; str+="\n"; char p[256]; strcpy(p,str.ToAscii()); tnode->setExpr(p); if(tnode->getExprNode()==0) update_needed=true; else{ update_needed=false; tnode->applyExpr(); } }
Colour* rayTrace(const Colour& ambient, const Point3D& eye, Ray ray, SceneNode* root, const std::list<Light*>& lights, int level, double fogDist){ if(level <= 0) return NULL; Intersection* i = root->intersect(ray); bool fogOn = true; if(fogDist <= 0) fogOn = false; if(i != NULL){ Colour color(0,0,0); Colour fog(0.8,0.8,0.8); Colour diffuse(0,0,0), specular(0,0,0); Material* material = i->getMaterial(); Vector3D n = i->getNormal(); n.normalize(); Point3D p = i->getPoint(); Vector3D v = eye - p; v.normalize(); for (std::list<Light*>::const_iterator I = lights.begin(); I != lights.end(); ++I) { Light light = **I; Vector3D l = light.position - p; l.normalize(); Vector3D r = 2*l*n*n - l; r.normalize(); // shadows Ray lightRay = Ray(p, l); Intersection* lightIsc = root->intersect(lightRay); if(lightIsc == NULL){ // add light contribution //std::cerr << "light" << std::endl; if(n*l > 0) diffuse = diffuse + material->getDiffuse() * (l*n) * light.colour; if(r*v > 0) specular = specular + material->getSpecular() * pow((r*v), material->getShininess()) * light.colour; } } //secondaty rays Vector3D r = 2*v*n*n - v; r.normalize(); Ray refRay(p, r); Colour* reflectedColor = rayTrace(ambient, eye, refRay, root, lights, level-1, fogDist); if(reflectedColor != NULL){ if(n*r > 0) diffuse = diffuse + material->getDiffuse() * (r*n) * material->getReflectivity() * (*reflectedColor); if(r*v > 0) specular = specular + material->getSpecular() * pow((r*v), material->getShininess()) * material->getReflectivity() * (*reflectedColor); } color = ambient*material->getColor() + diffuse + specular; if(fogOn){ double dist = i->getT()/fogDist; if(dist>1) dist=1; color = (1-dist)*color + dist*fog; } return new Colour(color); } return NULL; }
void a4_render(// What to render SceneNode* root, // Where to output the image const std::string& filename, // Image size int width, int height, // Viewing parameters const Point3D& eye, const Vector3D& view, const Vector3D& up, double fov, // Lighting parameters const Colour& ambient, const std::list<Light*>& lights, double fogDist ) { // Fill in raytracing code here. std::cerr << "Stub: a4_render(" << root << ",\n " << filename << ", " << width << ", " << height << ",\n " << eye << ", " << view << ", " << up << ", " << fov << ",\n " << ambient << ",\n {"; for (std::list<Light*>::const_iterator I = lights.begin(); I != lights.end(); ++I) { if (I != lights.begin()) std::cerr << ", "; std::cerr << **I; } std::cerr << "});" << std::endl; Vector3D viewVector = view; Vector3D upVector = up; Vector3D sideVector = viewVector.cross(upVector); viewVector.normalize(); upVector.normalize(); sideVector.normalize(); Image img(width, height, 3); int progress = 0; int numPixels = width*height; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int newProgress = (int)((double)(y*width + x)/numPixels*100); if(newProgress >= progress+5){ progress = newProgress; std::cerr << progress << std::endl; } double d = height/2.0/tan(toRadian(fov)/2); Vector3D dir = (x-(width/2.0))*sideVector + ((height/2.0)-y)*upVector + d*viewVector; dir.normalize(); Ray ray = Ray(eye, dir); bool fogOn = true; if(fogDist <= 0) fogOn = false; Colour* color = rayTrace(ambient, eye, ray, root, lights, 5, fogDist); Colour fog(1,1,1); if(color == NULL) { // sunset colours Colour horizon(0.94, 0.55, 0.05); Colour zenith(0.2, 0.27, 0.4); Colour bg = zenith*(1-(double)y/height) + horizon*((double)y/height); if(fogOn) color = new Colour(0.8,0.8,0.8); else color = new Colour(bg); } img(x, y, 0) = color->R(); img(x, y, 1) = color->G(); img(x, y, 2) = color->B(); } } img.savePng(filename); }
CharacterPreview::CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character, int sizeX, int sizeY, const osg::Vec3f& position, const osg::Vec3f& lookAt) : mParent(parent) , mResourceSystem(resourceSystem) , mPosition(position) , mLookAt(lookAt) , mCharacter(character) , mAnimation(NULL) , mSizeX(sizeX) , mSizeY(sizeY) { mTexture = new osg::Texture2D; mTexture->setTextureSize(sizeX, sizeY); mTexture->setInternalFormat(GL_RGBA); mTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR); mTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR); mCamera = new osg::Camera; // hints that the camera is not relative to the master camera mCamera->setReferenceFrame(osg::Camera::ABSOLUTE_RF); mCamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT, osg::Camera::PIXEL_BUFFER_RTT); mCamera->setClearColor(osg::Vec4(0.f, 0.f, 0.f, 0.f)); mCamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); const float fovYDegrees = 12.3f; mCamera->setProjectionMatrixAsPerspective(fovYDegrees, sizeX/static_cast<float>(sizeY), 0.1f, 10000.f); // zNear and zFar are autocomputed mCamera->setViewport(0, 0, sizeX, sizeY); mCamera->setRenderOrder(osg::Camera::PRE_RENDER); mCamera->attach(osg::Camera::COLOR_BUFFER, mTexture); mCamera->setNodeMask(Mask_RenderToTexture); osg::ref_ptr<SceneUtil::LightManager> lightManager = new SceneUtil::LightManager; lightManager->setStartLight(1); osg::ref_ptr<osg::StateSet> stateset = lightManager->getOrCreateStateSet(); stateset->setMode(GL_LIGHTING, osg::StateAttribute::ON); stateset->setMode(GL_NORMALIZE, osg::StateAttribute::ON); stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON); // assign large value to effectively turn off fog // shaders don't respect glDisable(GL_FOG) osg::ref_ptr<osg::Fog> fog (new osg::Fog); fog->setStart(10000000); fog->setEnd(10000000); stateset->setAttributeAndModes(fog, osg::StateAttribute::OFF|osg::StateAttribute::OVERRIDE); osg::ref_ptr<osg::LightModel> lightmodel = new osg::LightModel; lightmodel->setAmbientIntensity(osg::Vec4(0.25, 0.25, 0.25, 1.0)); stateset->setAttributeAndModes(lightmodel, osg::StateAttribute::ON); /// \todo Read the fallback values from INIImporter (Inventory:Directional*) ? osg::ref_ptr<osg::Light> light = new osg::Light; light->setPosition(osg::Vec4(-0.3,0.3,0.7, 0.0)); light->setDiffuse(osg::Vec4(1,1,1,1)); light->setAmbient(osg::Vec4(0,0,0,1)); light->setSpecular(osg::Vec4(0,0,0,0)); light->setLightNum(0); light->setConstantAttenuation(1.f); light->setLinearAttenuation(0.f); light->setQuadraticAttenuation(0.f); osg::ref_ptr<osg::LightSource> lightSource = new osg::LightSource; lightSource->setLight(light); lightSource->setStateSetModes(*stateset, osg::StateAttribute::ON); lightManager->addChild(lightSource); mCamera->addChild(lightManager); mNode = new osg::PositionAttitudeTransform; lightManager->addChild(mNode); mDrawOnceCallback = new DrawOnceCallback; mCamera->addUpdateCallback(mDrawOnceCallback); mParent->addChild(mCamera); mCharacter.mCell = NULL; }
/* * Update the weather. */ void weather_update( void ) { char buf[MAX_STRING_LENGTH]; DESCRIPTOR_DATA *d; buf[0] = '\0'; switch ( ++time_info.hour ) { case 5: weather_info.sunlight = SUN_LIGHT; strcat( buf, "The {yday{x has begun.\n\r" ); break; case 6: weather_info.sunlight = SUN_RISE; strcat( buf, "The {Ysun{x rises in the east.\n\r" ); break; case 19: weather_info.sunlight = SUN_SET; strcat( buf, "The {Ysun{x slowly disappears in the west.\n\r" ); break; case 20: weather_info.sunlight = SUN_DARK; strcat( buf, "The {Dnight{x has begun.\n\r" ); break; case 24: time_info.hour = 0; time_info.day++; break; } if ( time_info.day >= 35 ) { time_info.day = 0; time_info.month++; } if ( time_info.month >= 12 ) { time_info.month = 0; time_info.year++; } /* * Weather change. */ switch ( weather_info.sky ) { default: weather_info.sky = SKY_CLOUDLESS; break; case SKY_CLOUDLESS: if ((number_chance(10))&& (time_info.hour <= 6) ) { weather_info.sky = SKY_FOGGY; } else if (number_chance(15)) { weather_info.sky = SKY_CLOUDY; } else if (number_chance(30)) { weather_info.sky = SKY_RAINING; } else if (number_chance(45)) { weather_info.sky = SKY_CLOUDLESS; } break; case SKY_CLOUDY: if (number_chance(15)) { weather_info.sky = SKY_SNOWING; } else if (number_chance(15)) { weather_info.sky = SKY_HAILSTORM; } else if (number_chance(15)) { weather_info.sky = SKY_THUNDERSTORM; } else if (number_chance(15)) { weather_info.sky = SKY_ICESTORM; } else if (number_chance(15)) { weather_info.sky = SKY_CLOUDLESS; } else if (number_chance(25)) { weather_info.sky = SKY_CLOUDY; } case SKY_RAINING: if (number_chance(15)) { weather_info.sky = SKY_LIGHTNING; lightning ( ); } else if (number_chance(10)) { weather_info.sky = SKY_HAILSTORM; hail(); } else if (number_chance(10)) { weather_info.sky = SKY_THUNDERSTORM; } else if (number_chance(10)) { weather_info.sky = SKY_CLOUDY; } else if (number_chance(55)) { weather_info.sky = SKY_RAINING; } break; case SKY_SNOWING: if (number_chance(15)) { weather_info.sky = SKY_BLIZZARD; } else if (number_chance(15)) { weather_info.sky = SKY_CLOUDY; } else if (number_chance(15)) { weather_info.sky = SKY_RAINING; } else if (number_chance(55)) { weather_info.sky = SKY_SNOWING; } break; case SKY_LIGHTNING: if (number_chance(15)) { weather_info.sky = SKY_THUNDERSTORM; } else if (number_chance(15)) { weather_info.sky = SKY_RAINING; } else if (number_chance(15)) { weather_info.sky = SKY_CLOUDY; } else if (number_chance(15)) { weather_info.sky = SKY_HAILSTORM; } else if (number_chance(40)) { weather_info.sky = SKY_LIGHTNING; } break; case SKY_FOGGY: if (number_chance(45)) { weather_info.sky = SKY_CLOUDY; } else if (number_chance(55)) { fog(); weather_info.sky = SKY_FOGGY; break; } case SKY_THUNDERSTORM: if (number_chance(15)) { weather_info.sky = SKY_RAINING; } else if (number_chance(15)) { weather_info.sky = SKY_CLOUDY; } else if (number_chance(15)) { weather_info.sky = SKY_LIGHTNING; } else if (number_chance(15)) { weather_info.sky = SKY_HAILSTORM; hail (); } else if (number_chance(40)) { weather_info.sky = SKY_THUNDERSTORM; } break; case SKY_HAILSTORM: if (number_chance(15)) { weather_info.sky = SKY_CLOUDY; } else if (number_chance(30)) { weather_info.sky = SKY_RAINING; } else if (number_chance(55)) { weather_info.sky = SKY_HAILSTORM; hail(); } break; case SKY_ICESTORM: if (number_chance(15)) { weather_info.sky = SKY_CLOUDY; } else if (number_chance(15)) { weather_info.sky = SKY_BLIZZARD; } else if (number_chance(15)) { weather_info.sky = SKY_SNOWING; } else if (number_chance(55)) { ice(); weather_info.sky = SKY_ICESTORM; } break; case SKY_BLIZZARD: if (number_chance(15)) { weather_info.sky = SKY_SNOWING; } else if (number_chance(15)) { blizzard(); weather_info.sky = SKY_ICESTORM; ice(); } else if (number_chance(15)) { blizzard(); weather_info.sky = SKY_CLOUDY; } else if (number_chance(55)) { blizzard(); weather_info.sky = SKY_BLIZZARD; } break; } if ( buf[0] != '\0' ) { for ( d = descriptor_list; d != NULL; d = d->next ) { if ( d->connected == CON_PLAYING && IS_OUTDOORS(d->character) && IS_AWAKE(d->character) ) send_to_char( buf, d->character ); } } return; }
/* gestisce i tasti carattere */ void keyHandler(GLubyte key, GLint x, GLint y){ static int sCount=0; if(key== 'q'){ fprintf(stderr, "Exit\n"); programData.exit = 1; }else{ if(key == 'p'){ /* menu */ programData.menu = !programData.menu; }else{ if(key == 'm'){ /* multisampling */ programData.multisample = !programData.multisample; if(programData.multisample){ fprintf(stderr, "MULTISAMPING ON\n"); glEnable(GL_MULTISAMPLE); } else{ fprintf(stderr, "MULTISAMPING OFF\n"); glDisable(GL_MULTISAMPLE); } }else{ if(key == 'f'){ /* nebbia */ programData.fog= !programData.fog; if(programData.fog){ fprintf(stderr, "FOG ON\n"); fog(1); } else{ fprintf(stderr, "FOG OFF\n"); fog(0); } }else{ if(key == 'n'){ /* nuova partita */ programData.gameStatus = 1; programData.menu = 0; programData.points= 0; /* Inizializzo la posizione della telecamera */ worldData.angleX = 0.0f; worldData.angleY = 0.0f; worldData.angleMX = 0.0f; worldData.angleMY = 0.0f; worldData.nextAngleX = 0.0f; worldData.nextAngleY = 0.0f; worldData.nextAngleMX = 0.0f; worldData.nextAngleMY = 0.0f; /* Inizializzo il verme */ initializeWorm(0.0f, 0.0f, 83.5f, 0); srand(time(NULL)); /* Inizializzo la palla */ initializeBall(); /* Inizializzo i dati utilizzati per la telecamera */ worldData.kup = 0; worldData.kdown = 0; worldData.kleft = 0; worldData.kright = 0; worldData.xStatus = 0; worldData.yStatus = 0; worldData.nextXstatus = 0; worldData.nextYstatus = 0; programData.velocity = VELOCITY; programData.timeFrame = 1250/programData.velocity; programData.velAngolare = programData.velocity*0.2; programData.timerender = programData.time; programData.timebase = programData.time; programData.frame = 0; }else{ if(key == 's'){/* screenshot */ char sname[20]; sprintf(sname, "screenshot%d.tga",sCount); gltWriteTGA(sname); sCount++; } } } } } } }
void WeatherManager::HandleWeatherEvent(psWeatherGameEvent* event) { { CS::Threading::MutexScopedLock lock(eventsMutex); events.Delete(event); // Delete this from our "db" } // See if we want to ignore this event for(size_t i = 0; i < ignored.GetSize(); i++) { if(event == ignored[i]) { ignored.DeleteIndex(i); return; } } switch(event->type) { case psWeatherMessage::SNOW: case psWeatherMessage::RAIN: { event->si->current_rain_drops = event->value; Notify4(LOG_WEATHER,"New %s in sector '%s': %d",event->type == psWeatherMessage::SNOW ? "snow" : "rain", event->si->name.GetData(),event->value); psWeatherMessage::NetWeatherInfo info; info.has_downfall = true; info.downfall_is_snow = (event->type == psWeatherMessage::SNOW); info.has_fog = true; info.has_lightning = false; info.downfall_drops = event->value; // Save current fog and calculate new. if(event->value) { // Only save the fog 'history' once. After that we just override. if(!event->si->densitySaved) { event->si->fog_density_old = event->si->fog_density; event->si->densitySaved = true; } // Set fog colour if there's not already fog. if(!event->si->fog_density) { event->si->r = 255; event->si->g = 255; event->si->b = 255; } if(info.downfall_drops < 8000) { // Calculate fog to be linear in range 0 to 200 event->si->fog_density = (int)(200.0f*(info.downfall_drops-1000.0f)/8000.0f); } else { event->si->fog_density = 200; } } else if(event->si->fog_density) { // Restore fog, if the fog wasn't turned off. event->si->fog_density = event->si->fog_density_old; event->si->densitySaved = false; } info.fog_density = event->si->fog_density; info.r = event->si->r; info.g = event->si->g; info.b = event->si->b; info.sector = event->sector; if(event->fade) { info.downfall_fade = event->fade; info.fog_fade = event->fade; } else { if(event->value) { info.downfall_fade = event->si->GetRandomWeatherFadeIn((unsigned int)event->type); info.fog_fade = info.downfall_fade; } else { info.downfall_fade = event->si->GetRandomWeatherFadeOut((unsigned int)event->type); info.fog_fade = info.downfall_fade; } } Notify4(LOG_WEATHER,"Drops: %d Density: %d Sector: %s\n", info.downfall_drops,info.fog_density,info.sector.GetDataSafe()); psWeatherMessage rain(0,info); if(rain.valid) psserver->GetEventManager()->Broadcast(rain.msg,NetBase::BC_EVERYONE); else { Bug1("Could not create valid psWeatherMessage (rain) for broadcast.\n"); } // Make sure we don't have any other events in this sector that will disturb // Simple case is when event types are equal. In addition we have to test // for the mutal exclusive case where we are changing from snow to rain or // rain to snow. { CS::Threading::MutexScopedLock lock(eventsMutex); for(size_t i = 0; i < events.GetSize(); i++) { psWeatherGameEvent* evt = events[i]; if(evt->sector == event->sector && (evt->type == event->type || ((evt->type == psWeatherMessage::RAIN || evt->type == psWeatherMessage::SNOW) && (event->type == psWeatherMessage::RAIN || event->type == psWeatherMessage::SNOW)))) { ignored.Push(evt); // Ignore when the eventmanager handles the event events.DeleteIndex(i); i--; Notify4(LOG_WEATHER,"Removed disturbing event for sector '%s' (%d,%d)", evt->sector.GetData(),evt->value,evt->duration); } } } if(event->value) // Queue event to turn off rain/snow. { if(event->type != psWeatherMessage::SNOW) event->si->is_raining = true; else event->si->is_snowing = true; if(event->si->GetWeatherEnabled((unsigned int) psWeatherMessage::LIGHTNING) && event->value > 2000 && event->si->is_raining) { // Queue lightning during rain storm here first QueueNextEvent(event->si->GetRandomWeatherGap((unsigned int) psWeatherMessage::LIGHTNING), psWeatherMessage::LIGHTNING, 0, 0, 0, event->si->name, event->si, event->clientnum); } // Queue event to stop rain/snow int duration; if(event->duration != -1) { if(event->duration) { duration = event->duration; } else { duration = event->si->GetRandomWeatherDuration((unsigned int) event->type); } QueueNextEvent(duration, event->type, 0, 0, event->fade, event->si->name, event->si); } } else // Stop rain/snow. { if(event->type== psWeatherMessage::SNOW) event->si->is_snowing = false; else event->si->is_raining = false; // Queue event to turn on again later if enabled StartWeather(event->si); } break; } case psWeatherMessage::FOG: { // Update sector weather info event->si->fog_density = event->value; event->si->r = event->cr; event->si->g = event->cg; event->si->b = event->cb; // Update the clients psWeatherMessage::NetWeatherInfo info; info.has_downfall = false; info.downfall_is_snow = false; info.has_fog = true; info.has_lightning = false; info.sector = event->si->name; info.fog_density = event->si->fog_density; info.r = event->cr; info.g = event->cg; info.b = event->cb; info.downfall_drops = 0; info.downfall_fade = 0; Notify3(LOG_WEATHER,"New Fog in sector '%s': %d", event->si->name.GetData(), event->value); // Save the fade in so we can reverse it when fading out. if(event->fade) { event->si->fogFade = event->fade; } else { // We're removing fog, so removed the 'saved' flag. event->si->densitySaved = false; } info.fog_fade = event->si->fogFade; psWeatherMessage fog(0,info); if(fog.valid) psserver->GetEventManager()->Broadcast(fog.msg,NetBase::BC_EVERYONE); else { Bug1("Could not create valid psWeatherMessage (fog) for broadcast.\n"); } if(event->value) // Queue event to turn off fog. { // Queue event to stop rain/snow int duration; if(event->duration != -1) { if(event->duration) { duration = event->duration; } else { duration = event->si->GetRandomWeatherDuration((unsigned int) event->type); } QueueNextEvent(duration, event->type, 0, 0, event->si->GetRandomWeatherFadeOut((unsigned int)psWeatherMessage::FOG), event->si->name, event->si); } } else // Stop fog. { // Queue event to turn on again later if enabled StartWeather(event->si, psWeatherMessage::FOG); } break; } case psWeatherMessage::LIGHTNING: { if(event->si->is_raining) { Notify2(LOG_WEATHER,"Lightning in sector '%s'",event->sector.GetData()); psWeatherMessage::NetWeatherInfo info; info.has_downfall = false; info.downfall_is_snow = false; info.has_fog = false; info.has_lightning = true; info.sector = event->sector; info.fog_fade = info.downfall_fade = 0; info.r = info.g = info.b = 0; info.downfall_drops = info.fog_density = 0; psWeatherMessage lightning(0,info, event->clientnum); if(lightning.valid) { psserver->GetEventManager()->Broadcast(lightning.msg); } else { Bug1("Could not create valid psWeatherMessage (lightning) for broadcast.\n"); } if(event->si->is_raining && event->si->GetWeatherEnabled((unsigned int) psWeatherMessage::LIGHTNING)) { QueueNextEvent(event->si->GetRandomWeatherGap((unsigned int) psWeatherMessage::LIGHTNING), psWeatherMessage::LIGHTNING, 0, 0, 0, event->si->name, event->si, event->clientnum); } } break; } case psWeatherMessage::DAYNIGHT: { QueueNextEvent(GAME_MINUTE_IN_TICKS, psWeatherMessage::DAYNIGHT, 0, 0, 0, NULL, NULL); gameTimeMinute++; if(gameTimeMinute >= 60) { gameTimeMinute = 0; gameTimeHour++; if(gameTimeHour >= 24) { gameTimeHour = 0; gameTimeDay++; if(gameTimeDay >= monthLengths[gameTimeMonth-1]+1) { gameTimeDay = 1; gameTimeMonth++; if(gameTimeMonth >= MONTH_COUNT+1) { gameTimeMonth = 1; gameTimeYear++; } } } // Only save and broadcast every game hour. SaveGameTime(); BroadcastGameTime(); } else { // Super clients should get the time every minute BroadcastGameTimeSuperclients(); } break; } default: { break; } } }
/* ======================================================================================================================= Display function. Where the magic happens and everything is drawn. ======================================================================================================================= */ void display(void) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); /* adjust for zoom value */ gluPerspective(50 * zoom, (float) glutGet(GLUT_WINDOW_WIDTH) / (float) glutGet(GLUT_WINDOW_HEIGHT), 0.001, 40.0); glMatrixMode(GL_MODELVIEW); /* do rotation things */ alpha = alpha + (float) inc; if(alpha > (float) 360.0) alpha -= (float) 360.0; beta = beta + (float) inc2; if(beta > (float) 360.0) beta -= (float) 360.0; /* normalise any normals which aren't in unit form */ glEnable(GL_NORMALIZE); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* draw the fog */ fog(); glPushMatrix(); /* translate whole scene so we can actually see it */ glTranslatef((float) 0.0, -(float) 0.5, -(float) 5); /* rotate by rotation values */ glRotatef(beta, (float) 1.0, (float) 0.0, (float) 0.0); glRotatef(-alpha, (float) 0.0, (float) 1.0, (float) 0.0); /* it was a bit big... */ glScalef(0.50, 0.50, 0.50); /* set shade mode */ glShadeModel(shademode); glPushMatrix(); /* draw the floor */ glScalef(scale * 5, scale * 5, scale * 5); glRotatef(180, 0, 1.0, 1.0); drawCheck(20, 20, BLUE, YELLOW); /* draw ground */ glPopMatrix(); /* set up the lights */ glTranslatef(0.3, 0, 1.25); glEnable(GL_LIGHTING); /* this is a positioned light */ glEnable(GL_LIGHT0); /* this is a directed light */ glEnable(GL_LIGHT1); /* this is a spotlight (not initiated til later) */ glEnable(GL_LIGHT2); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* set the ambient light */ GLfloat ambientColor[] = { 0.2, 0.2, 0.2, 1.0 }; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientColor); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ GLfloat lightColor0[] = { 0.5, 0.5, 0.5, 1.0 }; GLfloat lightPos0[] = { 0.0f, 1.5f, -1.0f, 0.0f }; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0); glLightfv(GL_LIGHT0, GL_POSITION, lightPos0); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ GLfloat lightColor1[] = { 0.8f, 0.8f, 0.8f, 1.0f }; GLfloat lightPos1[] = { 1.0f, 2.0f, -2.0f, 0.0f }; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ glLightfv(GL_LIGHT1, GL_DIFFUSE, lightColor1); glLightfv(GL_LIGHT1, GL_POSITION, lightPos1); /* draw the table */ glPushMatrix(); glTranslatef(-0.3, 0, -1.25); glRotatef(180, 0, 1.0, 1.0); /*~~~~~~~~~~~~~~~~~~~~~~~*/ float cylbase = 0.60; float cyltop = 0.15; float cylheight = 1.0; float tableheight = 0.10; float tablecirc = 0.90; /*~~~~~~~~~~~~~~~~~~~~~~~*/ setMaterial(finTable); setColor(TABLE2); gluCylinder(quadratic, cylbase, cyltop, cylheight, splines * LOD, splines * LOD); glTranslatef(0, 0, cylheight); gluDisk(quadratic, 0.0, cyltop, splines * LOD, splines * LOD); gluCylinder(quadratic, tablecirc, tablecirc, tableheight, splines * LOD, splines * LOD); gluDisk(quadratic, 0.0, tablecirc, splines * LOD, splines * LOD); glTranslatef(0, 0, tableheight); gluDisk(quadratic, 0.0, tablecirc, splines * LOD, splines * LOD); setMaterial(finDefault); glPopMatrix(); glPushMatrix(); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* initiate the spotlight */ GLfloat light_ambient2[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat light_diffuse2[] = { 0.0, 0.3, 0, 1.0 }; GLfloat light_specular2[] = { 0.0, 0.3, 0, 1.0 }; GLfloat lightPos2[] = { 0.0f, 3.0f, 0.0f, 0.0f }; GLfloat spot_direction[] = { 0, -1.0, 0 }; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ glLightfv(GL_LIGHT2, GL_AMBIENT, light_ambient2); glLightfv(GL_LIGHT2, GL_DIFFUSE, light_diffuse2); glLightfv(GL_LIGHT2, GL_SPECULAR, light_specular2); glLightf(GL_LIGHT2, GL_SPOT_CUTOFF, 30.0); glLightfv(GL_LIGHT2, GL_POSITION, lightPos2); glLightfv(GL_LIGHT2, GL_SPOT_DIRECTION, spot_direction); /* draw the chairs and rotate them around the table */ glRotatef(270, 0.0, 1.0, 0.0); glTranslatef(-1.5, 0, 1.5); glPushMatrix(); glRotatef(90, 0, 1.0, 0.0); chair(); glPopMatrix(); glPushMatrix(); glTranslatef(0.3, 0, -1.25); glRotatef(90, 0, 1.0, 0.0); glTranslatef(-0.3, 0, 1.25); glRotatef(90, 0, 1.0, 0.0); chair(); glPopMatrix(); glPushMatrix(); glTranslatef(0.3, 0, -1.25); glRotatef(180, 0, 1.0, 0.0); glTranslatef(-0.3, 0, 1.25); glRotatef(90, 0, 1.0, 0.0); chair(); glPopMatrix(); glPushMatrix(); glTranslatef(0.3, 0, -1.25); glRotatef(270, 0, 1.0, 0.0); glTranslatef(-0.3, 0, 1.25); glRotatef(90, 0, 1.0, 0.0); chair(); glPopMatrix(); /* draw the cups/forks and rotate around the table */ glPushMatrix(); glTranslatef(0.35, 1.1, -0.25); cups(); glPushMatrix(); glTranslatef(-0.05, 0, -1.0); glRotatef(90, 0, 1.0, 0); glTranslatef(0.05, 0, 1.0); cups(); glPopMatrix(); glPushMatrix(); glTranslatef(-0.05, 0, -1.0); glRotatef(180, 0, 1.0, 0); glTranslatef(0.05, 0, 1.0); cups(); glPopMatrix(); glPushMatrix(); glTranslatef(-0.05, 0, -1.0); glRotatef(270, 0, 1.0, 0); glTranslatef(0.05, 0, 1.0); cups(); glPopMatrix(); glPopMatrix(); /* draw the teapot */ glPushMatrix(); /* put on table */ glTranslatef(0.3, 1.3, -1.25); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* trans values for animation */ static int rotateval = 1; static int rotatevalx = 0; static float transvaly = 0; static float transvalx = 0; /* clock values for animation */ static int beginslow = 0; static int slowclock = 0; static int pourclock = 0; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* only animate when playing */ if(ani_play) { { /*~~~*/ int ii; /*~~~*/ for(ii = 0; ii < speed; ii++) { { /* section where teapot slows */ if((beginslow)) { { if(((20 - slowclock / 10) > 0)) { rotateval = rotateval + (20 - slowclock / 10); slowclock++; } else { { /* section where teapot is pouring */ if(pourclock < 90) { { rotatevalx = pourclock / 2; transvaly = ((double) pourclock) / (double) 200; transvalx = ((double) pourclock) / (double) 400; } } else if(pourclock < 135) { /* teapot in mid air */ rotatevalx = 45; transvaly = 90.0 / 200; transvalx = 90.0 / 400; } else if(pourclock < 225) { { /* teapot is being set down */ rotatevalx = 45 - (pourclock - 135) / 2; transvaly = 90.0 / 200 - ((double) pourclock - 135) / (double) 200; transvalx = 90.0 / 400 - ((double) pourclock - 135) / (double) 400; } } else if(pourclock < 300) { /* teapot is back on table */ rotatevalx = 0; transvaly = 0; transvalx = 0; } else { { /* reset variables for next play */ ani_play = 0; ani_clock = 0; rotateval = 1; ani_direction = 0; slowclock = 0; pourclock = -speed; beginslow = 0; rotatevalx = 0; transvaly = 0; transvalx = 0; } } pourclock++; } } } } else if(ani_clock < 200) { /* teapot is speeding up it's spin */ rotateval = rotateval + ani_clock / 10; } else if(ani_clock < 500) { { /* teapot is at constant spin */ rotateval = rotateval + 20; if(ani_clock == 300) { /* choose the cup it will stop at */ ani_direction = rand() % 4 + 1; } } } if(rotateval > 360) rotateval -= 360; if ( (!beginslow) && (ani_direction != 0) && ( ( (rotateval >= ani_direction * 90 - SLOWMAGIC - 20) && (rotateval <= ani_direction * 90 - SLOWMAGIC) ) || ( (rotateval >= ani_direction * 90 - SLOWMAGIC + 340) && (rotateval <= ani_direction * 90 - SLOWMAGIC + 360) ) ) ) { /* choose opportune moment to slow down */ beginslow = 1; rotateval = ani_direction * 90 - SLOWMAGIC + 360; if(rotateval > 360) rotateval -= 360; } ani_clock++; } } } /* apply transformations */ } glRotatef(rotateval, 0, 1.0, 0); glTranslatef(transvalx, transvaly, 0); glRotatef(-rotatevalx, 0, 0, 1.0); /* apply texture */ glBindTexture(GL_TEXTURE_2D, texture[1]); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); /* apply finish */ setMaterial(finPot); glutSolidTeapot(0.2); setMaterial(finDefault); glDisable(GL_TEXTURE_2D); glPopMatrix(); glPopMatrix(); glPopMatrix(); /* 3D stuff is done */ glFlush(); /* draw text overlay */ glDisable(GL_NORMALIZE); glDisable(GL_LIGHTING); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT), 0, -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ char speedstring[20]; char str[500] = "<Z> and <z>: zoom in/out\n<X> or <x>: Start/Stop X rotation\n<Y> or <y> Start/Stop Y Rotation\n<A> or <a>: Start animation\n<F> or <f>: Speed up animation\n<S> or <s>: Slow down animation\n<T> or <t>: Pause animation\n<C> or <c>: Resume the animation\n<p>: switch the rendering to the flat shaded polygonization.\n<P> switch the rendering to the smooth shaded polygonization.\n<q> or <Q>: change fog mode\nspeed: "; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ sprintf(speedstring, "%d", speed); strcat(str, speedstring); strcat(str, "\nLOD: "); sprintf(speedstring, "%d", LOD); strcat(str, speedstring); strcat(str, "\nFog Mode: "); switch(fogfilter) { { case 0: strcat(str, "GL_EXP"); break; case 1: strcat(str, "GL_EXP2"); break; case 2: strcat(str, "GL_LINEAR"); break; case 3: strcat(str, "NO FOG"); break; } } bitmap_output(30, 30, str, GLUT_BITMAP_HELVETICA_12); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); /* draw transparent box for text */ glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT), 0, -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f((float) 0, (float) 0, (float) 0, (float) 0.6); glRecti(30 - 10, 30 - 20, 40 + 350, 30 + 250); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glFlush(); glutSwapBuffers(); }
HRESULT KG3DShadowMapLevel::ProcessShadowMap(KG3DCamera* pCameraLight,D3DXVECTOR3& vFocusPos,KG3DSceneSceneEditor* pEditor,KG3DSceneShadowMap* pShadow,LPDIRECT3DSURFACE9 pColorSur) { HRESULT hResult = E_FAIL; HRESULT hr = S_OK; LPDIRECT3DSURFACE9 pDepthSave = NULL; LPDIRECT3DSURFACE9 pTargetSave = NULL; D3DVIEWPORT9 ViewportSave; D3DVIEWPORT9 Viewport; BOOL bSetRenderTarget = FALSE; BOOL bSetDepthStencilSurface = FALSE; BOOL bSetViewport = FALSE; //float fDepthBias = 0.0002f; //float fBiasSlope = 0.5f; //g_pd3dDevice->SetRenderState(D3DRS_DEPTHBIAS,*(DWORD*)&fDepthBias); //g_pd3dDevice->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS,*(DWORD*)&fBiasSlope); pCameraLight->SetCamera(); m_lpShadowMapEntityMgr->FrameMove(pEditor,FALSE); if(g_dwRenderCount % 2 < 1) m_lpShadowMapEntityMgr->GetVisibleEntityEx(pCameraLight,pEditor,vFocusPos); ////////////////////////////////////////////////////////////////////////// Viewport.X = 0; Viewport.Y = 0; Viewport.Height = m_dwShadowmapSize; Viewport.Width = m_dwShadowmapSize; Viewport.MaxZ = 1; Viewport.MinZ = 0; hr = g_pd3dDevice->GetDepthStencilSurface(&pDepthSave); KGLOG_COM_PROCESS_ERROR(hr); hr = g_pd3dDevice->GetRenderTarget(0, &pTargetSave); KGLOG_COM_PROCESS_ERROR(hr); hr = g_pd3dDevice->GetViewport(&ViewportSave); KGLOG_COM_PROCESS_ERROR(hr); hr = g_pd3dDevice->SetRenderTarget(0, pColorSur); KGLOG_COM_PROCESS_ERROR(hr); bSetRenderTarget = TRUE; hr = g_pd3dDevice->SetDepthStencilSurface(m_lpSMShadowMapSurface); KGLOG_COM_PROCESS_ERROR(hr); bSetDepthStencilSurface = TRUE; hr = g_pd3dDevice->SetViewport(&Viewport); KGLOG_COM_PROCESS_ERROR(hr); bSetViewport = TRUE; ////////////////////////////////////////////////////////////////////////// //hr = g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE); //KGLOG_COM_PROCESS_ERROR(hr); //hr = g_pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE); //KGLOG_COM_PROCESS_ERROR(hr); hr = g_pd3dDevice->Clear(0, 0, D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, 0xFF000000, 1, 0); KGLOG_COM_PROCESS_ERROR(hr); { GraphicsStruct::RenderState cull(D3DRS_CULLMODE,D3DCULL_NONE); { GraphicsStruct::RenderStateAlpha Alpha(0x20,FALSE,FALSE,D3DBLEND_SRCALPHA,D3DBLEND_INVSRCALPHA); GraphicsStruct::RenderState colorWrite(D3DRS_COLORWRITEENABLE ,D3DCOLORWRITEENABLE_ALPHA); GraphicsStruct::RenderState ZWrite(D3DRS_ZWRITEENABLE,TRUE); GraphicsStruct::RenderState ZEnable(D3DRS_ZENABLE,TRUE); GraphicsStruct::RenderState lightEnable(D3DRS_LIGHTING,FALSE); GraphicsStruct::RenderState fog(D3DRS_FOGENABLE,FALSE); //GraphicsStruct::RenderState cullState(D3DRS_CULLMODE,D3DCULL_CW); if (g_cEngineOption.ModelShadowType >= EM_MODEL_SHADOW_TYPE_HIGH) { if(nIndex ==0) { m_lpShadowMapEntityMgr->RenderForShadowMap( pEditor, TRUE, g_cEngineManager.GetRenderOption(RENDER_TREE), g_cEngineManager.GetRenderOption(RENDER_ENTITY) && g_cEngineManager.GetRenderOption(RENDER_NORL_MESH), g_cEngineManager.GetRenderOption(RENDER_ENTITY) && g_cEngineManager.GetRenderOption(RENDER_SKIN_MESH) ); if(pEditor->m_pRepresentNPC) { pEditor->m_pRepresentNPC->Render(0); } } else { m_lpShadowMapEntityMgr->RenderForShadowMap( pEditor, TRUE, g_cEngineManager.GetRenderOption(RENDER_TREE), g_cEngineManager.GetRenderOption(RENDER_ENTITY) && g_cEngineManager.GetRenderOption(RENDER_NORL_MESH), FALSE ); } } else if (g_cEngineOption.ModelShadowType == EM_MODEL_SHADOW_TYPE_MIDDLE) { if(nIndex ==0) { m_lpShadowMapEntityMgr->RenderForShadowMap( pEditor, FALSE, FALSE, FALSE, g_cEngineManager.GetRenderOption(RENDER_ENTITY) && g_cEngineManager.GetRenderOption(RENDER_SKIN_MESH) ); if(pEditor->m_pRepresentNPC) { pEditor->m_pRepresentNPC->Render(0); } } } } } g_RenderRenderTwiceInfo(); m_lpShadowMapEntityMgr->RenderSpecialAlphaModel(); hResult = S_OK; Exit0: if (bSetRenderTarget) { hr = g_pd3dDevice->SetRenderTarget(0,pTargetSave); KGLOG_COM_CHECK_ERROR(hr); } KG_COM_RELEASE(pTargetSave); if (bSetDepthStencilSurface) { hr = g_pd3dDevice->SetDepthStencilSurface(pDepthSave); KGLOG_COM_CHECK_ERROR(hr); } KG_COM_RELEASE(pDepthSave); if (bSetViewport) { hr = g_pd3dDevice->SetViewport(&ViewportSave); KGLOG_COM_CHECK_ERROR(hr); } //g_pd3dDevice->SetRenderState(D3DRS_DEPTHBIAS,0); //g_pd3dDevice->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS,0); return hResult; }