示例#1
0
	//-----------------------------------------------------------------------
    Transform::Ptr Transform::Translate(const Vector3& d, TransformSpace relativeTo)
    {
        switch(relativeTo)
        {
        case TS_LOCAL:
            // position is relative to parent so transform downwards
            position += orientation.Rotate(d);
        	break;
        case TS_WORLD:
            // position is relative to parent so transform upwards
            if (parent)
            {
				Vector3 n = parent->_getDerivedOrientation().Inverse().Rotate(d);
				Vector3 d = parent->_getDerivedScale();
				position += Vector3(n.x/d.x, n.y/d.y, n.z/d.x);
            }
            else
            {
                position += d;
            }
        	break;
        case TS_PARENT:
            position += d;
            break;
        }
		// Ensure that updates only occur when translation has occurred.
		if (d.LengthSquared() > 0)
			needUpdate(true);

		return ThisPtr();

    }
示例#2
0
	//-----------------------------------------------------------------------
	Transform::Ptr Transform::SetLocalOrientation(const Quaternion & q)
	{
		orientation = q;
		orientation.Normalise();
		needUpdate(true);
		return ThisPtr();
	}
示例#3
0
    //-----------------------------------------------------------------------
    Transform::Ptr Transform::Rotate(const Quaternion& q, TransformSpace relativeTo)
    {
		// Normalise quaternion to avoid drift
		Quaternion qnorm = q;
		qnorm.Normalise();

        switch(relativeTo)
        {
        case TS_PARENT:
            // Rotations are normally relative to local axes, transform up
            orientation = qnorm * orientation;
            break;
        case TS_WORLD:
            // Rotations are normally relative to local axes, transform up
            orientation = orientation * _getDerivedOrientation().Inverse()
                * qnorm * _getDerivedOrientation();
            break;
        case TS_LOCAL:
            // Note the order of the mult, i.e. q comes after
            orientation = orientation * qnorm;
            break;
        }
        needUpdate(true);
		return ThisPtr();
    }
示例#4
0
    //-----------------------------------------------------------------------
    void Transform::requestUpdate(Transform::Ptr child, bool forceParentUpdate)
    {
        // If we're already going to update everything this doesn't matter
        if (needChildUpdate)
        {
            return;
        }

		childrenToUpdate.push_back(child);

        // Request selective update of me, if we didn't do it before
        if (parent && (!parentNotified || forceParentUpdate))
		{
			//Log("Request Update: " + ThisPtr()->componentParent->GetName());
            parent->requestUpdate(ThisPtr(), forceParentUpdate);
			parentNotified = true ;
		}

		// If there isn't a parent, and the needUpdate has hit this Transform
		// trigger a cascading update.
		if ( !parent )
		{
			//Log("Hit Root: " + ThisPtr()->componentParent->GetName());
			_update(needChildUpdate, needParentUpdate);
		}
    }
void FWidgetBlueprintEditor::RegisterApplicationModes(const TArray<UBlueprint*>& InBlueprints, bool bShouldOpenInDefaultsMode, bool bNewlyCreated/* = false*/)
{
	//FBlueprintEditor::RegisterApplicationModes(InBlueprints, bShouldOpenInDefaultsMode);

	if ( InBlueprints.Num() == 1 )
	{
		TSharedPtr<FWidgetBlueprintEditor> ThisPtr(SharedThis(this));

		// Create the modes and activate one (which will populate with a real layout)
		TArray< TSharedRef<FApplicationMode> > TempModeList;
		TempModeList.Add(MakeShareable(new FWidgetDesignerApplicationMode(ThisPtr)));
		TempModeList.Add(MakeShareable(new FWidgetGraphApplicationMode(ThisPtr)));

		for ( TSharedRef<FApplicationMode>& AppMode : TempModeList )
		{
			AddApplicationMode(AppMode->GetModeName(), AppMode);
		}

		SetCurrentMode(FWidgetBlueprintApplicationModes::DesignerMode);
	}
	else
	{
		//// We either have no blueprints or many, open in the defaults mode for multi-editing
		//AddApplicationMode(
		//	FBlueprintEditorApplicationModes::BlueprintDefaultsMode,
		//	MakeShareable(new FBlueprintDefaultsApplicationMode(SharedThis(this))));
		//SetCurrentMode(FBlueprintEditorApplicationModes::BlueprintDefaultsMode);
	}
}
示例#6
0
    //-----------------------------------------------------------------------
    Transform::Ptr Transform::Scaled(float x, float y, float z)
    {
        scale[0] *= x;
        scale[1] *= y;
        scale[0] *= z;
		needUpdate(true);
		return ThisPtr();
    }
示例#7
0
    //-----------------------------------------------------------------------
	Transform::Ptr Transform::SetLocalScale(float x, float y, float z)
    {
        scale.x = x;
        scale.y = y;
        scale.z = z;
		needUpdate(true);
		return ThisPtr();
    }
示例#8
0
    //-----------------------------------------------------------------------
    Transform::Ptr Transform::Scaled(const Vector3& multScale)
    {
        scale[0] *= multScale.x;
        scale[1] *= multScale.y;
        scale[0] *= multScale.z;
		needUpdate(true);
		return ThisPtr();
    }
示例#9
0
	//-----------------------------------------------------------------------
	Transform::Ptr Transform::SetLocalOrientation(float w, float x, float y, float z)
	{
		orientation.w = w;
		orientation.x = x;
		orientation.y = y;
		orientation.z = z;
		needUpdate(true);
		return ThisPtr();
	}
示例#10
0
	Transform::Ptr Transform::RemoveAllChildren()
	{
		// Remove all children setting their parent pointers to null
		for ( TransformList::iterator childNode = children.begin(); childNode != children.end(); childNode++)
		{
			(*childNode)->parent = nullptr;
		}
		children.clear();
		needUpdate();
		return ThisPtr();
	}
示例#11
0
	void RigidBody::Setup()
	{
		// If the rigid body hasn't yet been setup, and there is a parent transform
		if (!hasSetup && snTransform)
		{
			//create a dynamic rigidbody
            
			//btCollisionShape* colShape = new btBoxShape(btVector3(1,1,1));
			colShape = new btBoxShape(btVector3(0.5f, 0.5f, 0.5f));

			/// Create Dynamic Objects
			transform.setIdentity();

			//rigidbody is dynamic if and only if mass is non zero, otherwise static
			bool isDynamic = (mass != 0.f);

			btVector3 localInertia(0, 0, 0);
			if (isDynamic)
				colShape->calculateLocalInertia(mass, localInertia);

			Vector3 position = snTransform->GetPosition();
			transform.setOrigin(btVector3(position.x, position.y, position.z));
			Quaternion rot = snTransform->GetOrientation();
			transform.setRotation(btQuaternion(rot.x, rot.y, rot.z, rot.w));

			//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
			myMotionState = new btDefaultMotionState(transform);
			btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, myMotionState, colShape, localInertia);

			rigidBody = new btRigidBody(rbInfo);

			// Configure the Collision options for the object

			int collisionFlags = rigidBody->getCollisionFlags();

			// Indicate that the rigidbody will fire a callback on collision
			collisionFlags |= btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK;

			// if kinematic
			if (kinematic)
			{
				collisionFlags |= btCollisionObject::CF_KINEMATIC_OBJECT;
			}

			rigidBody->setCollisionFlags( collisionFlags );

			// Attach a handle to this object to the rigidbody
			rigidBody->setUserPointer(ThisPtr().get());

			createdCallback(GetId(), rigidBody);

			hasSetup = true;
		}
	}
示例#12
0
    //-----------------------------------------------------------------------
    void Transform::cancelUpdate(Transform::Ptr child)
    {
		childrenToUpdate.remove(child);

        // Propogate this up if we're done
		if (childrenToUpdate.empty() && parent && !needChildUpdate)
        {
            parent->cancelUpdate(ThisPtr());
			parentNotified = false ;
        }
    }
示例#13
0
	Transform::Ptr Transform::AddChild(Transform::Ptr childNode)
	{
		// Check if the node is already a child
		TransformList::iterator foundChild = find(children.begin(), children.end(), childNode);
		
		// If it's not already a child
		if ( foundChild == children.end() )
		{
			// if this node isn't the parent
			if ( (childNode->parent != nullptr) && (childNode->parent != ThisPtr() ) )
			{
				// Remove it from it's existing parent
				childNode->parent->RemoveChild(childNode);
			}

			// Set this node as the parent and add it to the children
			childNode->SetParentTransform(ThisPtr());
			children.push_back(childNode);
		}
		needUpdate();
		return ThisPtr();
	}
示例#14
0
	Transform::Ptr Transform::SetScale(const Vector3& newScale)
	{
		if (parent)
		{
			scale = newScale / parent->_getDerivedScale();
		}
		else
		{
			scale = newScale;
		}
		needUpdate(true);
		return ThisPtr();
	}
示例#15
0
	Transform::Ptr Transform::RemoveChild(Transform::Ptr childNode)
	{
		// Check if the node is already a child
		TransformList::iterator foundChild = find(children.begin(), children.end(), childNode);

		// If the node is a child
		if ( foundChild != children.end() )
		{
			children.remove(childNode);
			childNode->parent = nullptr;
		}
		needUpdate();
		return ThisPtr();
	}
示例#16
0
    //-----------------------------------------------------------------------
    Transform::Ptr Transform::SetOrientation( const Quaternion & q )
    {
		if (parent)
		{
			orientation = (parent->_getDerivedOrientation() * q);
		}
		else
		{
			orientation = q;
		}
		orientation.Normalise();
        needUpdate(true);
		return ThisPtr();
    }
示例#17
0
    //-----------------------------------------------------------------------
	Transform::Ptr Transform::SetPosition(const Vector3& pos)
	{
		// Convert World to local
		if (parent)
		{
			position = pos - parent->_getDerivedPosition();
		}
		else
		{
			position = pos;
		}
		needUpdate(true);
		return ThisPtr();
    }
void FWidgetBlueprintEditor::InitWidgetBlueprintEditor(const EToolkitMode::Type Mode, const TSharedPtr< IToolkitHost >& InitToolkitHost, const TArray<UBlueprint*>& InBlueprints, bool bShouldOpenInDefaultsMode)
{
	TSharedPtr<FWidgetBlueprintEditor> ThisPtr(SharedThis(this));
	WidgetToolbar = MakeShareable(new FWidgetBlueprintEditorToolbar(ThisPtr));

	InitBlueprintEditor(Mode, InitToolkitHost, InBlueprints, bShouldOpenInDefaultsMode);

	// register for any objects replaced
	GEditor->OnObjectsReplaced().AddSP(this, &FWidgetBlueprintEditor::OnObjectsReplaced);

	UWidgetBlueprint* Blueprint = GetWidgetBlueprintObj();

	// If this blueprint is empty, add a canvas panel as the root widget.
	if ( Blueprint->WidgetTree->RootWidget == nullptr )
	{
		UWidget* RootWidget = Blueprint->WidgetTree->ConstructWidget<UCanvasPanel>(UCanvasPanel::StaticClass());
		RootWidget->SetDesignerFlags(GetCurrentDesignerFlags());
		Blueprint->WidgetTree->RootWidget = RootWidget;
	}

	UpdatePreview(GetWidgetBlueprintObj(), true);

	// If the user has close the sequencer tab, this will not be initialized.
	if ( SequencerObjectBindingManager.IsValid() )
	{
		SequencerObjectBindingManager->InitPreviewObjects();
	}

	DesignerCommandList = MakeShareable(new FUICommandList);

	DesignerCommandList->MapAction(FGenericCommands::Get().Delete,
		FExecuteAction::CreateSP(this, &FWidgetBlueprintEditor::DeleteSelectedWidgets),
		FCanExecuteAction::CreateSP(this, &FWidgetBlueprintEditor::CanDeleteSelectedWidgets)
		);

	DesignerCommandList->MapAction(FGenericCommands::Get().Copy,
		FExecuteAction::CreateSP(this, &FWidgetBlueprintEditor::CopySelectedWidgets),
		FCanExecuteAction::CreateSP(this, &FWidgetBlueprintEditor::CanCopySelectedWidgets)
		);

	DesignerCommandList->MapAction(FGenericCommands::Get().Cut,
		FExecuteAction::CreateSP(this, &FWidgetBlueprintEditor::CutSelectedWidgets),
		FCanExecuteAction::CreateSP(this, &FWidgetBlueprintEditor::CanCutSelectedWidgets)
		);

	DesignerCommandList->MapAction(FGenericCommands::Get().Paste,
		FExecuteAction::CreateSP(this, &FWidgetBlueprintEditor::PasteWidgets),
		FCanExecuteAction::CreateSP(this, &FWidgetBlueprintEditor::CanPasteWidgets)
		);
}
示例#19
0
	//-----------------------------------------------------------------------
    void Transform::needUpdate(bool forceParentUpdate)
    {

        needParentUpdate = true;
		needChildUpdate = true;
        cachedTransformOutOfDate = true;
		//Log("needUpdate: " + ThisPtr()->componentParent->GetName());
        // Make sure we're not root and parent hasn't been notified before
        if (parent && (!parentNotified || forceParentUpdate))
        {
            parent->requestUpdate(ThisPtr(), forceParentUpdate);
			parentNotified = true ;
        }

        // all children will be updated
		childrenToUpdate.clear();
    }
示例#20
0
	Transform::Ptr Transform::SetParentTransform(Transform::Ptr newParent)
	{
		parent = newParent;
		needUpdate();
		return ThisPtr();
	}
示例#21
0
    //-----------------------------------------------------------------------
    Transform::Ptr Transform::Yaw(const float& angle, TransformSpace relativeTo)
    {
        Rotate(Up(), angle, relativeTo);
		return ThisPtr();

    }
示例#22
0
    //-----------------------------------------------------------------------
    Transform::Ptr Transform::Pitch(const float& angle, TransformSpace relativeTo)
    {
        Rotate(Right(), angle, relativeTo);
		return ThisPtr();
    }
示例#23
0
    //-----------------------------------------------------------------------
    Transform::Ptr Transform::Roll(const float& angle, TransformSpace relativeTo)
    {
        Rotate(Forward(), angle, relativeTo);
		return ThisPtr();
    }
void PointLightComponent::Register()
{
	Super::Register();
	mOwner.GetGame().GetRenderer().AddPointLight(ThisPtr());
}
示例#25
0
    //-----------------------------------------------------------------------
    Transform::Ptr Transform::Translate(float x, float y, float z, TransformSpace relativeTo)
    {
        Vector3 v(x,y,z);
        Translate(v, relativeTo);
		return ThisPtr();
    }
示例#26
0
	ShaderStage::Ptr ShaderStage::SetMaterialDefinition(std::string matDef)
	{
		materialDef = matDef;
		return ThisPtr();
	}
示例#27
0
    //-----------------------------------------------------------------------
    Transform::Ptr Transform::Translate(const Matrix3& axes, const Vector3& move, TransformSpace relativeTo)
    {
        Vector3 derived = axes * move;
        Translate(derived, relativeTo);
		return ThisPtr();
    }
示例#28
0
    //-----------------------------------------------------------------------
    Transform::Ptr Transform::Rotate(const Vector3& axis, const float& angle, TransformSpace relativeTo)
    {
        Quaternion q(axis, angle);
        Rotate(q, relativeTo);
		return ThisPtr();
    }
void PointLightComponent::Unregister()
{
	Super::Unregister();
	mOwner.GetGame().GetRenderer().RemovePointLight(ThisPtr());
}
示例#30
0
    //-----------------------------------------------------------------------
    Transform::Ptr Transform::Translate(const Matrix3& axes, float x, float y, float z, TransformSpace relativeTo)
    {
        Vector3 d(x,y,z);
        Translate(axes,d,relativeTo);
		return ThisPtr();
    }