本文整理汇总了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;
}
示例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;
//.........这里部分代码省略.........