当前位置: 首页>>代码示例>>C++>>正文


C++ ref_ptr::createVideoPlane方法代码示例

本文整理汇总了C++中ref_ptr::createVideoPlane方法的典型用法代码示例。如果您正苦于以下问题:C++ ref_ptr::createVideoPlane方法的具体用法?C++ ref_ptr::createVideoPlane怎么用?C++ ref_ptr::createVideoPlane使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ref_ptr的用法示例。


在下文中一共展示了ref_ptr::createVideoPlane方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: startup

Group* startup()
{
	// we need the scene's state set to enable the light for the entire scene
	Group *scene = new Group();
	lightStateSet = scene->getOrCreateStateSet();
	lightStateSet->ref();
	
	// create VideoGeometry
	try {
		videoGeode = new VideoGeode();
		
		// stars / starfield
		Material *material = new Material();
		material->setEmission(Material::FRONT, Vec4(1.0f, 1.0f, 1.0f, 1.0f));
		material->setAmbient(Material::FRONT,  Vec4(1.0f, 1.0f, 1.0f, 1.0f));
		material->setShininess(Material::FRONT, 25.0f);
		// creating a video plane
		videoGeode->prepareMaterial(material);
      //videoPlane = videoGeode->createVideoPlane(1,1, true);
      videoPlane = videoGeode->createVideoPlane(2,2, true);
      videoPlane->setPosition(Vec3(0,0,0));
	} catch (char *e) {
		std::cerr << e;
	}
	
   scene->addChild(videoPlane);
	
	return scene;
}
开发者ID:SPhoenixx,项目名称:NAM,代码行数:29,代码来源:main-VideoGeometry.cpp

示例2: main

int main(int argc, char **argv)
{
   // use an ArgumentParser object to manage the program arguments.
   osg::ArgumentParser arguments(&argc,argv);
   
   // read the first useful arguments for creating video geode
   int camNumber=0;
   arguments.read("--cam",camNumber);
   int imWidth = 640;
   arguments.read("--width",imWidth);
   int imHeight = 480;
   arguments.read("--height",imHeight);
   int threshold = 230;
   arguments.read("--thres",threshold);
   // do we want to use a movie?
   movieName="";
   arguments.read("--video", movieName);
   if(!movieName.empty())
      cout<<"Movie name: "<<movieName<<endl;
   
   // we need the scene's state set to enable the light for the entire scene
	scene = new Group();
	lightStateSet = scene->getOrCreateStateSet();
	lightStateSet->ref();
	
   /*cout<<"Number of arguments: "<<arguments.argc()<<endl;
   movieName = "";
   if(arguments.argc() >= 3 && arguments.isString(2)){
      movieName = arguments[2];
      cout<<"Movie name: "<<movieName<<endl;
   }*/
   
	// create VideoGeometry
	try {
		videoGeode = new VideoGeode(movieName,camNumber,imWidth,imHeight);
		videoGeode->setThreshold(threshold);
		// stars / starfield
		Material *material = new Material();
		material->setEmission(Material::FRONT, Vec4(1.0f, 1.0f, 1.0f, 1.0f));
		material->setAmbient(Material::FRONT,  Vec4(1.0f, 1.0f, 1.0f, 1.0f));
		material->setShininess(Material::FRONT, 25.0f);
		// creating a video plane
		videoGeode->prepareMaterial(material);
      //videoPlane = videoGeode->createVideoPlane(1,1, true);
      videoPlane = videoGeode->createVideoPlane(2,2, true);
      videoPlane->setPosition(Vec3(0,0,0));
	} catch (char *e) {
		std::cerr << e;
	}
	
   scene->addChild(videoPlane);
   
      
   // load the nodes from the commandline arguments.
   model = new PositionAttitudeTransform();
        
   Node *osgModel = osgDB::readNodeFiles(arguments);
   
   // if not loaded assume no arguments passed in, try use default mode instead.
   if (!osgModel) osgModel = osgDB::readNodeFile("cessna.osg"); // I can't get Xcode to search in this directory (OSG_FILE_PATH) so this does not work
   
   if (osgModel)
   {
      // Resizing the model so that it fits in the window
      BoundingSphere bs = osgModel->getBound();
      float bsR = bs.radius();
      float targetSize = 1.0f; // we set up the projection matrix as an ortho 2d between -1 and 1 --> hence the radius of the model should be of size 1
      float factor = targetSize / bsR;
      std::cout << "Model Bounding Sphere radius is: " << bsR << std::endl;
      std::cout << "Scale factor is: " << factor << std::endl;
      model->setScale(osg::Vec3d(factor,factor,factor));
   }
   
   // Adding the model to the PAT node
   model->addChild(osgModel);
   
   //Group *scene = startup();
	//if (!scene) return 1;
   
   // create a light
	lightSource = new LightSource();
	lightSource->setLight(createLight(Vec4(0.9f, 0.9f, 0.9f, 1.0f)));
	// enable the light for the entire scene
	lightSource->setLocalStateSetModes(StateAttribute::ON);
	lightSource->setStateSetModes(*lightStateSet, StateAttribute::ON);
	
	lightTransform = new PositionAttitudeTransform();
	lightTransform->addChild(lightSource);
	lightTransform->setPosition(Vec3(0, 0, 100));
   
   // Adding the 3D model to the scene
   scene->addChild(lightTransform);
   scene->addChild(model);
   
   
   // Testing the movie
   //osg::Image* image = osgDB::readImageFile(arguments[2]);
   
   //cout<<"Number of arguments: "<<arguments.argc()<<endl;
   
//.........这里部分代码省略.........
开发者ID:SPhoenixx,项目名称:NAM,代码行数:101,代码来源:main-VideoGeometry.cpp


注:本文中的ref_ptr::createVideoPlane方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。