Example #1
1
        private void CreatePointEntity(Scene scene, UUID uuid, Vector3 groupPos)
        {
            SceneObjectPart y = new SceneObjectPart();

            //Initialize part
            y.Name = "Very Small Point";
            y.RegionHandle = scene.RegionInfo.RegionHandle;
            y.CreationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
            y.OwnerID = UUID.Zero;
            y.CreatorID = UUID.Zero;
            y.LastOwnerID = UUID.Zero;
            y.UUID = uuid;

            y.Shape = PrimitiveBaseShape.CreateBox();
            y.Scale = new Vector3(0.01f,0.01f,0.01f);
            y.LastOwnerID = UUID.Zero;
            y.GroupPosition = groupPos;
            y.OffsetPosition = new Vector3(0, 0, 0);
            y.RotationOffset = new Quaternion(0,0,0,0);
            y.Velocity = new Vector3(0, 0, 0);
            y.RotationalVelocity = new Vector3(0, 0, 0);
            y.AngularVelocity = new Vector3(0, 0, 0);
            y.Acceleration = new Vector3(0, 0, 0);

            y.Flags = 0;
            y.TrimPermissions();

            //Initialize group and add part as root part
            SceneObjectGroup x = new SceneObjectGroup(y);
            x.SetScene(scene);
            x.RegionHandle = scene.RegionInfo.RegionHandle;
            x.SetScene(scene);

            m_Entity = x;
        }
Example #2
1
        public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            Log.Warn("Player " + player.Username + " should be banned for hacking!");

            var block = world.GetBlock(blockCoordinates);
            if (block is Tnt)
            {
                world.SetBlock(new Air() {Coordinates = block.Coordinates});
                new PrimedTnt(world)
                {
                    KnownPosition = new PlayerLocation(blockCoordinates.X, blockCoordinates.Y, blockCoordinates.Z),
                    Fuse = (byte) (new Random().Next(0, 20) + 10)
                }.SpawnEntity();
            }
            else if (block.IsSolid)
            {
                var affectedBlock = world.GetBlock(GetNewCoordinatesFromFace(blockCoordinates, BlockFace.Up));
                if (affectedBlock.Id == 0)
                {
                    var fire = new Fire
                    {
                        Coordinates = affectedBlock.Coordinates
                    };
                    world.SetBlock(fire);
                }
            }
        }
Example #3
1
        public static void drawLine(Vector3 pos1, Vector3 pos2, int bold, System.Drawing.Color color)
        {
            var wts1 = Drawing.WorldToScreen(pos1);
            var wts2 = Drawing.WorldToScreen(pos2);

            Drawing.DrawLine(wts1[0], wts1[1], wts2[0], wts2[1], bold, color);
        }
        public override void ShootBox(Vector3 camPos, Vector3 destination)
        {
            if (World != null)
            {
                const float mass = 1.0f;

                if (shootBoxShape == null)
                {
                    shootBoxShape = new BoxShape(1.0f);
                    shootBoxShape.InitializePolyhedralFeatures();
                }

                RigidBody body = LocalCreateRigidBody(mass, Matrix.Translation(camPos), shootBoxShape);
                body.LinearFactor = new Vector3(1, 1, 1);
                //body->setRestitution(1);

                Vector3 linVel = destination - camPos;
                linVel.Normalize();
                body.LinearVelocity = linVel * shootBoxInitialSpeed;
                body.AngularVelocity = Vector3.Zero;
                body.ContactProcessingThreshold = 1e30f;

                // when using m_ccdMode, disable regular CCD
                if (ccdMode)
                {
                    body.CcdMotionThreshold = 0.0001f;
                    body.CcdSweptSphereRadius = 0.4f;
                }
            }
        }
Example #5
1
 public override bool OnBlockPlaced(World world, Vector3 position, Vector3 clickedBlock, Vector3 clickedSide, Vector3 cursorPosition, Entities.Entity usedBy)
 {
     Metadata = (byte)MathHelper.DirectionByRotationFlat(usedBy);
     switch ((Direction)Metadata)
     {
         case Direction.North:
             Metadata = (byte)StairDirections.North;
             break;
         case Direction.South:
             Metadata = (byte)StairDirections.South;
             break;
         case Direction.West:
             Metadata = (byte)StairDirections.West;
             break;
         case Direction.East:
             Metadata = (byte)StairDirections.East;
             break;
     }
     if (clickedSide == Vector3.Down)
         Metadata |= 4;
     else if (clickedSide != Vector3.Up)
     {
         if (cursorPosition.Y >= 8)
             Metadata |= 4;
     }
     return true;
 }
Example #6
1
        public override void OnUpdate(long msec)
        {
            var g2d = Graphics2D.GetInstance ();
            var pos = g2d.GetMousePosition ();

            if (Input.GetKeyDown (KeyCode.Mouse0)) {
                var start = new Vector3 (pos.X, pos.Y, 1000);
                var end = new Vector3 (pos.X, pos.Y, -1000);
                var node = World.Pick (start, end);
                if (node != null) {
                    this.picked = node;
                    this.delta = pos - new Vector2 (node.Position.X, node.Position.Y);
                }
            }
            if (Input.GetKeyUp(KeyCode.Mouse0)) {
                this.picked = null;
            }

            if (picked != null) {
                var t = pos - delta;
                picked.Translation = new Vector3(t.X, t.Y, 0);
            }

            base.OnUpdate (msec);
        }
 public ExplosionOnSurface(MeshObject[] stages, Vector3 incRotationEarth)
 {
     Stages = stages;
     IncRotationEarth = incRotationEarth;
     CurrentStages = new List<int>();
     ExplosionsTurns = new List<Vector3>();
 }
Example #8
1
 public NPCAvatar(string firstname, string lastname, Vector3 position, Scene scene)
 {
     m_firstname = firstname;
     m_lastname = lastname;
     m_startPos = position;
     m_scene = scene;
 }
Example #9
1
 public override List<Vector3> GetNormals(Vector3 blockPos, bool XP, bool XM, bool YP, bool YM, bool TOP, bool BOTTOM)
 {
     List<Vector3> Norms = new List<Vector3>();
     // Sprite 1
     for (int i = 0; i < 6; i++)
     {
         Norms.Add(new Vector3(-0.7071f, 0.7071f, 0));
     }
     // Sprite 2
     for (int i = 0; i < 6; i++)
     {
         Norms.Add(new Vector3(0.7071f, -0.7071f, 0));
     }
     // Sprite 3
     for (int i = 0; i < 6; i++)
     {
         Norms.Add(new Vector3(0.7071f, 0.7071f, 0));
     }
     // Sprite 4
     for (int i = 0; i < 6; i++)
     {
         Norms.Add(new Vector3(-0.7071f, -0.7071f, 0));
     }
     return Norms;
 }
		public TrackBallController(Vector2 screenCenter, double trackBallRadius)
		{
			rotationStart = new Vector3();
			rotationCurrent = new Vector3();
			this.screenCenter = screenCenter;
			this.rotationTrackingRadius = trackBallRadius;
		}
 public BuffManagerArgs(string uniqueId, Obj_AI_Hero hero, Vector3 position, float endTime)
 {
     UniqueId = uniqueId;
     Hero = hero;
     Position = position;
     EndTime = endTime;
 }
Example #12
1
        /// <summary>
        /// Helper method creates a triangle fan to close the ends of the cylinder.
        /// </summary>
        /// <param name="tessellation">The tessellation.</param>
        /// <param name="height">The height.</param>
        /// <param name="radius">The radius.</param>
        /// <param name="normal">The normal.</param>
        private void CreateCap(int tessellation, float height, float radius, Vector3 normal)
        {
            // Create cap indices.
            for (int i = 0; i < tessellation - 2; i++)
            {
                if (normal.Y > 0)
                {
                    this.AddIndex(this.VerticesCount);
                    this.AddIndex(this.VerticesCount + ((i + 1) % tessellation));
                    this.AddIndex(this.VerticesCount + ((i + 2) % tessellation));
                }
                else
                {
                    this.AddIndex(this.VerticesCount);
                    this.AddIndex(this.VerticesCount + ((i + 2) % tessellation));
                    this.AddIndex(this.VerticesCount + ((i + 1) % tessellation));
                }
            }

            // Create cap vertices.
            for (int i = 0; i < tessellation; i++)
            {
                float angle = i * MathHelper.TwoPi / tessellation;

                var dx = (float)Math.Cos(angle);
                var dz = (float)Math.Sin(angle);

                Vector3 iniPosition = new Vector3(dx, 0, dz);
                Vector3 position = (iniPosition * radius) + (normal * height);

                this.AddVertex(position, normal, new Vector2(dx, dz));
            }
        }
 public void FromMatrix(ref Matrix matrix)
 {
     Position = matrix.Translation;
     Quaternion q;
     Quaternion.CreateFromRotationMatrix(ref matrix, out q);
     Orientation = new HalfVector4(q.ToVector4());
 }
        public void TestRezObjectFromInventoryItem()
        {
            TestHelper.InMethod();
//            log4net.Config.XmlConfigurator.Configure();
            
            Scene scene = SceneSetupHelpers.SetupScene();
            UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
            SceneObjectGroup sog1 = SceneSetupHelpers.CreateSceneObject(1, user1.PrincipalID);
            SceneObjectPart sop1 = sog1.RootPart;

            // Create an object embedded inside the first
            UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000");
            TaskInventoryItem taskSceneObjectItem
                = TaskInventoryHelpers.AddSceneObject(scene, sop1, "tso", taskSceneObjectItemId);

            scene.AddSceneObject(sog1);

            Vector3 rezPos = new Vector3(10, 10, 10);
            Quaternion rezRot = new Quaternion(0.5f, 0.5f, 0.5f, 0.5f);
            Vector3 rezVel = new Vector3(2, 2, 2);

            scene.RezObject(sop1, taskSceneObjectItem, rezPos, rezRot, rezVel, 0);

            SceneObjectGroup rezzedObject = scene.GetSceneObjectGroup("tso");

            Assert.That(rezzedObject, Is.Not.Null);
            Assert.That(rezzedObject.AbsolutePosition, Is.EqualTo(rezPos));

            // Velocity doesn't get applied, probably because there is no physics in tests (yet)
//            Assert.That(rezzedObject.Velocity, Is.EqualTo(rezVel));
            Assert.That(rezzedObject.Velocity, Is.EqualTo(Vector3.Zero));

            // Confusingly, this isn't the rezzedObject.Rotation
            Assert.That(rezzedObject.RootPart.RotationOffset, Is.EqualTo(rezRot));
        }
        public override void OnCreate(GameObject obj)
        {
            if (Missile == null)
            {
                Position = CastArgs.End;
            }
            else
            {
                Position = Missile.EndPosition;
                StartMissilePos = Missile.Position;
            }

            PrimaryCircle = new Circle
            {
                Radius = SpellData.Radius,
                BorderWidth = 3,
                Color = Color.White
            };

            SecondaryCircle = new Circle
            {
                Radius = 10,
                Color = Color.LawnGreen
            };
        }
Example #16
1
 public InitiatorArgs(Obj_AI_Hero hero, Vector3 start, Vector3 end, float range)
 {
     Hero = hero;
     Start = start;
     End = end;
     Range = range;
 }
        internal override float SignedDistance(ref Vector3 position, float lodVoxelSize, IMyModule macroModulator, IMyModule detailModulator)
        {
            Vector3 localPosition = position - m_translation;
            Vector3.Transform(ref localPosition, ref m_invRotation, out localPosition);

            var primaryDistance = new Vector2(localPosition.X, localPosition.Z).Length() - m_primaryRadius;
            var signedDistance = new Vector2(primaryDistance, localPosition.Y).Length() - m_secondaryRadius;

            var potentialHalfDeviation = m_potentialHalfDeviation + lodVoxelSize;
            if (signedDistance > potentialHalfDeviation)
                return 1f;
            else if (signedDistance < -potentialHalfDeviation)
                return -1f;

            if (m_enableModulation)
            {
                Debug.Assert(m_deviationFrequency != 0f);
                float normalizer = 0.5f * m_deviationFrequency;
                var tmp = localPosition * normalizer;
                float halfDeviationRatio = (float)macroModulator.GetValue(tmp.X, tmp.Y, tmp.Z);
                signedDistance -= halfDeviationRatio * m_secondaryHalfDeviation;
            }

            if (m_enableModulation && -m_detailSize < signedDistance && signedDistance < m_detailSize)
            {
                Debug.Assert(m_detailFrequency != 0f);
                float normalizer = 0.5f * m_detailFrequency;
                var tmp = localPosition * normalizer;
                signedDistance += m_detailSize * (float)detailModulator.GetValue(tmp.X, tmp.Y, tmp.Z);
            }

            return signedDistance / lodVoxelSize;
        }
Example #18
1
 public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth, ActorTypes type)
 {
     Type = type;
     Position = position;
     SurfaceNormal = surfaceNormal;
     PenetrationDepth = penetrationDepth;
 }
        public WheelInfo(WheelInfoConstructionInfo ci)
        {
            SuspensionRestLength1 = ci.SuspensionRestLength;
            MaxSuspensionTravelCm = ci.MaxSuspensionTravelCm;

            WheelsRadius = ci.WheelRadius;
            SuspensionStiffness = ci.SuspensionStiffness;
            WheelsDampingCompression = ci.WheelsDampingCompression;
            WheelsDampingRelaxation = ci.WheelsDampingRelaxation;
            ChassisConnectionPointCS = ci.ChassisConnectionCS;
            WheelDirectionCS = ci.WheelDirectionCS;
            WheelAxleCS = ci.WheelAxleCS;
            FrictionSlip = ci.FrictionSlip;
            Steering = 0;
            EngineForce = 0;
            Rotation = 0;
            DeltaRotation = 0;
            Brake = 0;
            RollInfluence = 0.1f;
            IsFrontWheel = ci.IsFrontWheel;
            MaxSuspensionForce = ci.MaxSuspensionForce;

            //ClientInfo = IntPtr.Zero;
            //ClippedInvContactDotSuspension = 0;
            WorldTransform = Matrix.Identity;
            //WheelsSuspensionForce = 0;
            //SuspensionRelativeVelocity = 0;
            //SkidInfo = 0;
            RaycastInfo = new RaycastInfo();
        }
 /* Convert world space coordinates (doubles) to view space (floats) */
 private Vector3[] ConvertPointsToViewSpace(List<Position> points, Camera camera)
 {
     Vector3[] verts = new Vector3[points.Count];
     for (int i = 0; i < points.Count; ++i)
         verts[i] = points[i].Diff(camera.Position);
     return verts;
 }
        public override void Init(MyObjectBuilder_AutopilotBase objectBuilder)
        {
            MyObjectBuilder_SimpleAutopilot ob = (MyObjectBuilder_SimpleAutopilot)objectBuilder;

            m_destination = ob.Destination;
            m_direction = ob.Direction;
        }
Example #22
1
 public Chunk(Vector3 chunkSize, Vector3 location, Island island)
 {
     this.mChunkSize = chunkSize;
     this.mChunkLocation = location;
     this.mVisible = new bool[16, 16, 16, 6];
     this.mIsland = island;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CylinderColliderShape"/> class.
        /// </summary>
        /// <param name="halfExtents">The half extents.</param>
        /// <param name="upAxis">Up axis.</param>
        public CylinderColliderShape(Vector3 halfExtents, Vector3 upAxis)
        {
            Type = ColliderShapeTypes.Cylinder;
            Is2D = false; //always false for cylinders

            Matrix rotation;
            Vector3 scaling;

            if (upAxis == Vector3.UnitX)
            {
                InternalShape = new BulletSharp.CylinderShapeX(halfExtents);

                rotation = Matrix.RotationZ((float)Math.PI / 2.0f);
                scaling = new Vector3(halfExtents.Y * 2.0f, halfExtents.X * 2.0f, halfExtents.Z * 2.0f);
            }
            else if (upAxis == Vector3.UnitZ)
            {
                InternalShape = new BulletSharp.CylinderShapeZ(halfExtents);

                rotation = Matrix.RotationX((float)Math.PI / 2.0f);
                scaling = new Vector3(halfExtents.X * 2.0f, halfExtents.Z * 2.0f, halfExtents.Y * 2.0f);
            }
            else //default to Y
            {
                InternalShape = new BulletSharp.CylinderShape(halfExtents);

                rotation = Matrix.Identity;
                scaling = halfExtents * 2.0f;
            }

            DebugPrimitiveMatrix = Matrix.Scaling(scaling * 1.01f) * rotation;
        }
Example #24
1
        public override void Action()
        {
            Random rng = Bot.Manager.Rng;
            GridRegion[] knownRegions;

            lock (Bot.Manager.RegionsKnown)
            {
                if (Bot.Manager.RegionsKnown.Count == 0)
                {
                    m_log.DebugFormat(
                        "[TELEPORT BEHAVIOUR]: Ignoring teleport action for {0} since no regions are known yet", Bot.Name);
                    return;
                }

                knownRegions = Bot.Manager.RegionsKnown.Values.ToArray();
            }

            Simulator sourceRegion = Bot.Client.Network.CurrentSim;
            GridRegion destRegion = knownRegions[rng.Next(knownRegions.Length)];
            Vector3 destPosition = new Vector3(rng.Next(255), rng.Next(255), 50);

            m_log.DebugFormat(
                "[TELEPORT BEHAVIOUR]: Teleporting {0} from {1} {2} to {3} {4}",
                Bot.Name, sourceRegion.Name, Bot.Client.Self.SimPosition, destRegion.Name, destPosition);

            Bot.Client.Self.Teleport(destRegion.RegionHandle, destPosition);
        }
        public override MyVoxelMaterialDefinition GetMaterialForPosition(ref Vector3 pos, float lodSize)
        {
           Vector3 localPosition = pos - Shape.Center();
            float lenghtToCenter = localPosition.Length();
            float angleToPole = Vector3.Dot(localPosition / lenghtToCenter,Vector3.Up);

            int nearestMaterial = -1;
            float minDistance = float.MaxValue;
            float noiseValue = (float)(0.5*m_noise.GetValue(pos.X, pos.Y, pos.Z)+0.5);
  

            for (int i = 0; i < m_materialLayers.Length; ++i)
            {
                float heightStartDistance = m_materialLayers[i].HeightStartDeviation * noiseValue;
                float angleStartDistance = m_materialLayers[i].AngleStartDeviation *noiseValue;

                float heightEndDistance = m_materialLayers[i].HeightEndDeviation * noiseValue;
                float angleEndDistance = m_materialLayers[i].AngleEndDeviation * noiseValue;

                if (lenghtToCenter >= (m_materialLayers[i].StartHeight - lodSize - heightStartDistance) && (m_materialLayers[i].EndHeight + lodSize+heightEndDistance) >= lenghtToCenter &&
                    angleToPole > m_materialLayers[i].StartAngle - angleStartDistance && m_materialLayers[i].EndAngle + angleEndDistance > angleToPole)
                {
                    float distanceTolayer = Math.Abs(lenghtToCenter - m_materialLayers[i].StartHeight + heightStartDistance);
                    if (minDistance > distanceTolayer)
                    {
                        minDistance = distanceTolayer;
                        nearestMaterial = i;
                    }
                    
                }
            }
            return nearestMaterial == -1 ? null : m_materialLayers[nearestMaterial].MaterialDefinition;
        }
 /// <summary>
 /// The points of the triangle are assigned counter clockwise
 /// and the normal points upward.
 /// </summary>
 public TriangleIntersector(Vector3 a, Vector3 b, Vector3 c)
 {
     // todo: verify the 3 points are not colinear
     A = a;
     B = b;
     C = c;
 }        
Example #27
0
        public DxMesh(
            Game renderer, 
            List<AdnMeshData> meshDataList)
        {
            _center = new Vector3(0, 0, 0);

            _meshEntities = new Dictionary<string, DxMeshEntity>();

            foreach (AdnMeshData meshData in meshDataList)
            {
                _center += new Vector3(
                    meshData.Center[0],
                    meshData.Center[1],
                    meshData.Center[2]);

                _meshEntities.Add(
                    meshData.Id,
                    new DxMeshEntity(
                        renderer,
                        meshData));
            }

            _center.X = -_center.X / meshDataList.Count;
            _center.Y = -_center.Y / meshDataList.Count;
            _center.Z = -_center.Z / meshDataList.Count;
        }
Example #28
0
 public static bool isMoving(Vector3 pos, int Index)
 {
     if (pos != Variables.EnemiesPos[Index])
         return true;
     else
         return false;
 }
Example #29
0
 public MyImportTriangle(Vector3 vertex0, Vector3 vertex1, Vector3 vertex2)
 {
     Vertex0 = vertex0;
     Vertex1 = vertex1;
     Vertex2 = vertex2;
     Normal = MyMwcUtils.Normalize(Vector3.Cross(vertex1 - vertex0, vertex2 - vertex0));
 }
Example #30
0
 /// 継承メソッド
 ///---------------------------------------------------------------------------
 /// 初期化
 public override bool DoInit()
 {
     useMdlHdl = new Common.ModelHandle();
     useMdlHdl.Init();
     baseScale = new Vector3( 1.0f, 1.0f, 1.0f );
     return true;
 }