void Java_zte_irrlib_scene_Scene_nativeRemoveNode( JNIEnv *env, jobject defaultObj, jint id) { ISceneNode* node = smgr->getSceneNodeFromId(id); if (!node) return; ISceneNode* parentNode = node->getParent(); if (!parentNode) return; parentNode->removeChild(node); }
bool CEvolEnviroment::onMessage(xWindowMsg& msg) { if(m_xuiWinMgr == NULL || m_pRenderApi == NULL) return false; bool bRet = m_xuiWinMgr->dispatchMsg(msg); if(msg.MsgID == WIN_CLOSE ) { m_pEngine->platform()->quit(); } if(msg.MsgID == WIN_RESIZE) { onResize(); return true; } else if(msg.MsgID == WIN_KEYUP) { if(msg.Keyboard.cKeyChar >= '1' && msg.Keyboard.cKeyChar <= '9') { //m_Model->setAction( msg.Keyboard.cKeyChar - '1' ); } if(msg.Keyboard.nKey == VKEY_F9) { bool bDrawPlane = m_pEngine->sysValue(L"defualt",L"drawPlane" , false); } if(msg.Keyboard.nKey == VKEY_DELETE) { bool bAllowOpScene = m_pEngine->sysValue(L"defualt",L"sceneEditable" , true); if(bAllowOpScene && GetSelection()->GetCurSelNode()) { ISceneNode* pNode = GetSelection()->GetCurSelNode(); ISceneNode* pParentNode = pNode->getParent(); if(pParentNode == NULL) { MessageBox(GetActiveWindow() , L"节点没有父节点", L"错误" , MB_OK); } else { pParentNode->removeChild(pNode,true); GetSelection()->setCurSelNode(NULL); } } } return false; } else if(msg.MsgID == WIN_KEYDOWN) { if(msg.Keyboard.cKeyChar == 'a' ) { m_pCamera->shift(-m_cameraStep); } else if(msg.Keyboard.cKeyChar == 'd') { m_pCamera->shift(m_cameraStep); } else if(msg.Keyboard.cKeyChar == 'w') { m_pCamera->toward(m_cameraStep); } else if(msg.Keyboard.cKeyChar == 's') { m_pCamera->toward(-m_cameraStep); } else if(msg.Keyboard.nKey == VKEY_UP) { m_pCamera->pitch(2); } else if(msg.Keyboard.nKey == VKEY_DOWN) { m_pCamera->pitch(-2); } else if(msg.Keyboard.nKey == VKEY_LEFT) { m_pCamera->yaw(2); } else if(msg.Keyboard.nKey == VKEY_RIGHT) { m_pCamera->yaw(-2); } else if(msg.Keyboard.nKey == VKEY_SHIFT) { m_pCamera->upDown(m_cameraStep); } else if(msg.Keyboard.nKey == VKEY_CONTROL) { m_pCamera->upDown(-m_cameraStep); } else { return false; } m_pRightCamera->copyFrom(m_pCamera); m_pRightCamera->shift(CameraDist); setSameViewTarget(m_pCamera , m_pRightCamera); return true; } m_pScenePlacementOprator->onMessage(msg); return false; }
// selectObject // detect list objs at mouse xy void CDocument::selectObject( int mouseX, int mouseY, bool isControlHold ) { ISceneManager *smgr = getIView()->getSceneMgr(); ICameraSceneNode *camera = smgr->getActiveCamera(); // if no camera if ( camera == NULL ) return; ISceneCollisionManager *collMan = smgr->getSceneCollisionManager(); // get select ray core::line3df selectRay = getIView()->getSelectRay(); // check hit test core::vector3df intersection; core::triangle3df hitTriangle; // check select ISceneNode *selectedSceneNode = collMan->getSceneNodeAndCollisionPointFromRay ( selectRay, intersection, hitTriangle ); if ( selectedSceneNode ) { CGameObject *pObj = searchObject( selectedSceneNode->getID() ); // try find parent while ( pObj == NULL ) { selectedSceneNode = selectedSceneNode->getParent(); if ( selectedSceneNode == NULL ) break; pObj = searchObject( selectedSceneNode->getID() ); } // add to select list if ( pObj && pObj->isVisible() ) { if ( isControlHold == false || pObj->getObjectState() == CGameObject::Normal ) m_selectObjects.push_back( pObj ); else { pObj->setObjectState( CGameObject::Normal ); ArrayGameObjectIter i = m_selectObjects.begin(), iEnd = m_selectObjects.end(); while ( i != iEnd ) { if ( (*i) == pObj ) { m_selectObjects.erase( i ); break; } i++; } } } } }