Beispiel #1
0
void RigidBody::external_set_position(Eigen::Vector3d setting_vec)
{
	position(0) = setting_vec(0);
	position(1) = setting_vec(1);
	position(2) = setting_vec(2);
	updateInternalState();
}
Beispiel #2
0
void RigidBody::sim_step(double dt)
{
	odeint::integrate(boost::ref(*this), internalState, 0.0, dt, dt);

	position(0) =  internalState[0]; 
	position(1) =  internalState[1]; 
	position(2) =  internalState[2]; 

	velocity(0) =  internalState[3]; 
	velocity(1) =  internalState[4]; 
	velocity(2) =  internalState[5]; 

	attitude.x() =  internalState[6]; 
	attitude.y() =  internalState[7]; 
	attitude.z() =  internalState[8]; 
	attitude.w() =  internalState[9]; 
	
	attitude.normalize();

	angularVelocity(0) =  internalState[10]; 
	angularVelocity(1) =  internalState[11]; 
	angularVelocity(2) =  internalState[12]; 
	
	updateInternalState();
	
	ticks += 1;
}
float OsmAnd::AtlasMapRenderer_OpenGL::getScaledTileSizeOnScreen()
{
    InternalState internalState;
    bool ok = updateInternalState(&internalState, state);

    return getReferenceTileSizeOnScreen(state) * internalState.tileScaleFactor;
}
Beispiel #4
0
void ButtonBase::onCaptureLost(WindowEventArgs& e)
{
    // Default processing
    Window::onCaptureLost(e);

    d_pushed = false;
    updateInternalState(MouseCursor::getSingleton().getPosition());
    requestRedraw();

    // event was handled by us.
    e.handled = true;
}
//----------------------------------------------------------------------------//
void ButtonBase::setPushedState(const bool pushed)
{
    d_pushed = pushed;

    if (!pushed)
	    updateInternalState(getUnprojectedPosition(
            getGUIContext().getCursor().getPosition()));
    else
        d_hovering = true;

    invalidate();
}
Beispiel #6
0
/*************************************************************************
    Handler for when mouse capture is lost
*************************************************************************/
void MenuItem::onCaptureLost(WindowEventArgs& e)
{
    // Default processing
    ItemEntry::onCaptureLost(e);

    d_pushed = false;
    updateInternalState(getUnprojectedPosition(
                            getGUIContext().getMouseCursor().getPosition()));
    invalidate();

    // event was handled by us.
    ++e.handled;
}
Beispiel #7
0
void ButtonBase::onMouseMove(MouseEventArgs& e)
{
    // this is needed to discover whether mouse is in the widget area or not.
    // The same thing used to be done each frame in the rendering method,
    // but in this version the rendering method may not be called every frame
    // so we must discover the internal widget state here - which is actually
    // more efficient anyway.

    // base class processing
    Window::onMouseMove(e);

    updateInternalState(e.position);
    e.handled = true;
}
Beispiel #8
0
void ButtonBase::onMouseButtonDown(MouseEventArgs& e)
{
    // default processing
    Window::onMouseButtonDown(e);

    if (e.button == LeftButton)
    {
        if (captureInput())
        {
            d_pushed = true;
            updateInternalState(e.position);
            requestRedraw();
        }

        // event was handled by us.
        e.handled = true;
    }
}
/*************************************************************************
	Handler for cursor press hold events
*************************************************************************/
void ButtonBase::onCursorPressHold(CursorInputEventArgs& e)
{
	// default processing
    Window::onCursorPressHold(e);

    if (e.source == CIS_Left)
	{
        if (captureInput())
        {
			d_pushed = true;
			updateInternalState(e.position);
			invalidate();
        }

		// event was handled by us.
		++e.handled;
	}
}
Beispiel #10
0
void FalagardActionButton::onMouseButtonDown(MouseEventArgs& e)
{
    //        FalagardButton::onMouseButtonDown(e);下面就是pushbutton中的部分
    // default processing
    Window::onMouseButtonDown(e);

    if (e.button == LeftButton || e.button == RightButton)
    {
        if (captureInput())
        {
            d_pushed = true;
            updateInternalState(e.position);
            requestRedraw();
        }

        // event was handled by us.
        e.handled = true;
    }
    /////////////////////////////////////////////////////////
    if (e.button == LeftButton && isDraggingEnabled())
    {
        if(!d_dragging)
        {
            // get position of mouse as co-ordinates local to this window.
            Point localPos = (getMetricsMode() == Relative) ?
                             relativeToAbsolute(screenToWindow(e.position)) :
                             screenToWindow(e.position);

            // store drag point for possible sizing or moving operation.
            d_dragPoint = localPos;
            d_leftMouseDown = true;

        }

        e.handled = true;
    }

    if (e.button == RightButton && isDraggingEnabled())
    {
        e.handled = true;
    }
}
Beispiel #11
0
RigidBody::RigidBody()
{
  ticks = 0;

  /* following data is obtained from shaojie simulator */
  mass = 0.74;
  double Ixx = 2.64e-3, Iyy = 2.64e-3, Izz = 4.96e-3;
  inertia = Eigen::Vector3d(Ixx, Iyy, Izz).asDiagonal();

  position = Eigen::Vector3d::Zero();
  velocity = Eigen::Vector3d::Zero();
  //acceleration = Eigen::Vector3d::Zero();
  force = Eigen::Vector3d::Zero();

  attitude = Eigen::Quaterniond(Eigen::Matrix3d::Identity());
  angularVelocity = Eigen::Vector3d::Zero();
  torque = Eigen::Vector3d::Zero();

  updateInternalState();
}
bool OsmAnd::AtlasMapRenderer_OpenGL::getLocationFromScreenPoint( const PointI& screenPoint, PointI64& location )
{
    InternalState internalState;
    bool ok = updateInternalState(&internalState, state);
    if(!ok)
        return false;

    glm::vec4 viewport(
        state.viewport.left,
        state.windowSize.y - state.viewport.bottom,
        state.viewport.width(),
        state.viewport.height());
    const auto nearInWorld = glm::unProject(glm::vec3(screenPoint.x, state.windowSize.y - screenPoint.y, 0.0f), internalState.mCameraView, internalState.mPerspectiveProjection, viewport);
    const auto farInWorld = glm::unProject(glm::vec3(screenPoint.x, state.windowSize.y - screenPoint.y, 1.0f), internalState.mCameraView, internalState.mPerspectiveProjection, viewport);
    const auto rayD = glm::normalize(farInWorld - nearInWorld);

    const glm::vec3 planeN(0.0f, 1.0f, 0.0f);
    const glm::vec3 planeO(0.0f, 0.0f, 0.0f);
    float distance;
    const auto intersects = Utilities_OpenGL_Common::rayIntersectPlane(planeN, planeO, rayD, nearInWorld, distance);
    if(!intersects)
        return false;

    auto intersection = nearInWorld + distance*rayD;
    intersection /= static_cast<float>(TileSize3D);

    double x = intersection.x + internalState.targetInTileOffsetN.x;
    double y = intersection.z + internalState.targetInTileOffsetN.y;

    const auto zoomDiff = ZoomLevel::MaxZoomLevel - state.zoomBase;
    const auto tileSize31 = (1u << zoomDiff);
    x *= tileSize31;
    y *= tileSize31;

    location.x = static_cast<int64_t>(x) + (internalState.targetTileId.x << zoomDiff);
    location.y = static_cast<int64_t>(y) + (internalState.targetTileId.y << zoomDiff);
    
    return true;
}
Beispiel #13
0
/*************************************************************************
    Handler for mouse button pressed events
*************************************************************************/
void MenuItem::onMouseButtonDown(MouseEventArgs& e)
{
    // default processing
    ItemEntry::onMouseButtonDown(e);

    if (e.button == LeftButton)
    {
        d_popupWasClosed = false;

        if (captureInput())
        {
            d_pushed = true;
            updateInternalState(e.position);
            d_popupWasClosed = !togglePopupMenu();
            invalidate();
        }

        // event was handled by us.
        ++e.handled;
    }

}
Beispiel #14
0
	void	FalagardCheckButton::onMouseButtonDown(MouseEventArgs& e)
	{
		PushButton::onMouseButtonDown(e);

		if (e.button == LeftButton)
		{
			if (captureInput())
			{
				if( d_nCheckMode == 1 )
				{
					if( d_bIsSelected ) // 如果已经被选中了
						return;
				}
				d_pushed = true;
				d_bIsSelected = !d_bIsSelected;
				updateInternalState(e.position);
				requestRedraw();
				
			}

			// event was handled by us.
			e.handled = true;
		}
	}