public UndoState(VoosActor actor) { position = actor.GetPosition(); rotation = actor.GetRotation(); spawnPosition = actor.GetSpawnPosition(); spawnRotation = actor.GetSpawnRotation(); }
void SetActorPosition(VoosActor actor, Vector3 newPosition) { Vector3 currPosition = actor.GetPosition(); Quaternion currRotation = actor.GetRotation(); bool autosetSpawn = AutosetSpawn(); undoStack.PushUndoForActor( actor, $"Set actor position", (undoActor) => { undoActor.SetPosition(newPosition); undoActor.SetRotation(currRotation); if (autosetSpawn) { undoActor.SetSpawnPositionRotationOfEntireFamily(); } }, (undoActor) => { undoActor.SetPosition(currPosition); undoActor.SetRotation(currRotation); if (autosetSpawn) { undoActor.SetSpawnPositionRotationOfEntireFamily(); } } ); }
public override void MoveCameraToActor(VoosActor actor) { Vector3 tempvec = actor.GetPosition() - mainTransform.position; rotation = Quaternion.LookRotation(tempvec); UpdateRotationValues(rotation); mainTransform.rotation = rotation; }
internal void Update(Vector3 delta) { actor.SweepTo(delta + initialPosition); // Set both, for placing rolling physics objects. actor.SetSpawnPosition(actor.GetPosition()); actor.SetSpawnRotation(actor.GetRotation()); }
public UndoState(VoosActor actor) { position = actor.GetPosition(); rotation = actor.GetRotation(); spawnPosition = actor.GetSpawnPosition(); spawnRotation = actor.GetSpawnRotation(); enablePhysics = actor.GetEnablePhysics(); }
private void SetSpawnToCurrentPosition() { VoosActor actor = editMain.GetSingleTargetActor(); if (actor == null) { return; } SetActorSpawnPosition(actor, actor.GetPosition(), true, actor.GetTransformParent()); }
public override void MoveCameraToActor(VoosActor actor) { Vector3 tempVec = actor.GetPosition() - mainTransform.position; // Prevent camera from spinning around when we are almost perfectly above the focus object. if (Vector3.Angle(tempVec, Vector3.up) <= 165) { rotation = Quaternion.LookRotation(tempVec); UpdateRotationValues(rotation); cameraPivot.rotation = rotation; } }
private void ActorUpdate(VoosActor actor) { assetUI.header.text = $"{actor.GetDisplayName()} : Move"; UpdateVec3Input(actor.GetPosition(), assetUI.currentInputs); UpdateVec3Input(actor.GetSpawnPosition(), assetUI.spawnInputs); UpdateVec3Input(actor.GetRenderableOffset(), assetUI.offsetInputs); VoosActor parent = actor.GetEngine().GetActor(actor.GetTransformParent()); assetUI.currentParentButtonText.text = parent != null?parent.GetDisplayName() : "<none>"; VoosActor spawnParent = actor.GetEngine().GetActor(actor.GetSpawnTransformParent()); assetUI.restartParentButtonText.text = spawnParent != null?spawnParent.GetDisplayName() : "<none>"; }
private Transforms.TransformUndoState GetQuickRotateTransformState(VoosActor actor, Vector3 pivot) { Rigidbody targetRigidbody = actor.GetComponent <Rigidbody>(); if (targetRigidbody != null) { targetRigidbody.angularVelocity = Vector3.zero; } Quaternion newRotation = actor.GetRotation() * Quaternion.Euler(0, QUICK_ROTATE_AMOUNT, 0); Vector3 diff = actor.GetPosition() - pivot; Vector3 newPosition = Quaternion.AngleAxis(QUICK_ROTATE_AMOUNT, Vector3.up) * diff + pivot; return(new Transforms.TransformUndoState(newPosition, newRotation, actor.GetTransformParent())); }
public ActorInfo(VoosActor actor, EditMain editMain) { this.actor = actor; hierarchyPath = new List <ActorHierarchyInfo>(); for (VoosActor thisActor = actor; thisActor != null; thisActor = thisActor.GetParentActor()) { ActorHierarchyInfo info = new ActorHierarchyInfo(); info.name = thisActor.name; info.displayName = thisActor.GetDisplayName(); if (editMain != null) { info.distance = Vector3.Distance(editMain.GetAvatarPosition(), thisActor.GetPosition()); } hierarchyPath.Insert(0, info); } }
public void SetToPaste() { VoosActor focusActor = editMain.GetFocusedTargetActor(); if (focusActor == null) { return; } containerNode.SetPositionAndRotation(focusActor.GetPosition(), focusActor.GetRotation()); foreach (VoosActor actor in voosEngine.GetActorsAndDescendants(editMain.GetTargetActors())) { pastePreview[actor] = GetPreviewOfActor(actor); } mode = Mode.Paste; }
void SetActorRotation(VoosActor actor, Vector3 vec) { Quaternion newRotation = Quaternion.Euler(vec); Vector3 currPosition = actor.GetPosition(); Quaternion currRotation = actor.GetRotation(); undoStack.PushUndoForActor( actor, $"Set actor rotation", (undoActor) => { undoActor.SetPosition(currPosition); undoActor.SetRotation(newRotation); }, (undoActor) => { undoActor.SetPosition(currPosition); undoActor.SetRotation(currRotation); } ); }
private GameObject GetPreviewOfActor(VoosActor actor) { GameObject actorRep = new GameObject("rep"); actorRep.transform.parent = containerNode; actorRep.transform.position = actor.GetPosition(); actorRep.transform.rotation = actor.GetRotation(); Bounds _newbounds = new Bounds(actorRep.transform.position, Vector3.zero); foreach (MeshFilter mf in actor.gameObject.GetComponentsInChildren <MeshFilter>()) { // TextMeshPro becomes unhappy when its meshes are assigned to another MeshFilter // (it stops updating the text), so skip TextMeshPro meshes... if (mf.GetComponent <TMPro.TextMeshPro>()) { continue; } GameObject _newGameobject = new GameObject("copymesh"); // Note: using mf.mesh instead of mf.sharedMesh, for reasons I don't understand, // causes a native crash in the EXE but not in the Unity Editor when copying // actors that have TextMeshPro components on them, even though we have the // guard above to prevent us from copying TextMeshPro objects. Using // mf.sharedMesh solved the problem. _newGameobject.AddComponent <MeshFilter>().mesh = mf.sharedMesh; _newGameobject.AddComponent <MeshRenderer>().material = copyMaterial; _newGameobject.transform.SetParent(actorRep.transform); _newGameobject.transform.position = mf.transform.position; _newGameobject.transform.rotation = mf.transform.rotation; _newGameobject.transform.localScale = mf.transform.lossyScale; _newbounds.Encapsulate(_newGameobject.GetComponent <MeshRenderer>().bounds); } return(actorRep); }
public override void ControllerLateUpdate() { mainTransform.position = cameraActor != null?cameraActor.GetPosition() : Vector3.zero; mainTransform.rotation = cameraActor != null?cameraActor.GetRotation() : Quaternion.identity; }