OGRESceneMgrView.cpp
资源名称:3dwind2.0.rar [点击查看]
上传用户:xhbjoy
上传日期:2014-10-07
资源大小:38068k
文件大小:44k
源码类别:
游戏引擎
开发平台:
Visual C++
- // OGRESceneMgrView.cpp : COGRESceneMgrView 类的实现
- //
- #include "stdafx.h"
- #include "OGRESceneMgr.h"
- #include "OGRESceneMgrDoc.h"
- #include "OGRESceneMgrView.h"
- #include "ImportParticle.h"
- #include "ImportParticle2.h"
- #include "SetTetureDlg.h"
- #include "OgreString.h"
- #include "ExampleFrameListener.h"
- #include ".ogrescenemgrview.h"
- #include "OgreStringConverter.h"
- #include "tinyxml.h"
- //#include <stdio.h>
- #include "fromindextoname.h"
- #include "indextoparticlename.h"
- #include "importscenemesh.h"
- #include "importsceneparticle.h"
- #include "SkyStyleChoose.h"
- #include "movemeshdlg.h"
- #include "OISMouse.h"
- #include "rotatesetdlg.h"
- #include "SkyPlaneDlg.h"
- #include "SkyBoxDlg.h"
- #include "SkyDomeDlg.h"
- #include "setshadowtechnich.h"
- #include "scalesetdlg.h"
- #include "OgreInstancedGeometry.h"
- StringUtil strutil;
- SkyBoxDlg skyboxdlgv;
- SkyDomeDlg skydomedlgv;
- SkyPlaneDlg skyplanedlgv;
- static Root *mRoot;
- static RenderWindow* mWindow;
- static SceneManager* mSceneMgr;
- static Camera* mCamera;
- bool btramove=false;
- bool bratate=false;
- bool bscaled=false;
- bool bimportworld=false;
- SceneNode* ballnode;
- Entity* ballent;
- RaySceneQuery* rsq = 0;
- StringConverter *stingconverter;
- SkyStyleChoose skystylechoosedlg;
- bool bimportmesh=false;
- bool bimportscene=false;
- static SceneNode* currentnode;
- static SceneNode* previousnode;
- CString meshfile;
- CPtrArray meshfileptr;
- CPtrArray parfileptr;
- CPtrArray importmeshptr;
- CPtrArray importparticleptr;
- MoveMeshDlg movemeshdlg;
- SceneNode* particlenode;
- SceneNode* meshnode;
- SceneNode*scenerootcc;
- Entity* meshentity;
- Entity *Particleaxesnode;
- char *str;
- CImportParticle2 ipdlg;
- RotateSetDlg rotatesetdlg;
- ScaleSetDlg scalesetddlg;
- float scalddefw=0;
- float scalnowset;
- float scalpreset;
- CSetTetureDlg settexturedlg;
- //CImportParticle2 *IMPORTPARTICLE;
- CString particlename;
- static int meshnumber=0;
- static int particlenumber=0;
- static int scenenumber=0;
- int scenemeshimportci=0;
- int scenepartci=0;
- bool bsetskyplane=false;
- bool bsetskybox=false;
- bool bsetskydome=false;
- bool bsetskyall=false;
- bool bsetshadowtech=false;
- Plane skyplane;
- float rcolommm,gcolommm,bcolommm;
- bool bsetfog=false;
- SetShadowTechnich setshadowtecdlg;
- static int mbrnum=0;
- SceneNode *axesXYZ;
- SceneNode *axesX;
- SceneNode *axesY;
- SceneNode *axesZ;
- SceneNode *axesarrayX;
- SceneNode *axesdownX;
- SceneNode *axesarrayY;
- SceneNode *axesdownY;
- SceneNode *axesarrayZ;
- SceneNode *axesdownZ;
- CString worldgemotry;
- //SceneNode *particleaxesnode;
- Vector3 axesshow;
- bool bmovecurent=true;
- static bool bgetmovenode=true;
- SceneNode *movenodeccc;
- Entity *axecolor;
- Entity *eneaxesarrayX;
- Entity *eneaxesarrayY;
- Entity *eneaxesarrayZ;
- Entity *ent;
- SceneNode *MOVENODE;
- bool wejwjw=true;
- Vector3 prexxxnode;
- Vector3 nowxxxnode;
- Vector3 changexxx;
- Vector3 endnodexxx;
- Vector3 statnodex;
- float movebuchang;
- bool bmrsX=false;
- bool bmrsY=false;
- bool bmrsZ=false;
- bool XYZscale=true;
- float forward=1;
- float rorateangle;
- bool bAxesXYZ=true;
- // OIS::MouseListener moulis;
- // Event handler to add ability to alter curvature
- class TerrainFrameListener : public ExampleFrameListener
- {
- public:
- SceneManager* mSceneMgr;
- RenderWindow* win;
- public:
- TerrainFrameListener(RenderWindow* win, Camera* cam,SceneManager* mSceneMgr)
- : ExampleFrameListener(win, cam)
- {this->mSceneMgr=mSceneMgr;
- this->win=win;
- }
- bool frameStarted(const FrameEvent& evt)
- {
- if( ExampleFrameListener::frameStarted(evt) == false )
- return false;
- if(bsetskyall){
- if(bsetskyplane){
- skyplane.d =skyplanedlgv.skyplaneheigh;
- skyplane.normal = -Vector3::UNIT_Y;
- CString skyplanema;
- skyplanema=skyplanedlgv.skyplanemarterial;
- if(skyplane.d==0) skyplane.d=5000;
- mSceneMgr->setSkyPlane(true, skyplane,skyplanema.GetBuffer(skyplanema.GetLength()),skyplanedlgv.skyplanedd,3);
- }
- else
- if(bsetskybox){
- CString skybmaterial;
- skybmaterial=skyboxdlgv.skyboxmater;
- mSceneMgr->setSkyBox(true,skybmaterial.GetBuffer(skybmaterial.GetLength()), 5000);
- }
- else
- if(bsetskydome){
- CString skdomemate;
- skdomemate=skydomedlgv.skydomemater;
- mSceneMgr->setSkyDome(true,skdomemate.GetBuffer(skdomemate.GetLength()));
- }
- bsetskyall=false;
- }
- if(bsetfog){
- ColourValue fadeColour(rcolommm/255,gcolommm/255,bcolommm/255);
- mSceneMgr->setFog( FOG_EXP2, fadeColour, .001, 500, 1000);
- win->getViewport(0)->setBackgroundColour(fadeColour);
- bsetfog=false;
- bsetfog=false;
- }
- if(bsetshadowtech){
- if(setshadowtecdlg.shadowtecenshu==0)
- mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE);
- else
- if(setshadowtecdlg.shadowtecenshu==1)
- mSceneMgr->setShadowTechnique(SHADOWDETAILTYPE_ADDITIVE);
- else
- if(setshadowtecdlg.shadowtecenshu==2)
- mSceneMgr->setShadowTechnique(SHADOWDETAILTYPE_MODULATIVE);
- else
- if(setshadowtecdlg.shadowtecenshu==3)
- mSceneMgr->setShadowTechnique(SHADOWDETAILTYPE_INTEGRATED);
- else
- if(setshadowtecdlg.shadowtecenshu==4)
- mSceneMgr->setShadowTechnique(SHADOWDETAILTYPE_STENCIL);
- else
- if(setshadowtecdlg.shadowtecenshu==5)
- mSceneMgr->setShadowTechnique(SHADOWDETAILTYPE_TEXTURE);
- else
- if(setshadowtecdlg.shadowtecenshu==6)
- mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_MODULATIVE);
- else
- if(setshadowtecdlg.shadowtecenshu==7)
- mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
- else
- if(setshadowtecdlg.shadowtecenshu==8)
- mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE);
- else
- if(setshadowtecdlg.shadowtecenshu==9)
- mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_ADDITIVE);
- else
- if(setshadowtecdlg.shadowtecenshu==10)
- mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED);
- else
- if(setshadowtecdlg.shadowtecenshu==11)
- mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED);
- bsetshadowtech=false;
- }
- if(mKeyboard->isKeyDown(OIS::KC_X)){
- if(bAxesXYZ)
- {bmrsX=true;
- bmrsY=false;
- bmrsZ=false;
- XYZscale=false;}}
- if(mKeyboard->isKeyDown(OIS::KC_Y)){
- if(bAxesXYZ){
- bmrsX=false;
- bmrsY=true;
- bmrsZ=false;
- XYZscale=false;
- bAxesXYZ=false; }
- }
- if(mKeyboard->isKeyDown(OIS::KC_Z)){
- if(bAxesXYZ){
- bmrsX=false;
- bmrsY=false;
- bmrsZ=true;
- XYZscale=false;
- bAxesXYZ=false; }}
- if(mKeyboard->isKeyDown(OIS::KC_F4)){
- if(bAxesXYZ){
- bmrsX=false;
- bmrsY=false;
- bmrsZ=false;
- XYZscale=true;
- bAxesXYZ=false; }}
- if(mKeyboard->isKeyDown(OIS::KC_UP)){forward=1;}
- if(mKeyboard->isKeyDown(OIS::KC_DOWN)){forward=-1;}
- return true;
- }
- bool frameEnded(const FrameEvent& evt)
- {
- if(ExampleFrameListener::frameEnded(evt)==false)
- return false;
- rsq->setRay(mCamera->getCameraToViewportRay(0.5, 0.5));
- rsq->setSortByDistance(true);
- RaySceneQueryResult& rsqResult = rsq->execute();
- RaySceneQueryResult::iterator ri = rsqResult.begin();
- if (ri != rsqResult.end())
- {
- RaySceneQueryResultEntry& res = *ri;
- if(mMouse->getMouseState().buttonDown(OIS::MB_Left)){
- previousnode=currentnode;
- currentnode=ri->movable->getParentSceneNode();
- if(currentnode==axesarrayX||currentnode==axesarrayY||currentnode==axesarrayZ)
- {
- eneaxesarrayX->setMaterialName("Examples/DarkMaterial");
- eneaxesarrayY->setMaterialName("Examples/DarkMaterial");
- eneaxesarrayZ->setMaterialName("Examples/DarkMaterial");
- axecolor=(Entity *)(currentnode->getAttachedObject(0));
- axecolor->setMaterialName("Examples/EnvMappedRustySteel");
- }
- else
- { previousnode->showBoundingBox(false);
- currentnode->showBoundingBox(true);
- axecolor->setMaterialName("Examples/DarkMaterial");
- }
- }
- ballnode->setPosition(rsq->getRay().getPoint(res.distance));
- if(mKeyboard->isKeyDown(OIS::KC_F1)){
- ballnode->setScale(0.01,0.01,0.01);}
- if(mKeyboard->isKeyDown(OIS::KC_F2)){
- ballnode->setScale(0.1,0.1,0.1);}
- if(bimportmesh){
- if(mMouse->getMouseState().buttonDown(OIS::MB_Left)){
- meshnumber++;
- String str2;
- str2=str;
- meshentity=mSceneMgr->createEntity("MESH"+stingconverter->toString(meshnumber),str2);
- meshnode=mSceneMgr->getRootSceneNode()->createChildSceneNode("MESHNODE"+stingconverter->toString(meshnumber));
- meshnode->setPosition(rsq->getRay().getPoint(res.distance));
- meshnode->attachObject(meshentity);
- FromIndexToName *frtona= new FromIndexToName(meshnumber,str,meshfile);
- meshfileptr.Add(frtona);
- bimportmesh=false;
- }
- }
- if(ipdlg.bimportpaticle)
- {
- if(mMouse->getMouseState().buttonDown(OIS::MB_Left))
- {
- particlenumber++;
- static String str3;
- str3=ipdlg.particlenamechar;
- Particleaxesnode=mSceneMgr->createEntity("AXESDEJI"+stingconverter->toString(particlenumber),"axes.mesh");
- particlenode=mSceneMgr->getRootSceneNode()->createChildSceneNode("PARTICLENODE"+stingconverter->toString(particlenumber));
- particlenode->setPosition(rsq->getRay().getPoint(res.distance));
- particlenode->attachObject(mSceneMgr->createParticleSystem("PARTICLE"+stingconverter->toString(particlenumber),str3 ));
- particlenode->attachObject(Particleaxesnode);
- IndexToParticleName *indextoparticle=new IndexToParticleName(ipdlg.importpa);
- parfileptr.Add(indextoparticle);
- ipdlg.bimportpaticle=false;
- }
- }
- if(bimportscene)
- {
- if(mMouse->getMouseState().buttonDown(OIS::MB_Left))
- {
- scenenumber++;
- scenerootcc=mSceneMgr->getRootSceneNode()->createChildSceneNode("SCENEIMORTNODE"+stingconverter->toString(scenenumber));
- scenerootcc->setPosition(rsq->getRay().getPoint(res.distance));
- Vector3 ssss=rsq->getRay().getPoint(res.distance);
- for(static int ccc=0;ccc<importmeshptr.GetSize();ccc++){
- meshnumber++;
- CString meshfilefff;
- meshfilefff=((ImportSceneMesh*)importmeshptr.GetAt(ccc))->meshfilenameddd;
- String meshfileggg=meshfilefff.GetBuffer(meshfilefff.GetLength());
- meshentity=mSceneMgr->createEntity("MESH"+stingconverter->toString(meshnumber),meshfileggg);
- meshnode=scenerootcc->createChildSceneNode("MESHNODE"+stingconverter->toString(meshnumber));
- meshnode->attachObject(meshentity);
- meshnode->translate(((ImportSceneMesh*)importmeshptr.GetAt(ccc))->pxddd,((ImportSceneMesh*)importmeshptr.GetAt(ccc))->pyddd,((ImportSceneMesh*)importmeshptr.GetAt(ccc))->pzddd);
- Real jiaopitch=((ImportSceneMesh*)importmeshptr.GetAt(ccc))->pitchddd;
- Radian radipitch(jiaopitch);
- meshnode->pitch(radipitch);
- Real jiaoroll=((ImportSceneMesh*)importmeshptr.GetAt(ccc))->pitchddd;
- Radian radiroll(jiaoroll);
- meshnode->roll(radiroll);
- Real jiaoyaw=((ImportSceneMesh*)importmeshptr.GetAt(ccc))->yawddd;
- Radian radiyaw(jiaoyaw);
- meshnode->yaw(radiyaw);
- meshnode->scale(((ImportSceneMesh*)importmeshptr.GetAt(ccc))->scalex,((ImportSceneMesh*)importmeshptr.GetAt(ccc))->scaley,((ImportSceneMesh*)importmeshptr.GetAt(ccc))->scalez);
- FromIndexToName *frtona= new FromIndexToName(1,"",meshfilefff);
- meshfileptr.Add(frtona);
- }
- for(static int eee=0;eee<importparticleptr.GetSize();eee++)
- {
- particlenumber++;
- CString parfilefff;
- Particleaxesnode=mSceneMgr->createEntity("AXESDEJI"+stingconverter->toString(particlenumber),"axes.mesh");
- parfilefff=((ImportSceneParticle*)importparticleptr.GetAt(eee))->particlefilenameddd;
- String particlefileggg=parfilefff.GetBuffer(parfilefff.GetLength());
- particlenode=scenerootcc->createChildSceneNode("PARTICLENODE"+stingconverter->toString(particlenumber));
- particlenode->attachObject(mSceneMgr->createParticleSystem("PARTICLE"+stingconverter->toString(particlenumber),particlefileggg));
- particlenode->attachObject(Particleaxesnode);
- particlenode->translate(((ImportSceneParticle*)importparticleptr.GetAt(eee))->pxddd,((ImportSceneMesh*)importmeshptr.GetAt(eee))->pyddd,((ImportSceneMesh*)importmeshptr.GetAt(eee))->pzddd);
- Real jiaopitch=((ImportSceneParticle*)importparticleptr.GetAt(eee))->pitchddd;
- Radian radipitch(jiaopitch);
- particlenode->pitch(radipitch);
- Real jiaoroll=((ImportSceneParticle*)importparticleptr.GetAt(eee))->rollddd;
- Radian radiroll(jiaoroll);
- particlenode->roll(radiroll);
- Real jiaoyaw=((ImportSceneParticle*)importparticleptr.GetAt(eee))->yawddd;
- Radian radiyaw(jiaoyaw);
- particlenode->yaw(radiyaw);
- particlenode->scale(((ImportSceneParticle*)importparticleptr.GetAt(eee))->scalex,((ImportSceneParticle*)importparticleptr.GetAt(eee))->scaley,((ImportSceneParticle*)importparticleptr.GetAt(eee))->scalez);
- // particlenode->showBoundingBox(true);
- IndexToParticleName *indextoparticle=new IndexToParticleName(parfilefff);
- parfileptr.Add(indextoparticle);
- }
- bimportscene=false;
- }
- }
- if(settexturedlg.getbimporttexture()){
- static String stringtru;
- stringtru=settexturedlg.texturename;
- mSceneMgr->getEntity(currentnode->getAttachedObject(0)->getName())->setMaterialName(stringtru);
- settexturedlg.setbolfase();
- }
- if(bimportworld){
- char *worldg;
- worldg=worldgemotry.GetBuffer(worldgemotry.GetLength());
- std::string terrain_cfg(worldg);
- mSceneMgr -> setWorldGeometry( terrain_cfg );
- bimportworld=false;
- }
- if(btramove){
- if(mKeyboard->isKeyDown(OIS::KC_X))
- movenodeccc->translate(forward,0,0, Node::TransformSpace::TS_WORLD);
- else
- if(mKeyboard->isKeyDown(OIS::KC_Y))
- movenodeccc->translate(0,forward,0, Node::TransformSpace::TS_WORLD);
- else
- if(mKeyboard->isKeyDown(OIS::KC_Z))
- movenodeccc->translate(0,0,forward, Node::TransformSpace::TS_WORLD);
- }
- if(bratate){
- if(mKeyboard->isKeyDown(OIS::KC_X))
- movenodeccc->pitch(Degree(forward),Node::TransformSpace::TS_WORLD);
- else
- if(mKeyboard->isKeyDown(OIS::KC_Y))
- movenodeccc->yaw(Degree(forward),Node::TransformSpace::TS_WORLD);
- else
- if(mKeyboard->isKeyDown(OIS::KC_Z))
- movenodeccc->roll(Degree(forward),Node::TransformSpace::TS_WORLD);
- }
- if(bscaled){
- /* if(forward==1) scalnowset*=scalddefw;
- else scalnowset/=scalddefw;*/
- if(bmrsX)
- {
- if(mKeyboard->isKeyDown(OIS::KC_X)){
- // if(forward==-1) scalddefw
- movenodeccc->scale(scalddefw,1,1);
- }
- }else
- if(bmrsY)
- { if(mKeyboard->isKeyDown(OIS::KC_Y))
- movenodeccc->scale(1,scalddefw,1);
- // Vector3 wordscale=movenodeccc->getScale();
- // float scaljgwe;
- // if(forward==-1) scalnowset=1/scalnowset;
- //scaljgwe= scalnowset*(wordscale.x);
- // else scaljgwe= 1/(scaljgwe= scalnowset*(wordscale.x));
- // movenodeccc->scale(wordscale.x,scalnowset*(wordscale.y),wordscale.z);}
- }else
- if(bmrsZ)
- { if(mKeyboard->isKeyDown(OIS::KC_Z))
- movenodeccc->scale(1,1,scalddefw);
- // Vector3 wordscale=movenodeccc->getScale();
- // if(forward==-1) scalnowset=1/scalnowset;
- // movenodeccc->scale(wordscale.x,wordscale.y,scalnowset*(wordscale.z));}
- }else
- if(XYZscale){
- if(mKeyboard->isKeyDown(OIS::KC_F4))
- movenodeccc->scale(scalddefw,scalddefw,scalddefw);
- // Vector3 wordscale=movenodeccc->getScale();
- // if(forward==-1) scalnowset=1/scalnowset;
- // movenodeccc->scale(scalnowset*(wordscale.x),scalnowset*(wordscale.y),scalnowset*(wordscale.z));}
- }
- // scalpreset=scalnowset;
- }
- }
- return true;
- }
- };
- using namespace Ogre;
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- // COGRESceneMgrView
- IMPLEMENT_DYNCREATE(COGRESceneMgrView, CView)
- BEGIN_MESSAGE_MAP(COGRESceneMgrView, CView)
- // 标准打印命令
- ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
- ON_COMMAND(ID_32785, OnImportMesh)
- ON_COMMAND(ID_Menu32786, OnImportParticle)
- ON_COMMAND(ID_32787, OnImportScene)
- ON_COMMAND(ID_32792, OnSetTexture)
- ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedImportParticle)
- ON_COMMAND(ID_FILE_SAVE, OnFileSave)
- ON_COMMAND(ID_32800, OnSetSky)
- ON_COMMAND(ID_32802, OnSetFogMenu)
- ON_COMMAND(ID_32803, OnSetShadowMenu)
- ON_COMMAND(ID_32796, OnTranslateMove)
- ON_COMMAND(ID_32798, OnTotateSce)
- ON_COMMAND(ID_32797, OnScaleScene)
- ON_COMMAND(ID_32795, OnDeleteSCENEMeshpa)
- ON_COMMAND(ID_32808, OnImportWorldGemotry)
- END_MESSAGE_MAP()
- // COGRESceneMgrView 构造/析构
- /* CEGUI::OgreCEGUIRenderer* mGUIRenderer;
- CEGUI::System* mGUISystem;
- */
- TerrainFrameListener* mFrameListener;
- COGRESceneMgrView::COGRESceneMgrView()
- {
- // TODO: 在此处添加构造代码
- mRoot=0;
- }
- COGRESceneMgrView::~COGRESceneMgrView()
- {
- delete rsq;
- delete mRoot;
- }
- BOOL COGRESceneMgrView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
- // 样式
- return CView::PreCreateWindow(cs);
- }
- // COGRESceneMgrView 绘制
- void COGRESceneMgrView::OnDraw(CDC* /*pDC*/)
- {
- COGRESceneMgrDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if (!pDoc)
- return;
- // TODO: 在此处为本机数据添加绘制代码
- static bool once = true;
- // TODO: 在此处为本机数据添加绘制代码
- if(once)
- {
- once=false;
- //mRoot =((COGRESceneMgrApp*)AfxGetApp())->GetOgreRoot();
- mRoot= new Root();
- ConfigFile cf;
- cf.load("resources.cfg");
- // Go through all sections & settings in the file
- ConfigFile::SectionIterator seci = cf.getSectionIterator();
- String secName, typeName, archName;
- while (seci.hasMoreElements())
- {
- secName = seci.peekNextKey();
- ConfigFile::SettingsMultiMap *settings = seci.getNext();
- ConfigFile::SettingsMultiMap::iterator i;
- for (i = settings->begin(); i != settings->end(); ++i)
- {
- typeName = i->first;
- archName = i->second;
- ResourceGroupManager::getSingleton().addResourceLocation(
- archName, typeName, secName);
- }
- }
- RenderSystemList* rl = Root::getSingleton().getAvailableRenderers();
- //D3D9RenderSystem
- D3D9RenderSystem* rsys = NULL;
- RenderSystemList::iterator it = rl->begin();
- while( it != rl->end() )
- {
- Ogre::String rName = (*it)->getName();
- if (rName == "Direct3D9 Rendering Subsystem")
- break;
- it++;
- }
- rsys=(D3D9RenderSystem*)(&it);
- //mRoot->setRenderSystem( rsys );
- if(mRoot->showConfigDialog())
- {
- // If returned true, user clicked OK so initialise
- // Here we choose to let the system create a default rendering window by passing 'true'
- mWindow = mRoot->initialise(true);
- }
- mSceneMgr = mRoot->createSceneManager("TerrainSceneManager");
- // Create the camera
- mCamera = mSceneMgr->createCamera("PlayerCam");
- // Position it at 500 in Z direction
- mCamera->setPosition(Vector3(0,0,500));
- // Look back along -Z
- mCamera->lookAt(Vector3(0,0,-300));
- mCamera->setNearClipDistance(5);
- //mCamera->setFarClipDistance( 1000 );
- // Create one viewport, entire window
- Viewport* vp = mWindow->addViewport(mCamera);
- vp->setBackgroundColour(ColourValue(0,0,0));
- // Alter the camera aspect ratio to match the viewport
- mCamera->setAspectRatio(
- Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
- TextureManager::getSingleton().setDefaultNumMipmaps(5);
- ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
- mCamera->setQueryFlags(0);
- //createScene();
- 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* targetEnt = mSceneMgr->createEntity("testray", "sphere.mesh");
- MaterialPtr mat = MaterialManager::getSingleton().create("targeter",
- ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
- Pass* pass = mat->getTechnique(0)->getPass(0);
- TextureUnitState* tex = pass->createTextureUnitState();
- tex->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT,
- ColourValue::Red);
- pass->setLightingEnabled(false);
- pass->setSceneBlending(SBT_ADD);
- pass->setDepthWriteEnabled(false);
- targetEnt->setMaterialName("targeter");
- targetEnt->setCastShadows(false);
- targetEnt->setQueryFlags(0);
- ent = mSceneMgr->createEntity("head", "axes.mesh");
- ballent=mSceneMgr->createEntity("ball",mSceneMgr->PT_SPHERE);
- //ballent->setMaterialName("Examples/TextureEffect1");
- //ballent->setCastShadows(false);
- ballent->setQueryFlags(0);
- // Set material loaded from Example.material
- // ent->setMaterialName("Examples/EnvMappedRustySteel");
- // ent->setMaterialName("Examples/EveningSkyBox");
- // Add entity to the root scene node
- SceneNode *nodehead=mSceneMgr->getRootSceneNode()->createChildSceneNode();
- nodehead->attachObject(ent);
- currentnode=nodehead;
- // nodehead->setScale(10,10,10);
- ballnode=mSceneMgr->getRootSceneNode()->createChildSceneNode("ballnodef");
- ballnode->attachObject(targetEnt);
- ballnode->setScale(0.1,0.1,0.1);
- rsq = mSceneMgr->createRayQuery(Ray(mCamera->getPosition(), mCamera->getDirection()));
- rsq->setSortByDistance(true, 1);
- // rsq->setWorldFragmentType(SceneQuery::WFT_SINGLE_INTERSECTION);
- Plane plane;
- plane.normal = Vector3::UNIT_Y;
- plane.d = 100;
- MeshManager::getSingleton().createPlane("Myplane",
- ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
- 1500,1500,20,20,true,1,60,60,Vector3::UNIT_Z);
- Entity* pPlaneEnt = mSceneMgr->createEntity( "plane", "Myplane" );
- axecolor=pPlaneEnt;
- pPlaneEnt->setMaterialName("Examples/Rockwall");
- //pPlaneEnt->setCastShadows(false);
- mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(0,99,0))->attachObject(pPlaneEnt);
- eneaxesarrayX = mSceneMgr->createEntity("ENTAXESARRAYX", "Pine1.mesh");
- //eneaxesarrayX->setQueryFlags(0);
- Entity *entaxesdownX=mSceneMgr->createEntity("ENTAXESDOWNX","pilon.mesh");
- entaxesdownX->setQueryFlags(0);
- eneaxesarrayX->setMaterialName("Examples/DarkMaterial");
- eneaxesarrayY = mSceneMgr->createEntity("ENTAXESARRAYY", "Pine1.mesh");
- Entity *entaxesdownY =mSceneMgr->createEntity("ENTAXESDOWNY","pilon.mesh");
- eneaxesarrayY->setMaterialName("Examples/DarkMaterial");
- entaxesdownY->setQueryFlags(0);
- eneaxesarrayZ = mSceneMgr->createEntity("ENTAXESARRAYZ", "Pine1.mesh");
- eneaxesarrayZ->setMaterialName("Examples/DarkMaterial");
- Entity *entaxesdownZ =mSceneMgr->createEntity("ENTAXESDOWNZ","pilon.mesh");
- entaxesdownZ->setQueryFlags(0);
- axesXYZ=mSceneMgr->getRootSceneNode()->createChildSceneNode("AXESXYZ");
- axesX=axesXYZ->createChildSceneNode("AXESX");
- axesY=axesXYZ->createChildSceneNode("AXESY");
- axesZ=axesXYZ->createChildSceneNode("AXESZ");
- axesarrayX=axesX->createChildSceneNode("AXESARRAYX");
- axesarrayX->attachObject(eneaxesarrayX);
- axesarrayX->translate(0,45,0);
- axesdownX=axesX->createChildSceneNode("AXESDOWNX");
- axesdownX->attachObject(entaxesdownX);
- axesdownX->scale(0.01,0.09,0.01);
- axesX->roll(Degree(270));
- axesarrayY=axesY->createChildSceneNode("AXESARRAYY");
- axesarrayY->attachObject(eneaxesarrayY);
- axesarrayY->translate(0,45,0);
- axesdownY=axesY->createChildSceneNode("AXESDOWNY");
- axesdownY->attachObject(entaxesdownY);
- axesdownY->scale(0.01,0.09,0.01);
- axesarrayZ=axesZ->createChildSceneNode("AXESARRAYZ");
- axesarrayZ->attachObject(eneaxesarrayZ);
- axesarrayZ->translate(0,45,0);
- axesdownZ=axesZ->createChildSceneNode("AXESDOWNZ");
- axesdownZ->attachObject(entaxesdownZ);
- axesdownZ->scale(0.01,0.09,0.01);
- axesZ->pitch(Degree(90));
- mFrameListener= new TerrainFrameListener(mWindow, mCamera,mSceneMgr);
- mFrameListener->showDebugOverlay(true);
- mRoot->addFrameListener(mFrameListener);
- mRoot->startRendering();
- }
- }
- // COGRESceneMgrView 打印
- BOOL COGRESceneMgrView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // 默认准备
- return DoPreparePrinting(pInfo);
- }
- void COGRESceneMgrView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: 打印前添加额外的初始化
- }
- void COGRESceneMgrView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: 打印后添加清除过程
- }
- // COGRESceneMgrView 诊断
- #ifdef _DEBUG
- void COGRESceneMgrView::AssertValid() const
- {
- CView::AssertValid();
- }
- void COGRESceneMgrView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- COGRESceneMgrDoc* COGRESceneMgrView::GetDocument() const // 非调试版本是内联的
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COGRESceneMgrDoc)));
- return (COGRESceneMgrDoc*)m_pDocument;
- }
- #endif //_DEBUG
- // COGRESceneMgrView 消息处理程序
- void COGRESceneMgrView::OnImportMesh()
- {
- // TODO: 在此添加命令处理程序代码
- CFileDialog importmeshdlg(TRUE);
- //importmeshdlg.m_ofn.lpstrTile="wode";
- importmeshdlg.m_pOFN->lpstrTitle="导入网格对话框";
- importmeshdlg.m_pOFN->lpstrFilter="网格文件(*.mesh) *.mesh ";
- if(IDOK==importmeshdlg.DoModal())
- {
- meshfile=importmeshdlg.GetFileName();
- str=meshfile.GetBuffer(meshfile.GetLength());
- bimportmesh=true;
- }
- }
- void COGRESceneMgrView::OnImportParticle()
- {
- // TODO: 在此添加命令处理程序代码
- ipdlg.DoModal();
- }
- void COGRESceneMgrView::OnImportScene()
- {
- // TODO: 在此添加命令处理程序代码
- CFileDialog importscenedlg(TRUE);
- importscenedlg.m_pOFN->lpstrFilter="场景文件(*.ogrescene.xml) *.xml ";
- if(IDOK==importscenedlg.DoModal())
- {
- CString scenefilename;
- scenefilename=importscenedlg.GetFileName();
- TiXmlDocument *myDocument = new TiXmlDocument(scenefilename.GetBuffer(scenefilename.GetLength()));
- myDocument->LoadFile();
- TiXmlElement *RootElement = myDocument->RootElement();
- TiXmlElement *FirstPerson = RootElement->FirstChildElement();
- TiXmlElement *loopelement=FirstPerson;
- while(loopelement){
- CString loopstr=loopelement->Value();
- //String sfewf=loopelement->Value();
- //strutil.trim(sfewf);
- if(loopstr.Left(1)=="M")
- {
- TiXmlElement *meshnameele=loopelement->FirstChildElement();
- TiXmlText *meshnametext=(TiXmlText *)meshnameele->FirstChild();
- CString meshfilenamed=meshnametext->Value();
- TiXmlElement *positionele=meshnameele->NextSiblingElement();
- TiXmlElement *pxele=positionele->FirstChildElement();
- TiXmlText *pxval=(TiXmlText *)pxele->FirstChild();
- float px=(atof)(pxval->Value());
- TiXmlElement *pyele=pxele->NextSiblingElement();
- TiXmlText *pyval=(TiXmlText *)pyele->FirstChild();
- float py=(atof)(pyval->Value());
- TiXmlElement *pzele=pyele->NextSiblingElement();
- TiXmlText *pzval=(TiXmlText *)pzele->FirstChild();
- float pz=(atof)(pzval->Value());
- TiXmlElement *quaternionele=positionele->NextSiblingElement();
- TiXmlElement *pitchele=quaternionele->FirstChildElement();
- TiXmlText *pitchval=(TiXmlText *)pitchele->FirstChild();
- float pitchn=(atof)(pitchval->Value());
- TiXmlElement *rollele=pitchele->NextSiblingElement();
- TiXmlText *rollval=(TiXmlText *)rollele->FirstChild();
- float rolln=(atof)(rollval->Value());
- TiXmlElement *yawele=rollele->NextSiblingElement();
- TiXmlText *yawval=(TiXmlText *)yawele->FirstChild();
- float yawn=(atof)(yawval->Value());
- TiXmlElement *scaleele=quaternionele->NextSiblingElement();
- TiXmlElement *scalexele=scaleele->FirstChildElement();
- TiXmlText *scalexval=(TiXmlText *)scalexele->FirstChild();
- float scalexn=(atof)(scalexval->Value());
- TiXmlElement *scaleyele=scalexele->NextSiblingElement();
- TiXmlText *scaleyval=(TiXmlText *)scaleyele->FirstChild();
- float scaleyn=(atof)(scaleyval->Value());
- TiXmlElement *scalezele=scaleyele->NextSiblingElement();
- TiXmlText *scalezval=(TiXmlText *)scalezele->FirstChild();
- float scalezn=(atof)(scalezval->Value());
- ImportSceneMesh *scenemeshdate=new ImportSceneMesh(meshfilenamed,px,py,pz,
- pitchn,rolln,yawn,scalexn,scaleyn,scalezn);
- importmeshptr.Add(scenemeshdate);
- }
- if(loopstr.Left(1)=="P")
- {
- TiXmlElement *meshnameele=loopelement->FirstChildElement();
- TiXmlText *meshnametext=(TiXmlText *)meshnameele->FirstChild();
- CString meshfilenamed=meshnametext->Value();
- TiXmlElement *positionele=meshnameele->NextSiblingElement();
- TiXmlElement *pxele=positionele->FirstChildElement();
- TiXmlText *pxval=(TiXmlText *)pxele->FirstChild();
- float px=(atof)(pxval->Value());
- TiXmlElement *pyele=pxele->NextSiblingElement();
- TiXmlText *pyval=(TiXmlText *)pyele->FirstChild();
- float py=(atof)(pyval->Value());
- TiXmlElement *pzele=pyele->NextSiblingElement();
- TiXmlText *pzval=(TiXmlText *)pzele->FirstChild();
- float pz=(atof)(pzval->Value());
- TiXmlElement *quaternionele=positionele->NextSiblingElement();
- TiXmlElement *pitchele=quaternionele->FirstChildElement();
- TiXmlText *pitchval=(TiXmlText *)pitchele->FirstChild();
- float pitchn=(atof)(pitchval->Value());
- TiXmlElement *rollele=pitchele->NextSiblingElement();
- TiXmlText *rollval=(TiXmlText *)rollele->FirstChild();
- float rolln=(atof)(rollval->Value());
- TiXmlElement *yawele=rollele->NextSiblingElement();
- TiXmlText *yawval=(TiXmlText *)yawele->FirstChild();
- float yawn=(atof)(yawval->Value());
- TiXmlElement *scaleele=quaternionele->NextSiblingElement();
- TiXmlElement *scalexele=scaleele->FirstChildElement();
- TiXmlText *scalexval=(TiXmlText *)scalexele->FirstChild();
- float scalexn=(atof)(scalexval->Value());
- TiXmlElement *scaleyele=scalexele->NextSiblingElement();
- TiXmlText *scaleyval=(TiXmlText *)scaleyele->FirstChild();
- float scaleyn=(atof)(scaleyval->Value());
- TiXmlElement *scalezele=scaleyele->NextSiblingElement();
- TiXmlText *scalezval=(TiXmlText *)scalezele->FirstChild();
- float scalezn=(atof)(scalezval->Value());
- ImportSceneParticle *scenemeshdate=new ImportSceneParticle(meshfilenamed,px,py,pz,
- pitchn,rolln,yawn,scalexn,scaleyn,scalezn);
- importparticleptr.Add(scenemeshdate);
- }
- loopelement=loopelement->NextSiblingElement();
- }
- delete myDocument;
- bimportscene=true;
- }
- }
- void COGRESceneMgrView::OnSetTexture()
- {
- // TODO: 在此添加命令处理程序代码
- if(currentnode)
- settexturedlg.DoModal();
- }
- void COGRESceneMgrView::OnBnClickedImportParticle()
- {
- // TODO: 在此添加控件通知处理程序代码
- }
- void COGRESceneMgrView::OnFileSave()
- {
- // TODO: 在此添加命令处理程序代码
- CFileDialog savedlg(FALSE);
- savedlg.m_pOFN->lpstrTitle="场景保存";
- savedlg.m_pOFN->lpstrFilter="场景文件(*.ogrescene.xml) *.ogrescene.xml ";
- if(IDOK==savedlg.DoModal())
- {
- TiXmlDocument *myDocument = new TiXmlDocument();
- TiXmlElement *RootElement = new TiXmlElement("Root");
- myDocument->LinkEndChild(RootElement);
- for(int i=1;i<meshnumber+1;i++){
- Entity *meshentddd;
- meshentddd=mSceneMgr->getEntity("MESH"+stingconverter->toString(i));
- SceneNode *meshnodefff;
- meshnodefff=meshentddd->getParentSceneNode();
- Vector3 meshvecpo;
- meshvecpo=meshnodefff->getWorldPosition();
- Quaternion meshquaternion;
- meshquaternion=meshnodefff->getWorldOrientation();
- Vector3 meshvecscale;
- meshvecscale=meshnodefff->getScale();
- TiXmlElement *mesheselement =new TiXmlElement("Meshes");
- RootElement->LinkEndChild(mesheselement);
- TiXmlElement *meshesnameelement =new TiXmlElement("MeshesName");
- mesheselement->LinkEndChild(meshesnameelement);
- CString mesnfse=((FromIndexToName*)meshfileptr.GetAt(i-1))->meshnamestr;
- char *megfer=mesnfse.GetBuffer(mesnfse.GetLength());
- TiXmlText *meshtext=new TiXmlText(megfer);
- meshesnameelement->LinkEndChild(meshtext);
- TiXmlElement *positionelement=new TiXmlElement("Position");
- mesheselement->LinkEndChild(positionelement);
- TiXmlElement *positionxelenment =new TiXmlElement("PositionX");
- positionelement->LinkEndChild(positionxelenment);
- char meshstrx[32];
- float positionx=meshvecpo.x;
- sprintf(meshstrx,"%fn",positionx);
- TiXmlText *positionxtext=new TiXmlText(meshstrx);
- positionxelenment->LinkEndChild(positionxtext);
- TiXmlElement *positionyelenment =new TiXmlElement("PositionY");
- positionelement->LinkEndChild(positionyelenment);
- char meshstry[32];
- float positiony=meshvecpo.y;
- sprintf(meshstry,"%fn",positiony);
- TiXmlText *positionytext=new TiXmlText(meshstry);
- positionyelenment->LinkEndChild(positionytext);
- TiXmlElement *positionzelenment =new TiXmlElement("PositionZ");
- positionelement->LinkEndChild(positionzelenment);
- char meshstrz[32];
- float positionz=meshvecpo.z;
- sprintf(meshstrz,"%fn",positionz);
- TiXmlText *positionztext=new TiXmlText(meshstrz);
- positionzelenment->LinkEndChild(positionztext);
- //meshquaternion.
- TiXmlElement *quaternionelement=new TiXmlElement("Quaternion");
- mesheselement->LinkEndChild(quaternionelement);
- TiXmlElement *pitchelement=new TiXmlElement("Pitch");
- quaternionelement->LinkEndChild(pitchelement);
- char meshpitch[32];
- Radian pitchnumr=meshquaternion.getPitch();
- //float pitchnumd=Math::RadiansToAngleUnits(pitchnumr.valueRadians());
- float pitchnumd=pitchnumr.valueRadians();
- sprintf(meshpitch,"%fn",pitchnumd);
- TiXmlText *pitchtext=new TiXmlText(meshpitch);
- pitchelement->LinkEndChild(pitchtext);
- TiXmlElement *rollelement=new TiXmlElement("Roll");
- quaternionelement->LinkEndChild(rollelement);
- char meshroll[32];
- Radian rollnumr=meshquaternion.getRoll();
- float rollnumd=Math::RadiansToAngleUnits(rollnumr.valueRadians());
- sprintf(meshroll,"%fn",rollnumd);
- TiXmlText *rolltext=new TiXmlText(meshroll);
- rollelement->LinkEndChild(rolltext);
- TiXmlElement *yawelement=new TiXmlElement("Yaw");
- quaternionelement->LinkEndChild(yawelement);
- char meshyaw[32];
- Radian yawnumr=meshquaternion.getYaw();
- float yawnumd=Math::RadiansToAngleUnits(yawnumr.valueRadians());
- sprintf(meshyaw,"%fn",yawnumd);
- TiXmlText *yawtext=new TiXmlText(meshyaw);
- yawelement->LinkEndChild(yawtext);
- TiXmlElement *scaleelement=new TiXmlElement("Scale");
- mesheselement->LinkEndChild(scaleelement);
- TiXmlElement *scalexelement =new TiXmlElement("ScaleX");
- scaleelement->LinkEndChild(scalexelement);
- char meshscalex[32];
- float scalex=meshvecscale.x;
- sprintf(meshscalex,"%fn",scalex);
- TiXmlText *scalextext=new TiXmlText(meshscalex);
- scalexelement->LinkEndChild(scalextext);
- TiXmlElement *scaleyelenment =new TiXmlElement("ScaleY");
- scaleelement->LinkEndChild(scaleyelenment);
- char meshscaley[32];
- float scaley=meshvecscale.y;
- sprintf(meshscaley,"%fn",scaley);
- TiXmlText *scaleytext=new TiXmlText(meshscaley);
- scaleyelenment->LinkEndChild(scaleytext);
- TiXmlElement *scalezelement =new TiXmlElement("ScaleZ");
- scaleelement->LinkEndChild(scalezelement);
- char meshscalez[32];
- float scalez=meshvecscale.z;
- sprintf(meshscalez,"%fn",scalez);
- TiXmlText *scaleztext=new TiXmlText(meshscalez);
- scalezelement->LinkEndChild(scaleztext);
- }
- for(int i=1;i<particlenumber+1;i++){
- ParticleSystem* psys;
- psys=mSceneMgr->getParticleSystem("PARTICLE"+stingconverter->toString(i));
- SceneNode *particlenodefff;
- particlenodefff=psys->getParentSceneNode();
- Vector3 meshvecpo;
- meshvecpo=particlenodefff->getWorldPosition();
- Quaternion meshquaternion;
- meshquaternion=particlenodefff->getWorldOrientation();
- Vector3 meshvecscale;
- meshvecscale=particlenodefff->getScale();
- TiXmlElement *mesheselement =new TiXmlElement("Particle");
- RootElement->LinkEndChild(mesheselement);
- TiXmlElement *particlefileelement =new TiXmlElement("ParticleName");
- mesheselement->LinkEndChild(particlefileelement);
- TiXmlText *parfilenameee=new TiXmlText(((IndexToParticleName*)(parfileptr.GetAt(i-1)))->parfilename);
- particlefileelement->LinkEndChild(parfilenameee);
- // TiXmlText *meshtext=new TiXmlText();
- TiXmlElement *positionelement=new TiXmlElement("Position");
- mesheselement->LinkEndChild(positionelement);
- TiXmlElement *positionxelenment =new TiXmlElement("PositionX");
- positionelement->LinkEndChild(positionxelenment);
- char meshstrx[32];
- float positionx=meshvecpo.x;
- sprintf(meshstrx,"%fn",positionx);
- TiXmlText *positionxtext=new TiXmlText(meshstrx);
- positionxelenment->LinkEndChild(positionxtext);
- TiXmlElement *positionyelenment =new TiXmlElement("PositionY");
- positionelement->LinkEndChild(positionyelenment);
- char meshstry[32];
- float positiony=meshvecpo.y;
- sprintf(meshstry,"%fn",positiony);
- TiXmlText *positionytext=new TiXmlText(meshstry);
- positionyelenment->LinkEndChild(positionytext);
- TiXmlElement *positionzelenment =new TiXmlElement("PositionZ");
- positionelement->LinkEndChild(positionzelenment);
- char meshstrz[32];
- float positionz=meshvecpo.z;
- sprintf(meshstrz,"%fn",positionz);
- TiXmlText *positionztext=new TiXmlText(meshstrz);
- positionzelenment->LinkEndChild(positionztext);
- //meshquaternion.
- TiXmlElement *quaternionelement=new TiXmlElement("Quaternion");
- mesheselement->LinkEndChild(quaternionelement);
- TiXmlElement *pitchelement=new TiXmlElement("Pitch");
- quaternionelement->LinkEndChild(pitchelement);
- char meshpitch[32];
- Radian pitchnumr=meshquaternion.getPitch();
- //float pitchnumd=Math::RadiansToAngleUnits(pitchnumr.valueRadians());
- float pitchnumd=pitchnumr.valueRadians();
- sprintf(meshpitch,"%fn",pitchnumd);
- TiXmlText *pitchtext=new TiXmlText(meshpitch);
- pitchelement->LinkEndChild(pitchtext);
- TiXmlElement *rollelement=new TiXmlElement("Roll");
- quaternionelement->LinkEndChild(rollelement);
- char meshroll[32];
- Radian rollnumr=meshquaternion.getRoll();
- float rollnumd=Math::RadiansToAngleUnits(rollnumr.valueRadians());
- sprintf(meshroll,"%fn",rollnumd);
- TiXmlText *rolltext=new TiXmlText(meshroll);
- rollelement->LinkEndChild(rolltext);
- TiXmlElement *yawelement=new TiXmlElement("Yaw");
- quaternionelement->LinkEndChild(yawelement);
- char meshyaw[32];
- Radian yawnumr=meshquaternion.getYaw();
- float yawnumd=Math::RadiansToAngleUnits(yawnumr.valueRadians());
- sprintf(meshyaw,"%fn",yawnumd);
- TiXmlText *yawtext=new TiXmlText(meshyaw);
- yawelement->LinkEndChild(yawtext);
- TiXmlElement *scaleelement=new TiXmlElement("Scale");
- mesheselement->LinkEndChild(scaleelement);
- TiXmlElement *scalexelement =new TiXmlElement("ScaleX");
- scaleelement->LinkEndChild(scalexelement);
- char meshscalex[32];
- float scalex=meshvecscale.x;
- sprintf(meshscalex,"%fn",scalex);
- TiXmlText *scalextext=new TiXmlText(meshscalex);
- scalexelement->LinkEndChild(scalextext);
- TiXmlElement *scaleyelenment =new TiXmlElement("ScaleY");
- scaleelement->LinkEndChild(scaleyelenment);
- char meshscaley[32];
- float scaley=meshvecscale.y;
- sprintf(meshscaley,"%fn",scaley);
- TiXmlText *scaleytext=new TiXmlText(meshscaley);
- scaleyelenment->LinkEndChild(scaleytext);
- TiXmlElement *scalezelement =new TiXmlElement("ScaleZ");
- scaleelement->LinkEndChild(scalezelement);
- char meshscalez[32];
- float scalez=meshvecscale.z;
- sprintf(meshscalez,"%fn",scalez);
- TiXmlText *scaleztext=new TiXmlText(meshscalez);
- scalezelement->LinkEndChild(scaleztext);
- }
- CString scenefilename;
- scenefilename=savedlg.GetFileName();
- char *scenefilebuffer;
- scenefilebuffer=scenefilename.GetBuffer(scenefilename.GetLength());
- //sprintf(scenefilebuffer,"%s.xml",scenefilebuffer);
- myDocument->SaveFile(scenefilebuffer);
- }
- }
- void COGRESceneMgrView::OnSetSky()
- {
- // TODO: 在此添加命令处理程序代码
- if(IDOK==skystylechoosedlg.DoModal())
- {
- UpdateData();
- if(1==skystylechoosedlg.SkyRadio)
- {
- if(IDOK==skyplanedlgv.DoModal())
- {
- // skyplanedlgv.GetDlgItemText(
- bsetskyplane=true;
- bsetskyall=true;
- if(skyplanedlgv.skyplanemarterial=="")
- MessageBox("没有选择天空材质!");
- if(skyplanedlgv.skyplanedd==0) MessageBox("没有选择天空宽度!");
- if(skyplanedlgv.skyplaneheigh==0) MessageBox("没有选择天空高度!");
- }
- }
- else
- if(2==skystylechoosedlg.SkyRadio)
- {
- if(IDOK==skyboxdlgv.DoModal())
- {bsetskybox=true;
- bsetskyall=true;}
- }
- else
- if(3==skystylechoosedlg.SkyRadio)
- {
- if(IDOK==skydomedlgv.DoModal())
- {bsetskydome=true;
- bsetskyall=true;}
- }
- else MessageBox("未选择");
- }
- }
- void COGRESceneMgrView::OnSetFogMenu()
- {
- // TODO: 在此添加命令处理程序代码
- CColorDialog colordlg;
- if(IDOK==colordlg.DoModal())
- {
- COLORREF RGbdd=colordlg.m_cc.rgbResult;
- //ColourValue fadeColour=RGbdd;
- WORD RGCOLOR=LOWORD(RGbdd);
- WORD BNCOLOR=HIWORD(RGbdd);
- BYTE rcolor=LOBYTE(RGCOLOR);
- BYTE gcolor=HIBYTE(RGCOLOR);
- BYTE bcolor=LOBYTE(BNCOLOR);
- int rccc=rcolor;
- int gccc=gcolor;
- int bccc=bcolor;
- rcolommm=rccc;
- gcolommm=gccc;
- bcolommm=bccc;
- bsetfog=true;
- }
- }
- void COGRESceneMgrView::OnSetShadowMenu()
- {
- if(IDOK==setshadowtecdlg.DoModal())
- {
- //if(setshadowtecdlg.shadowtecenshu==1) MessageBox("11111111");
- bsetshadowtech=true;
- }
- }
- void COGRESceneMgrView::OnTranslateMove()
- {
- // TODO: 在此添加命令处理程序代码
- if(currentnode){ movenodeccc=currentnode;
- /*if(IDOK==movemeshdlg.DoModal())
- {
- if(movemeshdlg.slidebuchang==false)
- {movebuchang=movemeshdlg.ZiDingyiBuchang;
- if(movebuchang==0) MessageBox("步长不可为零!");
- }else movebuchang=movemeshdlg.MoveBuChang.GetPos();
- */
- btramove=true;
- bratate=false;
- bscaled=false;
- bgetmovenode=true;
- bmovecurent=true;
- wejwjw=true;
- bAxesXYZ=true;
- //}
- }else MessageBox("未选择任何需要移动物体!");
- }
- void COGRESceneMgrView::OnTotateSce()
- {
- // TODO: 在此添加命令处理程序代码
- if(currentnode){movenodeccc=currentnode;
- /*if(IDOK==rotatesetdlg.DoModal()){
- if(rotatesetdlg.makesurecustom)
- {rorateangle=rotatesetdlg.ROTATEANGLECU;
- if(rorateangle==0) MessageBox("角度不设为零!");}
- else rorateangle=rotatesetdlg.RotateSliderCtrl.GetPos();*/
- btramove=false;
- bratate=true;
- bscaled=false;
- bAxesXYZ=true; //}
- }else MessageBox("未选择任何需要旋转物体!");
- }
- void COGRESceneMgrView::OnScaleScene()
- {
- // TODO: 在此添加命令处理程序代码
- if(currentnode){movenodeccc=currentnode;
- if(IDOK==scalesetddlg.DoModal()){
- if(scalesetddlg.bsetscalecustom){
- scalddefw=scalesetddlg.SCALEFLAOTSET;
- }else scalddefw=(scalesetddlg.SCALESETSLEDER.GetPos())/10000;
- if(scalddefw==0) MessageBox("旋转参数不能为零!");
- scalnowset=scalddefw;
- btramove=false;
- bratate=false;
- bscaled=true;
- bAxesXYZ=true;
- }}else MessageBox("未选中任何物体!");
- }
- void COGRESceneMgrView::OnDeleteSCENEMeshpa()
- {
- // TODO: 在此添加命令处理程序代码
- currentnode->detachAllObjects();
- }
- void COGRESceneMgrView::OnImportWorldGemotry()
- {
- // TODO: 在此添加命令处理程序代码
- CFileDialog importworld(TRUE);
- importworld.m_pOFN->lpstrTitle="导入世界地图";
- importworld.m_pOFN->lpstrFilter="地图文件(*.cfg) *.cfg ";
- if(IDOK==importworld.DoModal())
- {worldgemotry=importworld.GetFileName();
- bimportworld=true;
- }
- }