コード例 #1
0
ファイル: SkeletonMapper.cpp プロジェクト: AdamCarrick/BGE
void BGE::SkeletonMapper::UpdateBone(string tag, glm::vec3 start, glm::vec3 end, bool withKnobs)
{
	glm::vec3 jointPos[2];

	if (Params::GetBool("leapHeadMode"))
	{
		start.x = -start.x;
		end.x = -end.x;

		start.y = -start.y;
		end.y = -end.y;
	}

	jointPos[0] = transform.TransformPosition(start, true);
	jointPos[1] = transform.TransformPosition(end, true);

	
	glm::vec3 boneVector = jointPos[1] - jointPos[0];
	float boneLength = glm::length(boneVector);
	glm::vec3 centrePos = jointPos[0] + ((boneVector) / 2.0f);

	boneVector = glm::normalize(boneVector);
	glm::vec3 axis = glm::cross(Transform::basisUp, boneVector);
	axis = glm::normalize(axis);
	float theta = (float)glm::acos<float>(glm::dot<float>(Transform::basisUp, boneVector));
	glm::quat q = glm::angleAxis(glm::degrees(theta), axis);

	//LineDrawer::DrawLine(jointPos[0], jointPos[1], glm::vec3(0, 0, 1));
	
	//std::map<std::string, std::shared_ptr<PhysicsController>>::iterator it = mapStuff.find(tag);
	shared_ptr<GameComponent> bone = owner->FindComponentByTag(tag);
	shared_ptr<PhysicsController> boneController;
	if (bone == nullptr)
	{
		boneController = Game::Instance()->physicsFactory->CreateCylinder(0.5f, boneLength, centrePos, q, true, false);
		boneController->rigidBody->setMotionState(new KinematicMotionState(boneController));
		boneController->tag = "HandBoneController";
		boneController->parent->tag = tag;
		boneController->transform->diffuse = glm::vec3(0, 0, 1);
		mapStuff[tag] = boneController;
		owner->Attach(boneController->parent);
	}
	else
	{
		bone->transform->orientation = q;
		bone->transform->position = centrePos;
	}

	if (withKnobs)
	{
		string key[2];
		key[0] = tag + "0";
		key[1] = tag + "1";
		UpdateKnob(key[0], start);
		UpdateKnob(key[1], end);
	}
}
コード例 #2
0
ファイル: SliderWnd.cpp プロジェクト: malensek/3RVX
LRESULT SliderWnd::WndProc(
        HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {

    switch (message) {
    case WM_TIMER:
        if (wParam == TIMER_IGNORE_INPUT) {
            KillTimer(hWnd, TIMER_IGNORE_INPUT);
            _ignoreInput = false;
        }
        break;

    case WM_KILLFOCUS:
        Hide();
        break;

    case WM_ACTIVATEAPP:
        if (wParam == 0) {
            /* We're being deactivated */
            Hide();
        }
        break;

    case WM_MOUSEMOVE:
        if (_dragging) {
            int x = GET_X_LPARAM(lParam);
            int y = GET_Y_LPARAM(lParam);
            UpdateKnob(x, y);
        }
        break;

    case WM_LBUTTONDOWN: {
        if (_knob == NULL) {
            break;
        }

        int x = GET_X_LPARAM(lParam);
        int y = GET_Y_LPARAM(lParam);

        if (MouseOverKnob(x, y)) {
            _dragging = true;
            if (_vertical) {
                _dragOffset = y - _knob->Y();
            } else {
                _dragOffset = x - _knob->X();
            }
            SetCapture(hWnd);
        } else if (MouseOverTrack(x, y)) {
            /* Simulate the mouse dragging to the clicked location: */
            UpdateKnob(x, y);
        }

        break;
        }

    case WM_LBUTTONUP:
        _dragging = false;
        ReleaseCapture();
        break;
    }

    /* Input events: arrow keys, right or middle mouse buttons, scrolling */
    if (_ignoreInput == false) {
        switch (message) {
        case WM_MBUTTONUP:
            KeyPress(VK_MBUTTON);
            break;

        case WM_RBUTTONDOWN:
            KeyPress(VK_RBUTTON);
            break;

        case WM_MOUSEWHEEL: {
            if (_ignoreInput) {
                break;
            }

            short scroll = GET_WHEEL_DELTA_WPARAM(wParam);
            if (scroll > 0) {
                ScrollUp();
            } else if (scroll < 0) {
                ScrollDown();
            }
            break;
        }

        case WM_KEYUP:
            KeyPress(wParam);
            break;
        }
    }

    return MeterWnd::WndProc(hWnd, message, wParam, lParam);
}