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


C++ TriMesh::fromPoly方法代码示例

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


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

示例1: main

int main (int argc, char **argv)
{  
  //Initialize GLUT
  initGlut(argc, argv);
  
  Kernel kernel;
  kernel.enableVerticalSync( false );
  renderer = kernel.getRenderer();
  printf( "Kernel loaded\n" );
  
  //Load shape model
  LoaderObj ldr;
  File f( "zekko.obj" );
  ldr.setUVMeshClass( Class( ETexMesh ));
  
  int start = GE::Time::GetTicks();
  ldr.loadFile( f.getPathName() );
  int end = GE::Time::GetTicks();
  printf( "Time: %d\n", end - start );
  
  PolyMesh *dmesh;
  uvmesh = (ETexMesh*) ldr.getFirstResource( Class(TexMesh) );
  dmesh = (PolyMesh*) ldr.getFirstResource( Class(PolyMesh) );
  zekko = (PolyMeshActor*) ldr.getFirstObject( Class(PolyMeshActor) );
  if (dmesh == NULL) return EXIT_FAILURE;
  if (uvmesh == NULL) return EXIT_FAILURE;
  if (zekko == NULL) return EXIT_FAILURE;
  
  //Check if UV mesh type correct
  printf( "uvmesh = %s\n", StringOf( ClassOf( zekko->getTexMesh() )));
  
  printf( "uvmesh %s ETexMesh\n",
          SafeCast( ETexMesh, zekko->getTexMesh() ) ?
          "IS" : "is NOT");
  
  printf( "uvmesh %s TexMesh\n",
          SafeCast( TexMesh, zekko->getTexMesh() ) ?
          "IS" : "is NOT");
  
  printf( "uvmesh %s Resource\n",
          SafeCast( Resource, zekko->getTexMesh() ) ?
          "IS" : "is NOT");
  
  printf( "uvmesh %s PolyMesh\n",
          SafeCast( PolyMesh, zekko->getTexMesh() ) ?
          "IS" : "is NOT");
  
  //Setup camera
  cam3D.translate( 0,35,-100 );
  cam3D.setCenter( center );
  //cam3D.setNearClipPlane(100.0f);
  //cam3D.setFarClipPlane(100000.0f);
  
  //Find model center
  findCenter();
  
  //Set half bunny green
  for (PolyMesh::FaceIter f(dmesh); !f.end(); ++f) {
    //f->smoothGroups = 0x1;
    if (f->firstHedge()->dstVertex()->point.y > center.y)
      dmesh->setMaterialID( *f, 1 ); }

  //Convert to static mesh
  //dmesh->updateNormals();
  smesh.fromPoly( dmesh, uvmesh );
  
  //Load texture image
  imgDiff.readFile( "texture.jpg", "" );
  
  //Create texture from image
  texDiff = new Texture;
  texDiff->fromImage( &imgDiff );
  
  //Load specularity image
  Image imgSpec;
  imgSpec.readFile( "specularity.jpg", "" );

  //Create specularity texture
  texSpec = new Texture();
  texSpec->fromImage(&imgSpec);
  
  //Create material using texture
  PhongMaterial mat;
  mat.setDiffuseTexture( texDiff );
  //mat.setSpecularityTexture( texSpec );
  mat.setDiffuseColor( Vector3( 1,0.0f,0.0f ));
  mat.setAmbientColor( Vector3( 0.2f,0.2f,0.2f ));
  mat.setSpecularity( 1.0f );
  mat.setGlossiness( 0.2f );
  
  PhongMaterial mat2;
  mat2.setDiffuseTexture( texDiff );
  //mat2.setSpecularityTexture( texSpec );
  mat2.setDiffuseColor( Vector3( 0.0f, 1.0f, 0.0f ));
  mat2.setAmbientColor( Vector3( 0.2f, 0.2f, 0.2f ));
  mat2.setSpecularity( 1.0f );
  mat2.setGlossiness( 0.2f );
  
  MultiMaterial mm;
  mm.setNumSubMaterials( 2 );
//.........这里部分代码省略.........
开发者ID:ileben,项目名称:GameEngine,代码行数:101,代码来源:TexPainter.cpp


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