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


C++ TransformNode::addChild方法代码示例

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


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

示例1: render

void Picture::render(int w, int h)
{
   //picture will not look exactly like in class programs
   //normals used are those from the text file

   GLuint* tex_num = new GLuint[2];
   //obtain two unique integers that have not been used as texture id before
   glGenTextures(2, tex_num);

   const char* fileName = "sphere_texture.txt";
   BasicObject* sphere = new BasicObject(fileName);

   //sphere 1 with moon color texture
   InstanceObject* sphere1 = new InstanceObject(sphere);
   Color* d1 = new Color(0.3, 0.3, 0.9);
   sphere1->setDiffuseMaterial(d1);
   const char* texture = "MoonColor.raw";
   Texture* moon_color = new Texture(texture, 512, 256);
   sphere1->setColorTexture(moon_color, tex_num[0]);

   //sphere 2 with moon normal map texture
   InstanceObject* sphere2 = new InstanceObject(sphere);
   Color* d2 = new Color(1.0, 0.0, 0.0);
   sphere2->setDiffuseMaterial(d2);
   const char* normal = "MoonNormal.raw";
   Texture* moon_normal = new Texture(normal, 512, 256);
   sphere2->setColorTexture(moon_normal, tex_num[1]);

   Scene* scene = new Scene();

   TransformNode* tn = new TransformNode();
   tn->buildTransform(AffineTransforms::scale(.9, .3, .3));
   tn->buildTransform(AffineTransforms::rotateX(90));
   tn->buildTransform(AffineTransforms::rotateY(290));
   tn->buildTransform(AffineTransforms::translate(0, 0, 0));
   tn->addChild(sphere1);

   scene->addTransformNode(tn);

   tn = new TransformNode();
   tn->buildTransform(AffineTransforms::scale(.7, 1.3, .7));
   tn->buildTransform(AffineTransforms::rotateX(90));
   tn->buildTransform(AffineTransforms::rotateZ(290));
   tn->buildTransform(AffineTransforms::translate(-.75, .75, 0));
   tn->addChild(sphere2);

   scene->addTransformNode(tn);

   scene->render(w, h);
   delete scene;
}
开发者ID:pwestrich,项目名称:csc_4750,代码行数:51,代码来源:Picture.cpp

示例2: render

void Picture::render(Pixel* px)
{
	Color *ambient = new Color(1, 1, 1);
	Vertex *eye = new Vertex(0,0,0);
	Light *light = new Light();
	double attenuation = 0;
//while(true)
//{

   char* fileName = "sphere.txt";
   //cout<<"calling read object"<<endl;
   BasicObject* sphere = readObject(fileName);
   sphere->computeSandT();
   //sphere->printFaces();
   //cout<<"called it bitches"<<endl;
   //delete[] fileName;  //mingw appears to delete this automatically

   fileName = "trs.txt";
   InstanceObject* sphereInstance = buildInstanceObject(fileName, sphere);
   //delete[] fileName;

   //obtaining the window transform
   int widthPixels = px->getWidth();  //the dimensions of the panel on which the drawing will occur
   int heightPixels = px->getHeight();

   getShaderInfo(eye, ambient, light, &attenuation);
   Scene* scene = new Scene(light, ambient);
   scene->buildTransform(getCameraTransform("camera.txt"));
   scene->buildTransform(getPerspectiveTransform("fov.txt", widthPixels, heightPixels));
   scene->buildTransform(AffineTransforms::window(widthPixels, heightPixels));


   TransformNode* tn = new TransformNode();
   tn->addChild(sphereInstance);
   scene->addTransformNode(tn);

   //for(;;)
   //{
   scene->render(px, eye, attenuation);
   //}
   delete scene;
//}
}
开发者ID:alwalker,项目名称:TTU,代码行数:43,代码来源:Picture.cpp

示例3: copySelectedObjects

// Function to process the Copy menu command. 
void copySelectedObjects()
{
	if (!noAncestorDescendantSelections()) return;
	for (set<TransformNode*>::const_iterator iter = selections.begin();
	iter != selections.end();
		++iter)
	{
		TransformNode* target = *iter;
		if (target == sceneRoot)
		{
			sceneRoot = new TransformNode(NULL);
			sceneRoot->addChild(target);
			target->setParent(sceneRoot);
		}
		TransformNode* parent = target->getParent();
		TransformNode* newThing = target->clone();
		parent->addChild(newThing);
		newThing->setParent(parent);
		target->translate(COPY_OFF_X, COPY_OFF_Y);
	}
	glutPostRedisplay();
}
开发者ID:zuchermann,项目名称:GraphicsClass,代码行数:23,代码来源:drawing.cpp

示例4: FontFamily

BasicSceneExample::BasicSceneExample(int argc, const char* argv[]):
	ExampleApplication("Basic Scene", argc, argv)
{
	// Open Sans
	openSans = new FontFamily(resourceContext->getFontManager());

	openSans->setName("Open Sans");
	FontFace* openSansRegular = openSans->createFontFace();
	openSansRegular->setSource("data/fonts/Open_Sans/OpenSans-Regular.ttf");

	FontFace* openSansItalic = openSans->createFontFace();
	openSansItalic->setSource("data/fonts/Open_Sans/OpenSans-Italic.ttf");
	openSansItalic->setStyle(FontStyle::ITALIC);

	FontFace* openSansBold = openSans->createFontFace();
	openSansBold->setSource("data/fonts/Open_Sans/OpenSans-Bold.ttf");
	openSansBold->setWeight(FontWeight::BOLD);

	FontFace* openSansBoldItalic = openSans->createFontFace();
	openSansBoldItalic->setSource("data/fonts/Open_Sans/OpenSans-BoldItalic.ttf");
	openSansBoldItalic->setStyle(FontStyle::ITALIC);
	openSansBoldItalic->setWeight(FontWeight::BOLD);

	SharedFont font = openSansItalic->getFont(22);
	if (!font)
	{
		std::cerr << "Failed to find font.\n";
	}

	// Load meshes
	object = resourceContext->getMeshManager()->load("data/models/Hexapod.mesh");
	lightMesh = resourceContext->getMeshManager()->load("data/models/circle.obj");
	checker = resourceContext->getImageManager()->load("data/textures/checker2.tga", true);

	//scene.addChild(new AmbientCubeNode(&ambientCube));

	floor = resourceContext->getMeshManager()->load("data/models/CheckerFloor.obj");

	// Setup camera
	camera.setLens(20.0f, 24.0f);
	camera.setAspectRatio(graphicsContext->getViewport().getAspectRatio());
	camera.setClipNear(0.1f);
	camera.setClipFar(100.0f);
	camera.lookAt(
		{0.0f, 0.0f, 3.0f},
		{0.0f, 0.0f, 0.0f},
		{0.0f, 1.0f, 0.0f});
	camera.update();

	orthoCamera.setClipTop(0.0f);
	orthoCamera.setClipLeft(0.0f);
	orthoCamera.setClipBottom(window->getHeight());
	orthoCamera.setClipRight(window->getWidth());
	orthoCamera.setClipNear(-1.0f);
	orthoCamera.setClipFar(1.0f);
	orthoCamera.lookAt(
		{0.0f, 0.0f, 0.0f},
		{0.0f, 0.0f, -1.0f},
		{0.0f, 1.0f, 0.0f});
	orthoCamera.update();
	
	yaw = 0.0f;
	pitch = 0.0f;
	mouseDown = false;
	
	// Setup lighting
	light.setColor({1.0f, 1.0f, 1.0f});
	light.setPosition({0.0f, 2.5f, 4.0f});
	light.setAttenuation({1.0f, 0.025f, 0.01f});
	light.setDirection(-light.getPosition().normalized());
	light.setCutoff(std::cos(math::radians<float>(30.0f)));
	light.setExponent(20.0f);

	plight.setColor(light.getColor());
	plight.setPosition(light.getPosition());
	plight.setAttenuation(light.getAttenuation());

	sun.setColor({1.0f, 1.0f, 1.0f});
	sun.setDirection(Vector<3, float>(0.75f, -0.5f, -1.0f).normalized());

	// Add lights to scene
	//scene.addChild(new SpotlightNode(&light));
	scene.addChild(new DirectionalLightNode(&sun));
	//scene.addChild(new PointLightNode(&plight));
	
	// Add geometry to scene
	scene.addChild(new GeometryNode(floor));

	GeometryNode* objectNode = nullptr;
	if (object->getSkeleton() && object->getSkeleton()->isLoaded())
	{
		// Pose
		const Skeleton* skeleton = object->getSkeleton().get();
		pose = new SkeletonPose(skeleton);
		objectNode = new RiggedGeometryNode(object, pose);
	}
	else
	{
		objectNode = new GeometryNode(object);
	}
//.........这里部分代码省略.........
开发者ID:cjhoward,项目名称:ogf,代码行数:101,代码来源:basic-scene-example.cpp


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