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


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

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


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

示例1: ConstructTable

/**
 * Construct table
 * @param  unitSquare  Geometry node to use for table top
 * @param  legs        Geometry node to use for legs
 * @return  Returns a scene node representing the table
 */
SceneNode* ConstructTable(SceneNode* box, ConicSurface* leg)
{
   // Table legs (relative to center of table)
   TransformNode* lfLegTransform = new TransformNode;
   lfLegTransform->Translate(-20.0f, -10.0f, 10.0f);
   lfLegTransform->Scale(3.0f, 3.0f, 20.0f);
   TransformNode* lrLegTransform = new TransformNode;
   lrLegTransform->Translate(-20.0f, 10.0f, 10.0f);
   lrLegTransform->Scale(3.0f, 3.0f, 20.0f);
   TransformNode* rfLegTransform = new TransformNode;
   rfLegTransform->Translate(20.0f, -10.0f, 10.0f);
   rfLegTransform->Scale(3.0f, 3.0f, 20.0f);
   TransformNode* rrLegTransform = new TransformNode;
   rrLegTransform->Translate(20.0f, 10.0f, 10.0f);
   rrLegTransform->Scale(3.0f, 3.0f, 20.0f);
   
   // Construct dimensions for the table top
   TransformNode* topTransform = new TransformNode;
   topTransform->Translate(0.0f, 0.0f, 23.0f);
   topTransform->Scale(60.0f, 30.0f, 6.0f);

   // Create the tree
   SceneNode* table = new SceneNode;
   table->AddChild(topTransform);
   topTransform->AddChild(box);
   table->AddChild(lfLegTransform);
   lfLegTransform->AddChild(leg);
   table->AddChild(rfLegTransform);
   rfLegTransform->AddChild(leg);
   table->AddChild(lrLegTransform);
   lrLegTransform->AddChild(leg);
   table->AddChild(rrLegTransform);
   rrLegTransform->AddChild(leg);

   return table;
}
开发者ID:m-hogue,项目名称:JHU-Graphics,代码行数:42,代码来源:PhongShading.cpp

示例2: ConstructScene

/**
 * Construct the scene
 */
void ConstructScene()
{
   // -------------------- Geometry -------------------- //
   movingSquare = new UnitSquareFlatSurface(200,32.2f*.814f,true,Vector2(-.01f,0),.03f);

   SceneNode* house = ConstructHouse(70,90);

   // Construct a unit cylinder surface
   WasherSurface* cylinder = new WasherSurface(.9f, 1.0f, 18);
   
   //Wheel
   WasherSurface* washer = new WasherSurface(10,20,14);
   std::vector<LightNode*> lights;
   lights.push_back(new LightNode(GL_LIGHT3));
   lights.push_back(new LightNode(GL_LIGHT4));
   wheel = new WheelNode(10,20,washer,ConstructBox(9,19.5f,1),8,4,lights);

   waterfall = new ParticleNode(25);

   //-------------------- Materials ------------------------- //

   // Wood
   PresentationNode* wood = new PresentationNode;
   wood->SetMaterialAmbientAndDiffuse(Color4(0.5f, 0.5f, 0.5f));
   wood->SetMaterialSpecular(Color4(0.3f, 0.3f, 0.3f));
   wood->SetMaterialShininess(32.0f);
   wood->setTexture(LoadTextureBMP("images/wood.bin",true,128));

   // Stone
   PresentationNode* stone = new PresentationNode;
   stone->SetMaterialAmbient(Color4(0.19225f, 0.19225f, 0.19225f));
   stone->SetMaterialDiffuse(Color4(0.50754f, 0.50754f, 0.50754f));
   stone->SetMaterialSpecular(Color4(0.508273f, 0.508273f, 0.508273f));
   stone->SetMaterialShininess(10.2f);
   stone->setTexture(LoadTextureBMP("images/stone.bin",true,128));

   PresentationNode* steel = new PresentationNode;
   steel->SetMaterialAmbient(Color4(0.19225f, 0.19225f, 0.19225f));
   steel->SetMaterialDiffuse(Color4(0.7f, 0.7f, 0.7f));
   steel->SetMaterialSpecular(Color4(0.7f, 0.7f, 0.7f));
   steel->SetMaterialShininess(90.2f);

   // Water
   PresentationNode* water = new PresentationNode;
   water->SetMaterialAmbient(Color4(0.01f, 0.01f, 0.1f));
   water->SetMaterialDiffuse(Color4(0.2f, 0.2f, 0.6f));
   water->SetMaterialSpecular(Color4(0.5f, 0.5f, 0.5f));
   water->SetMaterialShininess(10);
   water->setTexture(LoadTextureBMP("images/water.bin",true,128));

   PresentationNode* blue = new PresentationNode;
   blue->SetMaterialAmbient(Color4(0.01f, 0.01f, 0.1f));
   blue->SetMaterialDiffuse(Color4(0.2f, 0.2f, 0.6f));
   blue->SetMaterialSpecular(Color4(0.5f, 0.5f, 0.5f));
   blue->SetMaterialShininess(10);
   // ------------------ Transformations ------------------- //
   TransformNode* wheelTransform = new TransformNode;
   wheelTransform->Translate(-80.0f, 35.0f, 40.0f);
   wheelTransform->Rotate(90.0f, 1.0f, 0.0f, 0.0f);

   TransformNode* houseTransform = new TransformNode;
   houseTransform->Translate(-100,35,0);

   TransformNode* house2Transform = new TransformNode;
   house2Transform->Rotate(180,0,0,1);
   house2Transform->Translate(-100,-35,0);

   TransformNode* wallTransform = new TransformNode;
   wallTransform->Translate(0,35,0);

   TransformNode* waterfallTransform = new TransformNode;
   waterfallTransform->Translate(-128.0f,35,15.0f);

   TransformNode* pipeTransform = new TransformNode;
   pipeTransform->Rotate(-90,0,1,0);
   pipeTransform->Translate(76.5f,35,125);
   pipeTransform->Scale(5,5,20);

   // -------------------- Lighting --------------------------/

   // Light 0 - point light source in back right corner
	LightNode* light0 = new LightNode(GL_LIGHT0);
	light0->SetDiffuse(Color4(0.5f, 0.5f, 0.5f, 1.0f));
	light0->SetSpecular(Color4(0.5f, 0.5f, 0.5f, 1.0f));
	light0->SetPosition(HPoint3(90.0f, 90.0f, 30.f, 1.0f));	
	light0->Enable();

   // Light1 - directional light from the ceiling
	LightNode* light1 = new LightNode(GL_LIGHT1);
	light1->SetDiffuse(Color4(0.7f, 0.7f, 0.7f, 1.0f ));
	light1->SetSpecular(Color4(0.7f, 0.7f, 0.7f, 1.0f));
	light1->SetPosition(HPoint3(0.0f, 0.0f, 1.0f, 0.0f));	
	light1->Enable();

   // Light2 - spotlight - we will place at the camera location
   // shining along -VPN
	LightNode* light2 = new LightNode(GL_LIGHT2);
//.........这里部分代码省略.........
开发者ID:zmnatz,项目名称:2010-Fall-Computer-Graphics-Class,代码行数:101,代码来源:PhongShading.cpp

示例3: ConstructScene

/**
 * Construct the scene
 */
void ConstructScene()
{
   // Construct the lighting shader node
   LightingShaderNode* lightingShader = new LightingShaderNode();
   if (!lightingShader->Create("phong.vert", "phong.frag") ||
       !lightingShader->GetLocations())
      exit(-1);

   int positionLoc = lightingShader->GetPositionLoc();
   int normalLoc = lightingShader->GetNormalLoc();

   // -------------------- Geometry -------------------- //

   // Construct a unit square - use less subdivisions to see how
   // phong shading improves the lighting
   UnitSquareSurface* unitSquare = new UnitSquareSurface(2, positionLoc, normalLoc);

   // Construct a unit box
   SceneNode* box = ConstructUnitBox(unitSquare);

   // Construct a unit cylinder surface
   ConicSurface* cylinder = new ConicSurface(1.0f, 1.0f, 18, 4, positionLoc, normalLoc);

   // Construct a torus
   TorusSurface* torus = new TorusSurface(20.0f, 5.0f, 18, 18, positionLoc, normalLoc);

   // Teapot
   MeshTeapot* teapot = new MeshTeapot(3, positionLoc, normalLoc);

   // Sphere
   SphereSection* sphere = new SphereSection(-90.0f, 90.0f, 18, 
               -180.0f, 180.0f, 36, 1.0f, positionLoc, normalLoc);

   //-------------------- Materials ------------------------- //

   // Wood
   PresentationNode* wood = new PresentationNode;
   wood->SetMaterialAmbientAndDiffuse(Color4(0.55f, 0.45f, 0.15f));
   wood->SetMaterialSpecular(Color4(0.3f, 0.3f, 0.3f));
   wood->SetMaterialShininess(64.0f);

   // Silver
   PresentationNode* silver = new PresentationNode;
   silver->SetMaterialAmbient(Color4(0.19225f, 0.19225f, 0.19225f));
   silver->SetMaterialDiffuse(Color4(0.50754f, 0.50754f, 0.50754f));
   silver->SetMaterialSpecular(Color4(0.508273f, 0.508273f, 0.508273f));
   silver->SetMaterialShininess(51.2f);

   // Black, shiny
   PresentationNode* shinyBlack = new PresentationNode;
   shinyBlack->SetMaterialAmbient(Color4(0.0f, 0.0f, 0.0f));
   shinyBlack->SetMaterialDiffuse(Color4(0.01f, 0.01f, 0.01f));
   shinyBlack->SetMaterialSpecular(Color4(0.5f, 0.5f, 0.5f));
   shinyBlack->SetMaterialShininess(32.0f);

   // Shiny blue
   PresentationNode* shinyBlue = new PresentationNode;
   shinyBlue->SetMaterialAmbient(Color4(0.05f, 0.05f, 0.2f));
   shinyBlue->SetMaterialDiffuse(Color4(0.2f, 0.2f, 0.6f));
   shinyBlue->SetMaterialSpecular(Color4(0.75f, 0.75, 0.75f));
   shinyBlue->SetMaterialShininess(76.8f);

   // ------------------ Transformations ------------------- //

   // Position the table in the room
   TransformNode* tableTransform = new TransformNode;
   tableTransform->Translate(-50.0f, 50.0f, 0.0f);
   tableTransform->Rotate(30.0f, 0.0f, 0.0f, 1.0f);

   // Teapot transform
   TransformNode* teapotTransform = new TransformNode;
   teapotTransform->Translate(0.0f, 0.0f, 26.0f);
   teapotTransform->Scale(2.5f, 2.5f, 2.5f);

   // Torus
   TransformNode* torusTransform = new TransformNode;
   torusTransform->Translate(0.0f, 90.0f, 20.0f);
   torusTransform->Rotate(60.0f, 1.0f, 0.0f, 0.0f);

   // Sphere
   TransformNode* sphereTransform = new TransformNode;
   sphereTransform->Translate(80.0f, 20.0f, 10.0f);
   sphereTransform->Scale(10.0f, 10.0f, 10.0f);

   // --------------------------- Camera ----------------------- //
   MyCamera = new CameraNode;
   MyCamera->SetPosition(Point3(0.0f, -100.0f, 20.0f));
   MyCamera->SetLookAtPt(Point3(0.0f, 0.0f, 20.0f));
   MyCamera->SetViewUp(Vector3(0.0, 0.0, 1.0));
   MyCamera->SetPerspective(50.0, 1.0, 1.0, 300.0);

   // -------------------- Lighting --------------------------/

   // Set the global light ambient
   Color4 globalAmbient(0.4f, 0.4f, 0.4f, 1.0f);
   lightingShader->SetGlobalAmbient(globalAmbient);

//.........这里部分代码省略.........
开发者ID:m-hogue,项目名称:JHU-Graphics,代码行数:101,代码来源:PhongShading.cpp

示例4: ConstructRoom

/**
 * Construct room as a child of the specified node
 * @param  parent      Parent node
 * @param  unitSquare  Geometry node to use
 */
void ConstructRoom(SceneNode* parent, UnitSquareSurface* unitSquare)
{
   // Contruct transform nodes for the walls. Perform rotations so the 
   // walls face inwards
   TransformNode* floorTransform = new TransformNode;
   floorTransform->Scale(200.0f, 200.0f, 1.0f);

   // Back wall is rotated +90 degrees about x: (y -> z)
   TransformNode* backWallTransform = new TransformNode;
   backWallTransform->Translate(0.0f, 100.0f, 40.0f);
   backWallTransform->Rotate(90.0f, 1.0f, 0.0f, 0.0f);   
   backWallTransform->Scale(200.0f, 80.0f, 1.0f);

   // Front wall is rotated -90 degrees about x: (z -> y)
   TransformNode* frontWallTransform = new TransformNode;
   frontWallTransform->Translate(0.0f, -100.0f, 40.0f);
   frontWallTransform->Rotate(-90.0f, 1.0f, 0.0f, 0.0f);   
   frontWallTransform->Scale(200.0f, 80.0f, 1.0f);

   // Left wall is rotated 90 degrees about y: (z -> x)
   TransformNode* leftWallTransform = new TransformNode;
   leftWallTransform->Translate(-100.0f, 0.0f, 40.0f);
   leftWallTransform->Rotate(90.0f, 0.0f, 1.0f, 0.0f);
   leftWallTransform->Scale(80.0f, 200.0f, 1.0f);

   // Right wall is rotated -90 about y: (z -> -x)
   TransformNode* rightWallTransform = new TransformNode;
   rightWallTransform->Translate(100.0f, 0.0f, 40.0f);
   rightWallTransform->Rotate(-90.0f, 0.0f, 1.0f, 0.0f);
   rightWallTransform->Scale(80.0f, 200.0f, 1.0f);

   // Ceiling is rotated 180 about x so it faces inwards
   TransformNode* ceilingTransform = new TransformNode;
   ceilingTransform->Translate(0.0f, 0.0f, 80.0f);
   ceilingTransform->Rotate(180.0f, 1.0f, 0.0f, 0.0f);
   ceilingTransform->Scale(200.0f, 200.0f, 1.0f); 

   // Floor should be tan, mostly dull
   PresentationNode* floorMaterial = new PresentationNode;
   floorMaterial->SetMaterialAmbientAndDiffuse(Color4(0.3f, 0.45f, 0.1f));
   floorMaterial->SetMaterialSpecular(Color4(0.1f, 0.1f, 0.1f));
   floorMaterial->SetMaterialShininess(2.0f);

   // Make the walls reddish, slightly shiny
   PresentationNode* wallMaterial = new PresentationNode;
   wallMaterial->SetMaterialAmbientAndDiffuse(Color4(0.7f, 0.55f, 0.55f));
   wallMaterial->SetMaterialSpecular(Color4(0.5f, 0.5f, 0.5f));
   wallMaterial->SetMaterialShininess(16.0f);

   // Ceiling should be white, moderately shiny
   PresentationNode* ceilingMaterial = new PresentationNode;
   ceilingMaterial->SetMaterialAmbientAndDiffuse(Color4(1.0f, 1.0f, 1.0f));
   ceilingMaterial->SetMaterialSpecular(Color4(0.9f, 0.9f, 0.9f));
   ceilingMaterial->SetMaterialShininess(64.0f);

   // Add floor and ceiling to the parent. Use convenience method to add material,
   // then presentation, then geometry.
   AddSubTree(parent, floorMaterial,   floorTransform,   unitSquare);
   AddSubTree(parent, ceilingMaterial, ceilingTransform, unitSquare);

   // Walls. We can group these all under a single presentation node.
   parent->AddChild(wallMaterial);
   wallMaterial->AddChild(backWallTransform);
   backWallTransform->AddChild(unitSquare);
   wallMaterial->AddChild(leftWallTransform);
   leftWallTransform->AddChild(unitSquare);
   wallMaterial->AddChild(rightWallTransform);
   rightWallTransform->AddChild(unitSquare);
   wallMaterial->AddChild(frontWallTransform);
   frontWallTransform->AddChild(unitSquare);
}
开发者ID:m-hogue,项目名称:JHU-Graphics,代码行数:76,代码来源:PhongShading.cpp


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