Beispiel #1
0
//--------------------------------------------------------------
void testApp::setup()
{
	mSession = PXCUPipeline_Init((PXCUPipeline)(PXCU_PIPELINE_GESTURE|PXCU_PIPELINE_COLOR_VGA));
	if(!mSession)
		return;

	if(PXCUPipeline_QueryLabelMapSize(mSession, &mlw, &mlh))
	{
		mLabelMap = new unsigned char[mlw*mlh];
		mLabelTex = ofTexture();
		mLabelTex.allocate(mlw,mlh,GL_LUMINANCE);
	}
	if(PXCUPipeline_QueryRGBSize(mSession, &mcw, &mch))
	{
		mRgbMap = new unsigned char[mcw*mch*4];
		mRgbTex = ofTexture();
		mRgbTex.allocate(mcw,mch,GL_RGBA);
	}
	ofSetWindowShape(mcw*2,mch);
	mDraw = false;
}
//--------------------------------------------------------------
void testApp::setup()
{
	ofSetWindowShape(640*2,800);
	ofSetBackgroundColor(0);
	ofSetLogLevel(OF_LOG_NOTICE);
	ofSetVerticalSync(true);
	glEnable(GL_DEPTH_TEST);
	ofEnableLighting();
	light.enable();
	pathLines.setMode(OF_PRIMITIVE_LINE_STRIP);

	camFixed = false;
	//PXC
	mSession = PXCUPipeline_Create();

	
	if(!PXCUPipeline_Init(mSession, (PXCUPipeline)(PXCU_PIPELINE_COLOR_VGA|PXCU_PIPELINE_DEPTH_QVGA|PXCU_PIPELINE_GESTURE)))
	{
		ofLogNotice() << "Unable to initialize session" << endl;
		return;
	}

	if(PXCUPipeline_QueryRGBSize(mSession, &mCW, &mCH))
	{

		mRGBMap = new unsigned char[mCW*mCH*4];
		mRGBTexture.allocate(mCW,mCH,GL_RGBA);
	}
	if(PXCUPipeline_QueryLabelMapSize(mSession, &mLW, &mLH))
	{
		mLabelMap = new unsigned char[mLW*mLH];
		mLabelTexture.allocate(mLW,mLH,GL_LUMINANCE);
	}
	if(PXCUPipeline_QueryDepthMapSize(mSession, &mLW, &mLH))
	{
		mDepthBuffer = new short[mLW*mLH];
		mDepthMap = new unsigned char[mLW*mLH];
		mDepthTexture.allocate(mLW,mLH,GL_LUMINANCE);
	}
	if(PXCUPipeline_QueryIRMapSize(mSession, &mLW, &mLH))
	{
		mIRBuffer = new short[mLW*mLH];
		mIRMap = new unsigned char[mLW*mLH];
		mIRTexture.allocate(mLW,mLH,GL_LUMINANCE);
	}

	//cam
	cam.resetTransform();
	cam.setFov(60);
	cam.clearParent();
	cam.setPosition(0, 10, 120);
	cam.setParent(hero);
	camSwith = false;
	frc.set(0,0,0);
	//node 
	float freqMult = 1;
	float amp = 30;	
	float scale = 1;
	hero_Pos.set(0,0,0);
	hero.setPosition(ofVec3f(sin(ofGetElapsedTimef() * freqMult) * amp, cos(ofGetElapsedTimef() * freqMult) * amp, sin(ofGetElapsedTimef() * freqMult * 0.7) * amp));
	hero.setOrientation(ofPoint(0,0,0));
	hero.setScale(scale);
	foc.set(0,0,0);

	for (int i = 0; i < 600; i ++)
	{
		freqMult = ofRandom(0.5,2);
		amp = ofRandom(10,30);	
		scale = ofRandom(1,15);
		ofNode temNode;
		temNode.setPosition(ofRandom(-1000,1000),ofRandom(-1000,1000),ofRandom(-50000,0));
		temNode.setOrientation(ofVec3f(sin(ofGetElapsedTimef() * freqMult * 0.2) * amp * 5, cos(ofGetElapsedTimef() * freqMult * 0.2) * amp * 5, sin(ofGetElapsedTimef() * freqMult * 0.2 * 0.7) * amp * 5));
		temNode.setScale(scale);
		nodes.push_back(temNode);
	}
}