EnvMapping.h
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2006 Torus Knot Software Ltd
Also see acknowledgements in Readme.html
You may use this sample code for anything you like, it is not covered by the
LGPL like the rest of the engine.
-----------------------------------------------------------------------------
*/
/**
/file
EnvMapping.cpp
/brief
Specialisation of OGRE's framework application to show the
environment mapping feature.
//环境映射(由程序可知,是否加载环境映射是在材质中)
material Examples/EnvMappedRustySteel
{
technique
{
pass
{
texture_unit
{
//纹理图片
texture RustySteel.jpg
}
texture_unit
{
//第二纹理
texture spheremap.png
//纹理混合
colour_op_ex add src_texture src_current
colour_op_multipass_fallback one one
//指定环境映射为球型的环境映射
env_map spherical
}
}
}
}
*/
#include "ExampleApplication.h"
class EnvMapApplication : public ExampleApplication
{
public:
EnvMapApplication() {}
protected:
// Just override the mandatory create scene method
void createScene(void)
{
// Set ambient light
// 设置环境光
mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
// Create a point light
// 创建一个点光源
Light* l = mSceneMgr->createLight("MainLight");
// Accept default settings: point light, white diffuse, just set position
// NB I could attach the light to a SceneNode if I wanted it to move automatically with
// other objects, but I don't
// 设置点光的位置
l->setPosition(20,80,50);
//由模型创建一个实体
Entity *ent = mSceneMgr->createEntity("head", "ogrehead.mesh");
// Set material loaded from Example.material
// 设置实体的材质名称
ent->setMaterialName("Examples/EnvMappedRustySteel");
// Add entity to the root scene node
//加入到场景
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
}
};
EnvMapping.cpp:
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2006 Torus Knot Software Ltd
Also see acknowledgements in Readme.html
You may use this sample code for anything you like, it is not covered by the
LGPL like the rest of the engine.
-----------------------------------------------------------------------------
*/
/**
/file
EnvMapping.cpp
/brief
Shows OGRE's environment mapping feature as well as the
blending modes available when using multiple texture layers
*/
#include "EnvMapping.h"
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
// Create application object
EnvMapApplication app;
try {
app.go();
} catch( Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
std::cerr << "An exception has occured: " << e.getFullDescription();
#endif
}
return 0;
}
#ifdef __cplusplus
}
#endif