internal void DoWarp(Warp WData) { // Set the warp info up. startTime = DateTime.Now; wData = WData; lastLocation = Player.Position; // Grab time to wait. List<RocketPermissionsGroup> groups = R.Permissions.GetGroups(Player, false); if (groups.Count != 0) { if (!Warps.WaitGroups.TryGetValue(groups[0].Id, out timetoWait)) if (!Warps.WaitGroups.TryGetValue("all", out timetoWait)) { Logger.LogWarning("Error: Was Unable to get time to wait on player, using default of 10 seconds."); timetoWait = 10; } } else { Logger.LogWarning("Error: Was Unable to get time to wait on player, using default of 10 seconds."); timetoWait = 10; } if (Warps.Instance.Configuration.Instance.EnableMovementRestriction) UnturnedChat.Say(Player, Warps.Instance.Translate("warp_wait_nomovement", wData.Name, timetoWait)); else UnturnedChat.Say(Player, Warps.Instance.Translate("warp_wait", wData.Name, timetoWait)); doWarp = true; }
private float get_theta(Vector3f pos_a_, Vector3f pos_b_, Vector3f pos_c_) { Vector3f top = pos_a_ - pos_b_; Vector3f bot = pos_c_ - pos_b_; return (float)(Vector3f.AngleBetween(top, bot) * (Math.PI / 180.0)); }
private static void UseAbilityTempEffect(BattleGame game,GameCharacter character, Tile target, Ability ability) { foreach (var ae in ability.activeEffects) { switch (ae.effectType) { case TempEffectType.Particle: game.gameControllerScript.StartTempParticles(ae.effectName, new UnityEngine.Vector3(target.x, -target.y)); break; case TempEffectType.Sprite: var spriteVector = new UnityEngine.Vector3(target.x, -target.y); game.gameControllerScript.StartTempSprite(spriteVector, spriteVector, ae.effectName, ae.effectIndex); break; case TempEffectType.Text: game.gameControllerScript.StartTempText(new UnityEngine.Vector3(target.x, -target.y), UnityEngine.Color.grey, ability.name); break; case TempEffectType.ProjectileSprite: var spriteVector1 = new UnityEngine.Vector3(game.ActiveCharacter.x, -game.ActiveCharacter.y); var spriteVector2 = new UnityEngine.Vector3(target.x, -target.y); game.gameControllerScript.StartTempSpriteProjectile(spriteVector1, spriteVector2, ae.effectName, ae.effectIndex); break; default: break; } } }
/// <summary> /// Tries to parse the given data to the target <see cref="IEvent"/>. /// </summary> /// <param name="eventParams">List of string-parameters to parse.</param> /// <param name="target">Target instance to parse the data to.</param> /// <returns><c>true</c> if the parsing was succesful, otherwise <c>false</c> is returned.</returns> public bool TryParse(List<string> eventParams, IEvent target) { if (eventParams.Count < 4) { return false; } if (string.IsNullOrEmpty(eventParams[0])) { return false; } float posX, posY, posZ; if( !float.TryParse(eventParams[1], out posX) || !float.TryParse(eventParams[2], out posY) || !float.TryParse(eventParams[3], out posZ) ) { return false; } if (!target.HasProperty("EntityName") || !target.HasProperty("Target")) { return false; } UnityEngine.Vector3 targetPosition = new UnityEngine.Vector3(); targetPosition.x = posX; targetPosition.y = posY; targetPosition.z = posZ; target.SetProperty("EntityName", eventParams[0]); target.SetProperty("Target", targetPosition); return true; }
/// <summary> /// Teleports this player's character to the specified position /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> public void Teleport(float x, float y, float z) { if (player.IsSpectating()) return; var dest = new UnityEngine.Vector3(x, y, z); player.transform.position = dest; player.ClientRPCPlayer(null, player, "ForcePositionTo", dest); }
public Zone(string line) : base(line) { Name = GetString(0); Min = new UnityEngine.Vector3(GetSingle(2), GetSingle(4), GetSingle(3)); Max = new UnityEngine.Vector3(GetSingle(5), GetSingle(7), GetSingle(6)); }
public RespawnEvent(Player p) { SpawnPos = UnityEngine.Vector3.zero; WakeUp = false; ChangePos = false; GiveDefault = true; Player = p; }
public Particle(Vector3f position_, Vector3f velocity_, float mass_, float radius_, float gravity_) { position = position_; velocity = velocity_; force = Vector3f.zero; acceleration = Vector3f.zero; mass = mass_; radius = radius_; gravity = gravity_; }
protected override void runPreLogic(float deltaTime) { if (p_simplePhysicsLogic != null) { m_drag = (float)m_attributes["DragCoefficient"] * (float)m_attributes["ReferenceArea"] * 0.5f * m_density * p_simplePhysicsLogic.m_velocity.sqrMagnitude; m_dragDirectionVector = -p_simplePhysicsLogic.m_velocity.normalized; } m_dragForce.force = m_drag * m_dragDirectionVector; }
public static UnityEngine.Vector3 LocalTranslatedVec3(UnityEngine.Vector3 input, UnityEngine.Transform localObj) { outputV3 = new UnityEngine.Vector3(); ang = UnityEngine.Mathf.Atan2(input.y, input.x); ang += localObj.localRotation.eulerAngles.z * UnityEngine.Mathf.Deg2Rad; len = input.magnitude; outputV3.x = UnityEngine.Mathf.Cos(ang) * len; outputV3.y = UnityEngine.Mathf.Sin(ang) * len; //UnityEngine.//Debug.Log(outputV3); return outputV3 + localObj.localPosition; }
protected override void runPostLogic(float deltaTime) { m_throttle = UnityEngine.Mathf.Clamp01(m_throttle); m_thrust = (float)m_attributes["MaxThrust"] * m_throttle; if (p_simplePhysicsLogic != null) { m_thrustDirectionVector = p_simplePhysicsLogic.m_velocity.normalized; } m_thrustForce.force = m_thrust * m_thrustDirectionVector; }
protected override void runPostLogic(float deltaTime) { UnityEngine.Vector3 totalForce = new UnityEngine.Vector3(0.0f, 0.0f, 0.0f); foreach (ConstantForce constantForce in m_constantForces) totalForce += constantForce.force; foreach (UnityEngine.Vector3 force in m_impulseForces) totalForce += force; m_position += m_velocity * deltaTime; m_velocity += totalForce / m_mass * deltaTime; }
public Vertex(WaterFace face, int offset) { Position = new UnityEngine.Vector3( face.GetSingle(offset + 0), face.GetSingle(offset + 2), face.GetSingle(offset + 1)); CurrentSpeed = new UnityEngine.Vector2( face.GetSingle(offset + 3), face.GetSingle(offset + 4)); WaveHeight = face.GetSingle(offset + 6); }
private Pendulum(Particle point_a_, Particle point_b_, Vector3f equilibrium_position_, Render callback_, params IConstraint[] constraints_) { point_a = point_a_; point_b = point_b_; callback = callback_; equilibrium_position = equilibrium_position_; constraints = new IConstraint[constraints_.Length]; for(int i = 0; i < constraints_.Length; ++i) { constraints[i] = constraints_[i]; } }
public static void Test_Vector3_Generic_ClampMagnitude_Methods_Against_Unity3D(float a, float b, float c, float clamp) { //arrange Vector3<float> genericVec3 = new Vector3<float>(a, b, c); UnityEngine.Vector3 unityVec3 = new UnityEngine.Vector3(a, b, c); //act Vector3<float> genericVec3Clamped = genericVec3.ClampMagnitude(clamp); UnityEngine.Vector3 unityVec3Clamped = UnityEngine.Vector3.ClampMagnitude(unityVec3, clamp); //assert for (int index = 0; index < 3; index++) Assert.AreEqual(unityVec3Clamped[index], genericVec3Clamped[index], UnityEngine.Vector3.kEpsilon, "Index: {0} was incorrect.", index); }
protected override void runPreLogic(float deltaTime) { if (p_simplePhysicsLogic != null) { m_desiredYawRate = UnityEngine.Mathf.Min(m_desiredYawRate, (float)m_attributes["YawRate"]); m_side = p_simplePhysicsLogic.m_mass * m_desiredYawRate * p_simplePhysicsLogic.m_velocity.magnitude; m_sideDirectionVector = p_simplePhysicsLogic.m_rotation * UnityEngine.Vector3.right; m_desiredPitchRate = UnityEngine.Mathf.Min(m_desiredPitchRate, (float)m_attributes["PitchRate"]); m_lift = p_simplePhysicsLogic.m_mass * m_desiredPitchRate * p_simplePhysicsLogic.m_velocity.magnitude; m_liftDirectionVector = -(p_simplePhysicsLogic.m_rotation * UnityEngine.Vector3.up); } m_sideForce.force = m_side * m_sideDirectionVector; m_liftForce.force = m_lift * m_liftDirectionVector; }
protected override void runPostLogic(float deltaTime) { if (m_parentObject is SimplePhysicsLogic) { p_velocity = p_simplePhysicsLogic.m_velocity; if (Actived && ActiveLength < m_CatapultLength) { ActiveLength += deltaTime; if (p_simplePhysicsLogic != null) { m_CatapultForce.force = (p_velocity) * (int)m_attributes["CatapultForce"]; } } if (ActiveLength >= m_CatapultLength) Actived = false; } }
public static void Test_Vector3_Generic_Cross_Product_Against_Unity3D(float a, float b, float c, float d, float e, float f) { //arrange Vector3<float> genericVec3One = new Vector3<float>(a, b, c); Vector3<float> genericVec3Two = new Vector3<float>(d, e, f); UnityEngine.Vector3 unityVec3One = new UnityEngine.Vector3(a, b, c); UnityEngine.Vector3 unityVec3Two = new UnityEngine.Vector3(d, e, f); //act Vector3<float> genericVec3Cross = genericVec3One.Cross(genericVec3Two); UnityEngine.Vector3 unityVec3Cross = UnityEngine.Vector3.Cross(unityVec3One, unityVec3Two); Vector3<float> manualCross = new Vector3<float>(genericVec3One.y * genericVec3Two.z - genericVec3One.z * genericVec3Two.y, genericVec3One.z * genericVec3Two.x - genericVec3One.x * genericVec3Two.z, genericVec3One.x * genericVec3Two.y - genericVec3One.y * genericVec3Two.x); double termOne = Operator<double>.Multiply((double)genericVec3One.y, (double)genericVec3Two.z); double termTwo = Operator<double>.Multiply((double)genericVec3One.z, (double)genericVec3Two.y); double termThree = Operator<double>.Multiply((double)genericVec3One.z, (double)genericVec3Two.x); double termFour = Operator<double>.Multiply((double)genericVec3One.x, (double)genericVec3Two.z); double termFive = Operator<double>.Multiply((double)genericVec3One.x, (double)genericVec3Two.y); double termSix = Operator<double>.Multiply((double)genericVec3One.y, (double)genericVec3Two.x); double newX = Operator<double>.Subtract((double)termOne, (double)termTwo); double newY = Operator<double>.Subtract((double)termThree, (double)termFour); double newZ = Operator<double>.Subtract((double)termFive, (double)termSix); Vector3<float> operatorGenericCross = new Vector3<float>((float)newX, (float)newY, (float)newZ); //assert for (int i = 0; i < 3; i++) //we have to accept a higher delta of error since cross product has so much float math. { Assert.AreEqual(operatorGenericCross[i], manualCross[i]); Assert.AreEqual(manualCross[i], unityVec3Cross[i]); Assert.AreEqual(unityVec3Cross[i], genericVec3Cross[i], UnityEngine.Vector3.kEpsilon * 5, "Index: {0} failed. Failed to compute cross product.", i); } }
static UnityEngine.Vector3[] CreateSphere(float radius, out int[] indices) { int slices = (int)(radius * 10.0f); int stacks = (int)(radius * 10.0f); slices = (slices > 16) ? 16 : (slices < 3) ? 3 : slices; stacks = (stacks > 16) ? 16 : (stacks < 2) ? 2 : stacks; float hAngleStep = (float)Math.PI * 2 / slices; float vAngleStep = (float)Math.PI / stacks; int vertexCount = 2 + slices * (stacks - 1); int indexCount = 6 * slices * (stacks - 1); UnityEngine.Vector3[] vertices = new UnityEngine.Vector3[vertexCount * 2]; indices = new int[indexCount]; int i = 0, v = 0; // Vertices // Top and bottom vertices[v++] = new UnityEngine.Vector3(0, -radius, 0); vertices[v++] = -UnityEngine.Vector3.up; vertices[v++] = new UnityEngine.Vector3(0, radius, 0); vertices[v++] = UnityEngine.Vector3.up; // Stacks int j, k; float angle = 0; float vAngle = -(float)Math.PI / 2; UnityEngine.Vector3 vTemp; for (j = 0; j < stacks - 1; j++) { vAngle += vAngleStep; for (k = 0; k < slices; k++) { angle += hAngleStep; vTemp = new UnityEngine.Vector3((float)Math.Cos(vAngle) * (float)Math.Sin(angle), (float)Math.Sin(vAngle), (float)Math.Cos(vAngle) * (float)Math.Cos(angle)); vertices[v++] = vTemp * radius; vertices[v++] = UnityEngine.Vector3.Normalize(vTemp); } } // Indices // Top cap ushort index = 2; for (k = 0; k < slices; k++) { indices[i++] = index++; indices[i++] = 0; indices[i++] = index; } indices[i - 1] = 2; // Stacks //for (j = 0; j < 1; j++) int sliceDiff = slices * 3; for (j = 0; j < stacks - 2; j++) { for (k = 0; k < slices; k++) { indices[i] = indices[i - sliceDiff + 2]; indices[i + 1] = index++; indices[i + 2] = indices[i - sliceDiff]; i += 3; } for (k = 0; k < slices; k++) { indices[i] = indices[i - sliceDiff + 1]; indices[i + 1] = indices[i - sliceDiff]; indices[i + 2] = indices[i - sliceDiff + 4]; i += 3; } indices[i - 1] = indices[i - sliceDiff]; } // Bottom cap index--; for (k = 0; k < slices; k++) { indices[i++] = index--; indices[i++] = 1; indices[i++] = index; } indices[i - 1] = indices[i - sliceDiff]; return vertices; }
public static UnityEngine.Vector3[] CreateConvexHull(ConvexHullShape shape) { ShapeHull hull = new ShapeHull(shape); hull.BuildHull(shape.Margin); int vertexCount = hull.NumIndices; UIntArray indices = hull.Indices; Vector3Array points = hull.Vertices; UnityEngine.Vector3[] vertices = new UnityEngine.Vector3[vertexCount * 2]; int v = 0, i; for (i = 0; i < vertexCount; i += 3) { UnityEngine.Vector3 v0 = points[(int)indices[i]].ToUnity(); UnityEngine.Vector3 v1 = points[(int)indices[i + 1]].ToUnity(); UnityEngine.Vector3 v2 = points[(int)indices[i + 2]].ToUnity(); UnityEngine.Vector3 v01 = v0 - v1; UnityEngine.Vector3 v02 = v0 - v2; UnityEngine.Vector3 normal; normal = UnityEngine.Vector3.Cross(v01, v02); normal.Normalize(); vertices[v++] = v0; vertices[v++] = normal; vertices[v++] = v1; vertices[v++] = normal; vertices[v++] = v2; vertices[v++] = normal; } return vertices; }
public static UnityEngine.Vector3[] CreateMultiSphere(MultiSphereShape shape, out int[] indices) { List<UnityEngine.Vector3[]> allVertices = new List<UnityEngine.Vector3[]>(); List<int[]> allIndices = new List<int[]>(); int vertexCount = 0; int indexCount = 0; int i; for (i = 0; i < shape.SphereCount; i++) { int[] sphereIndices; UnityEngine.Vector3[] sphereVertices = CreateSphere(shape.GetSphereRadius(i), out sphereIndices); // Adjust sphere position UnityEngine.Vector3 position = shape.GetSpherePosition(i).ToUnity(); for (int j = 0; j < sphereVertices.Length / 2; j++) { sphereVertices[j * 2] += position; } // Adjust indices if (indexCount != 0) { int indexOffset = vertexCount / 2; for (int j = 0; j < sphereIndices.Length; j++) { sphereIndices[j] += (int)indexOffset; } } allVertices.Add(sphereVertices); allIndices.Add(sphereIndices); vertexCount += sphereVertices.Length; indexCount += sphereIndices.Length; } UnityEngine.Vector3[] finalVertices = new UnityEngine.Vector3[vertexCount]; int vo = 0; foreach (UnityEngine.Vector3[] v in allVertices) { v.CopyTo(finalVertices, vo); vo += v.Length; } indices = new int[indexCount]; int io = 0; foreach (int[] ind in allIndices) { ind.CopyTo(indices, io); io += ind.Length; } return finalVertices; }
/** 更新。 */ public void Update() { this.forward = this.gameObject.transform.rotation * UnityEngine.Vector3.forward; }
static private void Serialize_Vector3(ref UnityEngine.Vector3 ioData, Serializer ioSerializer) { ioSerializer.Serialize("x", ref ioData.x, FieldOptions.PreferAttribute); ioSerializer.Serialize("y", ref ioData.y, FieldOptions.PreferAttribute); ioSerializer.Serialize("z", ref ioData.z, FieldOptions.PreferAttribute); }
public Unity.Entities.Entity __Gen_Delegate_Imp50(object p0, long p1, long p2, object p3, int p4, UnityEngine.Vector3 p5, float p6, float p7) { #if THREAD_SAFE || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.rawL; int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference); ObjectTranslator translator = luaEnv.translator; translator.PushAny(L, p0); LuaAPI.lua_pushint64(L, p1); LuaAPI.lua_pushint64(L, p2); translator.PushAny(L, p3); LuaAPI.xlua_pushinteger(L, p4); translator.PushUnityEngineVector3(L, p5); LuaAPI.lua_pushnumber(L, p6); LuaAPI.lua_pushnumber(L, p7); PCall(L, 8, 1, errFunc); Unity.Entities.Entity __gen_ret; translator.Get(L, errFunc + 1, out __gen_ret); LuaAPI.lua_settop(L, errFunc - 1); return(__gen_ret); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
public static GameWork.Core.Math.Types.Vector3 ToGameWorkType(this UnityEngine.Vector3 engineType) { return(new GameWork.Core.Math.Types.Vector3(engineType.x, engineType.y, engineType.z)); }
public UnityEngine.Vector3 __Gen_Delegate_Imp18(object p0, UnityEngine.Vector3 p1, UnityEngine.Vector3 p2) { #if THREAD_SAFE || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.rawL; int err_func = LuaAPI.load_error_func(L, errorFuncRef); ObjectTranslator translator = luaEnv.translator; LuaAPI.lua_getref(L, luaReference); translator.PushAny(L, p0); translator.PushUnityEngineVector3(L, p1); translator.PushUnityEngineVector3(L, p2); int __gen_error = LuaAPI.lua_pcall(L, 3, 1, err_func); if (__gen_error != 0) { luaEnv.ThrowExceptionFromError(err_func - 1); } UnityEngine.Vector3 __gen_ret; translator.Get(L, err_func + 1, out __gen_ret); LuaAPI.lua_settop(L, err_func - 1); return(__gen_ret); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
//[NamedItems("Top", "Bottom", "Left", "Right", "Front", "Back", "Tread", "Step", overflow = "Side {0}", fixedSize = 8)] //public ChiselSurfaceDefinition surfaceDefinition; #region OnEdit // // TODO: code below needs to be cleaned up & simplified // public override void OnEdit(IChiselHandles handles) { { var stepDepthOffset = settings.StepDepthOffset; var stepHeight = settings.stepHeight; var stepCount = settings.StepCount; var bounds = settings.bounds; var steps = handles.moveSnappingSteps; steps.y = stepHeight; if (handles.DoBoundsHandle(ref bounds, snappingSteps: steps)) { settings.bounds = bounds; } var min = math.min(bounds.Min, bounds.Max); var max = math.min(bounds.Min, bounds.Max); var size = (max - min); var heightStart = bounds.Max.y + (size.y < 0 ? size.y : 0); var edgeHeight = heightStart - stepHeight * stepCount; var pHeight0 = new Vector3(min.x, edgeHeight, max.z); var pHeight1 = new Vector3(max.x, edgeHeight, max.z); var depthStart = bounds.Min.z - (size.z < 0 ? size.z : 0); var pDepth0 = new Vector3(min.x, max.y, depthStart + stepDepthOffset); var pDepth1 = new Vector3(max.x, max.y, depthStart + stepDepthOffset); if (handles.DoTurnHandle(ref bounds)) { settings.bounds = bounds; } if (handles.DoEdgeHandle1D(out edgeHeight, Axis.Y, pHeight0, pHeight1, snappingStep: stepHeight)) { var totalStepHeight = math.clamp((heightStart - edgeHeight), size.y % stepHeight, size.y); const float kSmudgeValue = 0.0001f; var oldStepCount = settings.StepCount; var newStepCount = math.max(1, (int)math.floor((math.abs(totalStepHeight) + kSmudgeValue) / stepHeight)); settings.stepDepth = (oldStepCount * settings.stepDepth) / newStepCount; settings.plateauHeight = size.y - (stepHeight * newStepCount); } if (handles.DoEdgeHandle1D(out stepDepthOffset, Axis.Z, pDepth0, pDepth1, snappingStep: ChiselLinearStairs.kMinStepDepth)) { stepDepthOffset -= depthStart; stepDepthOffset = math.clamp(stepDepthOffset, 0, settings.AbsDepth - ChiselLinearStairs.kMinStepDepth); settings.stepDepth = ((settings.AbsDepth - stepDepthOffset) / settings.StepCount); } float heightOffset; var prevModified = handles.modified; { var direction = Vector3.Cross(Vector3.forward, pHeight0 - pDepth0).normalized; handles.DoEdgeHandle1DOffset(out var height0vec, Axis.Y, pHeight0, pDepth0, direction, snappingStep: stepHeight); handles.DoEdgeHandle1DOffset(out var height1vec, Axis.Y, pHeight1, pDepth1, direction, snappingStep: stepHeight); var height0 = Vector3.Dot(direction, height0vec); var height1 = Vector3.Dot(direction, height1vec); if (math.abs(height0) > math.abs(height1)) { heightOffset = height0; } else { heightOffset = height1; } } if (prevModified != handles.modified) { settings.plateauHeight += heightOffset; } } }
static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref UnityEngine.Vector3 instance_of_this_method) { ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); switch (ptr_of_this_method->ObjectType) { case ObjectTypes.Object: { __mStack[ptr_of_this_method->Value] = instance_of_this_method; } break; case ObjectTypes.FieldReference: { var ___obj = __mStack[ptr_of_this_method->Value]; if (___obj is ILTypeInstance) { ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { var t = __domain.GetType(___obj.GetType()) as CLRType; t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method); } } break; case ObjectTypes.StaticFieldReference: { var t = __domain.GetType(ptr_of_this_method->Value); if (t is ILType) { ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method); } } break; case ObjectTypes.ArrayReference: { var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as UnityEngine.Vector3[]; instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method; } break; } }
public bool NotifyAddTree(Nettention.Proud.HostID[] remotes, Nettention.Proud.RmiContext rmiContext, int groupID, int treeID, UnityEngine.Vector3 position) { Nettention.Proud.Message __msg = new Nettention.Proud.Message(); __msg.SimplePacketMode = core.IsSimplePacketMode(); Nettention.Proud.RmiID __msgid = Common.NotifyAddTree; __msg.Write(__msgid); SngClient.Marshaler.Write(__msg, groupID); SngClient.Marshaler.Write(__msg, treeID); SngClient.Marshaler.Write(__msg, position); return(RmiSend(remotes, rmiContext, __msg, RmiName_NotifyAddTree, Common.NotifyAddTree)); }
public static void DrawDebugLine(UnityEngine.Vector3 start, UnityEngine.Vector3 end, int colorIndex = 0) { UnityEngine.Debug.DrawRay(start, end, Helpers.Colors[colorIndex], 0.0f, false); UnityEngine.Debug.DrawRay(start + end, -(end * .05f), UnityEngine.Color.white, 0.0f, false); }
public static void DrawDebugBone(UnityEngine.Vector3 position, UnityEngine.Vector3 right, UnityEngine.Vector3 up, UnityEngine.Vector3 forward, ColorRange colorRange = ColorRange.RGB) { right *= .2f; up *= .2f; forward *= .2f; Helpers.DrawDebugLine(position, right, 3 * (short)colorRange + 0); Helpers.DrawDebugLine(position, up, 3 * (short)colorRange + 1); Helpers.DrawDebugLine(position, forward, 3 * (short)colorRange + 2); Helpers.DrawDebugLine(position + (forward * .8f), forward, 2); }
/// <summary> /// Attempts to create a new coordinate with this service. /// </summary> /// <param name="localPosition">Position at which the coordinate should be created.</param> /// <param name="localRotation">Orientation the coordinate should be created with.</param> /// <returns>The coordinate if the coordinate was succesfully created, otherwise null.</returns> public static Task <ISpatialCoordinate> TryCreateCoordinateAsync(this ISpatialCoordinateService spatialCoordinateService, UVector3 vector, UQuaternion quaternion, CancellationToken cancellationToken) { return(spatialCoordinateService.TryCreateCoordinateAsync(vector.AsNumericsVector(), quaternion.AsNumericsQuaternion(), cancellationToken)); }
public static UnityEngine.Vector3[] CreateCapsule(CapsuleShape shape, out int[] indices) { int up = shape.UpAxis; float radius = shape.Radius; float cylinderHalfHeight = shape.HalfHeight; int slices = (int)(radius * 10.0f); int stacks = (int)(radius * 10.0f); slices = (slices > 16) ? 16 : (slices < 3) ? 3 : slices; stacks = (stacks > 16) ? 16 : (stacks < 3) ? 3 : stacks; float hAngleStep = (float)Math.PI * 2 / slices; float vAngleStep = (float)Math.PI / stacks; int vertexCount = 2 + slices * (stacks - 1); int indexCount = 6 * slices * (stacks - 1); UnityEngine.Vector3[] vertices = new UnityEngine.Vector3[vertexCount * 2]; indices = new int[indexCount]; int i = 0, v = 0; // Vertices // Top and bottom vertices[v++] = GetVectorByAxis(0, -cylinderHalfHeight - radius, 0, up); vertices[v++] = GetVectorByAxis(-UnityEngine.Vector3.up, up); vertices[v++] = GetVectorByAxis(0, cylinderHalfHeight + radius, 0, up); vertices[v++] = GetVectorByAxis(UnityEngine.Vector3.up, up); // Stacks int j, k; float angle = 0; float vAngle = -(float)Math.PI / 2; UnityEngine.Vector3 vTemp; UnityEngine.Vector3 cylinderOffset = GetVectorByAxis(0, -cylinderHalfHeight, 0, up); for (j = 0; j < stacks - 1; j++) { float prevAngle = vAngle; vAngle += vAngleStep; if (vAngle > 0 && prevAngle < 0) { cylinderOffset = GetVectorByAxis(0, cylinderHalfHeight, 0, up); } for (k = 0; k < slices; k++) { angle += hAngleStep; vTemp = GetVectorByAxis((float)Math.Cos(vAngle) * (float)Math.Sin(angle), (float)Math.Sin(vAngle), (float)Math.Cos(vAngle) * (float)Math.Cos(angle), up); vertices[v++] = vTemp * radius + cylinderOffset; vertices[v++] = UnityEngine.Vector3.Normalize(vTemp); } } // Indices // Top cap int index = 2; for (k = 0; k < slices; k++) { indices[i++] = index++; indices[i++] = 0; indices[i++] = index; } indices[i - 1] = 2; // Stacks int sliceDiff = slices * 3; for (j = 0; j < stacks - 2; j++) { for (k = 0; k < slices; k++) { indices[i] = indices[i - sliceDiff + 2]; indices[i + 1] = index++; indices[i + 2] = indices[i - sliceDiff]; i += 3; } for (k = 0; k < slices; k++) { indices[i] = indices[i - sliceDiff + 1]; indices[i + 1] = indices[i - sliceDiff]; indices[i + 2] = indices[i - sliceDiff + 4]; i += 3; } indices[i - 1] = indices[i - sliceDiff]; } // Bottom cap index--; for (k = 0; k < slices; k++) { indices[i++] = index--; indices[i++] = 1; indices[i++] = index; } indices[i - 1] = indices[i - sliceDiff]; return vertices; }
public static UnityEngine.Object Instantiate(UnityEngine.Object prefab, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, System.Int32 group) { throw new NotImplementedException("This function was automatically generated by Mockery and has no real implementation yet."); }
/// <summary> /// Converst coordinate space position to world space position. /// </summary> public static UVector3 CoordinateToWorldSpace(this ISpatialCoordinate coordinate, UVector3 vector) { return(coordinate.CoordinateToWorldSpace(vector.AsNumericsVector()).AsUnityVector()); }
static StackObject *SphereCast_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 6); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Int32 @layerMask = ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Single @maxDistance = *(float *)&ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 3); UnityEngine.RaycastHit @hitInfo = (UnityEngine.RaycastHit) typeof(UnityEngine.RaycastHit).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack)); ptr_of_this_method = ILIntepreter.Minus(__esp, 4); UnityEngine.Vector3 @direction = new UnityEngine.Vector3(); if (ILRuntime.Runtime.Generated.CLRBindings.s_UnityEngine_Vector3_Binding_Binder != null) { ILRuntime.Runtime.Generated.CLRBindings.s_UnityEngine_Vector3_Binding_Binder.ParseValue(ref @direction, __intp, ptr_of_this_method, __mStack, false); } else { @direction = (UnityEngine.Vector3) typeof(UnityEngine.Vector3).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); } ptr_of_this_method = ILIntepreter.Minus(__esp, 5); System.Single @radius = *(float *)&ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 6); UnityEngine.Vector3 @origin = new UnityEngine.Vector3(); if (ILRuntime.Runtime.Generated.CLRBindings.s_UnityEngine_Vector3_Binding_Binder != null) { ILRuntime.Runtime.Generated.CLRBindings.s_UnityEngine_Vector3_Binding_Binder.ParseValue(ref @origin, __intp, ptr_of_this_method, __mStack, false); } else { @origin = (UnityEngine.Vector3) typeof(UnityEngine.Vector3).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); } var result_of_this_method = UnityEngine.Physics.SphereCast(@origin, @radius, @direction, out @hitInfo, @maxDistance, @layerMask); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); switch (ptr_of_this_method->ObjectType) { case ObjectTypes.StackObjectReference: { var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method); object ___obj = @hitInfo; if (___dst->ObjectType >= ObjectTypes.Object) { if (___obj is CrossBindingAdaptorType) { ___obj = ((CrossBindingAdaptorType)___obj).ILInstance; } __mStack[___dst->Value] = ___obj; } else { ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain); } } break; case ObjectTypes.FieldReference: { var ___obj = __mStack[ptr_of_this_method->Value]; if (___obj is ILTypeInstance) { ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @hitInfo; } else { var ___type = __domain.GetType(___obj.GetType()) as CLRType; ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @hitInfo); } } break; case ObjectTypes.StaticFieldReference: { var ___type = __domain.GetType(ptr_of_this_method->Value); if (___type is ILType) { ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @hitInfo; } else { ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @hitInfo); } } break; case ObjectTypes.ArrayReference: { var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as UnityEngine.RaycastHit[]; instance_of_arrayReference[ptr_of_this_method->ValueLow] = @hitInfo; } break; } __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 4); __intp.FreeStackValueType(ptr_of_this_method); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 5); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 6); __intp.FreeStackValueType(ptr_of_this_method); __intp.Free(ptr_of_this_method); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method ? 1 : 0; return(__ret + 1); }
public void __Gen_Delegate_Imp1(int p0, int p1, int p2, int p3, object p4, object p5, object p6, object p7, UnityEngine.Vector3 p8, UnityEngine.Vector2 p9, UnityEngine.Vector4 p10) { using (var pObjs = new Objects(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)) { methodInfo.Invoke(null, pObjs.objs); } }
public void ProcessPacket(CreatePrebuildsRequest packet, NebulaConnection conn) { PlanetData planet = GameMain.galaxy.PlanetById(packet.PlanetId); if (planet.factory == null) { // We only execute the code if the client has loaded the factory at least once. // Else it will get it once it goes to the planet for the first time. return; } PlayerAction_Build pab = GameMain.mainPlayer.controller?.actionBuild; if (pab != null) { FactoryManager.TargetPlanet = packet.PlanetId; //Make backup of values that are overwritten List <BuildPreview> tmpList = pab.buildPreviews; bool tmpConfirm = pab.waitConfirm; UnityEngine.Vector3 tmpPos = pab.previewPose.position; UnityEngine.Quaternion tmpRot = pab.previewPose.rotation; PlanetFactory tmpFactory = (PlanetFactory)AccessTools.Field(typeof(PlayerAction_Build), "factory").GetValue(GameMain.mainPlayer.controller.actionBuild); PlanetPhysics tmpPlanetPhysics = (PlanetPhysics)AccessTools.Field(typeof(PlayerAction_Build), "planetPhysics").GetValue(pab); //Create Prebuilds from incomming packet pab.buildPreviews = packet.GetBuildPreviews(); pab.waitConfirm = true; using (FactoryManager.EventFromServer.On()) { FactoryManager.EventFactory = planet.factory; pab.previewPose.position = new UnityEngine.Vector3(packet.PosePosition.x, packet.PosePosition.y, packet.PosePosition.z); pab.previewPose.rotation = new UnityEngine.Quaternion(packet.PoseRotation.x, packet.PoseRotation.y, packet.PoseRotation.z, packet.PoseRotation.w); AccessTools.Field(typeof(PlayerAction_Build), "factory").SetValue(GameMain.mainPlayer.controller.actionBuild, planet.factory); //Create temporary physics for spawning building's colliders if (planet.physics == null || planet.physics.colChunks == null) { planet.physics = new PlanetPhysics(planet); planet.physics.Init(); } //Take item from the inventory if player is author of the build if (packet.AuthorId == LocalPlayer.PlayerId) { foreach (BuildPreview buildPreview in pab.buildPreviews) { if (GameMain.mainPlayer.inhandItemId == buildPreview.item.ID && GameMain.mainPlayer.inhandItemCount > 0) { GameMain.mainPlayer.UseHandItems(1); } else { int num = 1; GameMain.mainPlayer.package.TakeTailItems(ref buildPreview.item.ID, ref num, false); } } } AccessTools.Field(typeof(PlayerAction_Build), "planetPhysics").SetValue(GameMain.mainPlayer.controller.actionBuild, planet.physics); pab.CreatePrebuilds(); FactoryManager.EventFactory = null; } //Author has to call this for the continuous belt building if (packet.AuthorId == LocalPlayer.PlayerId) { pab.AfterPrebuild(); } //Revert changes back AccessTools.Field(typeof(PlayerAction_Build), "planetPhysics").SetValue(GameMain.mainPlayer.controller.actionBuild, tmpPlanetPhysics); AccessTools.Field(typeof(PlayerAction_Build), "factory").SetValue(GameMain.mainPlayer.controller.actionBuild, tmpFactory); pab.waitConfirm = tmpConfirm; pab.previewPose.position = tmpPos; pab.previewPose.rotation = tmpRot; pab.buildPreviews = tmpList; FactoryManager.TargetPlanet = FactoryManager.PLANET_NONE; } }
public UnityEngine.Vector3 __Gen_Delegate_Imp17(object p0, UnityEngine.Vector3 p1, UnityEngine.Vector3 p2) { #if THREAD_SAFE || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.rawL; int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference); ObjectTranslator translator = luaEnv.translator; translator.PushAny(L, p0); translator.PushUnityEngineVector3(L, p1); translator.PushUnityEngineVector3(L, p2); PCall(L, 3, 1, errFunc); UnityEngine.Vector3 __gen_ret; translator.Get(L, errFunc + 1, out __gen_ret); LuaAPI.lua_settop(L, errFunc - 1); return(__gen_ret); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
public void Fill(UnityEngine.Vector3 v3) { x = v3.x; y = v3.y; z = v3.z; }
static void set_z_2(ref object o, object v) { UnityEngine.Vector3 ins = (UnityEngine.Vector3)o; ins.z = (System.Single)v; o = ins; }
private void OnDrawGizmos() { if (!enabled) { return; } UnityEngine.Gizmos.matrix = transform.localToWorldMatrix; var centreOffset = UnityEngine.Vector3.zero; var sizeMultiplier = UnityEngine.Vector3.one; var collider = GetComponent <UnityEngine.BoxCollider>(); if (collider) { centreOffset = collider.center; sizeMultiplier = collider.size; } // color faces var faceCenterPos = new UnityEngine.Vector3[6]; faceCenterPos[0] = UnityEngine.Vector3.Scale(new UnityEngine.Vector3(0.5f, 0.0f, 0.0f), sizeMultiplier); faceCenterPos[1] = UnityEngine.Vector3.Scale(new UnityEngine.Vector3(0.0f, 0.5f, 0.0f), sizeMultiplier); faceCenterPos[2] = UnityEngine.Vector3.Scale(new UnityEngine.Vector3(-0.5f, 0.0f, 0.0f), sizeMultiplier); faceCenterPos[3] = UnityEngine.Vector3.Scale(new UnityEngine.Vector3(0.0f, -0.5f, 0.0f), sizeMultiplier); faceCenterPos[4] = UnityEngine.Vector3.Scale(new UnityEngine.Vector3(0.0f, 0.0f, 0.5f), sizeMultiplier); faceCenterPos[5] = UnityEngine.Vector3.Scale(new UnityEngine.Vector3(0.0f, 0.0f, -0.5f), sizeMultiplier); var faceSize = new UnityEngine.Vector3[6]; faceSize[0] = new UnityEngine.Vector3(0, 1, 1); faceSize[1] = new UnityEngine.Vector3(1, 0, 1); faceSize[2] = faceSize[0]; faceSize[3] = faceSize[1]; faceSize[4] = new UnityEngine.Vector3(1, 1, 0); faceSize[5] = faceSize[4]; UnityEngine.Gizmos.color = new UnityEngine.Color32(255, 204, 0, 100); for (var i = 0; i < 4; i++) { UnityEngine.Gizmos.DrawCube(faceCenterPos[i] + centreOffset, UnityEngine.Vector3.Scale(faceSize[i], sizeMultiplier)); } if (!portalActive) { UnityEngine.Gizmos.color = new UnityEngine.Color32(255, 204, 0, 30); UnityEngine.Gizmos.DrawCube(faceCenterPos[4] + centreOffset, UnityEngine.Vector3.Scale(faceSize[4], sizeMultiplier)); UnityEngine.Gizmos.DrawCube(faceCenterPos[5] + centreOffset, UnityEngine.Vector3.Scale(faceSize[5], sizeMultiplier)); } // draw line in the center of the portal var CornerCenterPos = faceCenterPos; CornerCenterPos[0].y += 0.5f * sizeMultiplier.y; CornerCenterPos[1].x -= 0.5f * sizeMultiplier.x; CornerCenterPos[2].y -= 0.5f * sizeMultiplier.y; CornerCenterPos[3].x += 0.5f * sizeMultiplier.x; UnityEngine.Gizmos.color = UnityEngine.Color.red; for (var i = 0; i < 4; i++) { UnityEngine.Gizmos.DrawLine(CornerCenterPos[i] + centreOffset, CornerCenterPos[(i + 1) % 4] + centreOffset); } }
public AABB(vec3 min, vec3 max) { _min = min; _max = max; }
public float GetAuxSendValueForPosition(UnityEngine.Vector3 in_position) { return(1); }
public static UnityEngine.Vector3[] CreateCylinder(CylinderShape shape, out int[] indices) { int up = shape.UpAxis; float radius = shape.Radius; float halfHeight = shape.HalfExtentsWithoutMargin[up] + shape.Margin; const int numSteps = 10; const float angleStep = (2 * (float)Math.PI) / numSteps; const int vertexCount = 2 + 6 * numSteps; const int indexCount = (4 * numSteps + 2) * 3; UnityEngine.Vector3[] vertices = new UnityEngine.Vector3[vertexCount * 2]; indices = new int[indexCount]; int i = 0, v = 0; int index = 0; int baseIndex; UnityEngine.Vector3 normal; // Draw two sides for (int side = 1; side != -3; side -= 2) { normal = GetVectorByAxis(side * UnityEngine.Vector3.up, up); baseIndex = index; vertices[v++] = GetVectorByAxis(0, side * halfHeight, 0, up); vertices[v++] = normal; vertices[v++] = GetVectorByAxis(0, side * halfHeight, radius, up); vertices[v++] = normal; index += 2; for (int j = 1; j < numSteps; j++) { float x = radius * (float)Math.Sin(j * angleStep); float z = radius * (float)Math.Cos(j * angleStep); vertices[v++] = GetVectorByAxis(x, side * halfHeight, z, up); vertices[v++] = normal; indices[i++] = baseIndex; if (side == 1) { indices[i++] = index - 1; indices[i++] = index++; } else { indices[i++] = index; indices[i++] = index - 1; index++; } } indices[i++] = baseIndex; if (side == 1) { indices[i++] = index - 1; indices[i++] = baseIndex + 1; } else { indices[i++] = baseIndex + 1; indices[i++] = index - 1; } } normal = GetVectorByAxis(0, 0, radius, up); normal.Normalize(); baseIndex = index; vertices[v++] = GetVectorByAxis(0, halfHeight, radius, up); vertices[v++] = normal; vertices[v++] = GetVectorByAxis(0, -halfHeight, radius, up); vertices[v++] = normal; index += 2; for (int j = 1; j < numSteps + 1; j++) { float x = radius * (float)Math.Sin(j * angleStep); float z = radius * (float)Math.Cos(j * angleStep); normal = GetVectorByAxis(x, 0, z, up); normal.Normalize(); vertices[v++] = GetVectorByAxis(x, halfHeight, z, up); vertices[v++] = normal; vertices[v++] = GetVectorByAxis(x, -halfHeight, z, up); vertices[v++] = normal; indices[i++] = index - 2; indices[i++] = index - 1; indices[i++] = index; indices[i++] = index; indices[i++] = index - 1; indices[i++] = index + 1; index += 2; } indices[i++] = index - 2; indices[i++] = index - 1; indices[i++] = baseIndex; indices[i++] = baseIndex; indices[i++] = index - 1; indices[i] = baseIndex + 1; return vertices; }
private AddPointResult AddInternal(VECTOR np) { List <VECTOR> pts = _pts; int last = pts.Count; Debug.Assert(last != 0); // should always have one point at least _pts.Add(np); _arclen.Add(_totalLength = _totalLength + _linDist); if (last == 1) { // This is the second point Debug.Assert(_result.Count == 0); VECTOR p0 = pts[0]; VECTOR tanL = VectorHelper.Normalize(np - p0); VECTOR tanR = -tanL; _tanL = tanL; FLOAT alpha = _linDist / 3; VECTOR p1 = (tanL * alpha) + p0; VECTOR p2 = (tanR * alpha) + np; _result.Add(new CubicBezier(p0, p1, p2, np)); return(new AddPointResult(0, true)); } else { int lastCurve = _result.Count - 1; int first = _first; // If we're on the first curve, we're free to improve the left tangent VECTOR tanL = lastCurve == 0 ? GetLeftTangent(last) : _tanL; // We can always do the end tangent VECTOR tanR = GetRightTangent(first); // Try fitting with the new point int split; CubicBezier curve; if (FitCurve(first, last, tanL, tanR, out curve, out split)) { _result[lastCurve] = curve; return(new AddPointResult(lastCurve, false)); } else { // Need to split // first, get mid tangent VECTOR tanM1 = GetCenterTangent(first, last, split); VECTOR tanM2 = -tanM1; // PERHAPS do a full fitRecursive here since its our last chance? // our left tangent might be based on points outside the new curve (this is possible for mid tangents too // but since we need to maintain C1 continuity, it's too late to do anything about it) if (first == 0 && split < END_TANGENT_N_PTS) { tanL = GetLeftTangent(split); } // do a final pass on the first half of the curve int unused; FitCurve(first, split, tanL, tanM1, out curve, out unused); _result[lastCurve] = curve; // perpare to fit the second half FitCurve(split, last, tanM2, tanR, out curve, out unused); _result.Add(curve); _first = split; _tanL = tanM2; return(new AddPointResult(lastCurve, true)); } } }
private static UnityEngine.Vector3[] CreatePolyhedralConvexShape(PolyhedralConvexShape polyhedralConvexShape, out int[] indices) { int numVertices = polyhedralConvexShape.NumVertices; UnityEngine.Vector3[] vertices = new UnityEngine.Vector3[numVertices * 3]; for (int i = 0; i < numVertices; i += 4) { Vector3 v0, v1, v2, v3; polyhedralConvexShape.GetVertex(i, out v0); polyhedralConvexShape.GetVertex(i + 1, out v1); polyhedralConvexShape.GetVertex(i + 2, out v2); polyhedralConvexShape.GetVertex(i + 3, out v3); UnityEngine.Vector3 v01 = (v0 - v1).ToUnity(); UnityEngine.Vector3 v02 = (v0 - v2).ToUnity(); UnityEngine.Vector3 normal = UnityEngine.Vector3.Cross(v01, v02); int i3 = i * 3; vertices[i3] = v0.ToUnity(); vertices[i3 + 1] = normal; vertices[i3 + 2] = v1.ToUnity(); vertices[i3 + 3] = normal; vertices[i3 + 4] = v2.ToUnity(); vertices[i3 + 5] = normal; vertices[i3 + 6] = v0.ToUnity(); vertices[i3 + 7] = normal; vertices[i3 + 8] = v2.ToUnity(); vertices[i3 + 9] = normal; vertices[i3 + 10] = v3.ToUnity(); } indices = null; return vertices; }
public void HandleRotateRequest(Shape shape) { UnityEngine.Vector3 movementVector = new UnityEngine.Vector3 (0, 0, 0); shape.Rotate (); if (CheckCollisionWithAnyWall (shape, movementVector) || DoAnyShapesCollideInScene (shape, movementVector)) { shape.Rotate (true); } }
static UnityEngine.Vector3[] CreateTriangleMesh(StridingMeshInterface meshInterface) { // StridingMeshInterface can only be TriangleIndexVertexArray var meshes = (meshInterface as TriangleIndexVertexArray).IndexedMeshArray; int numTriangles = 0; foreach (var mesh in meshes) { numTriangles += mesh.NumTriangles; } int numVertices = numTriangles * 3; UnityEngine.Vector3[] vertices = new UnityEngine.Vector3[numVertices * 2]; int v = 0; for (int part = 0; part < meshInterface.NumSubParts; part++) { var mesh = meshes[part]; var indexStream = mesh.GetTriangleStream(); var vertexStream = mesh.GetVertexStream(); var indexReader = new BinaryReader(indexStream); var vertexReader = new BinaryReader(vertexStream); int vertexStride = mesh.VertexStride; int triangleStrideDelta = mesh.TriangleIndexStride - 3 * sizeof(int); while (indexStream.Position < indexStream.Length) { uint i = indexReader.ReadUInt32(); vertexStream.Position = vertexStride * i; float f1 = vertexReader.ReadSingle(); float f2 = vertexReader.ReadSingle(); float f3 = vertexReader.ReadSingle(); UnityEngine.Vector3 v0 = new UnityEngine.Vector3(f1, f2, f3); i = indexReader.ReadUInt32(); vertexStream.Position = vertexStride * i; f1 = vertexReader.ReadSingle(); f2 = vertexReader.ReadSingle(); f3 = vertexReader.ReadSingle(); UnityEngine.Vector3 v1 = new UnityEngine.Vector3(f1, f2, f3); i = indexReader.ReadUInt32(); vertexStream.Position = vertexStride * i; f1 = vertexReader.ReadSingle(); f2 = vertexReader.ReadSingle(); f3 = vertexReader.ReadSingle(); UnityEngine.Vector3 v2 = new UnityEngine.Vector3(f1, f2, f3); UnityEngine.Vector3 v01 = v0 - v1; UnityEngine.Vector3 v02 = v0 - v2; UnityEngine.Vector3 normal = UnityEngine.Vector3.Cross(v01, v02); normal.Normalize(); vertices[v++] = v0; vertices[v++] = normal; vertices[v++] = v1; vertices[v++] = normal; vertices[v++] = v2; vertices[v++] = normal; indexStream.Position += triangleStrideDelta; } indexStream.Dispose(); vertexStream.Dispose(); } return vertices; }
public static bool IsValid(UVector3 vector) { return(IsValid(vector.x) && IsValid(vector.y) && IsValid(vector.z)); }
public WorldNode(int para_nodeID, int para_nodeType, UnityEngine.Vector3 para_worldPt) : base(para_nodeID,para_nodeType) { worldPt = para_worldPt; }
/// <summary> /// Converts a UnityEngine.Vector3. to a System.Numerics.Vector3. /// </summary> public static Vector3 AsNumericsVector(this UVector3 input) { return(new Vector3(input.x, input.y, input.z)); }
public static Pendulum make(Particle point_a_, Particle point_b_, Vector3f equilibrium_position_, Render callback_, params IConstraint[] constraints_) { return new Pendulum(point_a_, point_b_, equilibrium_position_, callback_, constraints_); }
public static Vector2 ToVector2(this UnityEngine.Vector3 vector) { return(new Vector2(vector.x, vector.z)); }
/// <summary> /// Translation from basic BSEngine Types to UnityEnginge Types /// </summary> /// <param name="obj">Object to transfrom</param> /// <returns>Object with translated type</returns> private static object BSEngineToUnity(object obj) { if (obj.GetType() == typeof(BSEngine.Math.Vector2)) { BSEngine.Math.Vector2 bse = (BSEngine.Math.Vector2)obj; UnityEngine.Vector2 v2 = new UnityEngine.Vector2(bse.x, bse.y); return v2; } else if (obj.GetType() == typeof(BSEngine.Math.Vector3)) { BSEngine.Math.Vector3 bse = (BSEngine.Math.Vector3)obj; UnityEngine.Vector3 v3 = new UnityEngine.Vector3(bse.x, bse.y, bse.z); return v3; } else if (obj.GetType() == typeof(BSEngine.Math.Vector4)) { BSEngine.Math.Vector4 bse = (BSEngine.Math.Vector4)obj; UnityEngine.Vector4 v4 = new UnityEngine.Vector4(bse.x, bse.y, bse.z, bse.w); return v4; } else if (obj.GetType() == typeof(BSEngine.Math.Quaternion)) { BSEngine.Math.Quaternion bse = (BSEngine.Math.Quaternion)obj; UnityEngine.Quaternion q = new UnityEngine.Quaternion(bse.x, bse.y, bse.z, bse.w); return q; } else { return null; } }
/// <summary> /// Convert an Unity vector3 to a TES vector2. /// </summary> /// <remarks> /// The Z component is dropped. /// </remarks> /// <returns>The TES vector equivalent.</returns> /// <param name="uv">The Unity vector to convert.</param> public static Vector2 FromUnity(UnityEngine.Vector3 uv) { return(new Vector2(uv.x, uv.y)); }
public Assignment_bt_par_test_custom_property_as_left_value_and_param_node9() { opr = new UnityEngine.Vector3(); opr.x = 2f; opr.y = 2f; opr.z = 2f; }
static internal void Lua_DG_Tweening_Core_DOSetter_1_UnityEngine_Vector3(LuaFunction ld, UnityEngine.Vector3 a1) { IntPtr l = ld.L; int error = pushTry(l); pushValue(l, a1); ld.pcall(1, error); LuaDLL.lua_settop(l, error - 1); }
protected void HandleTouch() { int touchCountMax = this.touchInfos.Length; for (int i = 0; i < touchCountMax; ++i) { this.previousTouchInfos[i] = new TouchInfo(); } int touchCount = UnityEngine.Mathf.Min(touchCountMax, UnityEngine.Input.touchCount); for (int i = 0; i < touchCount; ++i) { int sameFinger = -1; UnityEngine.Touch touch = UnityEngine.Input.GetTouch(i); for (int previousInputId = 0; previousInputId < touchCountMax; ++previousInputId) { if (this.touchInfos[previousInputId].SameFingerID(ref touch)) { sameFinger = previousInputId; } } if (sameFinger != -1) { this.previousTouchInfos[i] = this.touchInfos[sameFinger]; } else { this.previousTouchInfos[i] = new TouchInfo(); } } this.previousMouseTouchInfo = this.mouseTouchInfo; for (int i = 0; i < touchCount; ++i) { UnityEngine.Touch touch = UnityEngine.Input.GetTouch(i); this.touchInfos[i] = new TouchInfo(ref touch, this); } UnityEngine.TouchPhase mouseTouchPhase = UnityEngine.Input.GetMouseButton(0) ? (UnityEngine.Input.GetMouseButtonDown(0) ? UnityEngine.TouchPhase.Began : UnityEngine.TouchPhase.Moved) : UnityEngine.TouchPhase.Ended; this.mouseTouchInfo = new TouchInfo() { ScreenPos = UnityEngine.Input.mousePosition, HitPos = GetIntersectionPoint(UnityEngine.Input.mousePosition), Phase = mouseTouchPhase }; for (int i = touchCount; i < touchCountMax; ++i) { this.touchInfos[i] = new TouchInfo(); } if (touchCount == 0 && this.mouseTouchInfo.Phase == UnityEngine.TouchPhase.Moved && this.TouchTranslation) { UnityEngine.Ray ray = this.usedCamera.ScreenPointToRay(this.mouseTouchInfo.ScreenPos); float previousHeight = this.transform.position.y; UnityEngine.Vector3 nextPosition = this.previousMouseTouchInfo.HitPos + ray.direction * (previousHeight / ray.direction.y); nextPosition.y = previousHeight; this.transform.position = nextPosition; } if (touchCount == 1) { if (this.touchInfos[0].Phase == UnityEngine.TouchPhase.Moved && this.previousTouchInfos[0].FingerId != -1 && this.TouchTranslation) { UnityEngine.Ray ray = this.usedCamera.ScreenPointToRay(this.touchInfos[0].ScreenPos); float previousHeight = this.transform.position.y; UnityEngine.Vector3 nextPosition = this.previousTouchInfos[0].HitPos + ray.direction * (previousHeight / ray.direction.y); nextPosition.y = previousHeight; this.transform.position = nextPosition; } } if (touchCount == 2) { if ((this.touchInfos[0].Phase == UnityEngine.TouchPhase.Moved || this.touchInfos[1].Phase == UnityEngine.TouchPhase.Moved) && (this.previousTouchInfos[0].FingerId != -1 && this.previousTouchInfos[1].FingerId != -1)) { UnityEngine.Vector3 previousDifHitPos = this.previousTouchInfos[0].HitPos - this.previousTouchInfos[1].HitPos; float previousDistance01 = UnityEngine.Vector3.Magnitude(previousDifHitPos); UnityEngine.Vector3 difHitPos = this.touchInfos[0].HitPos - this.touchInfos[1].HitPos; float currentDistance01 = UnityEngine.Vector3.Magnitude(difHitPos); UnityEngine.Vector3 nextPosition = this.transform.position; UnityEngine.Vector2 middleScreenPoint = (this.touchInfos[0].ScreenPos + this.touchInfos[1].ScreenPos) * 0.5f; UnityEngine.Ray ray = this.usedCamera.ScreenPointToRay(middleScreenPoint); nextPosition -= ray.direction * (previousDistance01 - currentDistance01); if (this.TouchZoom) { this.transform.position = nextPosition; } float deltaAngleAroundY = 0; { UnityEngine.Vector2 difScreenPos = this.touchInfos[0].ScreenPos - this.touchInfos[1].ScreenPos; UnityEngine.Vector2 previousDifScreenPos = this.previousTouchInfos[0].ScreenPos - this.previousTouchInfos[1].ScreenPos; float currentAngle = UnityEngine.Mathf.Atan2(difScreenPos.y, difScreenPos.x); float previousAngle = UnityEngine.Mathf.Atan2(previousDifScreenPos.y, previousDifScreenPos.x); deltaAngleAroundY += (currentAngle - previousAngle) * 180f / UnityEngine.Mathf.PI; } float deltaAngleX = 0; UnityEngine.Vector2 previousMiddlePoint = (this.previousTouchInfos[0].ScreenPos + this.previousTouchInfos[1].ScreenPos) * 0.5f; { UnityEngine.Vector2 modifiedPreviousMiddlePoint = previousMiddlePoint; modifiedPreviousMiddlePoint.x = middleScreenPoint.x; UnityEngine.Ray previousRay = this.usedCamera.ScreenPointToRay(modifiedPreviousMiddlePoint); float absDeltaAngleX = UnityEngine.Vector3.Angle(previousRay.direction, ray.direction); deltaAngleX += (previousMiddlePoint.y < middleScreenPoint.y) ? absDeltaAngleX : -absDeltaAngleX; } float deltaAngleY = 0; { //UnityEngine.Vector2 modifiedPreviousMiddlePoint = previousMiddlePoint; //UnityEngine.Ray previousRay = this.usedCamera.ScreenPointToRay(modifiedPreviousMiddlePoint); //UnityEngine.Vector3 projectedPreviousRayDirection = previousRay.direction; //projectedPreviousRayDirection.y = 0; //UnityEngine.Vector3 projectedRayDirection = previousRay.direction; //projectedRayDirection.y = 0; //float absDeltaAngleY = UnityEngine.Vector3.Angle(this.transform.forward, previousRay.direction); //deltaAngleY += (previousMiddlePoint.x < middleScreenPoint.x) ? absDeltaAngleY : -absDeltaAngleY; } if (deltaAngleAroundY != 0 || deltaAngleX != 0 || deltaAngleY != 0) { UnityEngine.Vector3 rotateAround = GetIntersectionPoint(middleScreenPoint); UnityEngine.Vector3 nextEulerAngles = this.transform.eulerAngles; nextEulerAngles.y += deltaAngleAroundY; this.transform.eulerAngles = nextEulerAngles; UnityEngine.Ray nextRay = this.usedCamera.ScreenPointToRay(middleScreenPoint); float originalDistance = UnityEngine.Vector3.Magnitude(rotateAround - this.transform.position); this.transform.position = rotateAround - originalDistance * nextRay.direction; nextEulerAngles.x += this.TouchRotationX ? deltaAngleX : 0; nextEulerAngles.y += this.TouchRotationY ? deltaAngleY : 0; this.transform.eulerAngles = nextEulerAngles; } } } for (int i = 0; i < touchCount; ++i) { UnityEngine.Touch touch = UnityEngine.Input.GetTouch(i); this.touchInfos[i] = new TouchInfo(ref touch, this); } this.mouseTouchInfo = new TouchInfo() { ScreenPos = UnityEngine.Input.mousePosition, HitPos = GetIntersectionPoint(UnityEngine.Input.mousePosition), Phase = mouseTouchPhase }; }
//只变化Y轴的角度 public static Rotation ToRotation2D(this UnityEngine.Vector3 dir) { UnityEngine.Quaternion quaternion = UnityEngine.Quaternion.LookRotation(dir, UnityEngine.Vector3.up); return(ToRotation2D(quaternion)); }