Example #1
0
static void glkeyboard(unsigned char key, int x, int y) {
	sv->cam.wasdKeyboard(key);
	hud->fixLCS();

	switch (key) {
	case 'r':
		resetScene();
		break;
	case 'q':
		exit(0);
		break;
    case 'f':
		((LitScene&)(sv->scene)).fog = !(((LitScene&)(sv->scene)).fog);
		break;
    case 'l':
		LightManager::toggleGlobalLighting();
		break;
	case 0x1b:
		sv->cam.uncaptureMouse();
		break;
	case '1':
		sv->scene.setAllSolid(false);
		break;
	case '2':
		sv->scene.setAllSolid(true);
		break;
	}

	glutPostRedisplay();
}
Example #2
0
void DrawWidget::initializeGL()
{
    renderer.initGL(width(), height(), false);
    resizeGL(width(), height());
    initPipeline();
    resetScene();
}
Example #3
0
void TutorialUnit::resetSetup(bool randomize)
{
    srand(QDateTime::currentDateTime().toTime_t());
    QMutexLocker lock(&mMutex);
    QMutexLocker waitLock(&mWaitMutex);
    mOffset = QPointF(0, 0);
    mScaling = 1.0;
    emit resetScene(randomize);
    mWait.wait(&mWaitMutex, 1000);
    mWait.wait(&mWaitMutex, 500);
}
Example #4
0
/*  ===============================================
      Desc: Callbacks for the scene
      Precondition:
      Postcondition:
    =============================================== */ 
void pointer_cb( GLUI_Control* control )
{
  if (control->get_id() == ACTION_ID ) {
  	std::cout << "And Action!" << std::endl;
  	startTheScene=true;
  	time(&start);
  }
  else if(control->get_id() == CUT_ID){
  	startTheScene=false;
  	resetScene();
  }
}
Example #5
0
bool InclinedPlaneExample::keyboardCallback(int key, int state) {
//	b3Printf("Key pressed: %d in state %d \n",key,state);

	switch (key) {
	case 32 /*ASCII for space*/: {
		resetScene();
		break;
	}
	}

	return false;
}
Example #6
0
void FeatureDemo::loadModel(const std::string& filename, bool showProgressBar)
{
    Mesh::resetGlobalIdCounter();
    resetScene();
    ProgressBar::SharedPtr pBar;
    if (showProgressBar)
    {
        pBar = ProgressBar::create("Loading Model");
    }
    Model::SharedPtr pModel = Model::createFromFile(filename.c_str());
    if (!pModel) return;
    Scene::SharedPtr pScene = Scene::create();
    pScene->addModelInstance(pModel, "instance");

    initScene(pScene);
}
Example #7
0
void AmbulanceC::reset(void){

digitalWrite(o_StatusLED,HIGH);

initializeTimers();

resetScene();

resetAl();

resetSrn();

resetInterrupts();

digitalWrite(o_StatusLED,LOW);
}
Example #8
0
void FeatureDemo::loadScene(const std::string& filename, bool showProgressBar)
{
    Mesh::resetGlobalIdCounter();
    resetScene();
    ProgressBar::SharedPtr pBar;
    if (showProgressBar)
    {
        pBar = ProgressBar::create("Loading Scene", 100);
    }
    Scene::SharedPtr pScene = Scene::loadFromFile(filename);

    if (pScene != nullptr)
    {
        initScene(pScene);
        applyCustomSceneVars(pScene.get(), filename);
    }
}
Example #9
0
	Scene::~Scene()
	{
		resetScene();
	}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    auto closeItem = MenuItemImage::create(
                                           "CloseNormal.png",
                                           "CloseSelected.png",
                                           CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
    
    closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
                                origin.y + closeItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    auto menu = Menu::create(closeItem, NULL);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu, 1);

    /////////////////////////////
    //// 3. add your codes below...

    //// add a label shows "Hello World"
    //// create and initialize a label
    //
    //auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 24);
    //
    //// position the label on the center of the screen
    //label->setPosition(Vec2(origin.x + visibleSize.width/2,
    //                        origin.y + visibleSize.height - label->getContentSize().height));

    //// add the label as a child to this layer
    //this->addChild(label, 1);

    //// add "HelloWorld" splash screen"
    //auto sprite = Sprite::create("HelloWorld.png");

    //// position the sprite on the center of the screen
    //sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

    //// add the sprite as a child to this layer
    //this->addChild(sprite, 0);
    
    _elementContainer = Layer::create();
    this->addChild(_elementContainer);
    _drawNode = DrawNode3D::create();
    _drawNode->setCameraMask((unsigned short)CameraFlag::USER1);
    this->addChild(_drawNode);
    resetScene();
    setCamera();
    setHandleEvent();
    return true;
}
Example #11
0
/*  ===============================================
      Desc: 
      Precondition:
      Postcondition:
    =============================================== */ 
void myGlutDisplay(void)
{
	static float scale = 0.1;
	// Set our background color that the screen refreshes too
	glClearColor(0.1f, 0.1f, 0.2f, 1.0f);
	// Which bit planes get cleared
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	// Set up
	glMatrixMode(GL_MODELVIEW);
	// Give us a default matrix to start our scene from
	glLoadIdentity();

	//glScalef(scale,scale,scale);
	if(startTheScene==false){
		glTranslatef( view_pos[0], view_pos[1]-2, -view_pos[2]-6 );
	}
	/* Perform camera transformations 
	   Each camera funtion will be called after
	   a certain amount of time has elapsed.
	
		You are free to implement your own camera functions!
		*** Be Creative! ***
	
	*/
	if(startTheScene==true){
		// Output the time to the console, just a a director would have time
		// running on the camera.
		cout << difftime(time(NULL),start) << "s : ";
		if(difftime(time(NULL),start) <= 2){
			std::cout << "orthogonal" << endl;
			camera1->orthogonal(-1,1,-1,1,1,10);	// Get a unit perspective from above
		}
		else if(difftime(time(NULL),start) > 2 && difftime(time(NULL),start) <= 6){
			std::cout << "Close Up" << endl;
			// Close up shot on the T-Rex
			camera1->closeUp(trex->getXPosition(), trex->getYPosition(),trex->getZPosition(),
							1,10);	
		}
		else if(difftime(time(NULL),start) > 6 && difftime(time(NULL),start) <= 10){
			std::cout << "follow cam" << endl;
			//camera1->perspective(105,.75,1,10);	// Get the regular perspective
			camera1->follow(jeep->getXPosition(), jeep->getYPosition(),jeep->getZPosition(),
				0, 0, 0,
				0, 0, 0); // attach the camera to the t-rex
		}
		else if(difftime(time(NULL),start) > 10 && difftime(time(NULL),start) <= 14){
			std::cout << "spin cam" << endl;
			// Spin around a point in space.
			// Radius is fixed, but could be adjusted.
			// Y height may also need to be adjusted.
			camera1->spinAroundPoint(jeep->getXPosition(),jeep->getYPosition()-2,jeep->getZPosition(),2);
		}
		else{
			startTheScene=false;
			resetScene();
		}
	}


	glMultMatrixf(view_rotate);

		if (filled) {
			glEnable(GL_POLYGON_OFFSET_FILL);
			glColor3f(0.5, 0.5, 0.5);
			glPolygonMode(GL_FRONT, GL_FILL);
			startScene();
		}
		// Set our scene to a wireframe mode.
		if (wireframe) {
			glDisable(GL_POLYGON_OFFSET_FILL);
			glColor3f(1.0, 1.0, 1.0);
			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
			startScene();
		}

		if(grid){
			draw_grid();
		}


	glutSwapBuffers();
}