• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ofMatrix4x4类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ofMatrix4x4的典型用法代码示例。如果您正苦于以下问题:C++ ofMatrix4x4类的具体用法?C++ ofMatrix4x4怎么用?C++ ofMatrix4x4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ofMatrix4x4类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: getBoundingBox

ofRectangle ofxSymbolInstance::getBoundingBox(ofMatrix4x4 mat) {
//    cout << "bounding box" << endl;
    ofRectangle rect(0,0,0,0);
    mat.preMult(this->mat);
    
    switch (type) {
        case BITMAP_INSTANCE: {
            ofVec2f p0 = mat.preMult(ofVec3f(0,0,0));
            ofVec2f p1 = mat.preMult(ofVec3f(bitmapItem->getWidth(),bitmapItem->getHeight()));
            rect = ofRectangle(p0.x,p0.y,p1.x-p0.x,p1.y-p0.y);
        } break;
            
        case SYMBOL_INSTANCE: {
            
            for (vector<layer>::iterator liter=layers.begin();liter!=layers.end();liter++) {
                frame &f = liter->frames[liter->currentFrame];
                
                vector<ofxSymbolInstance>::iterator iter=f.instances.begin();
                while (iter!=f.instances.end()) {
                    rect = iter->getBoundingBox(mat);
                    iter++;
                    if (rect.width!=0 || rect.height!=0) {
                        break;
                    }
                }
                
                while (iter!=f.instances.end()) {
                    
                    ofRectangle iterect = iter->getBoundingBox();
                    if (iterect.width!=0 || iterect.height!=0) {
                    
                        ofVec2f p0(rect.x,rect.y);
                        ofVec2f p1(p0.x+rect.width,p0.y+rect.height);
                        
                        ofVec2f q0(iterect.x,iterect.y);
                        ofVec2f q1(q0.x+iterect.width,q0.y+iterect.height);
                        
                        ofVec2f pos(MIN(p0.x,q0.x),MIN(p0.y,q0.y));
                        rect = ofRectangle(pos.x,pos.y,MAX(p1.x,q1.x)-pos.x,MAX(p1.y,q1.y)-pos.y);
                            
                       
                            //                    cout << rect.x << "\t" << rect.y << "\t" << rect.width << "\t" << rect.height << endl;
                            
                    }
                    iter++;
                   
                }
            }
        } break;
            
        default:
            break;
    } 
    
        
    return rect;
}
开发者ID:roikr,项目名称:openFrameworks007,代码行数:57,代码来源:ofxFlash.cpp


示例2:

//--------------------------------------------------------------
ofMatrix4x4 Path3D::zForward(ofMatrix4x4 originalMat){
    
    ofVec3f pos  = originalMat.getTranslation();
    ofVec3f y = originalMat.getRowAsVec3f(1);   // local y-axis
    
    originalMat.setTranslation(0,0,0);
    originalMat.rotate(90, y.x, y.y, y.z);     // rotate about the y
    originalMat.setTranslation(pos);
    
    return originalMat;
}
开发者ID:CreativeInquiry,项目名称:ofxRobotArm,代码行数:12,代码来源:Path3D.cpp


示例3: draw

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();
}
开发者ID:mcanthony,项目名称:ofGLSLSkeletalAnimation,代码行数:32,代码来源:Model.cpp


示例4: setTransformFromOF

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));
}
开发者ID:stdmtb,项目名称:instancedModeler,代码行数:7,代码来源:collisionTester.cpp


示例5: getWorld

ramPyramidPrimitive::ramPyramidPrimitive(const ofMatrix4x4& mat, float size)
{
	size *= 0.5;

	mesh.addVertex(ofVec3f(1, 1, 1) * size);
	mesh.addVertex(ofVec3f(-1, 1, -1) * size);
	mesh.addVertex(ofVec3f(-1, -1, 1) * size);
	mesh.addVertex(ofVec3f(1, -1, -1) * size);

	mesh.addTriangle(0, 1, 2);
	mesh.addTriangle(0, 2, 3);
	mesh.addTriangle(0, 3, 1);
	mesh.addTriangle(3, 2, 1);

	body = getWorld().addMesh(mesh, mat.getTranslation(), mat.getRotate().getEuler());
}
开发者ID:UIKit0,项目名称:RAMDanceToolkit,代码行数:16,代码来源:ramPrimitive.cpp


示例6: getProjectionPoint

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);
}
开发者ID:imclab,项目名称:ofkTools,代码行数:19,代码来源:ofkUnProjectionHelper.cpp


示例7: getProjectionPoint

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);
}
开发者ID:imclab,项目名称:ofkTools,代码行数:19,代码来源:ofkMatrixHelper.cpp


示例8: ofRectangleTransform

ofRectangle ofRectangleTransform(const ofRectangle & rect, const ofMatrix4x4 & mat) {
    ofVec3f tl = rect.getTopLeft();
    ofVec3f br = rect.getBottomRight();
    
    tl = mat.preMult(tl);
    br = mat.preMult(br);
    
    ofRectangle r;
    r.setPosition(tl);
    r.growToInclude(br);
    
    return r;
}
开发者ID:julapy,项目名称:ofxJulapyUtils,代码行数:13,代码来源:ofxJulapyUtils.cpp


示例9: getTranslationAndOrientation

void ofxARToolkitPlus::getTranslationAndOrientation(int markerIndex, ofVec3f &translation, ofMatrix4x4 &orientation) {
	
	ARToolKitPlus::ARMarkerInfo marker = tracker->getDetectedMarker(markerIndex);

	getTransMat( &marker, c, m34 );
	
	// Translation
	translation.set(m34[0][3], m34[1][3], m34[2][3]);
	
	// Orientation
	orientation.set(m34[0][0], m34[0][1], m34[0][2], 0,
					m34[1][0], m34[1][1], m34[1][2], 0,
					m34[2][0], m34[2][1], m34[2][2], 0,
					0, 0, 0, 1);
}
开发者ID:Meach,项目名称:ofxARtoolkitPlus,代码行数:15,代码来源:ofxARToolkitPlus.cpp


示例10: getLastHeadView

ofMatrix4x4 headTracking::getLastHeadView(ofMatrix4x4 headView)
{
    if (!mTracker.isReady()) {
        return headView;
    }

    ofOrientation fooRot = ofGetOrientation();
    double rotation = 0.0;

    if (fooRot == OF_ORIENTATION_DEFAULT) {
        rotation = 0.0;
    } else if (fooRot == OF_ORIENTATION_90_LEFT) {
        rotation = 90.0;
    } else if (fooRot == OF_ORIENTATION_90_RIGHT) {
        rotation = 180.0;
    } else {
        rotation = 270.0;
    }

    if (fooRot != mDisplayRotation) {
        mDisplayRotation = fooRot;

        mSensorToDisplay.makeRotationMatrix(
            ofQuaternion(0.0, ofVec3f(1, 0, 0), -rotation, ofVec3f(0, 0, 1),
                         0.0, ofVec3f(0, 1, 0)));
        mEkfToHeadTracker.makeRotationMatrix(
            ofQuaternion(0.0, ofVec3f(1, 0, 0), rotation, ofVec3f(0, 0, 1),
                         0.0, ofVec3f(0, 1, 0)));
    }

    double secondsSinceLastGyroEvent = (ofGetElapsedTimeMicros() -
                                        mLastGyroEventTimeNanos) * 1E-6;


    double secondsToPredictForward = secondsSinceLastGyroEvent + 0.0166666666;
    mTmpHeadView = mTracker.getPredictedGLMatrix(secondsToPredictForward);
    mTmpHeadView2.makeFromMultiplicationOf(mSensorToDisplay, mTmpHeadView);
    headView.makeFromMultiplicationOf(mTmpHeadView2, mEkfToHeadTracker);

    if (mNeckModelEnabled) {
        mTmpHeadView.makeFromMultiplicationOf(mNeckModelTranslation, headView);
        mTmpHeadView.translate(ofVec3f(0, 0.075, 0.0));
        headView = mTmpHeadView;
    }

    return headView;
}
开发者ID:ccccjason,项目名称:IMU,代码行数:47,代码来源:headTracking.cpp


示例11: loadViewMatrix

//----------------------------------------------------------
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);
			}
		}
	}
}
开发者ID:cooperyoo,项目名称:openFrameworks,代码行数:18,代码来源:ofGLRenderer.cpp


示例12: compute

void ofxIcp::compute(const vector<ofPoint> & initial, const vector<ofPoint> & target, vector<ofPoint> & output, ofMatrix4x4 & transformation, double & error, int & iterations){
    
    vector<cv::Point3d> initial_cv;
    vector<cv::Point3d> target_cv;
    
    toCV(initial, initial_cv);
    toCV(target, target_cv);
    
    cv::Mat transformation_matrix;
    
    vector<cv::Point3d> output_cv;
    compute(initial_cv, target_cv, output_cv, transformation_matrix, error, iterations);
    
    toOF(output_cv, output);
    
    transformation.set(transformation_matrix.ptr<double>());
}
开发者ID:matusv,项目名称:ofxICP,代码行数:17,代码来源:ofxICP.cpp


示例13: getChildMat

bool ofxSymbolInstance::getChildMat(ofxSymbolInstance *child,ofMatrix4x4 &mat) {
    if (this==child) {
        mat = this->mat;
        return true;
    }
    
    for (vector<layer>::iterator liter=layers.begin();liter!=layers.end();liter++) {
        frame &f = liter->frames[liter->currentFrame];
        for (vector<ofxSymbolInstance>::iterator iter=f.instances.begin(); iter!=f.instances.end(); iter++) {
            if (iter->getChildMat(child, mat)) {
                mat.postMult(this->mat);
                return  true;
            }
        }
    }
    
    return false;
}
开发者ID:roikr,项目名称:openFrameworks007,代码行数:18,代码来源:ofxFlash.cpp


示例14:

void ofxPolyline2Mesh::pushSegment(const ofColor& c2, const ofColor& c1,
				 const ofMatrix4x4 &m)
{
	for (int i = 0; i < shape.size(); i++)
	{
		const ofVec3f &p = m.preMult(shape[i]);
		current_segments[i] = p;
	}

	for (int i = 0; i < shape.size() - 1; i++)
	{
		const ofVec3f &p1 = last_segments[i];
		const ofVec3f &p2 = current_segments[i];

		const ofVec3f &n1 = last_segments[i + 1];
		const ofVec3f &n2 = current_segments[i + 1];

		const ofVec3f norm = (p2 - p1).crossed((n1 - p1)).normalized();

		mesh.addNormal(norm);
		mesh.addColor(c1);
		mesh.addVertex(p1);

		mesh.addNormal(norm);
		mesh.addColor(c2);
		mesh.addVertex(p2);

		mesh.addNormal(norm);
		mesh.addColor(c1);
		mesh.addVertex(n1);

		mesh.addNormal(norm);
		mesh.addColor(c1);
		mesh.addVertex(n1);

		mesh.addNormal(norm);
		mesh.addColor(c2);
		mesh.addVertex(p2);

		mesh.addNormal(norm);
		mesh.addColor(c2);
		mesh.addVertex(n2);
	}
}
开发者ID:arturoc,项目名称:ofxPolyline2Mesh,代码行数:44,代码来源:ofxPolyline2Mesh.cpp


示例15: getMultiMarkerTranslationAndOrientation

void ofxARToolkitPlus::getMultiMarkerTranslationAndOrientation(ofVec3f &translation, ofMatrix4x4 &orientation) {

	const ARToolKitPlus::ARMultiMarkerInfoT *multiMarkerConst = tracker->getMultiMarkerConfig();
	if(multiMarkerConst != NULL) {
		// Create a copy of the ARMultiMarkerInfoT struct
		ARToolKitPlus::ARMultiMarkerInfoT mm;
		size_t mmSize = sizeof(ARToolKitPlus::ARMultiMarkerInfoT);
		memcpy(&mm, multiMarkerConst, mmSize);
		
		// Copy and pass in the markers
		int numberOfMarkers = tracker->getNumDetectedMarkers();
#ifdef TARGET_WIN32
		ARToolKitPlus::ARMarkerInfo *marker = new ARToolKitPlus::ARMarkerInfo[numberOfMarkers];
#else
		ARToolKitPlus::ARMarkerInfo marker[numberOfMarkers];
#endif
		for (int i=0; i<numberOfMarkers; i++) {
			marker[i] = tracker->getDetectedMarker(i);
		}
		float result = tracker->rppMultiGetTransMat(marker, numberOfMarkers, &mm);
		
		// Check for error - yes this does occur
		if(result < 0 || result >= INT_MAX) {
			tracker->arMultiGetTransMat(marker, numberOfMarkers, &mm);
			ofLog(OF_LOG_VERBOSE, "RPP failed on multimarker");	
		} 
		
		// Translation
		translation.set(mm.trans[0][3], mm.trans[1][3], mm.trans[2][3]);		
		// Orientation
		orientation.set(mm.trans[0][0], mm.trans[0][1], mm.trans[0][2], 0,
						mm.trans[1][0], mm.trans[1][1], mm.trans[1][2], 0,
						mm.trans[2][0], mm.trans[2][1], mm.trans[2][2], 0,
						0, 0, 0, 1);
#ifdef TARGET_WIN32
		free(marker);
#endif
	} else {
		ofLog(OF_LOG_VERBOSE, "MultiMarkerConfig file NULL");
	}

}
开发者ID:Meach,项目名称:ofxARtoolkitPlus,代码行数:42,代码来源:ofxARToolkitPlus.cpp


示例16: setUniform

void Shader::setUniform( const char* name, ofMatrix4x4& _value, bool transpose ){
    if(uniforms.count( name )){
        begin();
        glUniformMatrix4fv(uniforms[name].loc,1, transpose, _value.getPtr() );
    }
}
开发者ID:Akira-Hayasaka,项目名称:ofxScene,代码行数:6,代码来源:Shader.cpp


示例17: transform

void ofxMesh::transform(const ofMatrix4x4 trans) {
    for (int i=0; i<getNumVertices(); i++) {
		getVertices()[i] = trans.preMult(getVertices()[i]);
    }
}
开发者ID:daitomanabe,项目名称:ofxMesh,代码行数:5,代码来源:ofxMesh.cpp


示例18: get

void ofQuaternion::get(ofMatrix4x4& matrix) const {
	matrix.makeRotationMatrix(*this);
}
开发者ID:terminalB,项目名称:openFrameworks,代码行数:3,代码来源:ofQuaternion.cpp


示例19: set

void ofQuaternion::set(const ofMatrix4x4& matrix) {
	*this = matrix.getRotate();
}
开发者ID:terminalB,项目名称:openFrameworks,代码行数:3,代码来源:ofQuaternion.cpp


示例20:

//--------------------------------------------------------------
void ofShader::setUniformMatrix4f(const char* name, const ofMatrix4x4 & m) {
	if(bLoaded)
		glUniformMatrix4fv(getUniformLocation(name), 1, GL_FALSE, m.getPtr());
}
开发者ID:3snail,项目名称:openFrameworks,代码行数:5,代码来源:ofShader.cpp



注:本文中的ofMatrix4x4类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ofMesh类代码示例发布时间:2022-05-31
下一篇:
C++ ofImage类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap