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


C++ GeometryNode::set_material方法代码示例

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


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

示例1: spawnSubBranches

void Branch::spawnSubBranches(const int level, const double length, const double thickness)
{
  if (level == recursiveDepth) return;

  // Spawn subbranches (make more as we get smaller)
  int numBranches = rand(0.2, 0.8, (level == 0 ? 2 : level) * initialBranches);
  for (int i = 0; i < numBranches; i++) {
    add_child(new Branch("SubBranch", level + 1,
                         nextThickness(thickness, level),
                         nextLength(length, level)));
    totalBranches++;
  }

  // Tree branches seem to split in two at the ends so simulate that.

  add_child(new Branch("SplitBranch", level + 1, nextThickness(thickness, level), 
                       nextLength(length, level), length, -30.0, 0.0));
  add_child(new Branch("SplitBranch", level + 1, nextThickness(thickness, level), 
                       nextLength(length, level), length, 30.0, 0.0));
  // Two branches coming out of the top looks a little weird so add a sphere.
  Sphere* p_sphere = new Sphere();
  GeometryNode* sphere = new GeometryNode("BranchTop", p_sphere);
  sphere->set_material(&wood);

  sphere->translate(Vector3D(0.0, 0.0, length));
  sphere->scale(Vector3D(thickness, thickness, thickness));

  add_child(sphere);

  totalBranches += 3;
}
开发者ID:dzelemba,项目名称:Ray-Tracing-Project,代码行数:31,代码来源:tree.cpp

示例2: createGeometryNode

void Branch::createGeometryNode(const double length, const double thickness, const double upDist,
                                const double upAngle, const double zAngle)
{  
  Cylinder* c_branch= new Cylinder;
  GeometryNode* branch = new GeometryNode("TreeTrunk", c_branch);
  branch->set_material(&wood);

  this->rotate('z', zAngle);
  this->translate(Vector3D(0.0, 0.0, upDist));
  this->rotate('y', upAngle);
  branch->scale(Vector3D(thickness, thickness, length));

  add_child(branch);
}
开发者ID:dzelemba,项目名称:Ray-Tracing-Project,代码行数:14,代码来源:tree.cpp

示例3: SceneNode

Leaf::Leaf(const std::string& name, const double branchThickness, const double branchLength)
  : SceneNode(name)
{
  ImagePrimitive* i_leaf = new ImagePrimitive();
  GeometryNode* leaf = new GeometryNode("Leaf", i_leaf);
  leaf->set_material(&leafTexture);

  double upDist = rand(1.0/3.0, 1.0, branchLength);
  double zAngle = rand(0.0, 1.0, 360.0);

  double diagonalDist = branchThickness + sqrt(2.0) - 0.25;
  double xyDist = -diagonalDist * sqrt(2.0) / 2.0;

  leaf->rotate('z', zAngle); 
  leaf->translate(Vector3D(xyDist, xyDist, upDist));

  add_child(leaf);
}
开发者ID:dzelemba,项目名称:Ray-Tracing-Project,代码行数:18,代码来源:tree.cpp

示例4: gr_node_set_material_cmd

int gr_node_set_material_cmd(lua_State* L)
{
  GRLUA_DEBUG_CALL;
  
  gr_node_ud* selfdata = (gr_node_ud*)luaL_checkudata(L, 1, "gr.node");
  luaL_argcheck(L, selfdata != 0, 1, "Node expected");

  GeometryNode* self = dynamic_cast<GeometryNode*>(selfdata->node);

  luaL_argcheck(L, self != 0, 1, "Geometry node expected");
  
  gr_material_ud* matdata = (gr_material_ud*)luaL_checkudata(L, 2, "gr.material");
  luaL_argcheck(L, matdata != 0, 2, "Material expected");

  Material* material = matdata->material;

  self->set_material(material);

  return 0;
}
开发者ID:jemartti,项目名称:Puppeteer,代码行数:20,代码来源:scene_lua.cpp


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