Exemplo n.º 1
0
void RemoteDebugger::setParameter(const SimplePlane& parameter, void* object, const char* name, unsigned int mask)
{
 mRemoteDebugger->writeParameter(NxPlane(Functions::XYZ<Vec3, NxVec3>(parameter.mNormal), parameter.mDistance), object, false, name, mask);
}
Exemplo n.º 2
0
Gesture::Detected PinchZoomGesture::isRecognizedImpl(GestureContext *gestureContext)
{	
	_gestureTouchPaths = gestureContext->getActiveTouchPaths();

	DWORD time = max(_gestureTouchPaths[0]->getFirstTouchPoint().relativeTimeStamp, _gestureTouchPaths[1]->getFirstTouchPoint().relativeTimeStamp);
	TouchPoint& firstFingerPoint = _gestureTouchPaths[0]->getTouchPointAt(time);
	TouchPoint& secondFingerPoint = _gestureTouchPaths[1]->getTouchPointAt(time);

	BumpObject * firstFingerObject = firstFingerPoint.getPickedObject();
	BumpObject * secondFingerObject = secondFingerPoint.getPickedObject();

	_cumulativeScaleFactor = 1.0f;
	float initialDistanceBetweenFingers = firstFingerPoint.calculateDisplacementFrom(secondFingerPoint).magnitude();

	TouchPoint& firstFingerEndPoint = _gestureTouchPaths[0]->getLastTouchPoint();
	TouchPoint& secondFingerEndPoint = _gestureTouchPaths[1]->getLastTouchPoint();

	float finalDistanceBetweenFingers = firstFingerEndPoint.calculateDisplacementFrom(secondFingerEndPoint).magnitude();

	if (abs(initialDistanceBetweenFingers - finalDistanceBetweenFingers) < MINIMUM_PATH_LENGTH)
		return Maybe;
	
	BumpObject *targetObject; // Using its plane to calculate world space distance for scaling

	if (firstFingerObject && firstFingerObject == secondFingerObject)
	{ // If both fingers are on the same object, user wants to zoom that object, so add it to selection
		targetObject = firstFingerObject;
		_pathOfTranslationPoint = _gestureTouchPaths[0];
	}	
	else if (firstFingerObject && !secondFingerObject)
	{ // If only first finger is on an object, zoom based on that object
		targetObject = firstFingerObject;
		_pathOfTranslationPoint = _gestureTouchPaths[0];
	}
	else if (secondFingerObject && !firstFingerObject)
	{ // If only second finger is on an object, zoom based on that object
		targetObject = secondFingerObject;
		_pathOfTranslationPoint = _gestureTouchPaths[1];
	}
	else
	{
		return gestureRejected("Fingers are on diff't objs, or no objs (probably camera zoom)");
	}

	if (!sel->isInSelection(targetObject))
		sel->add(targetObject);
	sel->setPickedActor(targetObject); // Set the picked object for selection to allow dragging

	//Work with the bottom most object in the pile if this is a pile
	if(targetObject->getObjectType() == ObjectType(BumpPile))
		targetObject = ((Pile *) targetObject)->getPileItems().back();

	//Calculate the normal and center point of the object
	Vec3 normal = targetObject->getGlobalOrientation() * Vec3(0.0f, 0.0f, 1.0f);
	Vec3 centerPoint = targetObject->getGlobalPosition() + (targetObject->getGlobalOrientation() * Vec3(0.0f, 0.0f, targetObject->getDims().z));

	// Create the plane representing the surface of the object and using that,
	// Find the distance between the two touch points on that plane, for scaling in world space
	_objectPlane = NxPlane(centerPoint, normal);
	_originalDistanceBetweenPoints = getDistanceInObjectPlane(firstFingerEndPoint, secondFingerEndPoint, _objectPlane);

	// Take a snapshot of the currently selected objects
	vector<BumpObject *> selected = sel->getBumpObjects();

	ObjectType griddedPile(BumpPile, SoftPile | HardPile, Grid);

	vector<BumpObject *>::iterator it;
	for(it = selected.begin(); it != selected.end(); it++)
	{
		BumpObject* obj = *it;
		if (obj->isObjectType(griddedPile) || obj->isParentType(griddedPile))
			continue;
		(*it)->updateReferenceDims();
		_selectedObjects.push_back(*it);
	}
	if (sel->getPickedActor())
		sel->getPickedActor()->onDragBegin();
	return gestureAccepted();
}