void CX3DCylinderNode::print(int indent) { FILE *fp = CX3DParser::getDebugLogFp(); char *nodeName = getNodeName(); if (nodeName) { CX3DParser::printIndent(indent); fprintf(fp, "%s (%s)\n", nodeName, CX3DNode::getNodeTypeString(getNodeType())); CX3DParser::printIndent(indent+1); fprintf(fp, "solid : %s\n", getSolid()->getValue() ? "TRUE" : "FALSE"); CX3DParser::printIndent(indent+1); fprintf(fp, "radius : (%f)\n", getRadius()->getValue()); CX3DParser::printIndent(indent+1); fprintf(fp, "height : (%f)\n", getHeight()->getValue()); CX3DParser::printIndent(indent+1); fprintf(fp, "bottom : %s\n", getBottom()->getValue() ? "TRUE" : "FALSE"); CX3DParser::printIndent(indent+1); fprintf(fp, "side : %s\n", getSide()->getValue() ? "TRUE" : "FALSE"); CX3DParser::printIndent(indent+1); fprintf(fp, "top : %s\n", getTop()->getValue() ? "TRUE" : "FALSE"); } }
/** * Checks if a tile is solid or not. * @param x The X grid coordinate. * @param y The Y grid coordinate. * @see setSolid() */ bool Area::isSolid(const int x, const int y) { if(x >= getWidth() || y >= getHeight() || x < 0 || y < 0) { return true; } return getSolid(x, y); }
void CX3DSphereNode::print(int indent) { FILE *fp = CX3DParser::getDebugLogFp(); char *nodeName = getNodeName(); if (nodeName) { CX3DParser::printIndent(indent); fprintf(fp, "%s (%s)\n", nodeName, CX3DNode::getNodeTypeString(getNodeType())); CX3DParser::printIndent(indent+1); fprintf(fp, "solid : %s\n", getSolid()->getValue() ? "TRUE" : "FALSE"); CX3DParser::printIndent(indent+1); fprintf(fp, "radius : (%f)\n", getRadius()->getValue()); } }
bool Map::rectOverlaps(int code, Rect r)//Basically, this function checks all the points in the rectangle { //So that if a tile was to be overlapping the rectangle, at least one //of the points is sure to be contained in the tile. //Points are checked in a grid the with each square of the grid //being tile sized and encompassing the entire rectangle int stepsX = r.getWidth()/tileWidth; int stepsY = r.getHeight()/tileHeight; /*if(r.getWidth() == 1) { for(int i = 0; i <= stepsY; i++) { int y = r.getY()-4;//(r.getY()+i*tileHeight); int x = r.getX()-4; system->getGraphics()->drawPoint(x,y,Color(0,0,0)); if(getSolid(x/tileWidth,y/tileHeight) == code) return true; } system->getGraphics()->drawPoint(r.getX(),r.getY2(),Color(0,0,0)); if(getSolid(r.getX()/tileWidth, r.getY2()/tileHeight)) return true; return false; }*/ for(int y1 = 0; y1 <= stepsY; y1++) //Check all the points on the top, left, and center for(int x1 = 0; x1 <= stepsX; x1++) { int x = (r.getX()+x1*tileWidth); int y = (r.getY()+y1*tileHeight); if(y1 > 0) y--; if(x1 > 0) x--; //system->getGraphics()->drawPoint(x,y,Color(0,0,0)); if(getSolid(x/tileWidth,y/tileHeight) == code) return true; } for(int y1 = 0; y1 <= stepsY; y1++) //Check all points on the right { int x = r.getX2(); int y = (r.getY()+(y1*tileHeight)); if(y1 > 0) y--; //system->getGraphics()->drawPoint(x,y,Color(0,0,0)); if(getSolid(x/tileWidth, y/tileHeight) == code) return true; } for(int x1 = 0; x1 <= stepsX; x1++) //Check all points on the bottom { int x = (r.getX()+x1*tileWidth); int y = r.getY2(); if(x1 > 0) x--; //system->getGraphics()->drawPoint(x,y,Color(0,0,0));//Debuggin purposes if(getSolid(x/tileWidth, y/tileHeight) == code) return true; } //system->getGraphics()->drawPoint(r.getX2(),r.getY2(),Color(0,0,0));//Debuggin purposes if(getSolid(r.getX2()/tileWidth, r.getY2()/tileHeight) == code) //Check bottom right corner return true; return false; }
/** * Renders the area and all its objects. * @param rm The resource manager to use to manage models and images. */ void Area::draw(Interface* interface) { #warning ['TODO']: Delete me.... ResourceManager* rm = interface->getResourceManager(); if(!rm) { return; } glEnable(GL_LIGHTING); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); //glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); /* This was cut, attenuation never worked right for some reason... // Disable unused lights for(int i = 0; i < MAX_LIGHTS; i++) { glDisable(GL_LIGHT0 + i); } // Process lights int light = 0; // We want to skip the first light as its a global one... for(vector<Light*>::iterator iter = lights_.begin(); iter != lights_.end(); iter++) { if(light > MAX_LIGHTS) { break; } Light* pl = *iter; if(!pl) { ERROR("A Light that is Not a light..."); continue; } glEnable(GL_LIGHT0 + light); // Set light position float position[] = {pl->getX(), pl->getY(), pl->getX(), pl->getDirectional()}; glLightfv(GL_LIGHT0 + light, GL_POSITION, position); float argba[] = {pl->ambient.red, pl->ambient.green, pl->ambient.blue, pl->ambient.alpha}; glLightfv(GL_LIGHT0+light, GL_AMBIENT, argba); float drgba[] = {pl->diffuse.red, pl->diffuse.green, pl->diffuse.blue, pl->diffuse.alpha}; glLightfv(GL_LIGHT0+light, GL_DIFFUSE, drgba); float srgba[] = {pl->specular.red, pl->specular.green, pl->specular.blue, pl->specular.alpha}; glLightfv(GL_LIGHT0+light, GL_SPECULAR, srgba); float ergba[] = {pl->emission.red, pl->emission.green, pl->emission.blue, pl->emission.alpha}; glLightfv(GL_LIGHT0+light, GL_EMISSION, ergba); glLightf(GL_LIGHT0+light, GL_CONSTANT_ATTENUATION, pl->getConstantAttenuation()); glLightf(GL_LIGHT0+light, GL_LINEAR_ATTENUATION, pl->getLinearAttenuation()); glLightf(GL_LIGHT0+light, GL_QUADRATIC_ATTENUATION, pl->getQuadraticAttenuation()); light++; }*/ glPushMatrix(); glTranslatef( TILEWIDTH * width_ / 2, 0.0f, TILEWIDTH * height_ / 2 ); for(int y = 0; y < height_; y++) { glPushMatrix(); for(int x = 0; x < width_; x++) { Tile* tile = getTile(x, y); if(tile) { if(interface->getEditMode() != MODE_NONE) { glEnable(GL_COLOR_MATERIAL); if(getSolid(x, y)) { glColor3f(1.0, 0.0, 0.0); } else { glColor3f(1.0, 1.0, 1.0); } tile->draw(interface); } else { tile->draw(interface); } } glTranslatef(-TILEWIDTH, 0.0f, 0.0f); } glPopMatrix(); glTranslatef(0.0f, 0.0f, -TILEWIDTH); } glPopMatrix(); // draw all the objects in the map for(vector<Contained*>::iterator iter = children_.begin(); iter != children_.end(); iter++) { Visual* object = dynamic_cast<Visual*>(*iter); if(object) { object->draw(interface); } } }