本文整理汇总了C++中Matrix44f类的典型用法代码示例。如果您正苦于以下问题:C++ Matrix44f类的具体用法?C++ Matrix44f怎么用?C++ Matrix44f使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Matrix44f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qDebug
//添加元素
void FilterParameter::addQDomElement(FilterParameterSet &par, QDomElement &np)
{
QString name=np.attribute("name");
QString type=np.attribute("type");
qDebug(" Reading Param with name %s : %s",qPrintable(name),qPrintable(type));
if(type=="Bool") { par.addBool(name,np.attribute("value")!=QString("false")); return; }
if(type=="Int") { par.addInt(name,np.attribute("value").toInt()); return; }
if(type=="Float") { par.addFloat(name,np.attribute("value").toDouble()); return; }
if(type=="String") { par.addString(name,np.attribute("value")); return; }
if(type=="AbsPerc") { par.addAbsPerc(name,np.attribute("value").toFloat(),np.attribute("min").toFloat(),np.attribute("max").toFloat()); return; }
if(type=="Color") { par.addColor(name,QColor::QColor(np.attribute("rgb").toUInt())); return; }
if(type=="Matrix44")
{
Matrix44f mm;
for(int i=0;i<16;++i)
mm.V()[i]=np.attribute(QString("val")+QString::number(i)).toDouble();
par.addMatrix44(name,mm);
return;
}
if(type=="Enum")
{
QStringList list = QStringList::QStringList();
for(QDomElement ns = np.firstChildElement("EnumString"); !ns.isNull(); ns = ns.nextSiblingElement("EnumString")){
list<<ns.attribute("value");
}
par.addEnum(name,np.attribute("value").toInt(),list);
return;
}
if(type == MeshPointerName()) { par.addMesh(name, np.attribute(ValueName()).toInt()); return; }
if(type == FloatListName())
{
QList<float> values;
for(QDomElement listItem = np.firstChildElement(ItemName());
!listItem.isNull();
listItem = listItem.nextSiblingElement(ItemName()))
{
values.append(listItem.attribute(ValueName()).toFloat());
}
par.addFloatList(name,values);
return;
}
if(type == DynamicFloatName()) { par.addDynamicFloat(name, np.attribute(ValueName()).toFloat(), np.attribute(MinName()).toFloat(), np.attribute(MaxName()).toFloat(), np.attribute(MaskName()).toInt()); return; }
if(type == OpenFileNameName()) { par.addOpenFileName(name, np.attribute(ValueName())); return; }
if(type == SaveFileNameName()) { par.addSaveFileName(name, np.attribute(ValueName())); return; }
if(type=="Point3f")
{
Point3f val;
val[0]=np.attribute("x").toFloat();
val[1]=np.attribute("y").toFloat();
val[2]=np.attribute("z").toFloat();
par.addPoint3f(name, val);
return;
}
assert(0); // we are trying to parse an unknown xml element
}
示例2: ColorA
void BubbleChamberApp::drawIntoRoomFbo()
{
mRoomFbo.bindFramebuffer();
gl::clear( ColorA( 0.0f, 0.0f, 0.0f, 0.0f ), true );
gl::setMatricesWindow( mRoomFbo.getSize(), false );
gl::setViewport( mRoomFbo.getBounds() );
gl::disableAlphaBlending();
gl::enable( GL_TEXTURE_2D );
glEnable( GL_CULL_FACE );
glCullFace( GL_BACK );
Matrix44f m;
m.setToIdentity();
m.scale( mRoom.getDims() );
mRoomShader.bind();
mRoomShader.uniform( "mvpMatrix", mActiveCam.mMvpMatrix );
mRoomShader.uniform( "mMatrix", m );
mRoomShader.uniform( "eyePos", mActiveCam.mCam.getEyePoint() );
mRoomShader.uniform( "roomDims", mRoom.getDims() );
mRoomShader.uniform( "power", mRoom.getPower() );
mRoomShader.uniform( "lightPower", mRoom.getLightPower() );
mRoomShader.uniform( "timePer", mRoom.getTimePer() * 1.5f + 0.5f );
mRoom.draw();
mRoomShader.unbind();
mRoomFbo.unbindFramebuffer();
glDisable( GL_CULL_FACE );
}
示例3: ColorA
void ShadedSphereApp::drawIntoRoomFbo()
{
mRoomFbo.bindFramebuffer();
gl::clear( ColorA( 0.0f, 0.0f, 0.0f, 0.0f ), true );
gl::setMatricesWindow( mRoomFbo.getSize(), false );
gl::setViewport( mRoomFbo.getBounds() );
gl::disableAlphaBlending();
gl::enable( GL_TEXTURE_2D );
glEnable( GL_CULL_FACE );
glCullFace( GL_BACK );
Matrix44f m;
m.setToIdentity();
m.scale( mRoom.getDims() );
// mLightsTex.bind( 0 );
mRoomShader.bind();
mRoomShader.uniform( "mvpMatrix", mSpringCam.mMvpMatrix );
mRoomShader.uniform( "mMatrix", m );
mRoomShader.uniform( "eyePos", mSpringCam.getEye() );
mRoomShader.uniform( "roomDims", mRoom.getDims() );
mRoomShader.uniform( "mainPower", mRoom.getPower() );
mRoomShader.uniform( "lightPower", mRoom.getLightPower() );
mRoom.draw();
mRoomShader.unbind();
mRoomFbo.unbindFramebuffer();
glDisable( GL_CULL_FACE );
}
示例4: unproject
/* transforms clip-space coordinates to object-space coordinates,
where z is within range [0.0 - 1.0] from near-plane to far-plane */
Vec3f Node::unproject(float x, float y, float z) const
{
// get viewport and projection matrix
Area viewport = gl::getViewport();
Matrix44f projection = gl::getProjection();
// find the inverse modelview-projection-matrix
Matrix44f mvp = projection * mWorldTransform;
mvp.invert(0.0f);
// map x and y from window coordinates
Vec4f in(x, float(viewport.getHeight()) - y - 1.0f, z, 1.0f);
in.x = (in.x - viewport.getX1()) / float( viewport.getWidth() );
in.y = (in.y - viewport.getY1()) / float( viewport.getHeight() );
// map to range [-1..1]
in.x = 2.0f * in.x - 1.0f;
in.y = 2.0f * in.y - 1.0f;
in.z = 2.0f * in.z - 1.0f;
//
Vec4f out = mvp * in;
if(out.w != 0.0f) out.w = 1.0f / out.w;
Vec3f result;
result.x = out.x * out.w;
result.y = out.y * out.w;
result.z = out.z * out.w;
return result;
}
示例5:
//----------------------------------------------------------------------------------------------------------------------
ci::Vec3f View::unproject(const ci::Vec3f& point)
{
// Find the inverse Modelview-Projection-Matrix
Matrix44f mInvMVP = ci::gl::getProjection() * ci::gl::getModelView();
mInvMVP.invert();
// Transform to normalized coordinates in the range [-1, 1]
Vec4f pointNormal;
ci::Area viewport = ci::gl::getViewport();
pointNormal.x = (point.x - viewport.getX1()) / viewport.getWidth() * 2.0f - 1.0f;
pointNormal.y = (point.y - viewport.getY1()) / viewport.getHeight() * 2.0f;
pointNormal.z = 2.0f * point.z - 1.0f;
pointNormal.w = 1.0f;
// Find the object's coordinates
Vec4f pointCoord = mInvMVP * pointNormal;
if (pointCoord.w != 0.0f)
{
pointCoord.w = 1.0f / pointCoord.w;
}
// Return coordinate
return Vec3f(pointCoord.x * pointCoord.w,
pointCoord.y * pointCoord.w,
pointCoord.z * pointCoord.w);
}
示例6: calcBoundingBox
AxisAlignedBox3f TriMesh::calcBoundingBox( const Matrix44f &transform ) const
{
if( mVertices.empty() )
return AxisAlignedBox3f( Vec3f::zero(), Vec3f::zero() );
Vec3f min( transform.transformPointAffine( mVertices[0] ) );
Vec3f max( min );
for( size_t i = 0; i < mVertices.size(); ++i ) {
Vec3f v = transform.transformPointAffine( mVertices[i] );
if( v.x < min.x )
min.x = v.x;
else if( v.x > max.x )
max.x = v.x;
if( v.y < min.y )
min.y = v.y;
else if( v.y > max.y )
max.y = v.y;
if( v.z < min.z )
min.z = v.z;
else if( v.z > max.z )
max.z = v.z;
}
return AxisAlignedBox3f( min, max );
}
示例7: viewFrame
void Decompressor::viewFrame() {
skinningProg.bind();
skinningProg.uniform("worldProxyJoints", frames.first[currentFrame], MaxProxyJoints);
skinningProg.uniform("worldProxyJointsT", frames.second[currentFrame], MaxProxyJoints);
skinningProg.unbind();
#ifdef GPUDEBUG
std::vector<Vec3f> debugPosBuffer;
for (int i=0; i<debugPoints.size(); i++) {
if (currentFrame == 0) {
debugPosBuffer.push_back(debugPoints[i]);
} else {
Vec3f pos = debugPoints[i] * (1-debugpjws[i][0]-debugpjws[i][1]-debugpjws[i][2]-debugpjws[i][3]);
for (int j=0; j<4; j++) {
Matrix33f& pjm = frames.first[currentFrame][(int)(debugpjis[i][j])];
Vec3f& pjv = frames.second[currentFrame][(int)(debugpjis[i][j])];
Matrix44f mat;
mat.setColumn(0, Vec4f(pjm.at(0, 0), pjm.at(1, 0), pjm.at(2, 0), 0));
mat.setColumn(1, Vec4f(pjm.at(0, 1), pjm.at(1, 1), pjm.at(2, 1), 0));
mat.setColumn(2, Vec4f(pjm.at(0, 2), pjm.at(1, 2), pjm.at(2, 2), 0));
mat.setColumn(3, Vec4f(pjv.x, pjv.y, pjv.z, 0));
Vec3f temp = mat.transformVec(debugPoints[i]);
pos += temp * debugpjws[i][j];
}
debugPosBuffer.push_back(pos);
}
}
debugMesh->bufferPositions(debugPosBuffer);
#endif
}
示例8: getRoot
void UiLayer::update()
{
Vec2f interfaceSize = getRoot()->getInterfaceSize();
// check for orientation change
if( interfaceSize != mInterfaceSize ){
updateLayout( interfaceSize );
}
if ( !mHasPanelBeenDragged ) {
// if we're not dragging, animate to current state
if( mIsPanelOpen ){
mPanelY += (mPanelOpenY - mPanelY) * 0.25f;
}
else {
mPanelY += (mPanelClosedY - mPanelY) * 0.25f;
}
}
mChooserY += (mChooserDestY - mChooserY) * 0.25f;
mSettingsY += (mSettingsDestY - mSettingsY) * 0.25f;
mPlaylistChooser->setTransform( Matrix44f::createTranslation( Vec3f(0, mChooserY, 0) ) );
mAlphaChooser->setTransform( Matrix44f::createTranslation( Vec3f(0, mChooserY, 0) ) );
mSettingsPanel->setTransform( Matrix44f::createTranslation( Vec3f(0, mSettingsY, 0) ) );
// don't use mPanelOpenY or current height as a constraint here,
// use maximum value because we want things to ease closed
const float maxPanelY = mInterfaceSize.y - getMaxPanelHeight();
mPanelY = constrain( mPanelY, maxPanelY, mPanelClosedY );
Matrix44f transform;
transform.translate( Vec3f( 0, ceil( mPanelY ), 0 ) );
setTransform( transform );
}
示例9: Translate
void Camera::Translate(Vector3f aVector)
{
Matrix44f translationMatrix;
translationMatrix.SetPosition(aVector);
myTransformation = translationMatrix * myTransformation;
}
示例10: z
/** Get a reversed transformation matrix to be used for cameras
* @param matrix place to place matrix in
*/
void Position::getCameraTransformationMatrix(Matrix44f& matrix)
{
// z is reversed
Vector3f z(-forward.getX(), -forward.getY(), -forward.getZ());
// get x vector
Vector3f x;
x.crossProduct(up, z);
// matrix is transposed (rows instead of columns)
#define MAGIC3D_A(row,col) matrix.data[col*4+row]
MAGIC3D_A(0, 0) = x.data[0];
MAGIC3D_A(0, 1) = x.data[1];
MAGIC3D_A(0, 2) = x.data[2];
MAGIC3D_A(0, 3) = 0.0;
MAGIC3D_A(1, 0) = up.data[0];
MAGIC3D_A(1, 1) = up.data[1];
MAGIC3D_A(1, 2) = up.data[2];
MAGIC3D_A(1, 3) = 0.0;
MAGIC3D_A(2, 0) = z.data[0];
MAGIC3D_A(2, 1) = z.data[1];
MAGIC3D_A(2, 2) = z.data[2];
MAGIC3D_A(2, 3) = 0.0;
MAGIC3D_A(3, 0) = 0.0;
MAGIC3D_A(3, 1) = 0.0;
MAGIC3D_A(3, 2) = 0.0;
MAGIC3D_A(3, 3) = 1.0;
#undef MAGIC3D_A
// apply reversed translation
Matrix44f trans;
trans.createTranslationMatrix(-location.getX(), -location.getY(), -location.getZ());
matrix.multiply(trans);
}
示例11: Translate
void PointCloud::Translate(Vector3f aPosition)
{
Matrix44f translationMatrix;
translationMatrix.SetPosition(aPosition);
myOffset = translationMatrix;
}
示例12: getWindowBounds
// Render
void SkeletonApp::draw()
{
// Clear window
gl::setViewport( getWindowBounds() );
gl::clear( Colorf::gray( 0.1f ) );
// We're capturing
if ( mKinect->isCapturing() ) {
// Set up 3D view
gl::setMatrices( mCamera );
// Iterate through skeletons
uint32_t i = 0;
for ( vector<Skeleton>::const_iterator skeletonIt = mSkeletons.cbegin(); skeletonIt != mSkeletons.cend(); ++skeletonIt, i++ ) {
// Set color
Colorf color = mKinect->getUserColor( i );
// Iterate through joints
for ( Skeleton::const_iterator boneIt = skeletonIt->cbegin(); boneIt != skeletonIt->cend(); ++boneIt ) {
// Set user color
gl::color( color );
// Get position and rotation
const Bone& bone = boneIt->second;
Vec3f position = bone.getPosition();
Matrix44f transform = bone.getAbsoluteRotationMatrix();
Vec3f direction = transform.transformPoint( position ).normalized();
direction *= 0.05f;
position.z *= -1.0f;
// Draw bone
glLineWidth( 2.0f );
JointName startJoint = bone.getStartJoint();
if ( skeletonIt->find( startJoint ) != skeletonIt->end() ) {
Vec3f destination = skeletonIt->find( startJoint )->second.getPosition();
destination.z *= -1.0f;
gl::drawLine( position, destination );
}
// Draw joint
gl::drawSphere( position, 0.025f, 16 );
// Draw joint orientation
glLineWidth( 0.5f );
gl::color( ColorAf::white() );
gl::drawVector( position, position + direction, 0.05f, 0.01f );
}
}
}
}
示例13: ExtractFromOGLState
void Frustum::ExtractFromOGLState() {
Matrix44f modelview;
Matrix44f projection;
glGetFloatv(GL_MODELVIEW_MATRIX, modelview.get_ptr());
glGetFloatv(GL_PROJECTION_MATRIX, projection.get_ptr());
Extract(projection * modelview);
}
示例14: Matrix44f
// T(c) S R T(t) T(-c) => S R T(S^(-1) R^(-1)(c) + t - c)
Matrix44f Trackball::Matrix() const {
Matrix44f r;
track.rot.ToMatrix(r);
Matrix44f sr = Matrix44f().SetScale(track.sca, track.sca, track.sca) * r;
Matrix44f s_inv = Matrix44f().SetScale(1/track.sca, 1/track.sca, 1/track.sca);
Matrix44f t = Matrix44f().SetTranslate(s_inv*r.transpose()*center + track.tra - center);
return Matrix44f(sr*t);
}
示例15: lastname
void DecorateBackgroundPlugin::decorateDoc(QAction *a, MeshDocument &m, RichParameterSet * parset,GLArea *gla, QPainter *, GLLogStream &)
{
static QString lastname("unitialized");
switch(ID(a))
{
case DP_SHOW_CUBEMAPPED_ENV :
{
if(!cm.IsValid() || (lastname != cubemapFileName ) )
{
qDebug( "Current CubeMapPath Dir: %s ",qPrintable(cubemapFileName));
glewInit();
bool ret = cm.Load(qPrintable(cubemapFileName));
lastname=cubemapFileName;
if(! ret ) return;
//QMessageBox::warning(gla,"Cubemapped background decoration","Warning unable to load cube map images: " + cubemapFileName );
cm.radius=10;
}
if(!cm.IsValid()) return;
Matrix44f tr;
glGetv(GL_MODELVIEW_MATRIX,tr);
// Remove the translation from the current matrix by simply padding the last column of the matrix
tr.SetColumn(3,Point4f(0,0,0,1.0));
//Remove the scaling from the the current matrix by adding an inverse scaling matrix
float scale = 1.0/pow(tr.Determinant(),1.0f/3.0f);
Matrix44f Scale;
Scale.SetDiagonal(scale);
tr=tr*Scale;
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
cm.DrawEnvCube(tr);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
} break;
case DP_SHOW_GRID :
{
emit this->askViewerShot("me");
Box3f bb=m.bbox();
float scaleBB = parset->getFloat(BoxRatioParam());
float majorTick = parset->getFloat(GridMajorParam());
float minorTick = parset->getFloat(GridMinorParam());
bool gridSnap = parset->getBool(GridSnapParam());
bool backFlag = parset->getBool(GridBackParam());
bool shadowFlag = parset->getBool(ShowShadowParam());
Color4b backColor = parset->getColor4b(GridColorBackParam());
Color4b frontColor = parset->getColor4b(GridColorFrontParam());
bb.Offset((bb.max-bb.min)*(scaleBB-1.0));
DrawGriddedCube(*m.mm(),bb,majorTick,minorTick,gridSnap,backFlag,shadowFlag,backColor,frontColor,gla);
} break;
}
}