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


C++ SoGroup::ref方法代码示例

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


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

示例1: main

int main(int, char **argv)
{
	// Initialize Inventor. This returns a main window to use.
	// If unsuccessful, exit.
	HWND myWindow = SoWin::init("Water molecule"); // pass the app name
	if (myWindow == NULL) exit(1);
	// Make a scene containing a red cone
	SoGroup *waterMolecule = new SoGroup; // water molecule
	SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
	SoGroup *oxygen = new SoGroup; // oxygen atom
	SoMaterial *redPlastic = new SoMaterial;
	SoSphere *sphere1 = new SoSphere;
	SoGroup *hydrogen1 = new SoGroup; // hydrogen atoms
	SoGroup *hydrogen2 = new SoGroup;
	SoTransform *hydrogenXform1 = new SoTransform;
	SoTransform *hydrogenXform2 = new SoTransform;
	SoMaterial *whitePlastic = new SoMaterial;
	SoSphere *sphere2 = new SoSphere;
	SoSphere *sphere3 = new SoSphere;
	// Set all field values for the oxygen atom
	redPlastic->ambientColor.setValue(1.0, 0.0, 0.0);
	redPlastic->diffuseColor.setValue(1.0, 0.0, 0.0);
	redPlastic->specularColor.setValue(0.5, 0.5, 0.5);
	redPlastic->shininess = 0.5;
	// Set all field values for the hydrogen atoms
	hydrogenXform1->scaleFactor.setValue(0.75, 0.75, 0.75);
	hydrogenXform1->translation.setValue(0.1, 1.2, 1.0);
	hydrogenXform2->translation.setValue(0.0, -3.2, 0.0);
	whitePlastic->ambientColor.setValue(1.0, 1.0, 1.0);
	whitePlastic->diffuseColor.setValue(1.0, 1.0, 1.0);
	whitePlastic->specularColor.setValue(0.5, 0.5, 0.5);
	whitePlastic->shininess = 0.5;
	// Create a hierarchy
	waterMolecule->ref();
	waterMolecule->addChild(oxygen);
	waterMolecule->addChild(hydrogen1);
	waterMolecule->addChild(hydrogen2);
	oxygen->addChild(redPlastic);
	oxygen->addChild(sphere1);
	hydrogen1->addChild(hydrogenXform1);
	hydrogen1->addChild(whitePlastic);
	hydrogen1->addChild(sphere2);
	hydrogen2->addChild(hydrogenXform2);
	hydrogen2->addChild(sphere3);
	SoWinExaminerViewer *myRenderArea = new SoWinExaminerViewer(myWindow);
	// Make myCamera see everything.
	myCamera->viewAll(waterMolecule, myRenderArea->getViewportRegion());
	// Put our scene in myRenderArea, change the title
	myRenderArea->setSceneGraph(waterMolecule);
	myRenderArea->setTitle("Water molecule");
	myRenderArea->show();
	SoWin::show(myWindow); // Display main window
	SoWin::mainLoop(); // Main Inventor event loop
	delete myRenderArea;
	waterMolecule->unref();
	return 0;
}
开发者ID:googleknight,项目名称:Coin3D_examples,代码行数:57,代码来源:water.cpp

示例2: saveModel

bool CoinVisualizationNode::saveModel(const std::string &modelPath, const std::string &filename)
{
	std::string outFile = filename;

	boost::filesystem::path completePath(modelPath);
	boost::filesystem::path fn(outFile);

	if (!boost::filesystem::is_directory(completePath))
	{
		if (!boost::filesystem::create_directories(completePath))
		{
			VR_ERROR << "Could not create model dir  " << completePath.string() << endl;
			return false;
		}
	}

	boost::filesystem::path completeFile = boost::filesystem::operator/(completePath,fn);

    SoOutput* so = new SoOutput();
    if (!so->openFile(completeFile.string().c_str()))
    {
        VR_ERROR << "Could not open file " << completeFile.string() << " for writing." << endl;
    }
	SoGroup *n = new SoGroup;
	n->ref();
	n->addChild(visualization);
	SoGroup* newVisu = CoinVisualizationFactory::convertSoFileChildren(n);
	newVisu->ref();
    SoWriteAction wa(so);
    wa.apply(newVisu);
	so->closeFile();

	newVisu->unref();
	n->unref();

    return true;
}
开发者ID:TheMarex,项目名称:simox,代码行数:37,代码来源:CoinVisualizationNode.cpp

示例3:

SoGroup *
SoFile::copyChildren() const
//
////////////////////////////////////////////////////////////////////////
{
    // Create a new SoGroup with our children, and return a copy of
    // it. This will ensure that connections are copied properly.
    SoGroup *holder = new SoGroup;
    holder->ref();

    for (int i = 0; i < children.getLength(); i++)
	holder->addChild(children[i]);

    SoGroup *result = (SoGroup *) holder->copy(TRUE);

    holder->unref();

    return result;
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:19,代码来源:SoFile.cpp

示例4:

// creates a part of a scene-graph which is a plane suitable for the decoration
// of our SoJackDragger
SoGroup *InvPlaneMover::makePlane()
{

    static float vertexPos[4][3] = {
        { 0, 0.5, -0.5 },
        { 0, 0.5, 0.5 },
        { 0, -0.5, 0.5 },
        { 0, -0.5, -0.5 }
    };

    static int indices[4] = { 3, 2, 1, 0 };

    SoGroup *plane = new SoGroup;
    plane->ref();

    SoMaterial *mat = new SoMaterial;

    mat->ambientColor.setValue(0.3f, 0.1f, 0.1f);
    mat->diffuseColor.setValue(0.8f, 0.7f, 0.2f);
    mat->specularColor.setValue(0.4f, 0.3f, 0.1f);
    mat->transparency = 0.3f;
    plane->addChild(mat);

    SoMaterialBinding *bndng = new SoMaterialBinding;
    bndng->value = SoMaterialBinding::DEFAULT;
    plane->addChild(bndng);

    SoCoordinate3 *coords = new SoCoordinate3;
    coords->point.setValues(0, 4, vertexPos);

    plane->addChild(coords);

    SoIndexedFaceSet *faceSet = new SoIndexedFaceSet;
    faceSet->coordIndex.setValues(0, 4, indices);

    plane->addChild(faceSet);

    return plane;
}
开发者ID:nixz,项目名称:covise,代码行数:41,代码来源:InvPlaneMover.cpp

示例5: return

/*!
  Returns a subgraph with a deep copy of the children of this node.
*/
SoGroup *
SoFile::copyChildren(void) const
{
  SoGroup * tmproot = new SoGroup;
  tmproot->ref();

  // Instead of individually copying our children one by one and
  // attaching to the new group node root, we use a temporary group
  // node to first *attach* our children to, and then copying the
  // root. This is done so any interconnections between sub-graphs are
  // also copied.

  const SoChildList * cl = this->children;
  for (int i = 0; i < cl->getLength(); i++) {
    tmproot->addChild(cl->operator[](i));
  }

  SoNode * n = tmproot->copy(TRUE);

  tmproot->unref();

  return (SoGroup *)n;
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:26,代码来源:SoFile.cpp


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