1. 程式人生 > >Ogitor探索之程式碼分析(3)---CBaseEditor::showBoundingBox(bool bShow)

Ogitor探索之程式碼分析(3)---CBaseEditor::showBoundingBox(bool bShow)

在Qtogitor中編輯場景時如何選中物體Object並讓它顯示出邊線(Ogitor稱它為Bounding Box)呢?

前面已經介紹了OnMouseMove的功能了,如果不知道的要先看一下OnMouseMove的功能;

1、當滑鼠在螢幕上移動時OnMouseMove實時獲得滑鼠在視口的座標

2、Ogitor經過系列運算(具體實現還有待發掘)

3、獲取滑鼠所在位置是否有Object

4、如果有Object在你點選滑鼠左鍵時就回呼叫CBaseEditor::showBoundingBox(bool bShow)並且此時傳遞到bShow的值為true BoundingBox就顯示出來了

在D:/OgreSDK/ogitor_src/src0_43/Ogitor/src/BaseEditor.cpp檔案中定義的CBaseEditor::showBoundingBox(bool bShow)

   1: void CBaseEditor::showBoundingBox(bool bShow) 
   2: {
   3:     if(!mBoxParentNode && getEditorType() != ETYPE_BASE)
   4:         createBoundingBox();
   5:  
   6:     if(mBBoxNode)
   7:     {
   8:         int matpos = 0;
   9:
if(mHighlighted->get())
  10:         {
  11:             ++matpos;
  12:             if(mSelected->get())
  13:                 ++matpos;
  14:         }
  15:         
  16:         mOBBoxRenderable->setMaterial(mOBBMaterials[matpos]);
  17:
mBBoxNode->setVisible(bShow || mSelected->get() || mHighlighted->get());
  18:     }
  19: }