private void getStartedRaver(ScriptEventData gotRaverStarted) { if (gotRaverStarted.Data == null) { return; } SendStartedRaver sendStartedRaver = gotRaverStarted.Data.AsInterface <SendStartedRaver>(); if (sendStartedRaver == null) { Log.Write(LogLevel.Error, Script.ID.ToString(), "Unable to create interface, check logs for missing member(s)"); return; } //Log.Write("sendStartedRaver.SetRaverStart[0] : " + sendStartedRaver.SetRaverStart[0]); //Log.Write("OnOrOffBlock: " + OnOrOffBlock); if (sendStartedRaver.SetRaverStart[0] == "on") { if (OnOrOffBlock == "off") { //move off block below stage RigidBody.SetMass(0.0f); RigidBody.SetPosition(HideOffPos); RigidBody.SetMass(SignMass); } else if (OnOrOffBlock == "on") { //move on block above start volume Wait(TimeSpan.FromSeconds(0.1)); RigidBody.SetMass(0.0f); RigidBody.SetPosition(DisplayPos); RigidBody.SetMass(SignMass); } } else if (sendStartedRaver.SetRaverStart[0] == "off") { if (OnOrOffBlock == "on") { //move on block below stage Wait(TimeSpan.FromSeconds(0.1)); RigidBody.SetMass(0.0f); RigidBody.SetPosition(HideOnPos); RigidBody.SetMass(SignMass); } else if (OnOrOffBlock == "off") { //move off block above start volume RigidBody.SetMass(0.0f); RigidBody.SetPosition(DisplayPos); RigidBody.SetMass(SignMass); } } }
private void DisplayBPMBlock() //Take Block from Bin and Place it Above The Bin to show what is currently playing { BeatBlockMass = RigidBody.GetMass(); CurPos = RigidBody.GetPosition(); RigidBody.SetMass(0.0f); float XDisplayPos = 1.0f; float YDisplayPos = 0.7f; float ZDisplayPos = 2.2f; Vector DisplayPos = new Vector(XDisplayPos, YDisplayPos, ZDisplayPos); RigidBody.SetPosition(DisplayPos); RigidBody.SetOrientation(RotQuat); RigidBody.SetMass(BeatBlockMass); }
private void ReturnBeatBlock() //Returns playing beat block from Display above Bin to 1st Floor Rack { //Take Block from Bin and Return it to Beat Box Staging Area BeatBlockMass = RigidBody.GetMass(); CurPos = RigidBody.GetPosition(); RigidBody.SetMass(0.0f); // float floorZPosition = 0.0f; // switch (newFloor) // { // case "1": // floorZPosition = ZWarehousePos - 3.0f; // break; // case "2": // floorZPosition = ZWarehousePos - 6.0f; // break; // case "3": // floorZPosition = ZWarehousePos - 9.0f; // break; // case "4": // floorZPosition = ZWarehousePos - 12.0f; // break; // case "5": // floorZPosition = ZWarehousePos - 15.0f; // break; // case "6": // floorZPosition = ZWarehousePos - 18.0f; // break; // case "7": // floorZPosition = ZWarehousePos - 21.0f; // break; // case "8": // floorZPosition = ZWarehousePos - 24.0f; // break; // case "9": // floorZPosition = ZWarehousePos - 27.0f; // break; // default: // ScenePrivate.Chat.MessageAllUsers("Not a valid floor in Sample Warehouse"); // break; // } RigidBody.SetPosition(CurPos - OffsetPos); //Take Block from Bin and Return it to Beat Box Staging Area //CurPos = RigidBody.GetPosition(); Vector WarehousePos = new Vector(XWarehousePos, YWarehousePos, ZWarehousePos); RigidBody.SetPosition(WarehousePos); RigidBody.SetOrientation(RotQuat); RigidBody.SetMass(BeatBlockMass); hitDetected = false; }
private void ReturnBeatBlock() { //Take Block from Bin and Return it to Beat Box Staging Area BeatBlockMass = RigidBody.GetMass(); CurPos = RigidBody.GetPosition(); RigidBody.SetMass(0.0f); RigidBody.SetPosition(CurPos - OffsetPos); //Take Block from Bin and Return it to Beat Box Staging Area CurPos = RigidBody.GetPosition(); Vector WarehousePos = new Vector(XWarehousePos, YWarehousePos, ZWarehousePos); RigidBody.SetPosition(WarehousePos); RigidBody.SetOrientation(RotQuat); RigidBody.SetMass(BeatBlockMass); }
private void LocalTeleport(int MoveNumber, ScriptEventData data) { Log.Write("MoveNumber: " + MoveNumber); LastCameraMan = CameraMan; foreach (AgentPrivate agent in ScenePrivate.GetAgents()) { Log.Write(agent.AgentInfo.Name); if (agent.AgentInfo.Name == CameraMan) { Log.Write("Camaeraman found"); ObjectPrivate objectPrivate = ScenePrivate.FindObject(agent.AgentInfo.ObjectId); if (objectPrivate != null) { AnimationComponent anim = null; if (objectPrivate.TryGetFirstComponent(out anim)) { RigidBody.SetPosition(MoveVector[MoveNumber]); Wait(TimeSpan.FromSeconds(0.05)); anim.SetPosition(MoveVector[MoveNumber]); Wait(TimeSpan.FromSeconds(0.05)); Quaternion rotation = Quaternion.FromEulerAngles(Mathf.RadiansPerDegree * RotateVector[MoveNumber]); RigidBody.SetOrientation(rotation); //PlayMovement(MoveNumber, data); } } } } }
bool ResetToInitialPosition(RigidBodyComponent rigidBody) { ObjectPrivate objectPrivate = ScenePrivate.FindObject(rigidBody.ComponentId.ObjectId); if (objectPrivate != null && objectPrivate.IsValid) { try { var motionType = rigidBody.GetMotionType(); WaitFor(rigidBody.SetMotionType, RigidBodyMotionType.MotionTypeKeyframed); rigidBody.SetAngularVelocity(Vector.Zero); rigidBody.SetLinearVelocity(Vector.Zero); rigidBody.SetOrientation(objectPrivate.InitialRotation); rigidBody.SetPosition(objectPrivate.InitialPosition); rigidBody.SetMotionType(motionType); return(true); } catch { Log.Write(LogLevel.Error, __SimpleTag, "Position Reset: error resetting object position."); } } return(false); }
void SetPositionOfCOM(Vector v) { Vector localCOM = RigidBody.GetCenterOfMass(); Quaternion rot = RigidBody.GetOrientation(); Vector offset = localCOM.Rotate(ref rot); RigidBody.SetPosition(v - offset); }
void ResetToInitialPosition() { var motionType = RigidBody.GetMotionType(); WaitFor(RigidBody.SetMotionType, RigidBodyMotionType.MotionTypeKeyframed); RigidBody.SetAngularVelocity(Vector.Zero); RigidBody.SetLinearVelocity(Vector.Zero); RigidBody.SetOrientation(ObjectPrivate.InitialRotation); RigidBody.SetPosition(ObjectPrivate.InitialPosition); RigidBody.SetMotionType(motionType); }
void ResetAfterTimeout() { Wait(ResetTimeout); _rb.SetMotionType(RigidBodyMotionType.MotionTypeKeyframed); _rb.SetAngularVelocity(Vector.Zero); _rb.SetLinearVelocity(Vector.Zero); _rb.SetPosition(ObjectPrivate.InitialPosition); _rb.SetOrientation(ObjectPrivate.InitialRotation); _rb.SetMotionType(RigidBodyMotionType.MotionTypeDynamic); }
private void UpdateLoop() { while (true) { //this is only one object, so we have it hard coded in to only follow the first agent., you could split this up later Boolean got1 = false; foreach (AgentPrivate agent in ScenePrivate.GetAgents()) { if (got1 == false) { ObjectPrivate agentObejct = ScenePrivate.FindObject(agent.AgentInfo.ObjectId); AnimationComponent anim; if (agentObejct.TryGetFirstComponent(out anim)) { Sansar.Vector fwd = anim.GetVectorAnimationVariable("LLCameraForward"); //Builds a rotation from the fwd vector Quaternion newRot = Quaternion.FromLook(fwd, Sansar.Vector.Up); //This is a basic check to make sure the camera rotation isnt all 0s if (fwd.LengthSquared() > 0) { try { RigidBody.SetAngularVelocity(Vector.Zero); RigidBody.SetLinearVelocity(Vector.Zero); RigidBody.SetPosition(agentObejct.Position + lightPositionOffset); //Order of multiplication matters here I think, start with the base rotation, //multiply by and base offset rotation for the light, then multiply by the rotation of the fwd //Keep in mind that multiplying quad A by quad b will rotate quad A by quad b RigidBody.SetOrientation(QuaternionToVector(startRot * lightOnObjectDirection * newRot).Normalized()); } catch { } } } got1 = true; } } Wait(TimeSpan.FromSeconds(.05)); } }
void OnDrop(HeldObjectData data) { try { unsubscribe?.Invoke(); if (ResetPositionOnDrop) { RigidBody.SetPosition(OriginalPosition); RigidBody.SetOrientation(OriginalOrientation); RigidBody.SetLinearVelocity(Sansar.Vector.Zero); RigidBody.SetAngularVelocity(Sansar.Vector.Zero); } } catch (NullReferenceException nre) { if (DebugSpam) { Log.Write("OnDrop", nre.Message); } } // ignore exceptions for not found agents. catch (Exception e) { if (DebugSpam) { Log.Write("OnDrop", e.ToString()); } } }
private void GetChatCommand(ChatData Data) { string DataCmd = Data.Message; //Log.Write("DataCmd: " + DataCmd); if (SubscribeToScriptEvent("SendScreenPos", getScreenPos).Active) { Log.Write("Subscription Was Active from getChatCommmand"); } else { Log.Write("Subscription Was NOT Active from getChatCommmand"); } if ((DataCmd.Substring(0, 1) == "/") && (DataCmd.Length > 1)) { string testSlide = DataCmd.Substring(0, 2); //it was a slide command Log.Write("testSlide: " + testSlide); if ((testSlide == "/0") || (testSlide == "/1") || (testSlide == "/2") || (testSlide == "/3") || (testSlide == "/4") || (testSlide == "/5") || (testSlide == "/6") || (testSlide == "/7") || (testSlide == "/8") || (testSlide == "/9")) { int from = DataCmd.IndexOf("/", StringComparison.CurrentCulture); Log.Write("from: " + from); //Log.Write("length: " + DataCmd.Length); string test = DataCmd.Substring(from + 1, DataCmd.Length - 1); Log.Write("test: " + test); if (test == SlideNumber) { //Take Block from Bin and Return it to Beat Box Staging Area //RigidBody.SetMotionType(RigidBodyMotionType.MotionTypeDynamic); Wait(TimeSpan.FromMilliseconds(200)); //Log.Write("Slide: " + SlideNumber + " Moving to Screen"); //SlideMass = RigidBody.GetMass(); CurPos = RigidBody.GetPosition(); //Log.Write("Slide: " + SlideNumber + " CurPos: " + CurPos); //RigidBody.SetMass(0.0f); //Log.Write("Slide: " + SlideNumber + " ScreenPos: " + ScreenPos); RigidBody.SetPosition(ScreenPos); //Take Block from Bin and Return it to Beat Box Staging Area RigidBody.SetOrientation(ScreenQuat); //Log.Write("Slide: " + SlideNumber + " ScreenRot: " + ScreenQuat); Wait(TimeSpan.FromMilliseconds(200)); //RigidBody.SetMotionType(RigidBodyMotionType.MotionTypeStatic); //RigidBody.SetMass(SlideMass); } else if ((testSlide == "/0") || (testSlide == "/1") || (testSlide == "/2") || (testSlide == "/3") || (testSlide == "/4") || (testSlide == "/5") || (testSlide == "/6") || (testSlide == "/7") || (testSlide == "/8") || (testSlide == "/9")) { Log.Write("Slide: " + SlideNumber + " Moving to Storage"); //RigidBody.SetMotionType(RigidBodyMotionType.MotionTypeDynamic); Wait(TimeSpan.FromMilliseconds(200)); //CurPos = RigidBody.GetPosition(); RigidBody.SetMass(0.0f); //Take Block from Bin and Return it to Beat Box Staging Area //CurPos = RigidBody.GetPosition(); RigidBody.SetPosition(CurPos); //CurQuat = Quaternion.FromEulerAngles(CurRot).Normalized(); RigidBody.SetOrientation(CurQuat); //Wait(TimeSpan.FromMilliseconds(200)); //RigidBody.SetMotionType(RigidBodyMotionType.MotionTypeStatic); RigidBody.SetMass(SlideMass); } } } }
private void UpdateLoop() { float Tick = 0.01f; float AngleStep = 5 * OpenAngle * Tick / SecondsToOpen; TimeSpan Moment = TimeSpan.FromSeconds(Tick); float Angle = 0.0f; while (true) { Wait(Moment); // If we're in the process of opening or closing, we'll adjust the angle a little toward the target if (Opening) { if (OpenOut) { Angle -= AngleStep; if (Angle < -OpenAngle) { Angle = -OpenAngle; } } else { Angle += AngleStep; if (Angle > OpenAngle) { Angle = OpenAngle; } } // If it's been a while since we've heard an open signal, let's start closing the door if (DateTime.Now.Subtract(LatestOpenSignal).TotalSeconds >= SecondsBeforeClose) { Opening = false; if (CloseSound != null) { ScenePrivate.PlaySound(CloseSound, PlaySettings.PlayOnce); } } } else { if (OpenOut) { Angle += AngleStep; if (Angle > 0f) { Angle = 0f; } } else { Angle -= AngleStep; if (Angle < 0f) { Angle = 0f; } } } // Compute the new position and rotation of the door Quaternion Rotation = Quaternion.FromEulerAngles(new Vector(0, 0, Angle, 0)); Quaternion NewOri = ClosedOrientation * Rotation; Vector NewPos = ClosedPosition - HingeOffset.Rotate(ref Rotation); // Update the door's position and orientation DoorBody.SetAngularVelocity(Vector.Zero); DoorBody.SetLinearVelocity(Vector.Zero); DoorBody.SetPosition(NewPos); DoorBody.SetOrientation(QuaternionToVector(NewOri)); } }
void SetPositionOfCOM(Vector v) { RigidBody.SetPosition(v - RigidBody.GetCenterOfMass().Rotate(RigidBody.GetOrientation())); }