void Score::SetCurrentValue(float value){ if(value>max_value){ current_value=max_value; } else{ current_value=value; } UpdateBody(); }
void MyPhysics::StepSimulation(float dt,_RigidBody *rigidcopy1,_RigidBody *rigidcopy2){ float dtime = dt; bool tryAgain = true; int check = 0; //while(tryAgain&& (dtime>tol)) //{ //tryAgain = false; UpdateBody(rigidcopy1,dtime); UpdateBody(rigidcopy2,dtime); UpdatePosition(rigidcopy1,rigidcopy2); CollisionBody1 = 0; CollisionBody2 = 0; check = CheckForCollisionP(rigidcopy1,rigidcopy2); //if (check == PENETRATING) //{ // dtime = dtime/2; // tryAgain = true; // //} //else if(check == COLLISION) { ApplyImpulseP(rigidcopy1, rigidcopy2); } /*}*/ }
void Score::Init(){ std::vector<Point> points; points.push_back(Point(0,0)); points.push_back(Point(width,0)); points.push_back(Point(width,degree)); points.push_back(Point(0,degree)); Polygon polygon; polygon.SetPoints(points); back.SetPolygon(polygon); back.SetColor(Color(0.2,0.2,0.2,0.5)); body.SetPolygon(polygon); body.SetColor(Color(1,0,1,0.5)); UpdateBack(); UpdateBody(); }
void MyPhysics::StepSimulation(float dt,_RigidBody square[][20]){ float dtime = dt; bool tryAgain = true; int check = 0; UpdateBody(square,dtime); UpdatePosition(square); for(int i = 0; i< 40; i ++){ for( int j =0; j < 40 ; j ++){ check = CheckForCollisionP(square[i],square[j]); if(check == COLLISION) { ApplyImpulseP(square[i], square[j]); } /*}*/ } } }
/** *@brief メインウインドウのコンストラクタ *@param argc コマンドライン引数の数 *@param argv コマンドライン引数 *@param parent 親ウィジェット */ MainWindow::MainWindow(int argc, char** argv, QWidget *parent) : QMainWindow(parent) { tc = QTextCodec::codecForLocale(); QHBoxLayout *layout = new QHBoxLayout; mOgreWidget = new OgreWidget() ; layout->addWidget(mOgreWidget); tabWidget = new QTabWidget; mBodySetWidget = new BodySetWidget(); tabWidget->addTab(mBodySetWidget, tc->toUnicode("ボディ")); mBornSetWidget = new BornSetWidget(); tabWidget->addTab(mBornSetWidget, tc->toUnicode("ボーン")); mCameraSetWidget = new CameraSetWidget(); tabWidget->addTab(mCameraSetWidget, tc->toUnicode("カメラ")); mGUISetWidget = new GUISetWidget(); tabWidget->addTab(mGUISetWidget, tc->toUnicode("CEGUI")); mGUITextSetWidget = new GUITextSetWidget(); tabWidget->addTab(mGUITextSetWidget, tc->toUnicode("CEGUIのテキスト")); mImageSetWidget = new ImageSetWidget(); tabWidget->addTab(mImageSetWidget, tc->toUnicode("CEGUIの画像")); mParticleSetWidget = new ParticleSetWidget(); tabWidget->addTab(mParticleSetWidget, tc->toUnicode("パーティクル")); mSubWindowSetWidget = new SubWindowSetWidget(); tabWidget->addTab(mSubWindowSetWidget, tc->toUnicode("画面分割")); mAnimationSetWidget = new AnimationSetWidget(); tabWidget->addTab(mAnimationSetWidget, tc->toUnicode("アニメーション")); mLightSetWidget = new LightSetWidget(); tabWidget->addTab(mLightSetWidget, tc->toUnicode("光源")); mNodeSetWidget = new NodeSetWidget(); tabWidget->addTab(mNodeSetWidget, tc->toUnicode("ノード")); mSimulationSetWidget = new SimulationSetWidget(); tabWidget->addTab(mSimulationSetWidget, tc->toUnicode("物理シミュレーション(設定)")); mSimBodySetWidget = new SimBodySetWidget(); tabWidget->addTab(mSimBodySetWidget, tc->toUnicode("物理シミュレーション(ボディ)")); mSimJointSetWidget = new SimJointSetWidget(); tabWidget->addTab(mSimJointSetWidget, tc->toUnicode("物理シミュレーション(ジョイント)")); mOtherSetWidget = new OtherSetWidget(); tabWidget->addTab(mOtherSetWidget, tc->toUnicode("その他")); connect(mBodySetWidget, SIGNAL(UpdateBody()), mBornSetWidget, SLOT(UpdateBody())); connect(mGUISetWidget, SIGNAL(UpdateGUI()), mGUITextSetWidget, SLOT(UpdateGUI())); connect(mGUISetWidget, SIGNAL(UpdateGUI()), mImageSetWidget, SLOT(UpdateGUI())); connect(this, SIGNAL(UpdateList()), mBodySetWidget, SLOT(UpdateList())); connect(this, SIGNAL(UpdateList()), mCameraSetWidget, SLOT(UpdateList())); connect(this, SIGNAL(UpdateList()), mGUISetWidget, SLOT(UpdateList())); connect(this, SIGNAL(UpdateList()), mGUITextSetWidget, SLOT(UpdateList())); connect(this, SIGNAL(UpdateList()), mImageSetWidget, SLOT(UpdateList())); connect(this, SIGNAL(UpdateList()), mParticleSetWidget, SLOT(UpdateList())); connect(this, SIGNAL(UpdateList()), mSubWindowSetWidget, SLOT(UpdateList())); connect(this, SIGNAL(UpdateList()), mAnimationSetWidget, SLOT(UpdateList())); connect(this, SIGNAL(UpdateList()), mLightSetWidget, SLOT(UpdateList())); connect(this, SIGNAL(UpdateList()), mNodeSetWidget, SLOT(UpdateList())); connect(this, SIGNAL(UpdateList()), mSimulationSetWidget, SLOT(UpdateList())); connect(this, SIGNAL(UpdateList()), mSimBodySetWidget, SLOT(UpdateList())); connect(this, SIGNAL(UpdateList()), mSimJointSetWidget, SLOT(UpdateList())); connect(this, SIGNAL(UpdateList()), mOtherSetWidget, SLOT(UpdateList())); connect(mBodySetWidget, SIGNAL(UpdateBody()), mNodeSetWidget, SLOT(UpdateList())); connect(mParticleSetWidget, SIGNAL(UpdateParticle()), mNodeSetWidget, SLOT(UpdateList())); connect(mAnimationSetWidget, SIGNAL(UpdateAnimation()), mNodeSetWidget, SLOT(UpdateList())); connect(mLightSetWidget, SIGNAL(UpdateLight()), mNodeSetWidget, SLOT(UpdateList())); connect(mSimBodySetWidget, SIGNAL(UpdateODEBody()), mNodeSetWidget, SLOT(UpdateList())); connect(mSimJointSetWidget, SIGNAL(UpdateODEJoint()), mNodeSetWidget, SLOT(UpdateList())); connect(mSimBodySetWidget, SIGNAL(UpdateODEBody()), mSimJointSetWidget, SLOT(UpdateList())); connect(mOgreWidget, SIGNAL(mouseMoveSignal(QMouseEvent*, int, int)), mCameraSetWidget, SLOT(mouseMoveSlot(QMouseEvent*, int, int))); connect(mOgreWidget, SIGNAL(mousePressSignal(QMouseEvent*)), mCameraSetWidget, SLOT(mousePressSlot(QMouseEvent*))); connect(mOgreWidget, SIGNAL(mouseReleaseSignal(QMouseEvent*)), mCameraSetWidget, SLOT(mouseReleaseSlot(QMouseEvent*))); connect(mOgreWidget, SIGNAL(mouseMoveSignal(QMouseEvent*, int, int)), mBodySetWidget, SLOT(mouseMoveSlot(QMouseEvent*, int, int))); connect(mOgreWidget, SIGNAL(mousePressSignal(QMouseEvent*)), mBodySetWidget, SLOT(mousePressSlot(QMouseEvent*))); connect(mOgreWidget, SIGNAL(mouseReleaseSignal(QMouseEvent*)), mBodySetWidget, SLOT(mouseReleaseSlot(QMouseEvent*))); QVBoxLayout *alayout = new QVBoxLayout; alayout->addWidget(tabWidget); QWidget *awidget = new QWidget; awidget->setLayout(alayout); tabWidget->setMinimumSize(250, 768); tabWidget->setMaximumWidth(250); QScrollArea *area = new QScrollArea(); area->setWidget(awidget); area->setMaximumSize(300, 708); area->setMinimumSize(300, 708); layout->addWidget(area); QWidget *widget = new QWidget; widget->setLayout(layout); widget->setMinimumSize(1244, 708); setCentralWidget(widget); setWindowTitle(tr("OgreRTC")); setUnifiedTitleAndToolBarOnMac(true); mOgreWidget->initOgre(); EC = mOgreWidget->mOgreRTCApplication; mBodySetWidget->EC = mOgreWidget->mOgreRTCApplication; mBornSetWidget->EC = mOgreWidget->mOgreRTCApplication; mCameraSetWidget->EC = mOgreWidget->mOgreRTCApplication; mGUISetWidget->EC = mOgreWidget->mOgreRTCApplication; mGUITextSetWidget->EC = mOgreWidget->mOgreRTCApplication; mImageSetWidget->EC = mOgreWidget->mOgreRTCApplication; mParticleSetWidget->EC = mOgreWidget->mOgreRTCApplication; mSubWindowSetWidget->EC = mOgreWidget->mOgreRTCApplication; mAnimationSetWidget->EC = mOgreWidget->mOgreRTCApplication; mLightSetWidget->EC = mOgreWidget->mOgreRTCApplication; mNodeSetWidget->EC = mOgreWidget->mOgreRTCApplication; mSimulationSetWidget->EC = mOgreWidget->mOgreRTCApplication; mSimBodySetWidget->EC = mOgreWidget->mOgreRTCApplication; mSimJointSetWidget->EC = mOgreWidget->mOgreRTCApplication; mOtherSetWidget->EC = mOgreWidget->mOgreRTCApplication; createAction(); createMenus(); if(EC && argc > 1) { EC->reset(); EC->OpenFile(argv[1]); } }
void NzPhysObject::SetRotation(const NzQuaternionf& rotation) { m_matrix.SetRotation(rotation); UpdateBody(); }
void NzPhysObject::SetPosition(const NzVector3f& position) { m_matrix.SetTranslation(position); UpdateBody(); }
void Score::SetPosition(Point pos){ this->pos=pos; UpdateBack(); UpdateBody(); }
void Kinect2Manager::Update(unsigned int options) { #ifdef _USE_KINECT IColorFrame * pColorFrame = NULL; IDepthFrame * pDepthFrame = NULL; IBodyFrame * pBodyFrame = NULL; IBodyIndexFrame * pBodyIndexFrame = NULL; IMultiSourceFrame * pMultiSourceFrame = NULL; m_nColorWidth = 0; m_nColorHeight = 0; m_nDepthWidth = 0; m_nDepthHeight = 0; m_bCalculateDepthRGBX = options & Update::DepthRGBX; int numUpdate = countUpdate(options); HRESULT hr = 1; if (numUpdate > 1) { hr = m_pMultiSourceFrameReader->AcquireLatestFrame(&pMultiSourceFrame); } if (SUCCEEDED(hr)) { if (options & Update::Color) { IColorFrameReference* pColorFrameReference = NULL; if (numUpdate > 1) { hr = pMultiSourceFrame->get_ColorFrameReference(&pColorFrameReference); if (SUCCEEDED(hr)) { hr = pColorFrameReference->AcquireFrame(&pColorFrame); } } else { hr = m_pColorFrameReader->AcquireLatestFrame(&pColorFrame); } if (SUCCEEDED(hr)) { m_bMapColorToDepth = options & Update::MapColorToDepth; } else { options &= ~Update::Color; } SafeRelease(pColorFrameReference); } if (options & Update::Depth) { IDepthFrameReference* pDepthFrameReference = NULL; if (numUpdate > 1) { hr = pMultiSourceFrame->get_DepthFrameReference(&pDepthFrameReference); if (SUCCEEDED(hr)) { hr = pDepthFrameReference->AcquireFrame(&pDepthFrame); } } else { hr = m_pDepthFrameReader->AcquireLatestFrame(&pDepthFrame); } if (SUCCEEDED(hr)) { m_bMapDepthToColor = options & Update::MapDepthToColor; } else { options &= ~Update::Depth; } SafeRelease(pDepthFrameReference); } if (options & Update::Body) { IBodyFrameReference* pBodyFrameReference = NULL; if (numUpdate > 1) { hr = pMultiSourceFrame->get_BodyFrameReference(&pBodyFrameReference); if (SUCCEEDED(hr)) { hr = pBodyFrameReference->AcquireFrame(&pBodyFrame); } } else { hr = m_pBodyFrameReader->AcquireLatestFrame(&pBodyFrame); } SafeRelease(pBodyFrameReference); } if (options & Update::Color && options & Update::Depth) { if (options & Update::BodyIndex && options & Update::MapColorToDepth) { if (m_bDepthColorMapCalculated) { IBodyIndexFrameReference* pBodyIndexFrameReference = NULL; hr = pMultiSourceFrame->get_BodyIndexFrameReference(&pBodyIndexFrameReference); if (SUCCEEDED(hr)) { hr = pBodyIndexFrameReference->AcquireFrame(&pBodyIndexFrame); } SafeRelease(pBodyIndexFrameReference); } } } } if (pBodyFrame) { UpdateBody(pBodyFrame); } if (pColorFrame) { UpdateColor(pColorFrame); } if (pDepthFrame) { UpdateDepth(pDepthFrame); if (options & Update::MapDepthToColor) { CalculateColorDepthMap(); if (m_bColorDepthMapCalculated) ProcessDepthToColor(m_pDepth, m_nDepthWidth, m_nDepthHeight, m_pColorDepthMap, m_nColorWidth, m_nColorHeight); } if (options & Update::MapColorToDepth) { CalculateDepthColorMap(); if (m_bDepthColorMapCalculated) { ProcessColorToDepth(m_pColorRGBX, m_nColorWidth, m_nColorHeight, m_pDepthColorMap, m_nDepthWidth, m_nDepthHeight); if (pBodyIndexFrame) { UpdateBodyIndex(pBodyIndexFrame); } } } } SafeRelease(pColorFrame); SafeRelease(pDepthFrame); SafeRelease(pBodyFrame); SafeRelease(pBodyIndexFrame); SafeRelease(pMultiSourceFrame); #else m_nDepthWidth = CAPTURE_SIZE_X_DEPTH; m_nDepthHeight = CAPTURE_SIZE_Y_DEPTH; m_nColorWidth = CAPTURE_SIZE_X_COLOR; m_nColorHeight = CAPTURE_SIZE_Y_COLOR; if (options & Update::MapDepthToColor) { CalculateColorDepthMap(); if (m_bColorDepthMapCalculated) ProcessDepthToColor(m_pDepth, m_nDepthWidth, m_nDepthHeight, m_pColorDepthMap, m_nColorWidth, m_nColorHeight); } if (options & Update::MapColorToDepth) { CalculateDepthColorMap(); if (m_bDepthColorMapCalculated) { ProcessColorToDepth(m_pColorRGBX, m_nColorWidth, m_nColorHeight, m_pDepthColorMap, m_nDepthWidth, m_nDepthHeight); } } UpdateBodyIndex(NULL); #endif }
void MainScene::update(float dt) { UpdatePhysics(); UpdateBody(); }