OGER SDK研究之三 Demo_SkyPlane 天空面

 SkyPlane.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
        SkyPlane.h      天空面
    /brief
        Specialisation of OGRE's framework application to show the
        skyplane feature where a fixed constant-distance
        skyplane is displayed in the background.
  //加入一个天空面
*/

#include "ExampleApplication.h"

class SkyPlaneApplication : public ExampleApplication
{
public:
    SkyPlaneApplication() {}

protected:
    // Just override the mandatory create scene method
    void createScene(void)
    {
        // Set ambient light
  //设置环境光
        mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));

        // Define the required skyplane
  //面
        Plane plane;
        // 5000 world units from the camera
  //设置高度
        plane.d = 5000;
        // Above the camera, facing down
  //设置法向量
        plane.normal = -Vector3::UNIT_Y;
        // Create the plane 10000 units wide, tile the texture 3 times
  //由自定义面创建天空面。
        mSceneMgr->setSkyPlane(true, plane, "Examples/SpaceSkyPlane",10000,3);

        // Create a 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);

        // Also add a nice dragon in
  //由模型文件创建一个实体并加入场景
        Entity *ent = mSceneMgr->createEntity("dragon", "dragon.mesh");
        mSceneMgr->getRootSceneNode()->attachObject(ent);

 

    }

};

 

SkyPlane.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
        SkyPlane.cpp
    /brief
        Shows OGRE's skyplane feature where a fixed constant-distance
        skyplane is displayed in the background.
*/

#include "SkyPlane.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
    SkyPlaneApplication app;

    try {
        app.go();
    } catch( Ogre::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().c_str() << std::endl;
#endif
    }

    return 0;
}

#ifdef __cplusplus
}
#endif

你可能感兴趣的:(exception,object,REST,File,application,winapi)