void EntitySettings::loadLightVertexColours() { _lightVertexColoursLoaded = true; _lightVertexColours[VERTEX_START_END_DESELECTED] = ColourSchemes().getColour("light_startend_deselected"); _lightVertexColours[VERTEX_START_END_SELECTED] = ColourSchemes().getColour("light_startend_selected"); _lightVertexColours[VERTEX_INACTIVE] = ColourSchemes().getColour("light_vertex_normal"); _lightVertexColours[VERTEX_DESELECTED] = ColourSchemes().getColour("light_vertex_deselected"); _lightVertexColours[VERTEX_SELECTED] = ColourSchemes().getColour("light_vertex_selected"); }
// This is called from main() to start up the Radiant stuff. void Radiant_Initialise (void) { // Load the ColourSchemes from the registry ColourSchemes().loadColourSchemes(); // Load the other modules Radiant_Construct(GlobalRadiantModuleServer()); g_VFSModuleObserver.realise(); GlobalTextureBrowser().createWidget(); // Rebuild the map path basing on the userGamePath std::string newMapPath = GlobalRadiant().getFullGamePath() + "maps/"; g_mkdir_with_parents(newMapPath.c_str(), 0755); Environment::Instance().setMapsPath(newMapPath); g_gameToolsPathObservers.realise(); g_gameModeObservers.realise(); GlobalUMPSystem().init(); // Construct the MRU commands and menu structure GlobalMRU().constructMenu(); // Initialise the most recently used files list GlobalMRU().loadRecentFiles(); gtkutil::MultiMonitor::printMonitorInfo(); }
void EClassManager::resolveInheritance() { // Resolve inheritance on the model classes for (Models::iterator i = _models.begin(); i != _models.end(); ++i) { resolveModelInheritance(i->first, i->second); } // Resolve inheritance for the entities. At this stage the classes // will have the name of their parent, but not an actual pointer to // it for (EntityClasses::iterator i = _entityClasses.begin(); i != _entityClasses.end(); ++i) { // Tell the class to resolve its own inheritance using the given // map as a source for parent lookup i->second->resolveInheritance(_entityClasses); // If the entity has a model path ("model" key), lookup the actual // model and apply its mesh and skin to this entity. if (i->second->getModelPath().size() > 0) { Models::iterator j = _models.find(i->second->getModelPath()); if (j != _models.end()) { i->second->setModelPath(j->second->mesh); i->second->setSkin(j->second->skin); } } } // greebo: Override the eclass colours of two special entityclasses Vector3 worlspawnColour = ColourSchemes().getColour("default_brush"); Vector3 lightColour = ColourSchemes().getColour("light_volumes"); Doom3EntityClassPtr light = findInternal("light"); if (light) { light->setColour(lightColour); } Doom3EntityClassPtr worldspawn = findInternal("worldspawn"); if (worldspawn) { worldspawn->setColour(worlspawnColour); } }
// Capture the shaders for the current colour void Doom3EntityClass::captureColour() { // Set the entity colour to default, if none was specified if (_colour == Vector3(-1, -1, -1)) { _colour = ColourSchemes().getColour("default_entity"); } // Capture fill and wire versions of the entity colour std::string fillCol = _colourTransparent ? (boost::format("[%g %g %g]") % _colour[0] % _colour[1] % _colour[2]).str() : (boost::format("(%g %g %g)") % _colour[0] % _colour[1] % _colour[2]).str(); std::string wireCol = (boost::format("<%g %g %g>") % _colour[0] % _colour[1] % _colour[2]).str(); _fillShader = GlobalRenderSystem().capture(fillCol); _wireShader = GlobalRenderSystem().capture(wireCol); }
void Doom3EntityClass::setColour(const Vector3& colour) { // Set the specified flag _colourSpecified = true; _colour = colour; // Set the entity colour to default, if none was specified if (_colour == Vector3(-1, -1, -1)) { _colour = ColourSchemes().getColour("default_entity"); } // Define fill and wire versions of the entity colour _fillShader = _colourTransparent ? (boost::format("[%f %f %f]") % _colour[0] % _colour[1] % _colour[2]).str() : (boost::format("(%f %f %f)") % _colour[0] % _colour[1] % _colour[2]).str(); _wireShader = (boost::format("<%f %f %f>") % _colour[0] % _colour[1] % _colour[2]).str(); }
// Resolve inheritance for this class void Doom3EntityClass::resolveInheritance(EntityClasses& classmap) { // If we have already resolved inheritance, do nothing if (_inheritanceResolved) return; // Lookup the parent name and return if it is not set. Also return if the // parent name is the same as our own classname, to avoid infinite // recursion. std::string parName = getAttribute("inherit").getValue(); if (parName.empty() || parName == _name) return; // Find the parent entity class EntityClasses::iterator pIter = classmap.find(parName); if (pIter != classmap.end()) { // Recursively resolve inheritance of parent pIter->second->resolveInheritance(classmap); // Copy attributes from the parent to the child, including editor keys pIter->second->forEachClassAttribute( std::bind(©InheritedAttribute, this, std::placeholders::_1), true ); // Set our parent pointer _parent = pIter->second.get(); } else { rWarning() << "[eclassmgr] Entity class " << _name << " specifies unknown parent class " << parName << std::endl; } // Set the resolved flag _inheritanceResolved = true; if (!getAttribute("model").getValue().empty()) { // We have a model path (probably an inherited one) setModelPath(getAttribute("model").getValue()); } if (getAttribute("editor_light").getValue() == "1" || getAttribute("spawnclass").getValue() == "idLight") { // We have a light setIsLight(true); } if (getAttribute("editor_transparent").getValue() == "1") { _colourTransparent = true; } // (Re)set the colour const EntityClassAttribute& colourAttr = getAttribute("editor_color"); if (!colourAttr.getValue().empty()) { setColour(string::convert<Vector3>(colourAttr.getValue())); } else { // If no colour is set, assign the default entity colour to this class static Vector3 defaultColour = ColourSchemes().getColour("default_entity"); setColour(defaultColour); } }
void CamWnd::Cam_Draw() { glViewport(0, 0, m_Camera.width, m_Camera.height); // enable depth buffer writes glDepthMask(GL_TRUE); Vector3 clearColour(0, 0, 0); clearColour = ColourSchemes().getColourVector3("camera_background"); glClearColor(clearColour[0], clearColour[1], clearColour[2], 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); render::RenderStatistics::Instance().resetStats(); Cull_ResetStats(); glMatrixMode(GL_PROJECTION); glLoadMatrixf(m_Camera.projection); glMatrixMode(GL_MODELVIEW); glLoadMatrixf(m_Camera.modelview); // one directional light source directly behind the viewer { GLfloat inverse_cam_dir[4], ambient[4], diffuse[4];//, material[4]; ambient[0] = ambient[1] = ambient[2] = 0.4f; ambient[3] = 1.0f; diffuse[0] = diffuse[1] = diffuse[2] = 0.4f; diffuse[3] = 1.0f; inverse_cam_dir[0] = m_Camera.vpn[0]; inverse_cam_dir[1] = m_Camera.vpn[1]; inverse_cam_dir[2] = m_Camera.vpn[2]; inverse_cam_dir[3] = 0; glLightfv(GL_LIGHT0, GL_POSITION, inverse_cam_dir); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glEnable(GL_LIGHT0); } unsigned int globalstate = RENDER_DEPTHTEST | RENDER_COLOURWRITE | RENDER_DEPTHWRITE | RENDER_ALPHATEST | RENDER_BLEND | RENDER_CULLFACE | RENDER_COLOURARRAY | RENDER_COLOURCHANGE; switch (getCameraSettings()->getMode()) { case drawWire: break; case drawSolid: globalstate |= (RENDER_FILL | RENDER_LIGHTING | RENDER_SMOOTH | RENDER_SCALED); break; case drawTexture: globalstate |= (RENDER_FILL | RENDER_LIGHTING | RENDER_TEXTURE_2D | RENDER_SMOOTH | RENDER_SCALED); break; default: globalstate = 0; break; } if (!getCameraSettings()->solidSelectionBoxes()) { globalstate |= RENDER_LINESTIPPLE; } { CamRenderer renderer(globalstate, m_state_select2, m_state_select1, m_view.getViewer()); Scene_Render(renderer, m_view); renderer.render(m_Camera.modelview, m_Camera.projection); } // greebo: Draw the clipper's points (skipping the depth-test) { glDisable(GL_DEPTH_TEST); glColor4f(1, 1, 1, 1); glPointSize(5); if (GlobalClipper().clipMode()) { GlobalClipper().draw(1.0f); } glPointSize(1); } // prepare for 2d stuff glColor4f(1, 1, 1, 1); glDisable(GL_BLEND); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, (float) m_Camera.width, 0, (float) m_Camera.height, -100, 100); glScalef(1, -1, 1); glTranslatef(0, -(float) m_Camera.height, 0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if (GlobalOpenGL().GL_1_3()) { glClientActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0); } glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); glDisable(GL_DEPTH_TEST); glLineWidth(1); // draw the crosshair if (m_bFreeMove) { glBegin(GL_LINES); glVertex2f((float) m_Camera.width / 2.f, (float) m_Camera.height / 2.f + 6); glVertex2f((float) m_Camera.width / 2.f, (float) m_Camera.height / 2.f + 2); glVertex2f((float) m_Camera.width / 2.f, (float) m_Camera.height / 2.f - 6); glVertex2f((float) m_Camera.width / 2.f, (float) m_Camera.height / 2.f - 2); glVertex2f((float) m_Camera.width / 2.f + 6, (float) m_Camera.height / 2.f); glVertex2f((float) m_Camera.width / 2.f + 2, (float) m_Camera.height / 2.f); glVertex2f((float) m_Camera.width / 2.f - 6, (float) m_Camera.height / 2.f); glVertex2f((float) m_Camera.width / 2.f - 2, (float) m_Camera.height / 2.f); glEnd(); } glRasterPos3f(1.0f, static_cast<float> (m_Camera.height) - 1.0f, 0.0f); GlobalOpenGL().drawString(render::RenderStatistics::Instance().getStatString()); glRasterPos3f(1.0f, static_cast<float> (m_Camera.height) - 11.0f, 0.0f); GlobalOpenGL().drawString(Cull_GetStats()); // bind back to the default texture so that we don't have problems // elsewhere using/modifying texture maps between contexts glBindTexture(GL_TEXTURE_2D, 0); }
/// \todo Define special-case shaders in a data file. void OpenGLShader::construct (const std::string& name) { static Vector4 highLightColour(1, 0, 0, 0.3); // Check the first character of the name to see if this is a special built-in shader switch (name[0]) { case '(': { // fill shader OpenGLState& state = appendDefaultPass(); sscanf(name.c_str(), "(%g %g %g)", &state.m_colour[0], &state.m_colour[1], &state.m_colour[2]); state.m_colour[3] = 1.0f; state.m_state = RENDER_FILL | RENDER_LIGHTING | RENDER_DEPTHTEST | RENDER_CULLFACE | RENDER_COLOURWRITE | RENDER_DEPTHWRITE; state.m_sort = OpenGLState::eSortFullbright; break; } case '[': { OpenGLState& state = appendDefaultPass(); sscanf(name.c_str(), "[%g %g %g]", &state.m_colour[0], &state.m_colour[1], &state.m_colour[2]); state.m_colour[3] = 0.5f; state.m_state = RENDER_FILL | RENDER_LIGHTING | RENDER_DEPTHTEST | RENDER_CULLFACE | RENDER_COLOURWRITE | RENDER_DEPTHWRITE | RENDER_BLEND; state.m_sort = OpenGLState::eSortTranslucent; break; } case '<': { // wireframe shader OpenGLState& state = appendDefaultPass(); sscanf(name.c_str(), "<%g %g %g>", &state.m_colour[0], &state.m_colour[1], &state.m_colour[2]); state.m_colour[3] = 1; state.m_state = RENDER_DEPTHTEST | RENDER_COLOURWRITE | RENDER_DEPTHWRITE; state.m_sort = OpenGLState::eSortFullbright; state.m_depthfunc = GL_LESS; state.m_linewidth = 1; state.m_pointsize = 1; break; } case '$': { OpenGLState& state = appendDefaultPass(); if (name == "$POINT") { state.m_state = RENDER_COLOURARRAY | RENDER_COLOURWRITE | RENDER_DEPTHWRITE; state.m_sort = OpenGLState::eSortControlFirst; state.m_pointsize = 4; } else if (name == "$SELPOINT") { state.m_state = RENDER_COLOURARRAY | RENDER_COLOURWRITE | RENDER_DEPTHWRITE; state.m_sort = OpenGLState::eSortControlFirst + 1; state.m_pointsize = 4; } else if (name == "$PIVOT") { state.m_state = RENDER_COLOURARRAY | RENDER_COLOURWRITE | RENDER_DEPTHTEST | RENDER_DEPTHWRITE; state.m_sort = OpenGLState::eSortGUI1; state.m_linewidth = 2; state.m_depthfunc = GL_LEQUAL; OpenGLState& hiddenLine = appendDefaultPass(); hiddenLine.m_state = RENDER_COLOURARRAY | RENDER_COLOURWRITE | RENDER_DEPTHTEST | RENDER_LINESTIPPLE; hiddenLine.m_sort = OpenGLState::eSortGUI0; hiddenLine.m_linewidth = 2; hiddenLine.m_depthfunc = GL_GREATER; } else if (name == "$WIREFRAME") { state.m_state = RENDER_DEPTHTEST | RENDER_COLOURWRITE | RENDER_DEPTHWRITE; state.m_sort = OpenGLState::eSortFullbright; } else if (name == "$CAM_HIGHLIGHT") { state.m_colour = highLightColour; state.m_state = RENDER_FILL | RENDER_DEPTHTEST | RENDER_CULLFACE | RENDER_BLEND | RENDER_COLOURWRITE; state.m_sort = OpenGLState::eSortHighlight; state.m_depthfunc = GL_LEQUAL; } else if (name == "$CAM_OVERLAY") { state.m_state = RENDER_CULLFACE | RENDER_DEPTHTEST | RENDER_COLOURWRITE | RENDER_DEPTHWRITE | RENDER_OFFSETLINE; state.m_sort = OpenGLState::eSortOverlayFirst + 1; state.m_depthfunc = GL_LEQUAL; OpenGLState& hiddenLine = appendDefaultPass(); hiddenLine.m_colour = Vector4(0.75, 0.75, 0.75, 1); hiddenLine.m_state = RENDER_CULLFACE | RENDER_DEPTHTEST | RENDER_COLOURWRITE | RENDER_OFFSETLINE | RENDER_LINESTIPPLE; hiddenLine.m_sort = OpenGLState::eSortOverlayFirst; hiddenLine.m_depthfunc = GL_GREATER; hiddenLine.m_linestipple_factor = 2; } else if (name == "$XY_OVERLAY") { Vector3 colorSelBrushes = ColourSchemes().getColourVector3("selected_brush"); state.m_colour = Vector4(colorSelBrushes, 1); state.m_state = RENDER_COLOURWRITE | RENDER_LINESTIPPLE; state.m_sort = OpenGLState::eSortOverlayFirst; state.m_linewidth = 2; state.m_linestipple_factor = 3; } else if (name == "$DEBUG_CLIPPED") { state.m_state = RENDER_COLOURARRAY | RENDER_COLOURWRITE | RENDER_DEPTHWRITE; state.m_sort = OpenGLState::eSortLast; } else if (name == "$SPHERE") { state.m_colour = Vector4(.05f, .05f, .05f, 1); state.m_state = RENDER_CULLFACE | RENDER_DEPTHTEST | RENDER_BLEND | RENDER_FILL; state.m_blend_src = GL_ONE; state.m_blend_dst = GL_ONE; state.m_sort = OpenGLState::eSortTranslucent; } else if (name == "$WIRE_OVERLAY") { #if 0 state._visStack = RENDER_COLOURARRAY | RENDER_COLOURWRITE | RENDER_DEPTHWRITE | RENDER_DEPTHTEST | RENDER_OVERRIDE; state.m_sort = OpenGLState::eSortOverlayFirst; #else state.m_state = RENDER_COLOURARRAY | RENDER_COLOURWRITE | RENDER_DEPTHWRITE | RENDER_DEPTHTEST | RENDER_OVERRIDE; state.m_sort = OpenGLState::eSortGUI1; state.m_depthfunc = GL_LEQUAL; OpenGLState& hiddenLine = appendDefaultPass(); hiddenLine.m_state = RENDER_COLOURARRAY | RENDER_COLOURWRITE | RENDER_DEPTHWRITE | RENDER_DEPTHTEST | RENDER_OVERRIDE | RENDER_LINESTIPPLE; hiddenLine.m_sort = OpenGLState::eSortGUI0; hiddenLine.m_depthfunc = GL_GREATER; #endif } else if (name == "$FLATSHADE_OVERLAY") { state.m_state = RENDER_CULLFACE | RENDER_LIGHTING | RENDER_SMOOTH | RENDER_SCALED | RENDER_COLOURARRAY | RENDER_FILL | RENDER_COLOURWRITE | RENDER_DEPTHWRITE | RENDER_DEPTHTEST | RENDER_OVERRIDE; state.m_sort = OpenGLState::eSortGUI1; state.m_depthfunc = GL_LEQUAL; OpenGLState& hiddenLine = appendDefaultPass(); hiddenLine.m_state = RENDER_CULLFACE | RENDER_LIGHTING | RENDER_SMOOTH | RENDER_SCALED | RENDER_COLOURARRAY | RENDER_FILL | RENDER_COLOURWRITE | RENDER_DEPTHWRITE | RENDER_DEPTHTEST | RENDER_OVERRIDE | RENDER_POLYGONSTIPPLE; hiddenLine.m_sort = OpenGLState::eSortGUI0; hiddenLine.m_depthfunc = GL_GREATER; } else if (name == "$CLIPPER_OVERLAY") { Vector3 colorClipper = ColourSchemes().getColourVector3("clipper"); state.m_colour = Vector4(colorClipper, 1); state.m_state = RENDER_CULLFACE | RENDER_COLOURWRITE | RENDER_DEPTHWRITE | RENDER_FILL | RENDER_POLYGONSTIPPLE; state.m_sort = OpenGLState::eSortOverlayFirst; } else { // default to something recognisable.. =) ERROR_MESSAGE("hardcoded renderstate not found"); state.m_colour = Vector4(1, 0, 1, 1); state.m_state = RENDER_COLOURWRITE | RENDER_DEPTHWRITE; state.m_sort = OpenGLState::eSortFirst; } break; } // case '$' default: { // This is not a hard-coded shader, construct from the shader system constructNormalShader(name); } } // switch }