Ejemplo n.º 1
0
//Draw
void OsgMainApp::draw(){
    //Every load o remove has to be done before any drawing

	//LOGI ("OsgMainApp::draw 1");
    loadModels();
    deleteModels();



    if(_trans)
    {
    	static double angle = 0;
        _trans->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(angle),1,0,0) *
         osg::Matrix::scale(_lodScale, _lodScale, _lodScale) *
         osg::Matrix::translate(_xTrans * _xFactor, 0,  -_yTrans * _xFactor)
        );



        angle += 0.3;

		LOGI ("angle = %f, _xFactor = %f", angle, _xFactor);
    }
//
//    // 创建矩阵,指定到视点的距离。
//    osg::Matrix trans;
//    trans.makeTranslate( 0., 0., -12. );



    _viewer->frame();
}
Ejemplo n.º 2
0
void initVideoData(void) {
    int i;

    gScreen = (Visual*) malloc(sizeof(Visual));
    gViewportType = getSettingi("display_type");

    {
        Visual *d = gScreen;
        d->w = getSettingi("width");
        d->h = getSettingi("height");
        d->vp_x = 0;
        d->vp_y = 0;
        d->vp_w = d->w;
        d->vp_h = d->h;
        d->onScreen = -1;
        d->textures = (unsigned int*) malloc(game_textures * sizeof(unsigned int));
    }

    gPlayerVisuals = (PlayerVisual*) malloc(MAX_PLAYERS * sizeof(PlayerVisual));

    loadModels();

    for(i = 0; i < eHUDElementCount; i++)
    {
        gpHUD[i] = NULL;
    }

    changeDisplay(-1);
}
Ejemplo n.º 3
0
//Draw
void OsgMainApp::draw(){
    //Every load o remove has to be done before any drawing
    loadModels();
    deleteModels();

    _viewer->frame();
}
Ejemplo n.º 4
0
Game::Game(IrrlichtDevice *d, CEvent* r) : device(d), reciever(r)
{
	driver = device->getVideoDriver();
	smgr = device->getSceneManager();
	guienv = device->getGUIEnvironment();
	loadFont();
	loadModels();
}
Ejemplo n.º 5
0
// ShowWait
void dWMShop_c::beginState_ShowWait() {
	MapSoundPlayer(SoundRelatedClass, SE_SYS_DIALOGUE_IN, 1);

	layout.disableAllAnimations();
	layout.enableNonLoopAnim(SHOW_ALL);
	visible = true;
	scaleEase = 0.0;

	loadInfo();
	loadModels();
}
Ejemplo n.º 6
0
void load(const std::string& name) {
    double brighten = 2.0;

    std::string dir = std::string(DATA_DIR + "quake2/players/") + name + "/";

    loadModels(dir);
    model.name = toUpper(name.substr(0, 1)) + name.substr(1, name.length() - 1);

    modelTexture.clear();
    weaponTexture = NULL;
    loadSkins(dir, brighten);
}
Ejemplo n.º 7
0
int main(int argc, char** argv){
	globalEngine = new Engine();
	globalCamera = new Camera();
	
	initGLUT(&argc, argv);
	initGLEW();
	loadModels();
	
	initOpenGL();
	glutMainLoop();
	return 0;
}
Ejemplo n.º 8
0
void Area::load(const Common::UString &resRef) {
	_resRef = resRef;

	loadLYT(); // Room layout
	loadVIS(); // Room visibilities

	loadModels(); // Room models
	loadVisibles();   // Room model visibilities

	Aurora::GFFFile are(_resRef, Aurora::kFileTypeARE, MKTAG('A', 'R', 'E', ' '));
	loadARE(are.getTopLevel());

	Aurora::GFFFile git(_resRef, Aurora::kFileTypeGIT, MKTAG('G', 'I', 'T', ' '));
	loadGIT(git.getTopLevel());

	_loaded = true;
}
Ejemplo n.º 9
0
bool World::init() {
    if (!Layer::init()) {
        return false;
    }

    _debugMode = false;

    _visibleSize = Director::getInstance()->getVisibleSize();
    _origin = Director::getInstance()->getVisibleOrigin();
    _canvasCenter = Vec2(_visibleSize / 2.f) + _origin;

    loadModels();

    _currentState = IDLE;

    _prefs = UserDefault::getInstance();
    _audioEngine = CocosDenshion::SimpleAudioEngine::getInstance();

    _backgroundSprite = Sprite::create("textures/background.png");
    _backgroundSprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
    _backgroundSprite->setPosition(Vec2(0.f, -80.f));
    addChild(_backgroundSprite);

    _planet = Planet::create();
    addChild(_planet);

    setState(MAIN_MENU);

    auto muted = _prefs->getBoolForKey("muted");
    _audioEngine->playBackgroundMusic("audio/ambient.mp3", true);

    if (!muted) {
        _audioEngine->setBackgroundMusicVolume(0.6f);
    } else {
        _audioEngine->setBackgroundMusicVolume(0.f);
        _audioEngine->setEffectsVolume(0.f);
    }

    // creating a keyboard event listener
    auto listener = EventListenerKeyboard::create();
    listener->onKeyReleased = CC_CALLBACK_2(World::onKeyReleased, this);

    _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);

    return true;
}
Ejemplo n.º 10
0
int main (int argc, char** argv){

  // Initialize ROS
  ros::init (argc, argv, "object_recognition_module");
  ros::NodeHandle nh;

  // Create a ROS subscriber for the input point cloud
  ros::Subscriber sub = nh.subscribe<sensor_msgs::PointCloud2> ("input", 1, cloud_cb);

  //Create the DB of trained ObjectModels (CAD)
  loadModels("/home/valerio/catkin_ws/src/obj_recognition/model");
  exit(0);

  // Create a ROS publisher for the output point cloud
  pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 1);

  // Spin
  ros::spin ();
}
Ejemplo n.º 11
0
/* Affichage de l'application */
void HomeCreator3D::show()
{
    // QFile file(".qglviewer.xml");
    // file.remove();

    window.show();
    loadTextures();
    loadModels();
    maison->addTexture(&textures["moquette1.jpg"], FLOOR_NAME);

    //GLViewer v(NULL);
    //v.show();
    //v.resize(1024, 800);

    QDesktopWidget *widget = QApplication::desktop();

    int x = widget->width() / 2 - window.width() / 2;
    int y = widget->height() / 2 - window.height() / 2 - 25;

    window.move(QPoint(x, y));
}
Ejemplo n.º 12
0
void Area::show() {
	if (_visible)
		return;

	loadModels();

	GfxMan.lockFrame();

	// Show area geometry model
	if (_model)
		_model->show();

	// Show objects
	for (ObjectList::iterator o = _objects.begin(); o != _objects.end(); ++o)
		(*o)->show();

	GfxMan.unlockFrame();

	playAmbientMusic();

	_visible = true;
}
Ejemplo n.º 13
0
// TODO move this function to the constructor ? 
void Scene::loadSceneFromFile(const char* filename){
	XMLDocument doc;
	doc.LoadFile(filename);

    // Check for errors in the XML
    if (doc.ErrorID() != 0)
    {
        doc.PrintError();
    }

    XMLElement *music = doc.FirstChildElement("scene");
    pathMusic = music->FirstChildElement("music")->GetText();

    XMLElement *end = doc.FirstChildElement("scene");
    if(end->FirstChildElement("end")) this->end = atoi(end->FirstChildElement("end")->GetText());
    else this->end = 0;

	loadModels(doc);
	loadDialogues(doc);
	loadLights(doc);
	loadRoom(doc);
}
Ejemplo n.º 14
0
void Scene::initializeGL()
{
    initializeGLFunctions();

    glClearColor( 0, 0, 0, 0 );
    glShadeModel( GL_SMOOTH );
    glEnable( GL_DEPTH_TEST );

    GLfloat lightAmbient[4]; lightAmbient[0] = 0.5f;  lightAmbient[1] = 0.5f;  lightAmbient[2] = 0.5f;  lightAmbient[3] = 1.0f;
    GLfloat lightDiffuse[4]; lightDiffuse[0] = 1.0f;  lightDiffuse[1] = 1.0f;  lightDiffuse[2] = 1.0f;  lightDiffuse[3] = 1.0f;
    GLfloat lightPosition[4];lightPosition[0]= 0.0f;  lightPosition[1]= 0.0f;  lightPosition[2]= 2.0f;  lightPosition[3]= 1.0f;

    glLightfv( GL_LIGHT1, GL_AMBIENT, lightAmbient );  glLightfv( GL_LIGHT1, GL_DIFFUSE, lightDiffuse );
    glLightfv( GL_LIGHT1, GL_POSITION,lightPosition ); glEnable( GL_LIGHT1 );

    textures->append( new Texture( "CameraTexture" ) );
    loadTextures();
    emit message( "Texturas cargadas" );
    loadModels();
    emit message( "Modelos cargadas" );
    loadVideos();
    emit message( "Videos cargados" );
}
Ejemplo n.º 15
0
void Area::show() {
	if (_visible)
		return;

	loadModels();

	GfxMan.lockFrame();

	// Show tiles
	for (std::vector<Tile>::iterator t = _tiles.begin(); t != _tiles.end(); ++t)
		t->model->show();

	// Show objects
	for (ObjectList::iterator o = _objects.begin(); o != _objects.end(); ++o)
		(*o)->show();

	GfxMan.unlockFrame();

	// Play music and sound
	playAmbientSound();
	playAmbientMusic();

	_visible = true;
}
Ejemplo n.º 16
0
// Loading stuff
void Graphics::loadGraphicsData(std::string directory){
	loadShaders(directory + "Shaders/");
	loadModels(directory + "Models/");
	loadSkyBoxes(directory + "SkyBoxes/");
	loadPlane();
}
Ejemplo n.º 17
0
void ModelPlotter::keyPressed(int key)
{	
	if(key == 'r') 
	{
		_recordMode = !_recordMode;
		
		if (!_recordMode) 
		{
			App::getInstance()->flagPageModelsChanged();
		}
	}
	else if(key == 'L')
	{
		loadModels();
	}
	else if(key == 'S')
	{
		saveModels();
	}
	
	if(_recordMode)
	{
		// delete
		if(key == 127)
		{
			deleteSelectedModel();
		}
		// right arrow
		else if (key == 358) 
		{
			if(_selectedModel != DISABLED && _selectedPoint != DISABLED)
			{
				App::getInstance()->getPageModelByIndex(_selectedModel)->pts[_selectedPoint].x += 1;
			}
		}
		// left arrow
		else if (key == 356) 
		{
			if(_selectedModel != DISABLED && _selectedPoint != DISABLED)
			{
				App::getInstance()->getPageModelByIndex(_selectedModel)->pts[_selectedPoint].x -= 1;
			}
		}
		// up arrow
		else if (key == 357) 
		{
			if(_selectedModel != DISABLED && _selectedPoint != DISABLED)
			{
				App::getInstance()->getPageModelByIndex(_selectedModel)->pts[_selectedPoint].y -= 1;
			}
		}
		// down arrow
		else if (key == 359) 
		{
			if(_selectedModel != DISABLED && _selectedPoint != DISABLED)
			{
				App::getInstance()->getPageModelByIndex(_selectedModel)->pts[_selectedPoint].y += 1;
			}
		}
		// d
		else if (key == 'd') 
		{
			if(_selectedModel != DISABLED)
			{
				moveModel(true, +1);
			}
		}
		// a
		else if (key == 'a') 
		{
			if(_selectedModel != DISABLED)
			{
				moveModel(true, -1);
			}
		}
		// w
		else if (key == 'w') 
		{
			if(_selectedModel != DISABLED)
			{
				moveModel(false, -1);
			}
		}
		// s
		else if (key == 's') 
		{
			if(_selectedModel != DISABLED)
			{
				moveModel(false, +1);
			}
		}
	}
}
Ejemplo n.º 18
0
void TORecognize::onNewImage()
{
	CLOG(LTRACE) << "onNewImage";
	try {


		// Change keypoint detector and descriptor extractor types (if required).
		setKeypointDetector();

		setDescriptorExtractor();

		// Re-load the model - extract features from model.
		loadModels();

		std::vector<KeyPoint> scene_keypoints;
		cv::Mat scene_descriptors;
		std::vector< DMatch > matches;

		// Clear vectors! ;)
		recognized_names.clear();
		recognized_centers.clear();
		recognized_corners.clear();
		recognized_scores.clear();


		// Load image containing the scene.
		cv::Mat scene_img = in_img.read();



		// Extract features from scene.
		extractFeatures(scene_img, scene_keypoints, scene_descriptors);
		CLOG(LINFO) << "Scene features: " << scene_keypoints.size();

		// Check model.
		for (unsigned int m=0; m < models_imgs.size(); m++) {
			CLOG(LDEBUG) << "Trying to recognize model (" << m <<"): " << models_names[m];

			if ((models_keypoints[m]).size() == 0) {
				CLOG(LWARNING) << "Model not valid. Please load model that contain texture";
				return;
			}//: if

			CLOG(LDEBUG) << "Model features: " << models_keypoints[m].size();

			// Change matcher type (if required).
			setDescriptorMatcher();

			// Find matches.
			matcher->match( models_descriptors[m], scene_descriptors, matches );

			CLOG(LDEBUG) << "Matches found: " << matches.size();

			if (m == prop_returned_model_number) {
				// Draw all found matches.
				Mat img_matches1;
				drawMatches( models_imgs[m], models_keypoints[m], scene_img, scene_keypoints,
					     matches, img_matches1, Scalar::all(-1), Scalar::all(-1),
					     vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
				out_img_all_correspondences.write(img_matches1);
			}//: if


			// Filtering.
			double max_dist = 0;
			double min_dist = 100;

			//-- Quick calculation of max and min distances between keypoints
			for( int i = 0; i < matches.size(); i++ ) {
				double dist = matches[i].distance;
				if( dist < min_dist ) min_dist = dist;
				if( dist > max_dist ) max_dist = dist;
			}//: for

			CLOG(LDEBUG) << "Max dist : " << max_dist;
			CLOG(LDEBUG) << "Min dist : " << min_dist;

			//-- Draw only "good" matches (i.e. whose distance is less than 3*min_dist )
			std::vector< DMatch > good_matches;

			for( int i = 0; i < matches.size(); i++ ) {
				if( matches[i].distance < 3*min_dist )
					good_matches.push_back( matches[i]);
			}//: for

			CLOG(LDEBUG) << "Good matches: " << good_matches.size();

			// Localize the object
			std::vector<Point2f> obj;
			std::vector<Point2f> scene;

			// Get the keypoints from the good matches.
			for( int i = 0; i < good_matches.size(); i++ ) {
			  obj.push_back( models_keypoints [m] [ good_matches[i].queryIdx ].pt );
			  scene.push_back( scene_keypoints [ good_matches[i].trainIdx ].pt );
			}//: for

			// Find homography between corresponding points.
			Mat H = findHomography( obj, scene, CV_RANSAC );

			// Get the corners from the detected "object hypothesis".
			std::vector<Point2f> obj_corners(4);
			obj_corners[0] = cv::Point2f(0,0);
			obj_corners[1] = cv::Point2f( models_imgs[m].cols, 0 );
			obj_corners[2] = cv::Point2f( models_imgs[m].cols, models_imgs[m].rows );
			obj_corners[3] = cv::Point2f( 0, models_imgs[m].rows );
			std::vector<Point2f> hypobj_corners(4);

			// Transform corners with found homography.
			perspectiveTransform( obj_corners, hypobj_corners, H);

			// Verification: check resulting shape of object hypothesis.
			// Compute "center of mass".
			cv::Point2f center = (hypobj_corners[0] + hypobj_corners[1] + hypobj_corners[2] + hypobj_corners[3])*.25;
			std::vector<double> angles(4);
			cv::Point2f tmp ;
			// Compute angles.
			for (int i=0; i<4; i++) {
				tmp = (hypobj_corners[i] - center);
				angles[i] = atan2(tmp.y,tmp.x);
				CLOG(LDEBUG)<< tmp << " angle["<<i<<"] = "<< angles[i];
			}//: if


			// Find smallest element.
			int imin = -1;
			double amin = 1000;
			for (int i=0; i<4; i++)
				if (amin > angles[i]) {
					amin = angles[i];
					imin = i;
				}//: if

			// Reorder table.
			for (int i=0; i<imin; i++) {
				angles.push_back (angles[0]);
				angles.erase(angles.begin());
			}//: for

			for (int i=0; i<4; i++) {
				CLOG(LDEBUG)<< "reordered angle["<<i<<"] = "<< angles[i];
			}//: if

			cv::Scalar colour;
			double score = (double)good_matches.size()/models_keypoints [m].size();
			// Check dependency between corners.
			if ((angles[0] < angles[1]) && (angles[1] < angles[2]) && (angles[2] < angles[3])) {
				// Order is ok.
				colour = Scalar(0, 255, 0);
				CLOG(LINFO)<< "Model ("<<m<<"): keypoints "<< models_keypoints [m].size()<<" corrs = "<< good_matches.size() <<" score "<< score << " VALID";
				// Store the model in a list in proper order.
				storeObjectHypothesis(models_names[m], center, hypobj_corners, score);

			} else {
				// Hypothesis not valid.
				colour = Scalar(0, 0, 255);
				CLOG(LINFO)<< "Model ("<<m<<"): keypoints "<< models_keypoints [m].size()<<" corrs = "<< good_matches.size() <<" score "<< score << " REJECTED";
			}//: else


			if (m == prop_returned_model_number) {
				Mat img_matches2;
				// Draw good matches.
				drawMatches( models_imgs[m], models_keypoints[m], scene_img, scene_keypoints,
					     good_matches, img_matches2, Scalar::all(-1), Scalar::all(-1),
					     vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
				// Draw the object as lines, with center and top left corner indicated.
				line( img_matches2, hypobj_corners[0] + Point2f( models_imgs[m].cols, 0), hypobj_corners[1] + Point2f( models_imgs[m].cols, 0), colour, 4 );
				line( img_matches2, hypobj_corners[1] + Point2f( models_imgs[m].cols, 0), hypobj_corners[2] + Point2f( models_imgs[m].cols, 0), colour, 4 );
				line( img_matches2, hypobj_corners[2] + Point2f( models_imgs[m].cols, 0), hypobj_corners[3] + Point2f( models_imgs[m].cols, 0), colour, 4 );
				line( img_matches2, hypobj_corners[3] + Point2f( models_imgs[m].cols, 0), hypobj_corners[0] + Point2f( models_imgs[m].cols, 0), colour, 4 );
				circle( img_matches2, center + Point2f( models_imgs[m].cols, 0), 2, colour, 4);
				circle( img_matches2, hypobj_corners[0] + Point2f( models_imgs[m].cols, 0), 2, Scalar(255, 0, 0), 4);
				out_img_good_correspondences.write(img_matches2);

			}//: if
		}//: for

		Mat img_object = scene_img.clone();
		if (recognized_names.size() == 0) {
			CLOG(LWARNING)<< "None of the models was not properly recognized in the image";
		} else {

			for (int h=0; h<recognized_names.size(); h++) {
				// Draw the final object - as lines, with center and top left corner indicated.
				line( img_object, recognized_corners[h][0], recognized_corners[h][1], Scalar(0, 255, 0), 4 );
				line( img_object, recognized_corners[h][1], recognized_corners[h][2], Scalar(0, 255, 0), 4 );
				line( img_object, recognized_corners[h][2], recognized_corners[h][3], Scalar(0, 255, 0), 4 );
				line( img_object, recognized_corners[h][3], recognized_corners[h][0], Scalar(0, 255, 0), 4 );
				circle( img_object, recognized_centers[h], 2, Scalar(0, 255, 0), 4);
				circle( img_object, recognized_corners[h][0], 2, Scalar(255, 0, 0), 4);
				CLOG(LNOTICE)<< "Hypothesis (): model: "<< recognized_names[h]<< " score: "<< recognized_scores[h];
			}//: for
		}//: else
		// Write image to port.
		out_img_object.write(img_object);

	} catch (...) {
		CLOG(LERROR) << "onNewImage failed";
	}//: catch
}
Ejemplo n.º 19
0
//--------------------------------------------------------------
void testApp::setup(){

	initGL();
	generateTextures();
	generateScreenSpaceFrameBuffers();
	printFramebufferInfo();
	loadModels();
	setupGUI();
	
	cameraXPos =0;
	cameraZPos = -100;
	cameraRotation = 0;
	
	camera = new Camera(cameraXPos,400,cameraZPos);
	fboUsed = true;
	blurStep = false;
	showGui = true;
	cameraRotate = false;
	doRecording = false;
	
#ifdef DEBUG
    glInfo glInfo;
    glInfo.getInfo();
    glInfo.printSelf();
#endif
	
	
	// Setup variable for Near and Far Camera ranges
	
	int w = ofGetWidth();
	int h = ofGetHeight();
	
	float halfFov, theTan, screenFov, aspect;
	screenFov               = 60.0f;
	float eyeX              = (float)w / 2.0;
	float eyeY              = (float)h / 2.0;
	halfFov                 = PI * screenFov / 360.0;
	theTan                  = tanf(halfFov);
	float dist              = eyeY / theTan;
	nearDist  = dist / 10.0;  // near / far clip plane
	farDist   = dist * 10.0;
	aspect                  = (float)w/(float)h;
	
	totStrength = 1.38;
	
	// Shaders for SSAO and Passing
	// NOTE! Settings for shaders can ONLY be set when they are set active!!!
	
	ssaoShader.loadShader("ssao");
	if (!ssaoShader.bLoaded){
		cout << "SSAO Shader not loaded correctly" << endl;
	}
		passShader.loadShader("pass");
	if (!passShader.bLoaded){
		cout << "PASS Shader not loaded correctly" << endl;
	}
	nmShader.loadShader("nm");
	if (!nmShader.bLoaded){
		cout << "NM Shader not loaded correctly" << endl;
	}
	ssao2Shader.loadShader("ssao2");
	if (!ssao2Shader.bLoaded){
		cout << "SSAO2 Shader not loaded correctly" << endl;
	}
	blurShader.loadShader("blur");
	if (!blurShader.bLoaded){
		cout << "Blur Shader not loaded correctly" << endl;
	}

	// Camera Recording Setup
	saver.listCodecs();
	saver.setCodecType(18);
	saver.setCodecQualityLevel(OF_QT_SAVER_CODEC_QUALITY_NORMAL);
	saver.setup(1280,720,"output.mov");
	
	ofSetFrameRate(30);
	
}
Ejemplo n.º 20
0
ComponentModelLibrary::ComponentModelLibrary()
{
	loadModels();
}