void EditTSCtrl::renderMissionArea() { MissionArea* obj = MissionArea::getServerObject(); if ( !obj ) return; if ( !mRenderMissionArea && !obj->isSelected() ) return; GFXDEBUGEVENT_SCOPE( Editor_renderMissionArea, ColorI::WHITE ); F32 minHeight = 0.0f; F32 maxHeight = 0.0f; TerrainBlock* terrain = getActiveTerrain(); if ( terrain ) { terrain->getMinMaxHeight( &minHeight, &maxHeight ); Point3F pos = terrain->getPosition(); maxHeight += pos.z + mMissionAreaHeightAdjust; minHeight += pos.z - mMissionAreaHeightAdjust; } const RectI& area = obj->getArea(); Box3F areaBox( area.point.x, area.point.y, minHeight, area.point.x + area.extent.x, area.point.y + area.extent.y, maxHeight ); GFXDrawUtil* drawer = GFX->getDrawUtil(); GFXStateBlockDesc desc; desc.setCullMode( GFXCullNone ); desc.setBlend( true ); desc.setZReadWrite( false, false ); desc.setFillModeSolid(); drawer->drawCube( desc, areaBox, mMissionAreaFillColor ); desc.setFillModeWireframe(); drawer->drawCube( desc, areaBox, mMissionAreaFrameColor ); }
// Given a ray, this will return the color from the lightmap of this object, return true if handled bool blTerrainSystem::getColorFromRayInfo(const RayInfo & collision, ColorF& result) const { TerrainBlock *terrain = dynamic_cast<TerrainBlock *>(collision.object); if (!terrain) return false; Point2F uv; F32 terrainlength = (F32)terrain->getBlockSize(); Point3F pos = terrain->getPosition(); uv.x = (collision.point.x - pos.x) / terrainlength; uv.y = (collision.point.y - pos.y) / terrainlength; // similar to x = x & width... uv.x = uv.x - F32(U32(uv.x)); uv.y = uv.y - F32(U32(uv.y)); const GBitmap* lightmap = terrain->getLightMap(); if (!lightmap) return false; result = lightmap->sampleTexel(uv.x, uv.y); // terrain lighting is dim - look into this (same thing done in shaders)... result *= 2.0f; return true; }