Created
May 15, 2015 20:07
-
-
Save Craigson/773ca58b836d8c0378f4 to your computer and use it in GitHub Desktop.
perparesettings not working
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "cinder/app/App.h" | |
| #include "cinder/app/RendererGl.h" | |
| #include "cinder/gl/gl.h" | |
| #include "cinder/GeomIO.h" | |
| #include "cinder/ImageIo.h" | |
| #include "cinder/MayaCamUI.h" | |
| #include "cinder/Utilities.h" | |
| #include "cinder/Rand.h" | |
| #include <sstream> | |
| #include <list> | |
| #include "Resources.h" | |
| using namespace ci; | |
| using namespace ci::app; | |
| using namespace std; | |
| using std::vector; | |
| using namespace ci; | |
| using namespace ci::app; | |
| using namespace std; | |
| class DigitalFabricApp : public App { | |
| public: | |
| void setup() override; | |
| void update() override; | |
| void draw() override; | |
| void record(); | |
| void keyDown( KeyEvent event ) override; | |
| void mouseDown(MouseEvent event); | |
| void prepareSettings( Settings *settings ); | |
| // bool saveGif; | |
| // int mCurrentFrame; | |
| private: | |
| gl::VboMeshRef mVboMesh; | |
| gl::TextureRef mTexture; | |
| MayaCamUI mMayaCam; | |
| }; | |
| void DigitalFabricApp::prepareSettings( Settings *settings ) | |
| { | |
| settings->setWindowSize( 1280,720 ); | |
| settings->setFrameRate( 30.0f ); | |
| } | |
| void DigitalFabricApp::setup() | |
| { | |
| //SUBSTITUTE THE FOLLOWING BLOCK OF CODE WITH A 640X480 GRID THAT REPRESENTS THE RAW | |
| //DEPTH VALUES COMING FROM THE KINECT | |
| //----------------------------------------------------------------------- | |
| // create some geometry using a geom::Plane | |
| auto plane = geom::Plane().size( vec2( 20, 20 ) ).subdivisions( ivec2( 200, 50 ) ); | |
| // Specify two planar buffers - positions are dynamic because they will be modified | |
| // in the update() loop. Tex Coords are static since we don't need to update them. | |
| vector<gl::VboMesh::Layout> bufferLayout = { | |
| gl::VboMesh::Layout().usage( GL_DYNAMIC_DRAW ).attrib( geom::Attrib::POSITION, 3 ), | |
| //gl::VboMesh::Layout().usage( GL_STATIC_DRAW ).attrib( geom::Attrib::TEX_COORD_0, 2 ) | |
| }; | |
| mVboMesh = gl::VboMesh::create( plane, bufferLayout ); | |
| //------------------------------------------------------------------------ | |
| mMayaCam.connect( getWindow() ); | |
| // saveGif = false; | |
| // mCurrentFrame = 0; | |
| } | |
| void DigitalFabricApp::mouseDown( MouseEvent event ) | |
| { | |
| } | |
| void DigitalFabricApp::keyDown(KeyEvent event){ | |
| /* | |
| if (event.getChar() =='s' ) | |
| saveGif = true; | |
| */ | |
| } | |
| void DigitalFabricApp::update() | |
| { | |
| float offset = getElapsedSeconds() * 4.0f; | |
| //REPLACE THE FOLLOWING CODE BLOCK WITH THE UPDATED Z-POSITIONS THAT ARE EXTRACTED FROM | |
| //THE KINECT'S DATA. | |
| //-------------------------------------------------------------------------- | |
| auto mappedPosAttrib = mVboMesh->mapAttrib3f( geom::Attrib::POSITION, false ); | |
| for( int i = 0; i < mVboMesh->getNumVertices(); i++ ) { | |
| vec3 &pos = *mappedPosAttrib; | |
| mappedPosAttrib->y = sinf( pos.x * 1.1467f + offset ) * 0.323f + cosf( pos.z * 0.7325f + offset ) * 0.431f; | |
| ++mappedPosAttrib; | |
| } | |
| mappedPosAttrib.unmap(); | |
| //-------------------------------------------------------------------------- | |
| /* | |
| if (saveGif == true && mCurrentFrame % 4 == 0 && mCurrentFrame < 125){ | |
| writeImage( getDocumentsDirectory() / "cinder" / "gif" / "saveGifB_" / ( toString( mCurrentFrame ) + ".png" ), copyWindowSurface() ); | |
| } | |
| if (saveGif == true){ | |
| mCurrentFrame++; | |
| cout << mCurrentFrame << endl; | |
| } | |
| */ | |
| cout << getWindowWidth(); | |
| cout << " "; | |
| cout << getWindowHeight() << endl; | |
| } | |
| void DigitalFabricApp::draw() | |
| { | |
| gl::clear( Color( 0.15f, 0.15f, 0.15f ) ); | |
| gl::setMatrices( mMayaCam.getCamera() ); | |
| gl::draw( mVboMesh ); | |
| } | |
| CINDER_APP( DigitalFabricApp, RendererGl ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment