本文整理汇总了C++中Matrix44f::setToIdentity方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix44f::setToIdentity方法的具体用法?C++ Matrix44f::setToIdentity怎么用?C++ Matrix44f::setToIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix44f
的用法示例。
在下文中一共展示了Matrix44f::setToIdentity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void BloomingNeonApp::update()
{
mTransform.setToIdentity();
mTransform.rotate( Vec3f::xAxis(), sinf( (float) getElapsedSeconds() * 3.0f ) * 0.08f );
mTransform.rotate( Vec3f::yAxis(), (float) getElapsedSeconds() * 0.1f );
mTransform.rotate( Vec3f::zAxis(), sinf( (float) getElapsedSeconds() * 4.3f ) * 0.09f );
}
示例2: drawIntoRoomFbo
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:
btSoftBody* SoftBody::createSoftMesh( btSoftBodyWorldInfo &info, const TriMesh &mesh, const Vec3f &scale,
const Vec3f &position, const Quatf &rotation )
{
Matrix44f transform;
transform.setToIdentity();
transform.translate( position );
transform.rotate( rotation.v );
transform.translate( position * -1.0f );
transform.translate( position );
btScalar* positions = new btScalar[ mesh.getNumVertices() * 3 ];
size_t i = 0;
for ( vector<Vec3f>::const_iterator iter = mesh.getVertices().begin(); iter != mesh.getVertices().end(); ++iter, i += 3 ) {
Vec3f position = transform.transformPoint( *iter );
positions[ i + 0 ] = position.x;
positions[ i + 1 ] = position.y;
positions[ i + 2 ] = position.z;
}
int* indices = new int[ mesh.getIndices().size() ];
i = 0;
for ( vector<size_t>::const_iterator iter = mesh.getIndices().begin(); iter != mesh.getIndices().end(); ++iter, ++i ) {
indices[ i ] = (int)*iter;
}
btSoftBody* body = btSoftBodyHelpers::CreateFromTriMesh( info, positions, indices, mesh.getNumTriangles() );
//body->scale( toBulletVector3( scale ) );
delete [] indices;
delete [] positions;
return body;
}
示例4: setup
void BloomingNeonApp::setup()
{
// setup our scene Fbo
mFboScene = gl::Fbo(512, 512);
// setup our blur Fbo's, smaller ones will generate a bigger blur
mFboBlur1 = gl::Fbo(512/8, 512/8);
mFboBlur2 = gl::Fbo(512/8, 512/8);
// load and compile the shaders
try {
mShaderBlur = gl::GlslProg( loadAsset("blur_vert.glsl"), loadAsset("blur_frag.glsl"));
mShaderPhong = gl::GlslProg( loadAsset("phong_vert.glsl"), loadAsset("phong_frag.glsl"));
}
catch( const std::exception &e ) {
console() << e.what() << endl;
quit();
}
// setup the stuff to render our ducky
mTransform.setToIdentity();
gl::Texture::Format format;
format.enableMipmapping(true);
mTexture = gl::Texture( loadImage( loadAsset("ducky.png") ), format );
mMesh.read( loadAsset("ducky.msh") );
mCamera.setEyePoint( Vec3f(2.5f, 5.0f, 5.0f) );
mCamera.setCenterOfInterestPoint( Vec3f(0.0f, 2.0f, 0.0f) );
mCamera.setPerspective( 60.0f, getWindowAspectRatio(), 1.0f, 1000.0f );
}
示例5: drawIntoRoomFbo
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 );
}
示例6: setup
void FBOBasicApp::setup()
{
gl::Fbo::Format format;
// format.setSamples( 4 ); // uncomment this to enable 4x antialiasing
mFbo = gl::Fbo( FBO_WIDTH, FBO_HEIGHT, format );
gl::enableDepthRead();
gl::enableDepthWrite();
mTorusRotation.setToIdentity();
}
示例7: setup
void FBOMultipleTargetsApp::setup()
{
gl::Fbo::Format format;
format.setSamples( 4 ); // uncomment this to enable 4x antialiasing
format.enableColorBuffer( true, 2 ); // create an FBO with two color attachments
mFbo = gl::Fbo( FBO_WIDTH, FBO_HEIGHT, format );
mShaderMultipleOuts = gl::GlslProg( loadResource( RES_SHADER_VERT ), loadResource( RES_SHADER_FRAG ) );
gl::enableDepthRead();
gl::enableDepthWrite();
mTorusRotation.setToIdentity();
}
示例8: setup
void MeshViewApp::setup()
{
loadConfig("configs/gaztank.ini");
setupCamera();
// Create lights
m_light1 = new gl::Light(gl::Light::DIRECTIONAL, 0);
m_light1->setDirection(Vec3f(0, 0, 1).normalized());
m_light1->setAmbient(Color(0.0f, 0.0f, 0.1f));
m_light1->setDiffuse(Color(0.9f, 0.6f, 0.3f));
m_light1->setSpecular(Color(0.9f, 0.6f, 0.3f));
m_light2 = new gl::Light(gl::Light::DIRECTIONAL, 1);
m_light2->setDirection(Vec3f(0, 0, -1).normalized());
m_light2->setAmbient(Color(0.0f, 0.0f, 0.0f));
m_light2->setDiffuse(Color(0.2f, 0.6f, 1.0f));
m_light2->setSpecular(Color(0.2f, 0.2f, 0.2f));
// Setup matrix
m_matrix.setToIdentity();
m_matrix.translate(Vec3f::zero());
m_matrix.rotate(Vec3f::zero());
m_matrix.scale(Vec3f::one());
m_rotateMesh = false;
// Create a parameter window
m_params = params::InterfaceGl::create(getWindow(), "Properties", Vec2i(180, 240));
m_params->addText("LMB + drag - rotate");
m_params->addText("RMB + drag - zoom");
m_params->addSeparator();
m_params->addButton("Full screen", [&] { setFullScreen(!isFullScreen()); });
m_params->addParam("Auto rotate", &m_rotateMesh);
m_params->addSeparator();
m_params->addParam("Diffuse", &m_diffuseEnabled);
m_params->addParam("Normal", &m_normalEnabled);
m_params->addParam("Specular", &m_specularEnabled);
m_params->addParam("AO", &m_aoEnabled);
m_params->addParam("Emissive", &m_emissiveEnabled);
m_params->addSeparator();
m_params->addParam("Gamma", &m_gamma, "min=0.0 max=10.0 step=0.1");
m_time = (float)getElapsedSeconds();
}
示例9: debugDrawIndices
void Diver::debugDrawIndices(const CameraOrtho &camera){
static const float fontScale = 0.005f;
Vec3f v;
Vec3f w;
Vec3f u;
camera.getBillboardVectors(&w, &u);
v = w.cross(u);
const static Vec2f zero;
const gl::TextureFontRef& sharedTextureFont = SharedTextureFont::Get();
float fontDescent = sharedTextureFont->getDescent();
Matrix44f mat;
Matrix44f rot = Matrix44f::createRotationOnb(u,w,v);
rot*= Matrix44f::createRotation(Vec3f::zAxis(), M_PI_2);
rot*= Matrix44f::createScale(Vec3f(fontScale,fontScale,fontScale));
gl::enableAlphaTest();
gl::enableAlphaBlending();
glColor3f(1,1,1);
int i = -1;
while(++i < mPoints.size()){
mat.setToIdentity();
mat *= Matrix44f::createTranslation(mPoints[i]);
mat *= rot;
string stringTexCoord = toString(mTexcoords[i]);
Vec2f stringSize = sharedTextureFont->measureString(stringTexCoord);
glPushMatrix();
glMultMatrixf(&mat[0]);
glColor4f(0,0,0,0.75f);
gl::drawSolidRect(Rectf(0,fontDescent,stringSize.x, stringSize.y * -1+fontDescent));
glColor3f(1,1,1);
sharedTextureFont->drawString(stringTexCoord, zero);
glPopMatrix();
}
gl::disableAlphaBlending();
gl::disableAlphaTest();
}
示例10: setup
void BloomingNeonApp::setup()
{
gl::Fbo::Format fmt;
fmt.setSamples(8);
fmt.setCoverageSamples(8);
// setup our scene Fbo
mFboScene = gl::Fbo(SCENE_SIZE, SCENE_SIZE, fmt);
// setup our blur Fbo's, smaller ones will generate a bigger blur
mFboBlur1 = gl::Fbo(BLUR_SIZE, BLUR_SIZE);
mFboBlur2 = gl::Fbo(BLUR_SIZE, BLUR_SIZE);
// load and compile the shaders
try {
mShaderBlur = gl::GlslProg( loadAsset("blur_vert.glsl"), loadAsset("blur_frag.glsl"));
mShaderPhong = gl::GlslProg( loadAsset("phong_vert.glsl"), loadAsset("phong_frag.glsl"));
}
catch( const std::exception &e ) {
console() << e.what() << endl;
quit();
}
// setup the stuff to render our ducky
mTransform.setToIdentity();
// model and textures generously provided by AngryFly:
// http://www.turbosquid.com/3d-models/free-3ds-mode-space/588767
mMesh.read( loadAsset("space_frigate.msh") );
mTextureIllumination = gl::Texture( loadImage( loadAsset("space_frigate_illumination.jpg") ) );
mTextureColor = gl::Texture( loadImage( loadAsset("space_frigate_color.jpg") ) );
mTextureSpecular = gl::Texture( loadImage( loadAsset("space_frigate_specular.jpg") ) );
//
mCamera.setEyePoint( Vec3f(0.0f, 8.0f, 25.0f) );
mCamera.setCenterOfInterestPoint( Vec3f(0.0f, -1.0f, 0.0f) );
mCamera.setPerspective( 60.0f, getWindowAspectRatio(), 1.0f, 1000.0f );
}
示例11: toBulletTransform
btSoftBody* SoftBody::createSoftHull( btSoftBodyWorldInfo &info, const TriMesh &mesh, const Vec3f &scale,
const Vec3f &position, const Quatf &rotation )
{
Matrix44f transform;
transform.setToIdentity();
transform.translate( position );
transform.rotate( rotation.v );
transform.translate( position * -1.0f );
transform.translate( position );
btVector3* positions = new btVector3[ mesh.getNumVertices() ];
size_t i = 0;
for ( vector<Vec3f>::const_iterator iter = mesh.getVertices().begin(); iter != mesh.getVertices().end(); ++iter, ++i ) {
positions[ i ] = toBulletVector3( *iter );
}
btSoftBody* body = btSoftBodyHelpers::CreateFromConvexHull( info, positions, mesh.getNumIndices(), false );
body->transform( toBulletTransform( transform ) );
body->scale( toBulletVector3( scale ) );
delete [] positions;
return body;
}
示例12: createSoftCloth
btSoftBody* SoftBody::createSoftCloth( btSoftBodyWorldInfo &info, const Vec2f &size, const Vec2i &resolution,
int32_t corners, const Vec3f &position, const Quatf &rotation )
{
Matrix44f transform;
transform.setToIdentity();
transform.translate( position );
transform.rotate( rotation.v );
transform.translate( position * -1.0f );
transform.translate( position );
float h = size.y * 0.5f;
float w = size.x * 0.5f;
btSoftBody* body = btSoftBodyHelpers::CreatePatch(
info,
toBulletVector3( transform.transformPoint( Vec3f( -w, 0.0f, -h ) ) ),
toBulletVector3( transform.transformPoint( Vec3f( w, 0.0f, -h ) ) ),
toBulletVector3( transform.transformPoint( Vec3f( -w, 0.0f, h ) ) ),
toBulletVector3( transform.transformPoint( Vec3f( w, 0.0f, h ) ) ),
resolution.x, resolution.y,
corners, true
);
return body;
}
示例13: update
void BloomingNeonApp::update()
{
mTransform.setToIdentity();
mTransform.rotate( Vec3f::yAxis(), (float) getElapsedSeconds() * 0.2f );
}
示例14: createCube
TriMesh MeshHelper::createCube( const Vec3i &resolution )
{
vector<uint32_t> indices;
vector<Vec3f> normals;
vector<Vec3f> positions;
vector<Vec2f> texCoords;
ci::TriMesh front = createSquare( Vec2i( resolution.x, resolution.y ) );
ci::TriMesh left = createSquare( Vec2i( resolution.z, resolution.y ) );
ci::TriMesh top = createSquare( Vec2i( resolution.x, resolution.z ) );
Vec3f normal;
Vec3f offset;
Matrix44f transform;
// Back
normal = Vec3f( 0.0f, 0.0f, -1.0f );
offset = normal * 0.5f;
transform.setToIdentity();
transform.translate( offset );
for ( vector<Vec3f>::iterator iter = front.getVertices().begin(); iter != front.getVertices().end(); ++iter ) {
positions.push_back( transform.transformPoint( *iter ) );
normals.push_back( normal );
}
for ( vector<Vec2f>::iterator iter = front.getTexCoords().begin(); iter != front.getTexCoords().end(); ++iter ) {
texCoords.push_back( *iter );
}
// Bottom
normal = Vec3f( 0.0f, -1.0f, 0.0f );
offset = normal * 0.5f;
transform.setToIdentity();
transform.translate( offset );
transform.rotate( Vec3f( -(float)M_PI * 0.5f, 0.0f, 0.0f ) );
transform.translate( offset * -1.0f );
transform.translate( offset );
for ( vector<Vec3f>::iterator iter = top.getVertices().begin(); iter != top.getVertices().end(); ++iter ) {
positions.push_back( transform.transformPoint( *iter ) );
normals.push_back( normal );
}
for ( vector<Vec2f>::iterator iter = top.getTexCoords().begin(); iter != top.getTexCoords().end(); ++iter ) {
texCoords.push_back( *iter );
}
normal = Vec3f( 0.0f, 0.0f, 1.0f );
offset = normal * 0.5f;
transform.setToIdentity();
transform.translate( offset );
for ( vector<Vec3f>::iterator iter = front.getVertices().begin(); iter != front.getVertices().end(); ++iter ) {
positions.push_back( transform.transformPoint( *iter ) );
normals.push_back( normal );
}
for ( vector<Vec2f>::iterator iter = front.getTexCoords().begin(); iter != front.getTexCoords().end(); ++iter ) {
texCoords.push_back( *iter );
}
normal = Vec3f( -1.0f, 0.0f, 0.0f );
offset = normal * 0.5f;
transform.setToIdentity();
transform.translate( offset );
transform.rotate( Vec3f( 0.0f, -(float)M_PI * 0.5f, 0.0f ) );
transform.translate( offset * -1.0f );
transform.translate( offset );
for ( vector<Vec3f>::iterator iter = left.getVertices().begin(); iter != left.getVertices().end(); ++iter ) {
positions.push_back( transform.transformPoint( *iter ) );
normals.push_back( normal );
}
for ( vector<Vec2f>::iterator iter = left.getTexCoords().begin(); iter != left.getTexCoords().end(); ++iter ) {
texCoords.push_back( *iter );
}
// Right
normal = Vec3f( 1.0f, 0.0f, 0.0f );
offset = normal * 0.5f;
transform.setToIdentity();
transform.translate( offset );
transform.rotate( Vec3f( 0.0f, (float)M_PI * 0.5f, 0.0f ) );
transform.translate( offset * -1.0f );
transform.translate( offset );
for ( vector<Vec3f>::iterator iter = left.getVertices().begin(); iter != left.getVertices().end(); ++iter ) {
positions.push_back( transform.transformPoint( *iter ) );
normals.push_back( normal );
}
for ( vector<Vec2f>::iterator iter = left.getTexCoords().begin(); iter != left.getTexCoords().end(); ++iter ) {
texCoords.push_back( *iter );
}
normal = Vec3f( 0.0f, 1.0f, 0.0f );
offset = normal * 0.5f;
transform.setToIdentity();
transform.translate( offset );
transform.rotate( Vec3f( (float)M_PI * 0.5f, 0.0f, 0.0f ) );
transform.translate( offset * -1.0f );
transform.translate( offset );
for ( vector<Vec3f>::iterator iter = top.getVertices().begin(); iter != top.getVertices().end(); ++iter ) {
positions.push_back( transform.transformPoint( *iter ) );
normals.push_back( normal );
}
for ( vector<Vec2f>::iterator iter = top.getTexCoords().begin(); iter != top.getTexCoords().end(); ++iter ) {
texCoords.push_back( *iter );
//.........这里部分代码省略.........
示例15: setup
void TextTestApp::setup()
{
hideBackground = false;
activeUserPresent = false;
// SET UP BLUR STUFF
// setup our scene Fbo
mFboScene = gl::Fbo( getWindowWidth(), getWindowHeight() );
// setup our blur Fbo's, smaller ones will generate a bigger blur
mFboBlur1 = gl::Fbo(getWindowWidth()/8, getWindowHeight()/8);
mFboBlur2 = gl::Fbo(getWindowWidth()/8, getWindowHeight()/8);
OutlineParams::getInstance()->init();
// load and compile the shaders
try {
mShaderBlur = gl::GlslProg(
loadFile("../shaders/blur_vert.glsl"),
loadFile("../shaders/blur_frag.glsl"));
} catch(...) {
console() << "Can't load/compile blur shader" << endl;
quit();
}
try {
mShaderPhong = gl::GlslProg(
loadFile("../shaders/phong_vert.glsl"),
loadFile("../shaders/phong_frag.glsl"));
} catch(...) {
console() << "Can't load/compile phong shader" << endl;
quit();
}
mTransform.setToIdentity();
gestureTracker = GestureTracker::getInstance();
gl::Texture::Format format;
format.enableMipmapping(true);
mCamera.setEyePoint( Vec3f(2.5f, 5.0f, 5.0f) );
mCamera.setCenterOfInterestPoint( Vec3f(0.0f, 2.0f, 0.0f) );
mCamera.setPerspective( 60.0f, getWindowAspectRatio(), 1.0f, 1000.0f );
for (int i=0; i<40; i++)
{
CinderClip cinderClip = CinderClip();
cinderClip.x = -200;
cinderClip.y = -200;
repelClips.push_back(cinderClip);
////
// TweenParticle userParticle = TweenParticle(cinderClip.x, cinderClip.y,10,true);
//userParticles.push_back(userParticle);
}
mbackground.setup();
mbackground.setRepelClips( repelClips ); // I KNOW THEY ON SCREEN
//load store config
cinder::XmlTree configXml(ci::app::loadAsset( "shopconfig.xml" ) );
ShopConfig::getInstance()->parseConfig(configXml);
ci::gl::Texture bubbleManWaveTexture = cinder::loadImage(ci::app::loadResource(BUBBLEMAN_WAVE));
mBubbleManWave = new SpriteSheet();
mBubbleManWave->init(bubbleManWaveTexture, "./spritesheetdata/bubbleman_wave.xml", SpriteSheet::FORMAT_TEXTUREPACKER_GENERIC_XML);
ci::gl::Texture bubbleManRunTexture = cinder::loadImage(ci::app::loadResource(BUBBLEMAN_RUN));
mBubbleManRun = new SpriteSheet();
mBubbleManRun->init(bubbleManRunTexture, "./spritesheetdata/bubbleman_run.xml", SpriteSheet::FORMAT_TEXTUREPACKER_GENERIC_XML);
TextureGlobals::getInstance()->setSpriteSheet(mBubbleManRun,TextureGlobals::SPRITE_BUBBLEMAN_RUN);
TextureGlobals::getInstance()->setSpriteSheet(mBubbleManWave,TextureGlobals::SPRITE_BUBBLEMAN_WAVE);
gl::Texture particleTexture0 = loadImage(loadAsset( "ParticleFullON.png" ) );
TextureGlobals::getInstance()->setParticleTexture(particleTexture0,0);
gl::Texture particleTexture1 = loadImage(loadAsset( "ParticlePatial01.png" ) );
TextureGlobals::getInstance()->setParticleTexture(particleTexture1,1);
gl::Texture particleTexture2 = loadImage(loadAsset( "ParticlePatial02.png" ) );
TextureGlobals::getInstance()->setParticleTexture(particleTexture2,2);
gl::Texture particleTexture3 = loadImage(loadAsset( "ParticlePatial03.png" ) );
TextureGlobals::getInstance()->setParticleTexture(particleTexture3,3);
gl::Texture particleTexture4 = loadImage(loadAsset( "ParticlePatial04.png" ) );
TextureGlobals::getInstance()->setParticleTexture(particleTexture4,4);
gl::Texture particleTexture5 = loadImage(loadAsset( "ParticlePatial05.png" ) );
TextureGlobals::getInstance()->setParticleTexture(particleTexture5,5);
gl::Texture particleTexture6 = loadImage(loadAsset( "background-particle.png" ) );
TextureGlobals::getInstance()->setParticleTexture(particleTexture6,6);
gl::Texture particleTexture7 = loadImage(loadAsset( "ParticleFullONYellow.png" ) );
TextureGlobals::getInstance()->setParticleTexture(particleTexture6,7);
//.........这里部分代码省略.........