Visual studio 无法打开包含文件:`osg/Node`:没有这样的文件或目录

Visual studio 无法打开包含文件:`osg/Node`:没有这样的文件或目录,visual-studio,openscenegraph,Visual Studio,Openscenegraph,我不知道该怎么问这个问题。如果我犯了任何错误,如果有人能改正,我将不胜感激 我在Openscenegraph中从microsoftvisualstudio开始编写了一个程序,但是当我按下debuged时,它给出了这样的错误 1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------ 1> GeometryTest.cpp 1>c:\osg\test\geomet

我不知道该怎么问这个问题。如果我犯了任何错误,如果有人能改正,我将不胜感激

我在
Openscenegraph
中从
microsoftvisualstudio
开始编写了一个程序,但是当我按下debuged时,它给出了这样的错误

1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
1>  GeometryTest.cpp
1>c:\osg\test\geometrytest.cpp(1): fatal error C1083: Cannot open include file: 'osg/Node': No such file or directory
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我是Openscenegraph和visual studio的新手,但我没有名为
节点的库

因此,请指导我如何解决这个错误? 多谢各位

#include <osg/Node>
#include <osg/Group>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Texture2D>
#include <osgDB/ReadFile> 
#include <osgViewer/Viewer>
#include <osg/PositionAttitudeTransform>
#include <osgGA/TrackballManipulator>
int main()
{
   osgViewer::Viewer viewer;
   osg::Group* root = new osg::Group();
   osg::Geode* pyramidGeode = new osg::Geode();
   osg::Geometry* pyramidGeometry = new osg::Geometry();
   osg::Geode* crossGeode = new osg::Geode();
   osg::Geometry* crossGeometry = new osg::Geometry();

   //Associate the pyramid geometry with the pyramid geode 
   //   Add the pyramid geode to the root node of the scene graph.

   pyramidGeode->addDrawable(pyramidGeometry); 
   root->addChild(pyramidGeode);
   crossGeode->addDrawable(crossGeometry); 
   root->addChild(crossGeode);

   //Declare an array of vertices. Each vertex will be represented by 
   //a triple -- an instances of the vec3 class. An instance of 
   //osg::Vec3Array can be used to store these triples. Since 
   //osg::Vec3Array is derived from the STL vector class, we can use the
   //push_back method to add array elements. Push back adds elements to 
   //the end of the vector, thus the index of first element entered is 
   //zero, the second entries index is 1, etc.
   //Using a right-handed coordinate system with 'z' up, array 
   //elements zero..four below represent the 5 points required to create 
   //a simple pyramid.

   osg::Vec3Array* pyramidVertices = new osg::Vec3Array;
   pyramidVertices->push_back( osg::Vec3( 0, 0, 0) ); // front left 
   pyramidVertices->push_back( osg::Vec3(10, 0, 0) ); // front right 
   pyramidVertices->push_back( osg::Vec3(10,10, 0) ); // back right 
   pyramidVertices->push_back( osg::Vec3( 0,10, 0) ); // back left 
   pyramidVertices->push_back( osg::Vec3( 5, 5,10) ); // peak

   float clen;
   clen = 12.0;
   osg::Vec3Array* crossVertices = new osg::Vec3Array;
   crossVertices->push_back (osg::Vec3(-clen, 0.0, 0.0));
   crossVertices->push_back (osg::Vec3( clen, 0.0, 0.0));
   crossVertices->push_back (osg::Vec3(  0.0, 0.0, -clen));
   crossVertices->push_back (osg::Vec3(  0.0, 0.0,  clen));  

   //Associate this set of vertices with the geometry associated with the 
   //geode we added to the scene.

   pyramidGeometry->setVertexArray( pyramidVertices );
   crossGeometry->setVertexArray (crossVertices);
   //Next, create a primitive set and add it to the pyramid geometry. 
   //Use the first four points of the pyramid to define the base using an 
   //instance of the DrawElementsUint class. Again this class is derived 
   //from the STL vector, so the push_back method will add elements in 
   //sequential order. To ensure proper backface cullling, vertices 
   //should be specified in counterclockwise order. The arguments for the 
   //constructor are the enumerated type for the primitive 
   //(same as the OpenGL primitive enumerated types), and the index in 
   //the vertex array to start from.

   osg::DrawElementsUInt* pyramidBase = 
      new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
   pyramidBase->push_back(3);
   pyramidBase->push_back(2);
   pyramidBase->push_back(1);
   pyramidBase->push_back(0);
   pyramidGeometry->addPrimitiveSet(pyramidBase);

   osg::DrawElementsUInt* cross = 
      new osg::DrawElementsUInt(osg::PrimitiveSet::LINES, 0);
   cross->push_back(3);
   cross->push_back(2);
   cross->push_back(1);
   cross->push_back(0);
   crossGeometry->addPrimitiveSet(cross);

   //Repeat the same for each of the four sides. Again, vertices are 
   //specified in counter-clockwise order. 

   osg::DrawElementsUInt* pyramidFaceOne = 
      new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0);
   pyramidFaceOne->push_back(0);
   pyramidFaceOne->push_back(1);
   pyramidFaceOne->push_back(4);
   pyramidGeometry->addPrimitiveSet(pyramidFaceOne);

   osg::DrawElementsUInt* pyramidFaceTwo = 
      new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0);
   pyramidFaceTwo->push_back(1);
   pyramidFaceTwo->push_back(2);
   pyramidFaceTwo->push_back(4);
   pyramidGeometry->addPrimitiveSet(pyramidFaceTwo);

   osg::DrawElementsUInt* pyramidFaceThree = 
      new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0);
   pyramidFaceThree->push_back(2);
   pyramidFaceThree->push_back(3);
   pyramidFaceThree->push_back(4);
   pyramidGeometry->addPrimitiveSet(pyramidFaceThree);

   osg::DrawElementsUInt* pyramidFaceFour = 
      new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0);
   pyramidFaceFour->push_back(3);
   pyramidFaceFour->push_back(0);
   pyramidFaceFour->push_back(4);
   pyramidGeometry->addPrimitiveSet(pyramidFaceFour);

   //Declare and load an array of Vec4 elements to store colors. 

   osg::Vec4Array* colors = new osg::Vec4Array;
   colors->push_back(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f) ); //index 0 red
   colors->push_back(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f) ); //index 1 green
   colors->push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f) ); //index 2 blue
   colors->push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f) ); //index 3 white

   //Declare the variable that will match vertex array elements to color 
   //array elements. This vector should have the same number of elements 
   //as the number of vertices. This vector serves as a link between 
   //vertex arrays and color arrays. Entries in this index array 
   //coorespond to elements in the vertex array. Their values coorespond 
   //to the index in he color array. This same scheme would be followed 
   //if vertex array elements were matched with normal or texture 
   //coordinate arrays.
   //   Note that in this case, we are assigning 5 vertices to four 
   //   colors. Vertex array element zero (bottom left) and four (peak) 
   //   are both assigned to color array element zero (red).

   osg::TemplateIndexArray
      <unsigned int, osg::Array::UIntArrayType,4,4> *colorIndexArray;
   colorIndexArray = 
      new osg::TemplateIndexArray<unsigned int, osg::Array::UIntArrayType,4,4>;
   colorIndexArray->push_back(0); // vertex 0 assigned color array element 0
   colorIndexArray->push_back(1); // vertex 1 assigned color array element 1
   colorIndexArray->push_back(2); // vertex 2 assigned color array element 2
   colorIndexArray->push_back(3); // vertex 3 assigned color array element 3
   colorIndexArray->push_back(0); // vertex 4 assigned color array element 0

   //The next step is to associate the array of colors with the geometry, 
   //assign the color indices created above to the geometry and set the 
   //binding mode to _PER_VERTEX.

   pyramidGeometry->setColorArray(colors);
   pyramidGeometry->setColorIndices(colorIndexArray);
   pyramidGeometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
   crossGeometry->setColorArray(colors);
   crossGeometry->setColorIndices(colorIndexArray);
   crossGeometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);

   //Now that we have created a geometry node and added it to the scene 
   //we can reuse this geometry. For example, if we wanted to put a 
   //second pyramid 15 units to the right of the first one, we could add 
   //this geode as the child of a transform node in our scene graph. 

   // Declare and initialize a transform node.
   osg::PositionAttitudeTransform* pyramidTwoXForm =
      new osg::PositionAttitudeTransform();

   // Use the 'addChild' method of the osg::Group class to
   // add the transform as a child of the root node and the
   // pyramid node as a child of the transform.

   root->addChild(pyramidTwoXForm);
   pyramidTwoXForm->addChild(pyramidGeode);

   // Declare and initialize a Vec3 instance to change the
   // position of the model in the scene

   osg::Vec3 pyramidTwoPosition(15,0,0);
   pyramidTwoXForm->setPosition( pyramidTwoPosition ); 

   //The final step is to set up and enter a simulation loop.

   viewer.setSceneData( root );
   //viewer.run();

   viewer.setCameraManipulator(new osgGA::TrackballManipulator());
   viewer.realize();

   while( !viewer.done() )
   {
      viewer.frame();
   } 

   return 0;
}
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
int main()
{
osgViewer::查看器;
osg::Group*root=新osg::Group();
osg::Geode*pyramidGeode=新osg::Geode();
osg::Geometry*pyramidGeometry=新osg::Geometry();
osg::Geode*crossGeode=新osg::Geode();
osg::Geometry*crossGeometry=新osg::Geometry();
//将棱锥体几何图形与棱锥体测地线关联
//将棱锥体大地坐标添加到场景图的根节点。
棱锥体几何体->可添加绘制(棱锥体几何体);
root->addChild(金字塔形几何体);
crossGeode->addDrawable(crossGeometry);
根->添加子对象(交叉节点);
//声明一个顶点数组。每个顶点将由
//三元组——vec3类的一个实例
//osg::Vec3Array可用于存储这些三元组
//Vec3Array是从STL向量类派生的,我们可以使用
//push_back方法添加数组元素。push back将元素添加到
//向量的末尾,因此输入第一个元素的索引
//零,第二个条目索引为1,以此类推。
//使用“z”向上的右手坐标系,数组
//以下元素0..4表示创建所需的5个点
//一个简单的金字塔。
osg::Vec3Array*金字塔顶点=新osg::Vec3Array;
金字塔顶点->向后推(osg::Vec3(0,0,0));//左前
金字塔顶点->向后推(osg::Vec3(10,0,0));//右前
金字塔顶点->向后推(osg::Vec3(10,10,0));//向右返回
金字塔顶点->向后推(osg::Vec3(0,10,0));//向后左
金字塔顶点->向后推(osg::Vec3(5,5,10));//峰值
浮动克莱恩;
克伦=12.0;
osg::Vec3Array*交叉顶点=新osg::Vec3Array;
交叉顶点->向后推(osg::Vec3(-clen,0.0,0.0));
交叉顶点->向后推(osg::Vec3(clen,0.0,0.0));
交叉顶点->向后推(osg::Vec3(0.0,0.0,-clen));
交叉顶点->向后推(osg::Vec3(0.0,0.0,clen));
//将此顶点集与与关联的几何体关联
//我们添加到场景中的geode。
金字塔几何->设置顶点阵列(金字塔顶点);
crossGeometry->setVertexArray(交叉顶点);
//接下来,创建一个基本体集并将其添加到棱锥体几何体中。
//使用棱锥体的前四个点使用
//DrawerElementSuint类的实例。再次派生该类
//从STL向量,因此push_back方法将在
//顺序。为确保正确的背面剔除,请选择顶点
//应按逆时针顺序指定。的参数
//构造函数是基元的枚举类型
//(与OpenGL原语枚举类型相同),以及中的索引
//要从中开始的顶点数组。
osg::Dropelementsuint*Pyramidabase=
新的osg::DrainElementSuint(osg::PrimitiveSet::QUADS,0);
金字塔底座->向后推(3);
金字塔底座->推回(2);
金字塔底座->推回(1);
金字塔底座->推回(0);
金字塔几何->添加图元集(金字塔基);
osg::抽屉入口*交叉=
新的osg::DrainElementSuint(osg::PrimitiveSet::LINES,0);
交叉->推回(3);
交叉->推回(2);
交叉->推回(1);
交叉->推回(0);
crossGeometry->addPrimitiveSet(交叉);
//对四条边中的每一条重复相同的操作。同样,顶点是
//按逆时针顺序指定。
osg::Dropelementsuint*pyramidFaceOne=
新的osg::DrainElementSuint(osg::PrimitiveSet::TRIANGLES,0);
金字塔面一->推回(0);
金字塔面一->推回(1);
金字塔面一->推回(4);
棱锥几何->添加图元集(棱锥面一);
osg::DrawerElementSuint*金字塔面WO=
新的osg::DrainElementSuint(osg::PrimitiveSet::TRIANGLES,0);
从WO->推回(1);
从WO->推回(2);
从WO->推回(4);
pyramidGeometry->addPrimitiveSet(pyramidFaceTwo);
osg::DrawerElementSuint*PyramidaFaceThree=
新的osg::DrainElementSuint(osg::PrimitiveSet::TRIANGLES,0);
金字塔面三->推回(2);
金字塔面三->推回(3);
金字塔面三->推回(4);
pyramidGeometry->addPrimitiveSet(pyramidFaceThree);
osg::DrawerElementSuint*pyramidFaceFour=
新的osg::DrainElementSuint(osg::PrimitiveSet::TRIANGLES,0);
金字塔面四->推回(3);
金字塔面四->推回(0);
金字塔面四->推回(4);
棱锥几何->添加基本体集(棱锥面四);
//声明并加载Vec4元素数组以存储颜色。
osg::Vec4Array*颜色=新osg::Vec4Array;
颜色->向后推(osg::Vec4(1.0f,0.0f,0.0f,1.0f));//索引0红色
颜色->向后推(osg::Vec4(0.0f,1.0f,0.0f,1.0f));//索引1绿色
颜色->向后推(osg::Vec4(0.0f,0.0f,1.0f,1.0f));//索引2蓝色
颜色->向后推(osg::Vec4(1.0f,1.0f,1.0f,1.0f));//索引3白色
//声明将顶点数组元素与颜色匹配的变量
//数组元素。此向量的元素数应相同
//作为顶点数。此向量用作
//顶点数组和颜色数组。此索引数组中的项
//CooResponse到顶点数组中的元素。它们的值CooResponse
//到颜色数组中的索引。将遵循相同的方案
//如果顶点数组元素与法线或纹理匹配
//坐标数组。
//注