void ramDrawBasicActor(const ramActor& actor) { if (actor.getNumNode() == 0) return; assert(actor.getNumNode() == ramActor::NUM_JOINTS); ofPushStyle(); const ofColor& color0 = ofGetStyle().color; const ofColor& color1 = ofColor::fromHsb(((int)color0.getHue() + 30) % 255, color0.getSaturation() * 0.5, color0.getBrightness(), color0.a); glPushMatrix(); for (int i = 0; i < actor.getNumNode(); i++) { const ramNode &node = actor.getNode(i); float jointSize = (i == ramActor::JOINT_HEAD) ? 8.0 : 5.0; ofPushStyle(); ofSetLineWidth(2); ofSetColor(color0); ramBox(node, jointSize); ofSetColor(color1); ramLine(node); ofPopStyle(); } glPopMatrix(); ofPopStyle(); }
void ramDrawBasicRigid(const ramRigidBody& rigid) { if (rigid.getNumNode() == 0) return; for (int i = 0; i < rigid.getNumNode(); i++) { const ramNode &node = rigid.getNode(i); ramBox(node, 5); } }
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(); }