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


C++ TransformPtr::world方法代码示例

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


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

示例1: ProcessEntities

void GuiMeshRender::ProcessEntities(const EntityMap &entities) {

	if (entities.empty()) {
		//printf("Warning: GuiMeshRender: Entity list is empty\n");
		return;
	}

	EntityMap::const_iterator it, ite;

	GuiMeshPtr mesh;
	TransformPtr transform;

	mat4 model, view, projection, model_view, mvp;
	mat3 normal;

	// warning: make sure the values here are all floats
	projection = glm::ortho(0.0f, 800.0f, 600.0f, 0.0f, -1.0f, 1.0f);

	for (it = entities.begin(), ite = entities.end(); it != ite; ++it) {
		mesh = gui_mesh_mapper_(it->second);
		transform = transform_mapper_(it->second);

		model = transform->world();
		model_view = model;				// camera does not need to effect this
		mvp = projection * model_view;
		normal = inverse(transpose(mat3(model_view)));

		shared_ptr<BasicMaterial> material = boost::dynamic_pointer_cast<BasicMaterial>(mesh->material);

		vec4 light_pos = material->light_position_;

		// hack to have light move with world
		// todo: implement light as entity
		material->light_position_ = model_view * light_pos;

		// do things like setup colors and lights
		// and attach shader program
		mesh->material->PreRender();

		material->light_position_ = light_pos;

		// push matrices up
		mesh->material->PushMatrices(model_view, projection, mvp, normal);

		// call draw
		mesh->geometry->Draw();

		// let go of shader program
		mesh->material->PostRender();
	}
}
开发者ID:tylorr,项目名称:Minigolf-Engine,代码行数:51,代码来源:gui_mesh_render.cpp


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