现在的位置: 首页 > 综合 > 正文

chap6_1 Sphere Environmental mapping in OGRE

2013年11月19日 ⁄ 综合 ⁄ 共 2617字 ⁄ 字号 评论关闭

OGRE帮我们实现了一些环境映射其中包括了球形环境映射,我们只需要在material脚本里面修改相映参数就可以了,所以这篇并不是讲球形环境映射的原理,而讲如何利用OGRE的球形映射,为了了解球形环境映射,我会用DX写一个例子,敬请期待!微笑

 

 

/*------------------------------------------------------------
	main.cpp -- Achieve sphere environmental mapping in OGRE
						(c) Seamanj.2013/7/21
------------------------------------------------------------*/
//Phase1 : Add Framework
//Phase2 : Add ogrehead with spheremap material
#define Phase1 1
#define Phase2 1
#if Phase1
#include "ExampleApplication.h"
#include <windows.h>

class MyApplication : public ExampleApplication
{
public:
	MyApplication()
	{}
	~MyApplication()
	{}
protected:
	void createScene()
	{
#if Phase2
		Entity* ent = mSceneMgr->createEntity("Head","ogrehead.mesh");
		ent->setMaterialName("Examples/SphereMappedRustySteel");//知识点1
/*知识点1:球形环境映射材质
---------------------------------------------
来自ogre_src_v1-7-4\Samples\Media\materials\scripts\Examples.material文件
---------------------------------------------
material Examples/SphereMappedRustySteel
{
	technique
	{
		pass
		{
			texture_unit
			{
				texture RustySteel.jpg
			}

			texture_unit
			{
				texture spheremap.png
// 				colour_op_ex <operation> <source1>			(Advanced) Type of texturelayer
// 				<source2> [<manual_factor>]					blending; operation is one of
// 				[<manual_colour1>]							source1, source2, modulate,
// 				[<manual_colour2>]							modulate_x2, modulate_x4, add,
// 															add_signed, add_smooth, subtract,
// 															blend_diffuse_alpha,
// 															blend_texture_alpha,
// 															blend_current_alpha,
// 															blend_manual, dotproduct,
// 															blend_diffuse_color; source1 and
// 															source2 are one of src_current,
// 															src_texture, src_diffuse,
// 															src_specular, src_manual; values
// 															for manual_factor, manual_colour1,
// 															and manual_colour2 are dependent
// 															on operation, source1, and source2
// 															values.
				colour_op_ex add src_texture src_current
// 				colour_op_ <src_factor> <dest_factor>		Fallback texture blending to use
// 															multipass_fallback when multitexturing not available;
// 															src_factor and dest_factor
// 															values same as for scene_blend.
				colour_op_multipass_fallback one one
// 				env_map <off> | <spherical> |				Enable this texture layer as an
// 				<planar> | cubic_reflection |				environment map (default off).
// 				cubic_normal
				env_map spherical
			}
		}
	}
}

]*/
		mSceneMgr->getRootSceneNode()->attachObject(ent);
#endif
	}


};
INT WINAPI WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )
{
	MyApplication app;
	try
	{
		app.go();
	}
	catch( Exception& e)
	{
		MessageBoxA( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
	}
	return 0;
}
#endif

 

/*RustySteel.jpg

---------------------------------------------
来自ogre_src_v1-7-4\Samples\Media\materials\textures

---------------------------------------------

*/

 

 

/*spheremap.png

---------------------------------------------
来自ogre_src_v1-7-4\Samples\Media\materials\textures

---------------------------------------------

*/

 

 

最后运行结果如下:

抱歉!评论已关闭.