コード例 #1
0
void ScheinrieseApp::handleKinect()
{
    if (!hasKinect) {
        return;
    }

    if( mKinectTilt != mKinect.getTilt() ) {
        mKinect.setTilt( mKinectTilt );
    }

    if( mKinect.checkNewDepthFrame() ) {
        mDepthTexture = mKinect.getDepthImage();
    }

    if( mKinect.checkNewVideoFrame() ) {
        mColorTexture = mKinect.getVideoImage();
    }

    /* debug view */
    if (mColorTexture && !mDebugViewColor) {
        mGui->addLabel("COLOR");
        mDebugViewColor = mGui->addParam("COLOR", &mColorTexture);
        mDebugViewColor->var = &mColorTexture;
        console() << "color" << endl;
    }

    if (mDepthTexture && !mDebugViewDepth) {
        mGui->addLabel("DEPTH");
        mDebugViewDepth = mGui->addParam("DEPTH", &mDepthTexture);
        mDebugViewDepth->var = &mDepthTexture;
        console() << "depth" << endl;
    }
}
コード例 #2
0
void ScheinrieseApp::setup()
{
    // GUI
    mGui = new SimpleGUI(this);
    mGui->addColumn();
    mGui->addLabel("CONTROLS");
    mGui->addParam("Threshold", &mThreshold, 0, 255, 127);
    mGui->addParam("Blur", &mBlur, 1, 20, 1);
    mGui->addParam("Tilt", &mKinectTilt, -30, 30, 0);
    mGui->addColumn();
    mGui->addLabel("DEBUG VIEW");
    mGui->addParam("Show Debug", &mShowDebug, true);
//    mGui->addButton("Show Debug")->registerClick(this, &ScheinrieseApp::showDebug);

    mGui->load(getResourcePath(RES_SETTINGS));
    mGui->setEnabled(false);

    mBlur = 1;
    mThreshold = 127;

    mShowDebug = true;

    // KINECT
    hasKinect = false;
    console() << "### INFO: There are " << Kinect::getNumDevices() << " Kinects connected." << endl;
    if (Kinect::getNumDevices() >= 1) {
        mKinect = Kinect( Kinect::Device() );
        mKinect.setTilt(mKinectTilt);
        hasKinect = true;
    }
}
コード例 #3
0
ファイル: RogersGuiApp.cpp プロジェクト: muglikar/Cinder
void RogersGuiApp::keyDown( KeyEvent event ) {
	switch(event.getChar()) {				
		case 'd': gui->dump(); break; //prints values of all the controls to the console			
		case 'l': gui->load(CONFIG_FILE); break;
		case 's': gui->save(CONFIG_FILE); break;					
	}
	switch(event.getCode()) {
		case KeyEvent::KEY_ESCAPE: quit(); break;
	}
}
コード例 #4
0
void ButtonsAndTexturesApp::draw(){
    float currTime = timer.getSeconds();
	float deltaTime = currTime - prevTime;
	prevTime = currTime;
    
    rotation += deltaTime/2;
    
    gl::clear(ColorA(0.1, 0.1, 0.5, 0.92));
    gl::enableAdditiveBlending();
    gl::disableDepthRead();    
    gl::pushMatrices();
    gl::translate(Vec3f(getWindowWidth()/2, getWindowHeight()/2, 0));
    
    gl::color(ColorA(1, 0.2, 0.2, 0.1));    
    for(int i=0;i<50; i++) {
        gl::rotate(Vec3f(0, 0, rotation));
        gl::drawSolidRect(Rectf(20, 20, 140, 140));
    }
    
    gl::color(ColorA(0.5, 0.25, 0.0, 0.05));    
    for(int i=0;i<50; i++) {
        gl::rotate(Vec3f(0, 0, rotation/4));
        gl::drawSolidRect(Rectf(50, 50, 340, 340));
    }
    
    gl::enableDepthRead();    
    gl::disableAlphaBlending();
    gl::popMatrices();	
	gui->draw();
}
コード例 #5
0
ファイル: RogersGuiApp.cpp プロジェクト: muglikar/Cinder
void RogersGuiApp::draw(){
    float currTime = timer.getSeconds();
	float deltaTime = currTime - prevTime;
	prevTime = currTime;
    
	if (autoRotation)
		rotation += deltaTime/2;
    
    gl::clear( colorBack );
    gl::enableAdditiveBlending();
    gl::disableDepthRead();    
    gl::pushMatrices();
    gl::translate(Vec3f(getWindowWidth()/2, getWindowHeight()/2, 0));
    
    gl::color( color );    
    for(int i=0;i<50; i++) {
        gl::rotate(Vec3f(0, 0, rotation));
        gl::drawSolidRect(Rectf(20, 20, 140, 140));
    }
    
    gl::color(ColorA(0.5, 0.25, 0.0, 0.05));    
    for(int i=0;i<50; i++) {
        gl::rotate(Vec3f(0, 0, rotation/4));
        gl::drawSolidRect(Rectf(50, 50, 340, 340));
    }
    
    gl::enableDepthRead();    
    gl::disableAlphaBlending();
    gl::popMatrices();	
	
	FPS = getAverageFps();
	gui->draw();
	
	//std::cout << "LIST = " << listVal << std::endl;
}
コード例 #6
0
void ButtonsAndTexturesApp::setup() {
    rotation = 0;
    screenshot = gl::Texture(getWindowWidth(), getWindowHeight()); //uninitialized texture with random pixels from GPU memory
        
    gui = new SimpleGUI(this);
	gui->lightColor = ColorA(1, 1, 0, 1);		
	gui->addLabel("CONTROLS");
    
    //let's add a button
    gui->addButton("Restart")->registerClick(this, &ButtonsAndTexturesApp::restartButtonClick);
    
    gui->addSeparator();
    gui->addLabel("SCREENSHOT");
    
    screenshotTextureControl = gui->addParam("Screenshot", &screenshot);
    
    //you can also store reference to it and add callback as a second step
    takeScreenshotButton = gui->addButton("Take screenshot");    
	cbTakeScreenshotButtonClick = takeScreenshotButton->registerClick(this, &ButtonsAndTexturesApp::takeScreenshotButtonClick);    
    
    //to stop listening to click do this:
    //takeScreenshotButton->unregisterClick(cbTakeScreenshotButtonClick);
    
	gui->load(CONFIG_FILE); //we load settings after specifying all the 
    //params because we need to know their name and type
	
	timer.start();
	prevTime = timer.getSeconds();

}
コード例 #7
0
ファイル: Winmain.cpp プロジェクト: GameProject/Tower
void CALLBACK
	OnGUIEvent(int ID)
{
	switch(ID)
	{
	case PLACE_TOWER:
		gui.GetButton(PLACE_TOWER)->SetPressed(true);
		return;
	}

}
コード例 #8
0
void ScheinrieseApp::draw()
{
    gl::clear( Color( 0, 0, 0 ) );
    gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );
    glColor3f( 1.0f, 1.0f, 1.0f );

    /* debug view */
    drawDebug();

    //	glPushMatrix();
    //	for (int i = 0; i < mContours.size(); i++) {
    //		glColor3f(0.0f,1.0f,1.0f);
    //		glBegin( GL_LINE_STRIP );
    //		for (int j = 0; j < mContours[i].size(); j+=10) {
    //			glVertex2f( mContours[i][j].x, mContours[i][j].y);
    //		}
    //		glEnd();
    //	}
    //	glPopMatrix();

    /*
     //for (int i = 0; i < mContours.size(); i++) {
     //		vector<p2t::Point*> polyline;
     //		for (int j = 0; j < mContours[i].size(); j+=1) {
     //			polyline.push_back(new p2t::Point(mContours[i][j].x, mContours[i][j].y));
     //		}
     //		if (polyline.size() > 9) {
     //		cout << "Number of line points = " << polyline.size() << endl;
     //		CDT* cdt = new CDT(polyline);
     //		cdt->Triangulate();
     //		//vector<p2t::Triangle*> triangles = cdt->GetTriangles();
     //		//cout << "Number of triangles = " << triangles.size() << endl;
     //		}
     //	}

     gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );
     glPushMatrix();
     glTranslatef(200,200,0);
     GLdouble quad1[4*3] = { -100,300,0, 0,0,0, 100,300,0, 0,200,0 };
     tessellate(quad1, 12);
     glPopMatrix();

     for (int i = 0; i < mContours.size(); i++) {
     gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );
     glPushMatrix();
     for (int j = 0; j < mContours[i].size(); j+=1) {

     }
     glPopMatrix();
     }
     */
    // GUI
    mGui->draw();
}
コード例 #9
0
void GesichtertauschApp::keyDown( KeyEvent pEvent ) {
    switch(pEvent.getChar()) {				
        case 'd': mGui->dump(); break;
        case 'l': mGui->load(getResourcePath(RES_SETTINGS)); break;
        case 's': mGui->save(getResourcePath(RES_SETTINGS)); break;
//        case 'm':
//            CGDirectDisplayID mDisplayID = getSettings().getDisplay()->getCGDirectDisplayID();
//            CGDisplayConfigRef pConfigRef;
//            CGBeginDisplayConfiguration (&pConfigRef);
//            CGConfigureDisplayOrigin (pConfigRef,
//                                      mDisplayID,
//                                      -100, 0);
//            CGCompleteDisplayConfiguration (pConfigRef, kCGConfigureForAppOnly);
//            break;
    }
    switch(pEvent.getCode()) {
        case KeyEvent::KEY_ESCAPE:  setFullScreen( false ); quit(); break;
        case KeyEvent::KEY_SPACE: mGui->setEnabled(!mGui->isEnabled());break;
    }
}
コード例 #10
0
void RogalarmApp::keyDown( KeyEvent event )
{
	if( event.getChar() == 'f' ){
		mFullscreen = !mFullscreen; 
		setFullScreen(mFullscreen);
	} else if( event.getChar() == 'p' ){
		cout << "User Position = " << mUserPos << endl;
	} else if( event.getChar() == 'd' ){
		mGui->dump();
	} 
	
}
コード例 #11
0
void ScheinrieseApp::keyDown( KeyEvent event )
{
    switch(event.getChar()) {
    case 'd':
        mGui->dump();
        break;
    case 'l':
        mGui->load(getResourcePath(RES_SETTINGS));
        break;
    case 's':
        mGui->save(getResourcePath(RES_SETTINGS));
        break;
    }
    switch(event.getCode()) {
    case KeyEvent::KEY_ESCAPE:
        quit();
        break;
    case KeyEvent::KEY_SPACE:
        mGui->setEnabled(!mGui->isEnabled());
    }
}
コード例 #12
0
void GroupingApp::draw() {
	float currTime = timer.getSeconds();
	float deltaTime = currTime - prevTime;
	prevTime = currTime;
	
	if (autoRotation) {
		rotation += deltaTime * 60;
		rotation = fmod(rotation, 360);
	}
	
	fbo.bindFramebuffer();
	
	gl::pushMatrices();
	gl::clear(ColorA(0.2, 0.2, 0.2, 1.0));
	gl::translate(Vec2f(getWindowWidth()/2, getWindowHeight()/2));
	gl::rotate(rotation);
	gl::color(color);
	gl::enableAlphaBlending();
	gl::disableDepthRead();
	
	if (fill) {
		gl::translate(Vec2f(-50, -50));
		gl::drawSolidRect(Rectf(-size/2, -size/2, size/2, size/2));
		gl::translate(Vec2f(+100, +100));
		gl::drawSolidRect(Rectf(-size/2, -size/2, size/2, size/2));
	}
	else if (stroke) {
		glLineWidth(thickness);
		gl::translate(Vec2f(-50, -50));
		gl::drawLine(Vec2f(-size/2, -size/2), Vec2f( size/2, -size/2));
		gl::drawLine(Vec2f( size/2, -size/2), Vec2f( size/2,  size/2));
		gl::drawLine(Vec2f( size/2,  size/2), Vec2f(-size/2,  size/2));
		gl::drawLine(Vec2f(-size/2,  size/2), Vec2f(-size/2, -size/2));		
		gl::translate(Vec2f(+100, +100));
		gl::drawLine(Vec2f(-size/2, -size/2), Vec2f( size/2, -size/2));
		gl::drawLine(Vec2f( size/2, -size/2), Vec2f( size/2,  size/2));
		gl::drawLine(Vec2f( size/2,  size/2), Vec2f(-size/2,  size/2));
		gl::drawLine(Vec2f(-size/2,  size/2), Vec2f(-size/2, -size/2));
		glLineWidth(1);
	}
	gl::popMatrices();	
	
	fbo.unbindFramebuffer();
	
	gl::color(ColorA(1,1,1,1));
	gl::draw(fbo.getTexture());
	
	strokePanel->enabled = stroke ? true : false;
	gui->draw();
}
コード例 #13
0
ファイル: BasicApp.cpp プロジェクト: TheProduct/iopera
void BasicApp::draw() {
	float currTime = timer.getSeconds();
	float deltaTime = currTime - prevTime;
	prevTime = currTime;

	if (autoRotation) {
		rotation += deltaTime * 60;
		rotation = fmod(rotation, 360);
	}
	
	gl::pushMatrices();
	gl::clear(ColorA(0.0, 0.0, 0.0, 0.92));
	gl::translate(Vec2f(getWindowWidth()/2, getWindowHeight()/2));
	gl::rotate(rotation);
	gl::color(color);
	gl::enableAlphaBlending();
	gl::disableDepthRead();
	
	if (fill) {
		gl::translate(Vec2f(-50, -50));
		gl::drawSolidRect(Rectf(-size/2, -size/2, size/2, size/2));
		gl::translate(Vec2f(+100, +100));
		gl::drawSolidRect(Rectf(-size/2, -size/2, size/2, size/2));
	}
	else if (stroke) {
		gl::translate(Vec2f(-50, -50));
		gl::drawLine(Vec2f(-size/2, -size/2), Vec2f( size/2, -size/2));
		gl::drawLine(Vec2f( size/2, -size/2), Vec2f( size/2,  size/2));
		gl::drawLine(Vec2f( size/2,  size/2), Vec2f(-size/2,  size/2));
		gl::drawLine(Vec2f(-size/2,  size/2), Vec2f(-size/2, -size/2));		
		gl::translate(Vec2f(+100, +100));
		gl::drawLine(Vec2f(-size/2, -size/2), Vec2f( size/2, -size/2));
		gl::drawLine(Vec2f( size/2, -size/2), Vec2f( size/2,  size/2));
		gl::drawLine(Vec2f( size/2,  size/2), Vec2f(-size/2,  size/2));
		gl::drawLine(Vec2f(-size/2,  size/2), Vec2f(-size/2, -size/2));
	}
	gl::popMatrices();	
	gui->draw();
}
コード例 #14
0
void RogalarmApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
	gl::enableAlphaBlending();
	
	if (mKinectConected) {
        
		//Rectf centeredRect = Rectf( mDepthTexture.getBounds() ).getCenteredFit( getWindowBounds(), true );
		//gl::draw( mDepthTexture, centeredRect  );
		
		
		//gl::drawLine(Vec2f(mUserPos, 0), Vec2f(mUserPos, 640));
		gl::color (Color8u(255 ,255, 0));
		gl::drawSolidRect (Rectf(mUserPos-2, 0, mUserPos+2, 640) ,false);
        
		mGui->draw();
        
	}else {
		Rectf centeredRect2 = Rectf( mKonnect.getBounds() ).getCenteredFit( getWindowBounds(), true );
		gl::draw( mKonnect, centeredRect2  );
	}

}
コード例 #15
0
ファイル: Winmain.cpp プロジェクト: GameProject/Tower
bool InitWindowsApp(HINSTANCE instanceHandle, int show)
{
	//ShowCursor(0);

	// The first task to creating a window is to describe some of its 
	// characteristics by filling out a WNDCLASS structure.
	WNDCLASS wc;
	wc.style         = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc   = WndProc; 
	wc.cbClsExtra    = 0;
	wc.cbWndExtra    = 0;
	wc.hInstance     = instanceHandle;
	wc.hIcon         = LoadIcon(0, IDI_APPLICATION);
	wc.hCursor       = LoadCursor(0, IDC_CROSS);
	wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
	wc.lpszMenuName  = 0;
	wc.lpszClassName = L"BasicWndClass";

	// Next, we register this WNDCLASS instance with Windows so that we can 
	// create a window based on it.
	if(!RegisterClass(&wc)) 
	{
		MessageBox(0, L"RegisterClass FAILED", 0, 0);
		return false;
	}

	// With our WNDCLASS instance registered, we can create a window with the
	// CreateWindow function.  This function returns a handle to the window it
	// creates (an HWND).  If the creation failed, the handle will have the value
	// of zero.  A window handle is a way to refer to the window, which is internally
	// managed by Windows.  Many of the Win32 API functions that operate on windows
	// require an HWND so that they know what window to act on.

	RECT rc;
	rc.left = 0;
	rc.top = 0;
	rc.right = SCREEN_WIDTH;
	rc.bottom = SCREEN_HEIGHT;
	AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, false);

	g_Hwnd = CreateWindow(
		L"BasicWndClass",	 // Registered WNDCLASS instance to use.
		L"Gruppuppgift",	// window title
		WS_OVERLAPPEDWINDOW, // style flags
		CW_USEDEFAULT,		 // x-coordinate
		CW_USEDEFAULT,       // y-coordinate
		rc.right - rc.left,        // width
		rc.bottom - rc.top,       // height
		0,               // parent window
		0,               // menu handle
		instanceHandle,      // app instance
		0);              // extra creation parameters

	if(g_Hwnd == 0)
	{
		MessageBox(0, L"CreateWindow FAILED", 0, 0);
		return false;
	}

	// Even though we just created a window, it is not initially shown.  
	// Therefore, the final step is to show and update the window we just
	// created, which can be done with the following two function calls.
	// Observe that we pass the handle to the window we want to show and
	// update so that these functions know which window to show and update.

	ShowWindow(g_Hwnd, show);
	UpdateWindow(g_Hwnd);

	//________________________________

	// Fill out a DXGI_SWAP_CHAIN_DESC to describe our swap chain.
	DXGI_SWAP_CHAIN_DESC sd;
	sd.BufferDesc.Width  = SCREEN_WIDTH;
	sd.BufferDesc.Height = SCREEN_HEIGHT;
	sd.BufferDesc.RefreshRate.Numerator = 60;
	sd.BufferDesc.RefreshRate.Denominator = 1;
	sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;

	// No multisampling.
	sd.SampleDesc.Count   = 1;
	sd.SampleDesc.Quality = 0;

	sd.BufferUsage  = DXGI_USAGE_RENDER_TARGET_OUTPUT;
	sd.BufferCount  = 1;
	sd.OutputWindow = g_Hwnd;
	sd.Windowed     = true;
	sd.SwapEffect   = DXGI_SWAP_EFFECT_DISCARD;
	sd.Flags        = 0;

	D3D10CreateDeviceAndSwapChain(
		0,                 //default adapter
		D3D10_DRIVER_TYPE_HARDWARE,
		0,                 // no software device
		0, 
		D3D10_SDK_VERSION,
		&sd,
		&mSwapChain,
		&md3dDevice);

	ID3D10Texture2D* backBuffer;
	mSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&backBuffer);
	md3dDevice->CreateRenderTargetView(backBuffer, 0, &mRenderTargetView);
	backBuffer->Release();
	backBuffer = 0;

	
	// Create depth stencil texture
	D3D10_TEXTURE2D_DESC descDepth;
	ZeroMemory( &descDepth, sizeof(descDepth) );
	descDepth.Width = SCREEN_WIDTH;
	descDepth.Height = SCREEN_HEIGHT;
	descDepth.MipLevels = 1;
	descDepth.ArraySize = 1;
	descDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
	descDepth.SampleDesc.Count = 1;
	descDepth.SampleDesc.Quality = 0;
	descDepth.Usage = D3D10_USAGE_DEFAULT;
	descDepth.BindFlags = D3D10_BIND_DEPTH_STENCIL;
	descDepth.CPUAccessFlags = 0;
	descDepth.MiscFlags = 0;
	md3dDevice->CreateTexture2D( &descDepth, NULL, &mDepthStencil );

	// Create the depth stencil view
	D3D10_DEPTH_STENCIL_VIEW_DESC descDSV;
	ZeroMemory( &descDSV, sizeof(descDSV) );
	descDSV.Format = descDepth.Format;
	descDSV.ViewDimension = D3D10_DSV_DIMENSION_TEXTURE2D;
	descDSV.Texture2D.MipSlice = 0;

	// Bind the render target view and depth/stencil view to the pipeline.
	md3dDevice->CreateDepthStencilView( mDepthStencil, &descDSV, &mDepthStencilView );
	md3dDevice->OMSetRenderTargets( 1, &mRenderTargetView, mDepthStencilView );

	// Set the viewport transform.
	vp.TopLeftX = 0;
	vp.TopLeftY = 0;
	vp.Width    = SCREEN_WIDTH;
	vp.Height   = SCREEN_HEIGHT;
	vp.MinDepth = 0.0f;
	vp.MaxDepth = 1.0f;
	md3dDevice->RSSetViewports(1, &vp);
	//________________________________

	Effects::InitAll(md3dDevice);
	fxU.init(md3dDevice, Effects::MeshFX);

	Terrain::InitInfo tii;
	tii.CellSpacing = 1.0f;
	tii.HeightmapFilename = L"flat513.raw";
	tii.HeightOffset = -30.0f;
	tii.HeightScale = 0.2f;
	tii.NumCols = 513;
	tii.NumRows = 513;
	land.init(md3dDevice, tii);
	//mTerrain.init(md3dDevice, (std::string)"Textures/Terrain/HeightMap.raw", 0.35f, -50.0f, 0.1f, 512, 512);

	//Cube c;
	//c.init(md3dDevice, D3DXVECTOR3(2.0f, 2.0f, 2.0f), D3DXVECTOR3(-16.0f, land.getHeight(-16.0f, -16.0f)+1.0f, -16.0f));
	//mCubes.push_back(c);
	//nr.push_back(0);

	nrOfTowers.push_back(0);
	
	mCubes.resize(10);
	for(int i = 0; i < mCubes.size();i++)
	{
		mCubes[i].init(i, md3dDevice, D3DXVECTOR3(5.0f,5.0f,5.0f), D3DXVECTOR3(0.0f, land.getHeight(0.0f,0.0f), 0.0f), (i*0.50f+0.50f));
		nr.push_back(0);
	}
	pWave = new wave(1, 20, md3dDevice, &land);
	pWave->initMonsters();
	
	mPyramid.init(md3dDevice, D3DXVECTOR3(2.0f, 2.0f, 2.0f), D3DXVECTOR3(-16.0f, land.getHeight(-16.0f, -16.0f)+5.0f, -16.0f));
	mCylinder.init(md3dDevice, 1.0f, D3DXVECTOR3(-2.0f, land.getHeight(-2.0f, -8.0f)+1.0f, -8.0f));

	//GetCamera().setPosY(land.getHeight(GetCamera().getPos().x, GetCamera().getPos().z));
	GetCamera().setLens(0.30f*pi, (float)SCREEN_WIDTH/SCREEN_HEIGHT, 1.0f, 1000.0f);

	fire.init(md3dDevice, Effects::FireFX, L"Textures/Particle/flare0.dds", 500);
	fire.setEmitPos(D3DXVECTOR3(-2.0f, land.getHeight(-5.0f, 2.0f)+2.5f, -8.0f));

	rain.init(md3dDevice, Effects::RainFX, L"Textures/Particle/raindrop.gif", 1000);

	sky.init(md3dDevice, L"Textures/Terrain/grassenvmap1024.dds", 5000.0f);
	
	//Trees
	D3DXVECTOR3 treeCenters[6];

	float x = -20.0f;
	float z = 20.0f;
	treeCenters[0] = D3DXVECTOR3(x,land.getHeight(x,z) + 10.0f,z);

	x = -23.0f;
	z = 16.0f;
	treeCenters[1] = D3DXVECTOR3(x,land.getHeight(x,z) + 10.0f,z);

	x = -3.0f;
	z = 18.0f;
	treeCenters[2] = D3DXVECTOR3(x,land.getHeight(x,z) + 10.0f,z);

	x = 22.0f;
	z = 13.0f;
	treeCenters[3] = D3DXVECTOR3(x,land.getHeight(x,z) + 10.0f,z);

	x = 17.0f;
	z = -23.0f;
	treeCenters[4] = D3DXVECTOR3(x,land.getHeight(x,z) + 10.0f,z);

	x = 22.0f;
	z = -20.0f;
	treeCenters[5] = D3DXVECTOR3(x,land.getHeight(x,z) + 10.0f,z);
	mTrees.init(md3dDevice, treeCenters, 6, L"Textures/Wood/tree3.dds");

	//QuadTree
	qtc.init(md3dDevice, &land, GetCamera().proj(), GetCamera().view());

	//init GUI
	gui.Init(md3dDevice,SCREEN_WIDTH,SCREEN_HEIGHT);
	//set gui callback
	gui.SetCallback(OnGUIEvent);
	//adding a button
	gui.AddButton(PLACE_TOWER,L"test.png",10,10,100,100);

	GetTowerScript().Init("tower");

	return true;
}
コード例 #16
0
void GesichtertauschApp::draw() {
    
    glClearColor( 0, 0, 0, 1.0 );
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    
    if ( ! mCameraTexture ) {
        return;
    }
        
//    gl::setMatricesWindow( getWindowSize() ),
    gl::setMatricesWindow(WINDOW_WIDTH, WINDOW_HEIGHT);
    gl::enableAlphaBlending();
    glScalef(-1.0, 1.0, 1.0);
    glTranslatef(-WINDOW_WIDTH, 0, 0);
    
    /* shader */
    // TODO make this more opt'd
    if (ENABLE_SHADER) {
        mShader.bind();
        const int STEPS = 32;
        float mThresholds[STEPS];// = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0};
        for (int i=0; i < STEPS; ++i) {
            mThresholds[i] = float(i) / float(STEPS - 1);
        }
        mShader.uniform("thresholds", mThresholds, STEPS);   
        mShader.uniform( "tex0", 0 );
    }

    /* draw the webcam image */
    gl::color( BACKGROUND_IMAGE_COLOR );
    gl::draw( mCameraTexture, Rectf(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT) );
    mCameraTexture.disable();
    
    /* normalize texture coordinates */
    Vec2f mNormalizeScale = Vec2f(1.0 / float(WINDOW_WIDTH), 1.0 / float(WINDOW_HEIGHT));
    glMatrixMode(GL_TEXTURE);
    glPushMatrix();
    glScalef(mNormalizeScale.x, mNormalizeScale.y, 1.0);
    glMatrixMode(GL_MODELVIEW);
    
    /* draw orgiginal faces */
    if (mEntities.size() < 2) {
        gl::enableAlphaBlending();
        mCameraTexture.enableAndBind();
        for( vector<FaceEntity>::const_iterator mIter = mEntities.begin(); mIter != mEntities.end(); ++mIter ) {
            drawEntity(*mIter, FACE_COLOR_UNO);
        }    
        mCameraTexture.disable();
        gl::disableAlphaBlending();
    }
    
    /* HACK // swap faces */
    mCameraTexture.enableAndBind();
    if (mEntities.size() >= 2) {
        const FaceEntity A = mEntities[0];
        const FaceEntity B = mEntities[1];
        if (A.visible && B.visible) {
            FaceEntity mEntityA = FaceEntity();
            FaceEntity mEntityB = FaceEntity();
            
            mEntityA.border = B.border;
            mEntityB.border = A.border;
            mEntityA.slice = A.slice;
            mEntityB.slice = B.slice;
            mEntityA.visible = A.visible;
            mEntityB.visible = B.visible;
            mEntityA.ID = A.ID;
            mEntityB.ID = B.ID;
            
            drawEntity(mEntityA, FACE_COLOR_DUO);
            drawEntity(mEntityB, FACE_COLOR_DUO);
        }
    }

    /* restore texture coordinates */
    glMatrixMode(GL_TEXTURE);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);

    mCameraTexture.disable();

    /* shader */
    if (ENABLE_SHADER) {
        mShader.unbind();
    }

    /* mask */
    float MASK_LEFT_TOP = 1;
    float MASK_LEFT_BOTTOM = 1;
    float MASK_RIGHT_TOP = 1;
    float MASK_RIGHT_BOTTOM = 1;
    
    gl::color(0, 0, 0, 1);

    Path2d mPathLeft;
    mPathLeft.moveTo(0, 0);
    mPathLeft.lineTo(MASK_LEFT_TOP, 0);
    mPathLeft.lineTo(MASK_LEFT_BOTTOM, WINDOW_HEIGHT);
    mPathLeft.lineTo(0, WINDOW_HEIGHT);
    mPathLeft.close();    
    gl::drawSolid(mPathLeft);
    
    Path2d mPathRight;
    mPathRight.moveTo(WINDOW_WIDTH, 0);
    mPathRight.lineTo(WINDOW_WIDTH-MASK_RIGHT_TOP, 0);
    mPathRight.lineTo(WINDOW_WIDTH-MASK_RIGHT_BOTTOM, WINDOW_HEIGHT);
    mPathRight.lineTo(WINDOW_WIDTH, WINDOW_HEIGHT);
    mPathRight.close();    
    gl::drawSolid(mPathRight);

    /* draw entity IDs */
    const bool DRAW_ENTITY_ID = false;
    if (DRAW_ENTITY_ID) {
        for( vector<FaceEntity>::const_iterator mIter = mEntities.begin(); mIter != mEntities.end(); ++mIter ) {
            const FaceEntity mEntity = *mIter;
            std::stringstream mStr;
            mStr << mEntity.ID;
            gl::drawStringCentered(mStr.str(), mEntity.border.getCenter(), Color(1, 0, 0), mFont);
        }    
    }
        
    /* gooey */
    mGui->draw();
}
コード例 #17
0
void GesichtertauschApp::setup() {
    
    console() << "+++ Gesichtertausch (PID " << getpid() << ")." << endl;
    
    mTime = 0.0;
    mSerialID = 0;
    FACE_COLOR_UNO = ColorA(0, 1, 1, 1);
    FACE_COLOR_DUO = ColorA(1, 0, 0, 1);
    BACKGROUND_IMAGE_COLOR = ColorA(1, 1, 1, 1);
    
    /* watchdog */
    mWatchdogHost = "localhost";
	mWatchdogPort = 8080;
	mWatchdogSender.setup(mWatchdogHost, mWatchdogPort);
    mWatchdogCounter = 0.0;
    mWatchdogInterval = 2.5;
    
    /* shader */
    try {
		mShader = gl::GlslProg( loadResource( RES_PASSTHRU_VERT ), loadResource( RES_BLUR_FRAG ) );
	}
	catch( gl::GlslProgCompileExc &exc ) {
		console() << "Shader compile error: " << std::endl;
		console() << exc.what();
	}
	catch( ... ) {
		console() << "Unable to load shader" << std::endl;
	}
    
    /* settings */
    mGui = new SimpleGUI(this);
    mGui->addParam("WINDOW_WIDTH", &WINDOW_WIDTH, 0, 2048, 640);
    mGui->addParam("WINDOW_HEIGHT", &WINDOW_HEIGHT, 0, 2048, 480);
    mGui->addParam("CAMERA_WIDTH", &CAMERA_WIDTH, 0, 2048, 640);
    mGui->addParam("CAMERA_HEIGHT", &CAMERA_HEIGHT, 0, 2048, 480);
    mGui->addParam("DETECTION_WIDTH", &DETECTION_WIDTH, 0, 2048, 320);
    mGui->addParam("DETECTION_HEIGHT", &DETECTION_HEIGHT, 0, 2048, 240);
    mGui->addParam("FULLSCREEN", &FULLSCREEN, false, 0);
    mGui->addParam("TRACKING", &TRACKING, 0, 1, 0);
    //
    mGui->addParam("FRAME_RATE", &FRAME_RATE, 1, 120, 30);
    mGui->addParam("MIN_TRACKING_DISTANCE", &MIN_TRACKING_DISTANCE, 1, 100, 50);
    mGui->addParam("TIME_BEFOR_IDLE_DEATH", &TIME_BEFOR_IDLE_DEATH, 0, 10, 0.5);
    mGui->addParam("MIN_LIFETIME_TO_VIEW", &MIN_LIFETIME_TO_VIEW, 0, 10, 1.0);
    mGui->addParam("ENABLE_SHADER", &ENABLE_SHADER, 0, 1, 0);
    mGui->addParam("FACE_COLOR_UNO", &FACE_COLOR_UNO, ColorA(0, 1, 1, 1), SimpleGUI::RGB);
    mGui->addParam("FACE_COLOR_DUO", &FACE_COLOR_DUO, ColorA(1, 1, 1, 1), SimpleGUI::RGB);
    mGui->addParam("BACKGROUND_IMAGE_COLOR", &BACKGROUND_IMAGE_COLOR, ColorA(1, 1, 1, 1), SimpleGUI::RGB);
    mGui->addParam("FACE_BORDER_SCALE", &FACE_BORDER_SCALE, 0, 3, 0.7);
    mGui->addParam("FACE_FADE_BORDER_SCALE", &FACE_FADE_BORDER_SCALE, 1, 2, 1.4);
            
    /* clean up controller window */
    mGui->getControlByName("WINDOW_WIDTH")->active=false;
    mGui->getControlByName("WINDOW_HEIGHT")->active=false;
    mGui->getControlByName("CAMERA_WIDTH")->active=false;
    mGui->getControlByName("CAMERA_HEIGHT")->active=false;
    mGui->getControlByName("DETECTION_WIDTH")->active=false;
    mGui->getControlByName("DETECTION_HEIGHT")->active=false;
    mGui->getControlByName("FULLSCREEN")->active=false;
    mGui->getControlByName("TRACKING")->active=false;
    mGui->getControlByName("BACKGROUND_IMAGE_COLOR")->active=false;
    mGui->getControlByName("BACKGROUND_IMAGE_COLOR")->active=false;
    
    mGui->load(getResourcePath(RES_SETTINGS));
    mGui->setEnabled(false);
    
    setWindowSize( WINDOW_WIDTH, WINDOW_HEIGHT );
    setFullScreen( FULLSCREEN );
    if (FULLSCREEN) {
        hideCursor();
//        switch_resolution (WINDOW_WIDTH, WINDOW_HEIGHT, 60.0);
    }
    
    mFont = Font(loadResource("pf_tempesta_seven.ttf"), 8);

    /* setting up capture device */
    mCameraTexture = gl::Texture(CAMERA_WIDTH, CAMERA_HEIGHT);
    switch (TRACKING) {
        case 0:
            mFaceDetection = new FeatureDetectionCinder();
            break;
#ifdef COMPILE_CAPTURE_FIREFLY
        case 1:
            mFaceDetection = new FeatureDetectionFireFly();
            break;
#endif
#ifdef COMPILE_CAPTURE_OPENCV
        case 2:
            mFaceDetection = new FeatureDetectionOpenCV();
            break;
#endif
        default:
            console() << "### choosing default tracking method." << endl;
            mFaceDetection = new FeatureDetectionCinder();
            break;
    }

    mGui->addParam("DETECT_FLAGS",&(mFaceDetection->DETECT_FLAGS), CV_HAAR_DO_CANNY_PRUNING, CV_HAAR_DO_ROUGH_SEARCH, CV_HAAR_DO_CANNY_PRUNING);
    mGui->addParam("DETECT_SCALE_FACTOR",&(mFaceDetection->DETECT_SCALE_FACTOR), 1.1, 5, 1.2);
    mGui->addParam("DETECT_MIN_NEIGHBORS",&(mFaceDetection->DETECT_MIN_NEIGHBORS), 1, 20, 2);

    mGui->addParam("CAMERA_EXPOSURE", &(mFaceDetection->CAMERA_EXPOSURE), 0, 255, 20);
    mGui->addParam("CAMERA_SHUTTER", &(mFaceDetection->CAMERA_SHUTTER), 0, 255, 200);
    mGui->addParam("CAMERA_BRIGHTNESS", &(mFaceDetection->CAMERA_BRIGHTNESS), 0, 255, 166);
    mGui->addParam("CAMERA_GAIN", &(mFaceDetection->CAMERA_GAIN), 0, 255, 17);

    mGui->load(getResourcePath(RES_SETTINGS)); // HACK this is quite stupid, but we have a catch 22 here ...
    mFaceDetection->setup(CAMERA_WIDTH, 
                          CAMERA_HEIGHT, 
                          DETECTION_WIDTH, 
                          DETECTION_HEIGHT,
                          0);
    mGui->dump();
    
    mGui->addSeparator();
    mFaceOut = mGui->addLabel("");
    mFPSOut = mGui->addLabel("");
}
コード例 #18
0
ファイル: RogersGuiApp.cpp プロジェクト: muglikar/Cinder
void RogersGuiApp::setup() {
    rotation = 0;
    screenshot = gl::Texture(getWindowWidth(), getWindowHeight()); //uninitialized texture with random pixels from GPU memory
	IntVarControl *ic;
	BoolVarControl *bc;
	PanelControl *pc;
	ByteVarControl *btc;
	FlagVarControl *fc;
	aString = "whatever";
	
    gui = new SimpleGUI(this);
	gui->lightColor = ColorA(1, 1, 0, 1);
	gui->addColumn();
	gui->addLabel("> READ ONLY");
    gui->addSeparator();
	gui->addLabel("READONLY");
	gui->addParam("String", &aString);						// !NEW! Update aString will update label 
	gui->addParam("Window Width", &windowWidth, 0, 1920, getWindowWidth())->setReadOnly();		// !NEW! No slider, just value
	gui->addParam("Window Height", &windowHeight, 0, 1080, getWindowHeight())->setReadOnly();	// !NEW! No slider, just value
	gui->addParam("FPS", &FPS, 0, 60, 0)->setReadOnly();	// !NEW! No slider, just value
    gui->addSeparator();
    
	// Textures
	gui->addLabel("> TEXTURES");
    gui->addSeparator();
    takeScreenshotButton = gui->addButton("Take screenshot");    
	takeScreenshotButton->registerClick(this, &RogersGuiApp::takeScreenshotButtonClick);    
    screenshotTextureControl = gui->addParam("Screenshot", &screenshot);
	screenshotTextureControl->refreshRate = 0.0;		// !NEW! let's refresh manually
	//screenshotTextureControl->refreshRate = 0.1;		// !NEW! use this for movies or syphon
    //takeScreenshotButton->unregisterClick(cbTakeScreenshotButtonClick);
    gui->addSeparator();
    gui->addParam("Null Texture example", &nullTex);	// !NEW! Null textures will be marked so
	
    //
	// ROGER:: From Grouping example
	gui->addColumn();
	gui->addLabel("> CONTROLS");
    gui->addSeparator();
    gui->addButton("Restart Animation")->registerClick(this, &RogersGuiApp::restartButtonClick);
	bc = gui->addParam("Auto Rotation ON", &autoRotation, true);
	bc->nameOff = "Auto Rotation OFF";	// !NEW! Alternative label when OFF
	gui->addParam("Rotation", &rotation, 0, 360, 0)->setDisplayValue();
	gui->addParam("Size", &size, 100, 600, 200)->setDisplayValue();
	gui->addParam("Background", &colorBack, Color(0.1, 0.1, 0.5), SimpleGUI::RGB); //use R,G,B,A sliders
	gui->addParam("Color", &color, ColorA(1, 0.2, 0.2, 0.1), SimpleGUI::RGB); //use R,G,B,A sliders
	gui->addParam("HSV", &colorBackHSV, Color(0.1, 0.1, 0.5), SimpleGUI::HSV);
	gui->addParam("HSV+A", &colorHSV, ColorA(1, 0.2, 0.2, 0.1), SimpleGUI::HSV);
    gui->addSeparator();
	gui->addLabel("RENDER TYPE");
	gui->addParam("Fill", &fill, true, RENDER_TYPE_GROUP); //if we specify group id, we create radio button set
	bc = gui->addParam("Stroke", &stroke, false, RENDER_TYPE_GROUP); //i.e. only one of the buttons can be active at any time	
	pc = gui->addPanel();
	bc->switchPanel( pc );		// !NEW! Automatically open/close a panel
	gui->addParam("Thickness", &thickness, 1, 10);
	
	//
	// LIST CONTROL
	gui->addColumn();
	gui->addLabel("> LISTS");
    gui->addSeparator();
    gui->addButton("Increase List")->registerClick(this, &RogersGuiApp::addToList);
    gui->addButton("Decrease List")->registerClick(this, &RogersGuiApp::removeFromList);
	valueLabels[0] = "val 0";
	valueLabels[1] = "val 1";
	valueLabels[2] = "val 2";
    gui->addSeparator();
	theDropDownControl = gui->addParamDropDown("Drop-Down List", &listVal, valueLabels);	// !NEW! Drop-Down control
    gui->addSeparator();
	theListControl = gui->addParamList("Explicit List", &listVal, valueLabels);				// !NEW! List control
    gui->addSeparator();
    gui->addLabel("just a label");
	
	//
	// INTS CONTROL
	gui->addColumn();
	gui->addLabel("> INTS");
    gui->addSeparator();
	gui->addParam("Int Radio (<=10)", &intValue1, 1, 3, 0)->setDisplayValue();		// !NEW! small int range will be displayed as radios
	gui->addParam("Int Radio (<=10)", &intValue2, 1, 10, 0)->setDisplayValue();		// !NEW! small int range will be displayed as radios
	gui->addParam("Int slider (>10)", &intValue3, 1, 11, 0)->setDisplayValue();		// !NEW! Display the value beside labels
	// stepped
    gui->addSeparator();
	ic = gui->addParam("Int Step 2", &intValue4, 0, 10, 0);
	ic->setDisplayValue();
	ic->setStep(2);														// !NEW! int step
	ic = gui->addParam("Int Step 2", &intValue5, 0, 18, 0);
	ic->setDisplayValue();
	ic->setStep(2);														// !NEW! int step
	ic = gui->addParam("Int Step 2", &intValue6, 0, 20, 0);
	ic->setDisplayValue();
	ic->setStep(2);														// !NEW! int step
	
	//
	// BYTE CONTROL
	gui->addColumn();
	gui->addLabel("> BYTES");
    gui->addSeparator();
	gui->addParam("Byte", &byteValue1, 0)->setDisplayValue();			// !NEW! ranges from 0-255
	btc = gui->addParam("Byte as char", &byteValue2, 0);				// !NEW! display as char
	btc->setDisplayValue();
	btc->displayChar = true;
	btc = gui->addParam("Byte as hex", &byteValue3, 0);					// !NEW! display as hex
	btc->setDisplayValue();
	btc->displayHex = true;
	// FLAGS
    gui->addSeparator();
	fc = gui->addParamFlag("Byte Flag", &flagValue, 8, 0x55);			// !NEW! Byte Flag
	fc->setDisplayValue();
	fc->displayHex = true;
	
	
	gui->load(CONFIG_FILE); //we load settings after specifying all the 
    //params because we need to know their name and type
	
	timer.start();
	prevTime = timer.getSeconds();
	
}
コード例 #19
0
ファイル: Winmain.cpp プロジェクト: GameProject/Tower
LRESULT CALLBACK
WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	POINT mousePos;
	int dx = 0;
	int dy = 0;

	switch( msg )
	{
	case WM_LBUTTONDOWN:
		if( wParam & MK_LBUTTON )
		{
			SetCapture(hwnd);

			mOldMousePos.x = ( short )LOWORD(lParam);
			mOldMousePos.y = ( short )HIWORD(lParam);
			gui.UpdateMouse(mOldMousePos.x,mOldMousePos.y,true);
		}
		return 0;

	case WM_LBUTTONUP:
		ReleaseCapture();
		return 0;

	case WM_RBUTTONDOWN:
		if( wParam & MK_RBUTTON )
		{
			SetCapture(hwnd);

			mOldMousePos.x = ( short )LOWORD(lParam);
			mOldMousePos.y = ( short )HIWORD(lParam);
			POINT d;
			d.x = ( short )LOWORD(lParam);
			d.y = ( short )HIWORD(lParam);
			//qtc.TEST(vp, d, qtc.getBLS(), 5, md3dDevice);
			if(gui.GetButton(PLACE_TOWER)->GetPressed())
			{
				D3DXVECTOR3 res = qtc.PlaceATower(vp, d);
				if (res != D3DXVECTOR3(-99,-99,-99))
				{
					mTowers.push_back(Tower());
					mTowers.back().init(md3dDevice, D3DXVECTOR3(7.5f, 7.5f, 7.5f), res);
					newCube = true;
					nrOfTowers.resize(mTowers.size());
					currentTower = (int)nrOfTowers.size()-1;
					gui.GetButton(PLACE_TOWER)->SetPressed(false);
				}
			}
			//cam.setLens(0.30f*(gameTime.getDeltaTime()*20), (float)SCREEN_WIDTH/SCREEN_HEIGHT, 1.0f, 1000.0f);
		}
		return 0;

	case WM_RBUTTONUP:
		GetCamera().setLens(0.30f*pi, (float)SCREEN_WIDTH/SCREEN_HEIGHT, 1.0f, 1000.0f);
		ReleaseCapture();
		return 0;

	case WM_MOUSEMOVE:
		if( wParam & MK_LBUTTON || wParam & MK_RBUTTON )
		{
			mousePos.x = ( short )LOWORD(lParam);
			mousePos.y = ( short )HIWORD(lParam);

			dx = mousePos.x - mOldMousePos.x;
			dy = mousePos.y - mOldMousePos.y;

			GetCamera().rotateY( dx * 0.0087266f );
			GetCamera().pitch( dy * 0.0087266f );

			mOldMousePos = mousePos;
		}
		return 0;

	case WM_KEYDOWN:
		if(wParam == VK_CONTROL) GetCamera().crouch();
		if(wParam == VK_SPACE)	
		{
			if (!jumping)
				GetCamera().setJump(GetTime().getGameTime());
			jumping = true;
		}
		if (GetAsyncKeyState('F') & 0x8000)
		{
			if (funRot)
				funRot = false;
			else
				funRot = true;
		}
		if (GetAsyncKeyState('R') & 0x8000)
		{
			if (grid)
				grid = false;
			else
				grid = true;
		}
		if (GetAsyncKeyState('O') & 0x8000)
		{
			if(!newCube)
			{
				Tower c;
				mTowers.push_back(c);
				mTowers.back().init(md3dDevice, D3DXVECTOR3(1.0f, 1.0f, 1.0f), GetCamera().getPos());
				newCube = true;
				nrOfTowers.resize(mTowers.size());
				currentTower = (int)nrOfTowers.size()-1;
			}
			else
				newCube = false;
		}
		if (GetAsyncKeyState('Z') & 0x8000) 
		{
			if(newCube)
				nrOfTowers[currentTower] = 0;
			else
				nrOfTowers[0] = 0;
		}
		if (GetAsyncKeyState('X') & 0x8000)
		{
			if(newCube)
				nrOfTowers[currentTower] = 3;
			else
				nrOfTowers[0] = 3;
		}
		if (GetAsyncKeyState('C') & 0x8000)
		{
			if(newCube)
				nrOfTowers[currentTower] = 6;
			else
				nrOfTowers[0] = 6;
		}
		if (GetAsyncKeyState('Q') & 0x8000)
		{
			pWave->CalldmgCalc(1,10000,"Fire");
			pWave->CalldmgCalc(0,10000,"Fire");
		}
		return 0;

		// WM_DESTROY is sent when the window is being destroyed.
	case WM_DESTROY:
		DestroyWindow(g_Hwnd);
		PostQuitMessage(0);
		return 0;
	}
	return DefWindowProc(hwnd, msg, wParam, lParam);
}
コード例 #20
0
void GroupingApp::setup() {
	fbo = gl::Fbo(getWindowWidth(), getWindowHeight());
	
	gui = new SimpleGUI(this, Font(loadResource(RES_SGUI_FONT), 8));
	gui->lightColor = ColorA(1, 1, 0, 1);	
	gui->addColumn();
	gui->addLabel("CONTROLS");
	gui->addParam("Rotation", &rotation, 0, 360, 0);
	gui->addParam("Size", &size, 100, 600, 200); 	
	gui->addParam("Color", &color, ColorA(0,0.5,1,0.5), SimpleGUI::RGB); //use R,G,B,A sliders
	gui->addColumn();	
	gui->addLabel("RENDER TYPE");
	gui->addParam("Fill", &fill, true, RENDER_TYPE_GROUP); //if we specify group id, we create radio button set
	gui->addParam("Stroke", &stroke, false, RENDER_TYPE_GROUP); //i.e. only one of the buttons can be active at any time	
	strokePanel = gui->addPanel();
	gui->addParam("Thickness", &thickness, 1, 10);
	gui->addColumn();
	gui->addLabel("OPTIONS");
	gui->addParam("Auto Rotation", &autoRotation, false); 	
	gui->addColumn();
	gui->addLabel("PREVIEW");
	gui->addParam("PreviewTex", &fbo.getTexture()); 	
	
	gui->load(CONFIG_FILE); //we load settings after specifying all the 
	//params because we need to know their name and type
	
	timer.start();
	prevTime = timer.getSeconds();
	
	
}
コード例 #21
0
ファイル: BasicApp.cpp プロジェクト: TheProduct/iopera
void BasicApp::setup() {
	gui = new SimpleGUI(this);
	gui->lightColor = ColorA(1, 1, 0, 1);	
	gui->addLabel("CONTROLS");
	gui->addParam("Rotation", &rotation, 0, 360, 0);
	gui->addParam("Size", &size, 100, 600, 200); 	
	gui->addParam("Color", &color, ColorA(0,0.5,1,0.5), SimpleGUI::RGB); //use R,G,B,A sliders
	gui->addSeparator();
	gui->addLabel("OPTIONS");
	gui->addParam("Auto Rotation", &autoRotation, false); 
	gui->addSeparator();	
	gui->addLabel("RENDER TYPE");
	gui->addParam("Fill", &fill, true, RENDER_TYPE_GROUP); //if we specify group id, we create radio button set
	gui->addParam("Stroke", &stroke, false, RENDER_TYPE_GROUP); //i.e. only one of the buttons can be active at any time
	
	gui->load(CONFIG_FILE); //we load settings after specifying all the 
	                       //params because we need to know their name and type
	
	timer.start();
	prevTime = timer.getSeconds();
}
コード例 #22
0
void RogalarmApp::setup()
{
	mFullscreen = false;
	mUser		= false;
	mNoUserMessage    = false;
	setFullScreen(mFullscreen);
	mUserPos = 0;
	mDebug = false;	
	mKonnect = loadImage(loadResource("konnect-kinect.jpg") );
	
	try {
		mKinect = Kinect( Kinect::Device() );
		mKinectConected = true;
		
	} catch( ... ){
		mKinectConected = false;
	}
    
    
    mConfigPath = getResourcePath().c_str();
    mConfigPath += "settings.sgui.txt";
   
	
    
	mStopedTime = getElapsedSeconds();
	
	
	mTargetPosition = Vec3f::zero();
	
	mContourTexture = gl::Texture(getWindowWidth(), getWindowHeight());
	mDepthTexture = gl::Texture(getWindowWidth(), getWindowHeight());
	
	mGui = new SimpleGUI(this);
	mGui->lightColor = ColorA(1, 1, 0, 1);
	
	mGui->addLabel("CONTROLS");
	mGui->addParam("Depth Threshold", &mThreshold, 0, 255, 70);
	mGui->addParam("Min Contour Area", &mBlobMin, 10, 100, 30);
	mGui->addParam("Max Contour Area", &mBlobMax, 100, 500, 200);
	mGui->addSeparator();
	mGui->addParam("Reflection Top", &mReflectionTop, 0, 480, 0);
	mGui->addParam("Reflection Bottom", &mReflectionBottom, 0, 480, 0);
	mGui->addSeparator();
	mGui->addLabel("OPTIONS");
	mGui->addParam("Fullscreen (f)", &mFullscreen, false);
	mGui->addButton("Save Configuration")->registerClick(this, &RogalarmApp::openSaveConfigClick);
	mGui->addColumn(142, 7);
	mGui->addLabel("Contour Image");
	mGui->addParam("Contour Texture", &mContourTexture); 
	mGui->addLabel("Depth Image");
	mGui->addParam("Depth Texture", &mDepthTexture);
	
	mGui->load(mConfigPath);
	
	mHost = "10.0.1.137";
	mPort = 7110;
	mSender.setup(mHost, mPort);



}
コード例 #23
0
ファイル: Winmain.cpp プロジェクト: GameProject/Tower
void Render()
{
	md3dDevice->ClearRenderTargetView(mRenderTargetView, mClearColor);
	md3dDevice->ClearDepthStencilView(mDepthStencilView, D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, 1.0f, 0);
	md3dDevice->OMSetDepthStencilState(0, 0);

	md3dDevice->OMSetBlendState(0, blendFactor, 0xffffffff);

	//draw Trees
	mTrees.draw(GetCamera().getPos(), GetCamera().view()*GetCamera().proj());

	D3D10_TECHNIQUE_DESC techDesc;
	fxU.setRenderUtil(techDesc);

	for(UINT p = 0; p < techDesc.Passes; ++p)
	{
		//draw Cube
		pWave->render(fxU,p);

		//draw Cube "Tower"
		for (UINT i=0; i < mTowers.size(); ++i)
		{
			fxU.setMfx(GetCamera().wvp(mTowers.at(i).getWorld()), mTowers.at(i).getWorld(), 1, nrOfTowers[i]);
			fxU.ApplyPassByIndex(p);
			mTowers.at(i).Draw();
		}

		//draw Pyramid
		fxU.setMfx(GetCamera().wvp(mPyramid.getWorld()), mPyramid.getWorld(), 2, 3);
		fxU.ApplyPassByIndex(p);
		mPyramid.Draw();

		//draw Cylinder
		fxU.setMfx(GetCamera().wvp(mCylinder.getWorld()), mCylinder.getWorld(), 3, 6);
		fxU.ApplyPassByIndex(p);
		mCylinder.Draw();

		//draw Terrain
		//fxU.setMfx(GetCamera().wvp(mTerrain.getWorld()), mTerrain.getWorld(), 0, 9);
		//fxU.ApplyPassByIndex(p);
		//mTerrain.Draw();

		fxU.setMfx(GetCamera().wvp(land.getWorld()), land.getWorld(), 0, 9);
		fxU.ApplyPassByIndex(p);
		land.draw();
	}

	//draw gui
	gui.Render();

	//draw grid
	qtc.draw(GetCamera().view(), GetCamera().proj(), grid);

	//draw Sky
	sky.draw(GetCamera().view(), GetCamera().proj(), GetCamera().getPos(), mLight.lightType);

	//draw Fire
	fire.draw(GetCamera().view(), GetCamera().proj());
	
	md3dDevice->OMSetBlendState(0, blendFactor, 0xffffffff);
	
	//draw Rain
	rain.draw(GetCamera().view(), GetCamera().proj());
	
	mSwapChain->Present(0, 0);
}
コード例 #24
0
bool RogalarmApp::openSaveConfigClick( MouseEvent event ) {
	mGui->save(mConfigPath);
	return false;
}