Exemplo n.º 1
0
//--------------------------------------------------------------
void ofxBulletPatch::draw() {
    if(!checkCreate()) {
        ofLogWarning("ofxBulletPatch") << "draw() : must call create() first and add() after";
        return;
    }
    transformGL();
    getMesh().draw();
    restoreTransformGL();
}
Exemplo n.º 2
0
//--------------------------------------------------------------
void ofxBulletSphere::draw() {
	if(!_bCreated || _rigidBody == NULL) {
		ofLog(OF_LOG_WARNING, "ofxBulletSphere :: draw : must call create() first and add() after");
		return;
	}
	transformGL();
    ofDrawSphere( 0, 0, 0, getRadius() );
    restoreTransformGL();
}
Exemplo n.º 3
0
void oscThread::draw()
{
    ofPushMatrix();
    ofTranslate((originP.x+destP.x)/2,(originP.y+destP.y)/2,(originP.z+destP.z)/2);
    direction = (destP - originP).getNormalized();
    axis.set(1, 0, 0);
    rotation.makeRotate(axis, direction);
    rotation.getRotate(rotationAmount, rotationAngle);
    ofRotate(rotationAmount, rotationAngle.x, rotationAngle.y, rotationAngle.z);
    transformGL();
    this->getMesh().draw();
    restoreTransformGL();
    ofPopMatrix();
}
Exemplo n.º 4
0
//----------------------------------------
void ofNode::draw() {
	transformGL();
	customDraw();
	restoreTransformGL();
}
Exemplo n.º 5
0
//--------------------------------------------------------------
void ofxBulletCapsule::draw() {
	if(!_bCreated || _rigidBody == NULL) {
		ofLog(OF_LOG_WARNING, "ofxBulletCapsule :: draw : must call create() first and add() after");
		return;
	}
	
	transformGL();
	
	if(hull == NULL) {
		hull = new btShapeHull((btConvexShape*)_rigidBody->getCollisionShape());
	
		btScalar margin = _rigidBody->getCollisionShape()->getMargin();
		hull->buildHull(margin);
	}
    
    if(_cachedMesh.getNumVertices() != hull->numTriangles() * 3) {
        _cachedMesh.setMode( OF_PRIMITIVE_TRIANGLES );
        _cachedMesh.clear();
        
        if (hull->numTriangles () > 0) {
            int index = 0;
            const unsigned int* idx = hull->getIndexPointer();
            const btVector3* vtx = hull->getVertexPointer();
            
            for (int i = 0; i < hull->numTriangles (); i++) {
                int i1 = index++;
                int i2 = index++;
                int i3 = index++;
                btAssert(i1 < hull->numIndices () &&
                         i2 < hull->numIndices () &&
                         i3 < hull->numIndices ());
                
                int index1 = idx[i1];
                int index2 = idx[i2];
                int index3 = idx[i3];
                btAssert(index1 < hull->numVertices () &&
                         index2 < hull->numVertices () &&
                         index3 < hull->numVertices ());
                
                btVector3 v1 = vtx[index1];
                btVector3 v2 = vtx[index2];
                btVector3 v3 = vtx[index3];
                btVector3 normal = (v3-v1).cross(v2-v1);
                normal.normalize();
                
                _cachedMesh.addVertex( ofVec3f(v1.x(), v1.y(), v1.z()) );
                _cachedMesh.addVertex( ofVec3f(v2.x(), v2.y(), v2.z()) );
                _cachedMesh.addVertex( ofVec3f(v3.x(), v3.y(), v3.z()) );
                
                _cachedMesh.addNormal( ofVec3f(normal.x(), normal.y(), normal.z()) );
                _cachedMesh.addNormal( ofVec3f(normal.x(), normal.y(), normal.z()) );
                _cachedMesh.addNormal( ofVec3f(normal.x(), normal.y(), normal.z()) );
                
            }
        }
        
        _cachedMesh.setupIndicesAuto();
        
    }
    
    if(_cachedMesh.getNumVertices() > 2) {
        _cachedMesh.draw();
    }
    
	restoreTransformGL();
}