ogre 模型读入 和 产生 阴影

#include "ExampleApplication.h"
class MyApplication : public ExampleApplication
{
public:
 MyApplication() {
 }
 ~MyApplication() {  }
protected:
 // Just override the mandatory create scene method
  virtual void createCamera( void )
  { 
          mCamera = mSceneMgr->createCamera("playerCam");
    mCamera->setPosition(Vector3( 0, 100,500));
    mCamera->lookAt(Vector3( 0, 0, 0));
    mCamera->setNearClipDistance(50);
   
  }
  virtual void createViewports( void )
  {
   Viewport *vp = mWindow->addViewport(mCamera);
   vp->setBackgroundColour(ColourValue(0,0,0));
   mCamera->setAspectRatio(Real(vp->getActualWidth())/Real(vp->getActualHeight()));
  }
 void createScene(void)
 {
  
  Entity *ent;
  Light *light;

  mSceneMgr->setAmbientLight( ColourValue( 0, 0, 0 ) );
  mSceneMgr->setShadowTechnique( SHADOWTYPE_STENCIL_ADDITIVE );

  ent = mSceneMgr->createEntity("Ninja", "ninja.mesh");
  ent->setCastShadows(true);
  mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);

  Plane plane(Vector3::UNIT_Y, 0);

  MeshManager::getSingleton().createPlane("ground",
   ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
   1500,1500,20,20,true,1,5,5,Vector3::UNIT_Z);

  ent = mSceneMgr->createEntity("GroundEntity", "ground");
  mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);

  ent->setMaterialName("Examples/Rockwall");
  ent->setCastShadows(false);

  light = mSceneMgr->createLight("Light1");
  light->setType(Light::LT_POINT);
  light->setPosition(Vector3(0, 150, 250));

  light->setDiffuseColour(1.0, 0.0, 0.0);
  light->setSpecularColour(1.0, 0.0, 0.0);

  light = mSceneMgr->createLight("Light3");
  light->setType(Light::LT_DIRECTIONAL);
  light->setDiffuseColour(ColourValue(.25, .25, 0));
  light->setSpecularColour(ColourValue(.25, .25, 0));

  light->setDirection(Vector3( 0, -1, 1 ));

  light = mSceneMgr->createLight("Light2");
  light->setType(Light::LT_SPOTLIGHT);
  light->setDiffuseColour(0, 0, 1.0);
  light->setSpecularColour(0, 0, 1.0);

  light->setDirection(-1, -1, 0);
  light->setPosition(Vector3(300, 300, 0));

  light->setSpotlightRange(Degree(35), Degree(50));
 }
};
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif
#ifdef __cplusplus 1
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
  MyApplication  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

 



代码引用:文档:教程:中级教程:中级教程二

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值