chap6_1 Sphere Environmental mapping in OGRE

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

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

*/

 

 

最后运行结果如下:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值