OGER SDK研究之二 Demo_EnvMapping 环境映射

 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

火云洞红孩儿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值