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


C++ FaceSet::Add方法代码示例

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


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

示例1: CreateDome

  FaceSet* SkyDome::CreateDome(int horiRes, int vertRes, float texturePercentage, float domePercentage, float radius, Vector<3,float> center, ITextureResourcePtr texture) {
  	// COPYRIGHT NOTICE: Code in this method is based on code written by Anders la Cour-Harbo for the irrlicht engine
  
	if (domePercentage < 0.0)	domePercentage =- domePercentage;
	if (domePercentage > 2.0)	domePercentage = 2.0;

	float azimuth = 0.0;
	float azimuth_step = 2.0 * Math::PI / (float)horiRes;
	
	float elevation_step = domePercentage * Math::PI / 2.0 / (float)vertRes;

	const float tcV = (float)texturePercentage / (float)vertRes;
	for (int i = 0; i <= horiRes; i++)	{
		float elevation = Math::PI / 2.0;
		const float tcU = (float)i / (float)horiRes;
		const float sinA = sin(azimuth);
		const float cosA = cos(azimuth);
		for (int j = 0; j <= vertRes; j++) {
			const float cosEr = radius * cos(elevation);
			Vector<3,float> pos((cosEr * sinA),
								(radius * sin(elevation) + 50.0f),
								(cosEr * cosA));
			positions.push_back(pos);
			texCoords.push_back(Vector<2,float>(tcU, (float)j*tcV));

			elevation -= elevation_step;
		}
		azimuth += azimuth_step;
	}
	
	FaceSet* faces = new FaceSet();
	for (int i = 0; i < horiRes; i++) {
		faces->Add(CreateDomeFace(vertRes+2+(vertRes+1)*i, 1+(vertRes+1)*i, 0+(vertRes+1)*i, texture));

		for (int j = 1; j < vertRes; j++)	{
			faces->Add(CreateDomeFace(vertRes+2+(vertRes+1)*i+j, 1+(vertRes+1)*i+j, 0+(vertRes+1)*i+j, texture));
			faces->Add(CreateDomeFace(vertRes+1+(vertRes+1)*i+j, vertRes+2+(vertRes+1)*i+j, 0+(vertRes+1)*i+j, texture));
		}
	}
	
	positions.clear();
	texCoords.clear();
	
	return faces;
  }
开发者ID:OpenEngineDK,项目名称:extensions-Sky,代码行数:45,代码来源:SkyDome.cpp

示例2: SetupLight

void SetupLight(Config& config) {
    // Set up a light node
    PointLightNode* pln = config.setup.GetShadowLightNode();
    pln->active = true;

    //draw something at the pos of the light node
    FacePtr face1(new Face(Vector<3, float>(0,0,0), Vector<3, float>(-10,0,10),
                        Vector<3, float>(-10,0,-10), Vector<3, float>(0,1,0),
                        Vector<3, float>(0,1,0), Vector<3, float>(0,1,0)));
    FacePtr face2(new Face(Vector<3, float>(0,0,0), Vector<3, float>(10,0,-10),
                        Vector<3, float>(10,0,10), Vector<3, float>(0,1,0),
                        Vector<3, float>(0,1,0), Vector<3, float>(0,1,0)));


    Vector<4,float> color = Vector<4,float>(1.0,0.0,0.0,0.0);

    face1->colr[0] = color;
    face1->colr[1] = color;
    face1->colr[2] = color;
    face2->colr[0] = color;
    face2->colr[1] = color;
    face2->colr[2] = color;

    FaceSet* faceSet = new FaceSet();
    faceSet->Add(face1);
    faceSet->Add(face2);
    GeometryNode* geom = new GeometryNode(faceSet);
    TransformationNode* light_geom_lift = new TransformationNode();
    light_geom_lift->SetPosition(Vector<3, float>(0, 10, 0));

    light_geom_lift->AddNode(geom);    

    pln->AddNode(light_geom_lift);

    // Attach light node
    TransformationNode* light_tran = new TransformationNode();
    light_tran->SetPosition(Vector<3, float>(0, 100, 200));
        light_tran->AddNode(pln);
    config.lightTrans = light_tran;

    LightRenderer* lr = new LightRenderer(*config.camera);
    config.setup.GetRenderer().InitializeEvent().Attach(*lr);
    config.setup.GetRenderer().PreProcessEvent().Attach(*lr);
    config.setup.GetRenderer().DeinitializeEvent().Attach(*lr);

    RenderStateNode* rsn = new RenderStateNode();
    rsn->EnableOption(RenderStateNode::LIGHTING);
    config.renderingScene = rsn;
}
开发者ID:OpenEngineDK,项目名称:projects-ShadowDemo,代码行数:49,代码来源:main.cpp


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