Пример #1
0
void collisionTester::setTransformFromOF(ofMatrix4x4& mat, ofVec3f& s, btCollisionObject& obj){
    
    btTransform trans;
    trans.setFromOpenGLMatrix(mat.getPtr());
    obj.setWorldTransform(trans);
    obj.getCollisionShape()->setLocalScaling(btVector3(s.x, s.y, s.z));
}
Пример #2
0
void Model::draw(ofMatrix4x4 camMvpMatrix)
{
    diffuseTex.bind();
    shader.begin();
    ofPushStyle();
    
    GLuint matLoc = glGetUniformLocation(shader.getProgram(), "camMvpMatrix");
    if (matLoc != -1)
    {
        glUniformMatrix4fv(matLoc, 1, GL_FALSE, camMvpMatrix.getPtr());
    }

    shader.setUniformTexture("modelTransTexture", modelTransTexture, 1);
    
    for (auto p : pieces)
    {
        shader.setUniformTexture("animationTexture", p.instancedAnimTextre, 2);
        shader.setUniformTexture("diffuseTex", diffuseTex, 3);
        
        p.material.begin();
        
        ofEnableBlendMode(p.blendmode);
        
        p.vbo.drawElements(GL_TRIANGLES, p.vbo.getNumIndices());
        
        p.material.end();
    }
    
    ofPopStyle();
    shader.end();
    diffuseTex.unbind();
}
Пример #3
0
static inline aiMatrix4x4 ofMatrix4x4ToAiMatrix44(const ofMatrix4x4 &m)
{
	const float *d = m.getPtr();
	return aiMatrix4x4(d[0], d[4], d[8], d[12],
					d[1], d[5], d[9], d[13],
					d[2], d[6], d[10], d[14],
					d[3], d[7], d[11], d[15]);
}
Пример #4
0
ofVec3f ofkUnProjectionHelper::getProjectionPoint(float ofScreenPosX, float ofScreenPosY, ofMatrix4x4 modelView, ofMatrix4x4 projection, float viewWidth, float viewHeight )
{
    GLdouble modelMAT[16];
    GLdouble projectionMAT[16];
    GLint view[4];
    
    for(int i = 0 ; i < 16 ; i++)
    {
        modelMAT[i] = modelView.getPtr()[i];
        projectionMAT[i] = projection.getPtr()[i];
    }
    
    view[0] = 0;
    view[1] = 0;
    view[2] = viewWidth;
    view[3] = viewHeight;
    
    return getProjectionPoint(ofScreenPosX,  ofScreenPosY, modelMAT, projectionMAT, view);
}
Пример #5
0
ofVec3f ofkMatrixHelper::getProjectionPoint(ofVec3f pos, const ofMatrix4x4 modelView, ofMatrix4x4 projection, const int *_view)
{
	GLdouble modelMAT[16];
    GLdouble projectionMAT[16];
    GLint view[4];
    
    for(int i = 0 ; i < 16 ; i++)
    {
        modelMAT[i] = modelView.getPtr()[i];
        projectionMAT[i] = projection.getPtr()[i];
    }
    
    view[0] = _view[0];
    view[1] = _view[1];
    view[2] = _view[2];
    view[3] = _view[3];

	return getProjectionPoint(pos,modelMAT, projectionMAT,view);
}
Пример #6
0
//----------------------------------------------------------
void ofGLRenderer::loadViewMatrix(const ofMatrix4x4 & m){
	int matrixMode;
	glGetIntegerv(GL_MATRIX_MODE,&matrixMode);
	matrixStack.loadViewMatrix(m);
	glMatrixMode(GL_MODELVIEW);
	glLoadMatrixf(m.getPtr());
	glMatrixMode(matrixMode);

	if(lightingEnabled){
		for(size_t i=0;i<ofLightsData().size();i++){
			shared_ptr<ofLight::Data> lightData = ofLightsData()[i].lock();
			if(lightData && lightData->isEnabled){
				glLightfv(GL_LIGHT0 + lightData->glIndex, GL_POSITION, &lightData->position.x);
			}
		}
	}
}
Пример #7
0
//----------------------------------------------------------
void ofGLRenderer::multMatrix (const ofMatrix4x4 & m){
	multMatrix( m.getPtr() );
}
Пример #8
0
//----------------------------------------------------------
void ofGLRenderer::loadMatrix (const ofMatrix4x4 & m){
	loadMatrix( m.getPtr() );
}
Пример #9
0
//--------------------------------------------------------------
void ofShader::setUniformMatrix4f(const string & name, const ofMatrix4x4 & m, int count)  const{
	if(bLoaded) {
		int loc = getUniformLocation(name);
		if (loc != -1) glUniformMatrix4fv(loc, count, GL_FALSE, m.getPtr());
	}
}
Пример #10
0
void applyMatrix(const ofMatrix4x4& matrix) {
	glMultMatrixf((GLfloat*) matrix.getPtr());
}
Пример #11
0
//----------------------------------------
void ofNode::setTransformMatrix(const ofMatrix4x4 &m44) {
	setTransformMatrix(m44.getPtr());
}
Пример #12
0
//--------------------------------------------------------------
void ofShader::setUniformMatrix4f(const char* name, const ofMatrix4x4 & m) {
	if(bLoaded)
		glUniformMatrix4fv(getUniformLocation(name), 1, GL_FALSE, m.getPtr());
}
Пример #13
0
void ofxOpenVR::setCurrentHMDMatrix(ofMatrix4x4 & mat) {

	_mat4HMDPose.set(mat.getPtr());
}
Пример #14
0
void VDB::transform(ofMatrix4x4 & mat) {
	tempTransform.postMult(mat);
	math::Mat4d vMat(mat.getPtr());
	grid->transform().postMult(vMat);
}
Пример #15
0
void Shader::setUniform( const char* name, ofMatrix4x4& _value, bool transpose ){
    if(uniforms.count( name )){
        begin();
        glUniformMatrix4fv(uniforms[name].loc,1, transpose, _value.getPtr() );
    }
}