Beispiel #1
0
const ofMatrix4x4 ofxBone::getGlobalTransformMatrix() const {
	if (tr1::shared_ptr<ofxBone> p = parent.lock()) {
		return getLocalTransformMatrix() * p->getGlobalTransformMatrix();
	} else {
		return getLocalTransformMatrix() * localJointTransformMatrix;
	}
}
Beispiel #2
0
//----------------------------------------
void ofNode::createMatrix() {
	//if(isMatrixDirty) {
	//	isMatrixDirty = false;
	localTransformMatrix.makeScaleMatrix(scale);
	localTransformMatrix.rotate(orientation);
	localTransformMatrix.setTranslation(position);
	
	if(scale[0]>0) axis[0] = getLocalTransformMatrix().getRowAsVec3f(0)/scale[0];
	if(scale[1]>0) axis[1] = getLocalTransformMatrix().getRowAsVec3f(1)/scale[1];
	if(scale[2]>0) axis[2] = getLocalTransformMatrix().getRowAsVec3f(2)/scale[2];
}
void BasicInteractiveObject::drawForPicking(){
	if (isVisible() && isParentTreeVisible()) {
		
		glPushMatrix();
		glMultMatrixf(getLocalTransformMatrix().getPtr());
		
		if (hasmask) setupMask();
		
		depthtestbefore = glIsEnabled(GL_DEPTH_TEST);
		if (depthtestenabled && !depthtestbefore)glEnable(GL_DEPTH_TEST);
		if (!depthtestenabled && depthtestbefore)glDisable(GL_DEPTH_TEST);
		
		ofPushStyle();
		ofColor pickingColor = pickingNameToColor(pickingName);
		ofSetColor(pickingColor.r, pickingColor.g, pickingColor.b);
		_drawForPicking();
		ofPopStyle();			
		
		drawChildrenForPicking();
		
		if(depthtestenabled && !depthtestbefore){
			glDisable(GL_DEPTH_TEST);
		}
		if(!depthtestenabled && depthtestbefore){
			glEnable(GL_DEPTH_TEST);
		}
		if(hasmask) restoreMask();		
		glPopMatrix();
	}
}
void BasicScreenObject::drawForPicking() {
  if (isvisible && _isParentTreeVisible && _isAddedToRenderer) {

    glPushMatrix();
    glMultMatrixf(getLocalTransformMatrix().getPtr());

    if (hasmask) {
      setupMask();
    }

    depthtestbefore = glIsEnabled(GL_DEPTH_TEST);
    if (depthtestenabled && !depthtestbefore)
      glEnable(GL_DEPTH_TEST);
    if (!depthtestenabled && depthtestbefore)
      glDisable(GL_DEPTH_TEST);

    drawChildrenForPicking();

    if (depthtestenabled && !depthtestbefore) {
      glDisable(GL_DEPTH_TEST);
    }
    if (!depthtestenabled && depthtestbefore) {
      glEnable(GL_DEPTH_TEST);
    }
    if (hasmask) {
      restoreMask();
    }
    glPopMatrix();
  }
}
void BasicScreenObject::draw() {

  // int elapsed = 0;

  if ((isvisible && _isParentTreeVisible && _isAddedToRenderer) || ismask) {

    glPushMatrix();
    glMultMatrixf(getLocalTransformMatrix().getPtr());

    if (hasmask)
      setupMask();

    glBlendFunc(sfactor, dfactor);

    lightingbefore = glIsEnabled(GL_LIGHTING);
    depthtestbefore = glIsEnabled(GL_DEPTH_TEST);

    if (depthtestenabled && !depthtestbefore)
      glEnable(GL_DEPTH_TEST);
    if (!depthtestenabled && depthtestbefore)
      glDisable(GL_DEPTH_TEST);

    if (lightingenabled && !lightingbefore)
      glEnable(GL_LIGHTING);
    if (!lightingenabled && lightingbefore)
      glDisable(GL_LIGHTING);

    ofPushMatrix();
    ofPushStyle();
    ofSetColor(color.r, color.g, color.b, getCombinedAlpha());
    _draw();
    ofPopStyle();
    ofPopMatrix();

    ofPushMatrix();
    drawChildren();
    ofPopMatrix();
    ofPushMatrix();
    _drawAfterChildren();
    ofPopMatrix();

    // lighting out
    if (lightingenabled && !lightingbefore)
      glDisable(GL_LIGHTING);
    if (!lightingenabled && lightingbefore)
      glEnable(GL_LIGHTING);

    // Depthtest out
    if (depthtestenabled && !depthtestbefore)
      glDisable(GL_DEPTH_TEST);
    if (!depthtestenabled && depthtestbefore)
      glEnable(GL_DEPTH_TEST);

    if (hasmask)
      restoreMask();

    glPopMatrix();
  }
}
Beispiel #6
0
//----------------------------------------
void ofNode::rotateAround(const ofQuaternion& q, const ofVec3f& point) {
	ofMatrix4x4 m = getLocalTransformMatrix();
	//	m.setTranslation(point);
	//	m.rotate(q);
	
	onOrientationChanged();
	onPositionChanged();
}
Beispiel #7
0
void Ocean::customDraw() {
    ofPushStyle();
    shader_.begin();
    shader_.setUniformTexture("tex", texture_, 0);
    shader_.setUniform1f("tick", ofGetElapsedTimef());
    shader_.setUniformMatrix4f("modelMatrix", getLocalTransformMatrix());
    shader_.setUniform1f("white", 1.0 - CalibrationMesh::white);
    mesh_.drawFaces();
    shader_.end();
    ofPopStyle();
}
Beispiel #8
0
const ofMatrix4x4 ofxBone::getJointTransformMatrix() const {
	ofMatrix4x4 m;
	
	if (tr1::shared_ptr<ofxBone> p = parent.lock()){
		m = ofMatrix4x4::getInverseOf(getLocalTransformMatrix());
	} else {
		m = localJointTransformMatrix;
	}
	
	return m;
}
Beispiel #9
0
//----------------------------------------
glm::mat4 ofNode::getGlobalTransformMatrix() const {
	if(parent) return parent->getGlobalTransformMatrix() * getLocalTransformMatrix();
	else return getLocalTransformMatrix();
}
Beispiel #10
0
//----------------------------------------
void ofNode::updateAxis() {
	if(scale->x>0) axis[0] = (getLocalTransformMatrix()[0]/scale->x).xyz();
	if(scale->y>0) axis[1] = (getLocalTransformMatrix()[1]/scale->y).xyz();
	if(scale->z>0) axis[2] = (getLocalTransformMatrix()[2]/scale->z).xyz();
}
Beispiel #11
0
//----------------------------------------
ofMatrix4x4 ofNode::getGlobalTransformMatrix() const {
    if(parent) return getLocalTransformMatrix() * parent->getGlobalTransformMatrix();
    else return getLocalTransformMatrix();
}
Beispiel #12
0
//----------------------------------------
void ofNode::updateAxis() {
    if(scale[0]>0) axis[0] = getLocalTransformMatrix().getRowAsVec3f(0)/scale[0];
    if(scale[1]>0) axis[1] = getLocalTransformMatrix().getRowAsVec3f(1)/scale[1];
    if(scale[2]>0) axis[2] = getLocalTransformMatrix().getRowAsVec3f(2)/scale[2];
}
Beispiel #13
0
const ofQuaternion ofxBone::getOrientation() const {
	return getLocalTransformMatrix().getRotate();
}
Beispiel #14
0
//----------------------------------------
void ofNode::updateAxis() {
	if(scale->x>0) axis[0] = getLocalTransformMatrix().getRowAsVec3f(0)/scale->x;
	if(scale->y>0) axis[1] = getLocalTransformMatrix().getRowAsVec3f(1)/scale->y;
	if(scale->z>0) axis[2] = getLocalTransformMatrix().getRowAsVec3f(2)/scale->z;
}