void TowerRenderable::Init() { back = new RectRenderable(size, size); back->setup_vertexes(); back->set_shader(this->shader); Color3f back_color(0.1f, 0.2f, 0.3f); back->SetColor(back_color); front = new RectRenderable(size, size); front->set_shader(this->shader); Color3f front_color(0.0f, 0.3f, 0.9f); front->SetColor(front_color); }
void ramActorsScene::drawNodes(const ramNodeArray &NA) { ofPushStyle(); ofNoFill(); ofSetRectMode(OF_RECTMODE_CENTER); glPushAttrib(GL_ALL_ATTRIB_BITS); glEnable(GL_CULL_FACE); ofColor front_color(ofGetStyle().color, 200); ofColor back_color(ofGetStyle().color, 150); for (int i = 0; i < NA.getNumNode(); i++) { ofSetColor(front_color); const ramNode &node = NA.getNode(i); const ramNode *parent = node.getParent(); if (parent == NULL) continue; ramBox(node, 2); parent->beginTransform(); ofVec3f axis(0, 0, 1); ofVec3f c = node.getPosition().normalized().crossed(axis); ofRotate(90, c.x, c.y, c.z); ofVec3f p0 = node.getGlobalPosition(); ofVec3f p1 = parent->getGlobalPosition(); float dist = p0.distance(p1); float offset = 0.2; glNormal3f(0, 0, 0); ofLine(ofVec3f(0), ofVec3f(0, 0, -dist)); if (i < 4) glScalef(1., 1.8, 1); else if (i == 4) glScalef(1, 1, 3); else glScalef(1., 0.8, 1); glBegin(GL_TRIANGLE_STRIP); for (int n = 0; n < 6; n++) { float d = ofMap(n, 0, 5, 0, 1); float dd = ofMap(d, 0, 1, offset, 1 - offset); float xx = sin(d * PI) * 2 + 4; float zz = dd * -dist; float w = 5; glNormal3f(1, 0.5, 0); glVertex3f(xx, w, zz); glNormal3f(1, -0.5, 0); glVertex3f(xx, -w, zz); } glEnd(); ofSetColor(back_color); glBegin(GL_TRIANGLE_STRIP); for (int n = 0; n < 6; n++) { float d = ofMap(n, 0, 5, 0, 1); float dd = ofMap(d, 0, 1, offset, 1 - offset); float xx = -sin(d * PI) * 1 - 6; float zz = dd * -dist; float w = 3; glNormal3f(-1, 0.5, 0); glVertex3f(xx, -w, zz); glNormal3f(-1, -0.5, 0); glVertex3f(xx, w, zz); } glEnd(); parent->endTransform(); } glPopAttrib(); ofPopStyle(); }