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


C++ Time::AsFloat方法代码示例

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


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

示例1: Voxelizer

void Voxelizer()
{
	std::cout << "Loading Model . . . ";
	// auto model = LoadObjModuleFromFile("data/sponza/sponza.obj");
	// auto model = LoadObjModuleFromFile("data/leather_chair/leather_chair.obj");
	auto model = LoadObjModuleFromFile("data/primitives/box.obj");
	std::cout << "DONE" << std::endl;

	std::cout << "Rasterizing . . . ";
	RasterData raster;
	raster.voxelSize = voxelSize;
	RasterizeModel(&raster, *model, Matrix44f(zero));
	std::cout << "DONE" << std::endl;

	std::cout << "Generating Sparce Map . . . ";
	SparceMap<SparceMapData, sparceMapSize> sparceMap;
	for (auto fragment : raster.fragments)
		SparceTreeInsertPoint(&sparceMap, sparceMapBox, fragment.position, sparceMapLevels);
	std::cout << "DONE" << std::endl;
	
	Vector3f center = Vector3f(zero);
	float dist = 10.0f;
	if (!raster.fragments.empty())
	{
		for (auto fragment : raster.fragments)
			center = center + fragment.position;
		center = center * (1.0f / raster.fragments.size());
		dist = 0.0f;
		for (auto fragment : raster.fragments)
			dist = Max(dist, Distance(center, fragment.position));
	}

	ProtoGL protoGL;
	protoGL.Initialize(ProtoGLDesc());

	OrbitalCamera camera(protoGL.GetCanvas());
	camera.SetPerspective(1.4f, 1.0f, sparceMapDimension * 2.0f);
	camera.SetCamera(center, Quaternionf(zero), dist * 2.0f);

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);

	TimeCounter counter;
	while (protoGL.Update())
	{
		Time deltaTime = counter.GetElapsed();

		camera.Update(deltaTime);
		camera.CommitToGL();

		glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		Time time = GetTime();
		Matrix44f objectTM = ToMatrix44(QuaternionAxisAngle(Vector3f(0.0f, 1.0f, 0.0f), time.AsFloat()*0.15f));
		
		raster.fragments.clear();
		SparceTreeClearData(&sparceMap);
		RasterizeModel(&raster, *model, objectTM);
		for (auto fragment : raster.fragments)
			SparceTreeInsertPoint(&sparceMap, sparceMapBox, fragment.position, sparceMapLevels);

		glPushMatrix();
		glMultMatrixf(&objectTM[0]);
		DrawModel(*model);
		glPopMatrix();
		DrawSparceMap(sparceMap, sparceMapBox);

		protoGL.Swap();
	}
}
开发者ID:filami,项目名称:vidf,代码行数:71,代码来源:voxelizer.cpp


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