Exemplo n.º 1
0
 public bool BoxHit(Box3D box)
 {
     currentHit[0] = 0;
     currentHit[1] = 0;
     currentHit[2] = 0;
     return Intersection.CheckLineBox(box, currentLine, currentHit);
 }
Exemplo n.º 2
0
    public BlockPosSide[] LineIntersection(DelegateIsBlockEmpty isEmpty, DelegateGetBlockHeight getBlockHeight, Line3D line, IntRef retCount)
    {
        lCount = 0;
        currentLine = line;
        currentHit[0] = 0;
        currentHit[1] = 0;
        currentHit[2] = 0;
        ListBox3d l1 = Search(PredicateBox3DHit.Create(this));
        for (int i = 0; i < l1.count; i++)
        {
            Box3D node = l1.arr[i];
            float[] hit = currentHit;
            float x = node.MinEdge[0];
            float y = node.MinEdge[2];
            float z = node.MinEdge[1];
            if (!isEmpty.IsBlockEmpty(platform.FloatToInt(x),platform.FloatToInt(y),platform.FloatToInt( z)))
            {
                Box3D node2 = new Box3D();
                node2.MinEdge = Vec3.CloneIt(node.MinEdge);
                node2.MaxEdge = Vec3.CloneIt(node.MaxEdge);
                node2.MaxEdge[1] = node2.MinEdge[1] + getBlockHeight.GetBlockHeight(platform.FloatToInt(x),platform.FloatToInt(y),platform.FloatToInt(z));

                BlockPosSide b = new BlockPosSide();
                float[] hit2 = new float[3];

                float[] dir = new float[3];
                dir[0] = line.End[0] - line.Start[0];
                dir[1] = line.End[1] - line.Start[1];
                dir[2] = line.End[2] - line.Start[2];
                bool ishit = Intersection.HitBoundingBox(node2.MinEdge, node2.MaxEdge, line.Start, dir, hit2);
                if (ishit)
                {
                    //hit2.pos = Vec3.FromValues(x, z, y);
                    b.blockPos = Vec3.FromValues(platform.FloatToInt(x), platform.FloatToInt(z), platform.FloatToInt(y));
                    b.collisionPos = hit2;
                    l[lCount++] = b;
                }
            }
        }
        BlockPosSide[] ll = new BlockPosSide[lCount];
        for (int i = 0; i < lCount; i++)
        {
            ll[i] = l[i];
        }
        retCount.value = lCount;
        return ll;
    }
Exemplo n.º 3
0
        public LensflareSceneNode(SceneNode parent, SceneManager mgr, int id)
            : base(parent, mgr, id)
        {
            draw_flare = true;
            ign_geom = false;
            smgr = mgr;

            indices = new ushort[6];
            indices[0] = 0;
            indices[1] = 2;
            indices[2] = 1;
            indices[3] = 0;
            indices[4] = 3;
            indices[5] = 2;

            vertices = new Vertex3D[4];
            for (int i = 0; i < 4; i++)
            {
                vertices[i] = new Vertex3D();
            }
            vertices[0].TCoords = Vector2D.From(0.0f, 1.0f);
            vertices[0].Color = Color.White;
            vertices[1].TCoords = Vector2D.From(0.0f, 0.0f);
            vertices[1].Color = Color.White;
            vertices[2].TCoords = Vector2D.From(1.0f, 0.0f);
            vertices[2].Color = Color.White;
            vertices[3].TCoords = Vector2D.From(1.0f, 1.0f);
            vertices[3].Color = Color.White;

            material = new Material();

            material.Lighting = false;

            material.MaterialType = MaterialType.TransparentAddColor;

            material.ZBuffer = 0;

            material.ZWriteEnable = false;

            bbox = new Box3D();

            bbox.MinEdge = Vector3D.From(-2, -2, -2);

            bbox.MaxEdge = Vector3D.From(2, 2, 2);

        }
Exemplo n.º 4
0
 public BlockOctreeSearcher()
 {
     intersection = new Intersection();
     pool = new Box3D[10000];
     for (int i = 0; i < 10000; i++)
     {
         pool[i] = new Box3D();
     }
     listpool = new ListBox3d[50];
     for (int i = 0; i < 50; i++)
     {
         listpool[i] = new ListBox3d();
         listpool[i].arr = new Box3D[1000];
     }
     l = new BlockPosSide[1024];
     lCount = 0;
     currentHit = new float[3];
 }
Exemplo n.º 5
0
 ListBox3d SearchPrivate(PredicateBox3D query, Box3D box)
 {
     if (box.LengthX() == 1)
     {
         ListBox3d l1 = newListBox3d();
         l1.count = 1;
         l1.arr[0] = box;
         return l1;
     }
     ListBox3d l = newListBox3d();
     l.count = 0;
     ListBox3d children = Children(box);
     for (int k = 0; k < children.count; k++)
     {
         Box3D child = children.arr[k];
         if (query.Hit(child))
         {
             ListBox3d l2 = SearchPrivate(query, child);
             for (int i = 0; i < l2.count; i++)
             {
                 Box3D n = l2.arr[i];
                 l.arr[l.count++] = n;
             }
             recycleListBox3d(l2);
         }
     }
     recycleListBox3d(children);
     return l;
 }
Exemplo n.º 6
0
 public override bool Hit(Box3D o)
 {
     return(s.BoxHit(o));
 }
Exemplo n.º 7
0
    void PickEntity(Game game, Line3D pick, BlockPosSide[] pick2, IntRef pick2count)
    {
        game.SelectedEntityId = -1;
        game.currentlyAttackedEntity = -1;
        float one = 1;
        for (int i = 0; i < game.entitiesCount; i++)
        {
            if (game.entities[i] == null)
            {
                continue;
            }
            if (i == game.LocalPlayerId)
            {
                continue;
            }
            if (game.entities[i].drawModel == null)
            {
                continue;
            }
            Entity p_ = game.entities[i];
            if (p_.networkPosition == null)
            {
                continue;
            }
            if (!p_.networkPosition.PositionLoaded)
            {
                continue;
            }
            if (!p_.usable)
            {
                continue;
            }
            float feetposX = p_.position.x;
            float feetposY = p_.position.y;
            float feetposZ = p_.position.z;

            float dist = game.Dist(feetposX, feetposY, feetposZ, game.player.position.x, game.player.position.y, game.player.position.z);
            if (dist > 5)
            {
                continue;
            }

            //var p = PlayerPositionSpawn;
            Box3D bodybox = new Box3D();
            float h = p_.drawModel.ModelHeight;
            float r = one * 35 / 100;

            bodybox.AddPoint(feetposX - r, feetposY + 0, feetposZ - r);
            bodybox.AddPoint(feetposX - r, feetposY + 0, feetposZ + r);
            bodybox.AddPoint(feetposX + r, feetposY + 0, feetposZ - r);
            bodybox.AddPoint(feetposX + r, feetposY + 0, feetposZ + r);

            bodybox.AddPoint(feetposX - r, feetposY + h, feetposZ - r);
            bodybox.AddPoint(feetposX - r, feetposY + h, feetposZ + r);
            bodybox.AddPoint(feetposX + r, feetposY + h, feetposZ - r);
            bodybox.AddPoint(feetposX + r, feetposY + h, feetposZ + r);

            float[] p;
            float localeyeposX = game.EyesPosX();
            float localeyeposY = game.EyesPosY();
            float localeyeposZ = game.EyesPosZ();
            p = Intersection.CheckLineBoxExact(pick, bodybox);
            if (p != null)
            {
                //do not allow to shoot through terrain
                if (pick2count.value == 0 || (game.Dist(pick2[0].blockPos[0], pick2[0].blockPos[1], pick2[0].blockPos[2], localeyeposX, localeyeposY, localeyeposZ)
                    > game.Dist(p[0], p[1], p[2], localeyeposX, localeyeposY, localeyeposZ)))
                {
                    game.SelectedEntityId = i;
                    if (game.cameratype == CameraType.Fpp || game.cameratype == CameraType.Tpp)
                    {
                        game.currentlyAttackedEntity = i;
                    }
                }
            }
        }
    }
Exemplo n.º 8
0
 public override bool Hit(Box3D o)
 {
     return s.BoxHit(o);
 }
Exemplo n.º 9
0
 public static float[] CheckLineBoxExact(Line3D line, Box3D box)
 {
     float[] dir_ = new float[3];
     dir_[0] = line.End[0] - line.Start[0];
     dir_[1] = line.End[1] - line.Start[1];
     dir_[2] = line.End[2] - line.Start[2];
     float[] hit = new float[3];
     if (!Intersection.HitBoundingBox(box.MinEdge, box.MaxEdge, line.Start, dir_, hit))
     {
         return null;
     }
     return hit;
 }
Exemplo n.º 10
0
 private void Form1_Load(object sender, EventArgs e)
 {
     oGraf  = Box3D.CreateGraphics();
     nScale = (int)(Width / 5f);
     Clear();
 }
Exemplo n.º 11
0
        public override void Render()
        {
            VideoDriver driver = _mgr.VideoDriver;
            CameraSceneNode camera = _mgr.ActiveCamera;

            if (camera == null || driver == null)
                return;

            if (!redrawnextloop)
            {
                driver.SetTransform(TransformationState.World, AbsoluteTransformation);
                driver.SetMaterial(_material);
                driver.DrawIndexedTriangleList(Vertices, lastdrawcount * 4,
                                               Indices, lastdrawcount * 4);
            }
            else
            {
                ReallocateBuffers();

                Vector3D campos = camera.AbsolutePosition;
                Box3D cbox = camera.ViewFrustum.BoundingBox;

                Vector3D pos = Position;
                int drawcount = 0;
                int max = (Particles.Length < MaxDensity) ? Particles.Length : MaxDensity;

                double d = pos.DistanceFrom(campos) / GRASS_PATCH_SIZE;
                if (d > 1.0)
                    max = (int)(max / d);

                //Matrix4 m = new Matrix4();

                for (int i = 0; i < max; i++)
                {
                    int idx = drawcount * 4;

                    GrassParticle particle = Particles[i];
                    Vector3D gpos = particle.pos + pos;

                    double dist = campos.DistanceFromSQ(gpos);
                    if (dist > NewMath.Sqr(DrawDistance))
                        continue;

                    if (!cbox.IsPointInside(gpos))
                        continue;

                    if (dist > NewMath.Sqr(DrawDistance * 0.5))
                    {
                        if (particle.sprite.Height == 0)
                        {
                            float i1 = ((float)i) / ((float)max);
                            float i2 = ((float)(dist / DrawDistance)) / 2f;

                            if (i1 < i2)
                                continue;
                        }
                    }

                    int igridsize = GRASS_PATCH_SIZE / (int)WindRes;
                    int ihalfres = (int)WindRes / 2;

                    int xgrid = (int)(particle.pos.X / (igridsize) + ihalfres);
                    int zgrid = (int)(particle.pos.Z / (igridsize) + ihalfres);

                    float xnext = particle.pos.X / ((float)GRASS_PATCH_SIZE / (float)WindRes) + (WindRes / 2f) - xgrid;
                    float znext = particle.pos.Z / ((float)GRASS_PATCH_SIZE / (float)WindRes) + (WindRes / 2f) - zgrid;

                    Vector2D wind1 = WindGrid[xgrid * WindRes + zgrid];
                    Vector2D wind2 = WindGrid[(xgrid + 1) * WindRes + zgrid];
                    Vector2D wind3 = WindGrid[xgrid * (WindRes + 1) + zgrid];
                    Vector2D wind4 = WindGrid[(xgrid + 1) * (WindRes + 1) + zgrid];
                    Vector2D wind2d = wind1 * (1.0f - xnext) * (1.0f - znext) +
                                      wind2 * xnext * (1.0f - znext) +
                                      wind3 * (1.0f - xnext) * znext +
                                      wind4 * xnext * znext;

                    wind2d *= particle.flex;
                    Vector3D wind = new Vector3D(wind2d.X, 0f, wind2d.Y);

                    Color gcol = new Color(particle.color.A,
                                           (int)(particle.color.R * 0.8f),
                                           (int)(particle.color.G * 0.8f),
                                           (int)(particle.color.B * 0.8f));

                    Vertices[0 + idx].Position = particle.points[0];
                    Vertices[0 + idx].Color = gcol;

                    Vertices[1 + idx].Position = particle.points[1] + wind;
                    Vertices[1 + idx].Color = particle.color;

                    Vertices[2 + idx].Position = particle.points[2] + wind;
                    Vertices[2 + idx].Color = particle.color;

                    Vertices[3 + idx].Position = particle.points[3];
                    Vertices[3 + idx].Color = gcol;

                    int arrpos = (_imagecount.Width * particle.sprite.Height) + particle.sprite.Width;
                    Vertices[0 + idx].TCoords = new Vector2D(v1[arrpos], v2[arrpos]);
                    Vertices[1 + idx].TCoords = new Vector2D(v1[arrpos], v3[arrpos]);
                    Vertices[2 + idx].TCoords = new Vector2D(v4[arrpos], v3[arrpos]);
                    Vertices[3 + idx].TCoords = new Vector2D(v4[arrpos], v2[arrpos]);

                    drawcount++;
                }
                driver.SetTransform(TransformationState.World, AbsoluteTransformation);
                driver.SetMaterial(_material);

                driver.DrawIndexedTriangleList(Vertices, drawcount * 4,
                                               Indices, drawcount * 4);
                lastdrawcount = drawcount;
            }

            if (DebugDataVisible == DebugSceneType.BoundingBox)
            {
                driver.SetTransform(TransformationState.World, AbsoluteTransformation);
                Material m = new Material();
                m.Lighting = false;
                driver.SetMaterial(m);
                driver.Draw3DBox(BoundingBox, Color.From(0, 255, 255, 255));
                Box3D b2 = new Box3D();

                b2.AddInternalPoint(BoundingBox.MaxEdge * 0.01f);
                driver.Draw3DBox(b2, Color.From(0, 255, 255, 255));
            }
        }
Exemplo n.º 12
0
        bool Create(bool save)
        {
            Random rand = new Random((int)((100 * gridpos.X) + gridpos.Z));
            int count = rand.Next(3000, 3200);

            _bbox = new Box3D();

            Particles = new GrassParticle[count];

            /*Matrix4 m = new Matrix4();
            m.RotationDegrees = Terrain.Rotation;
            m.Translation = Terrain.AbsolutePosition;
            m.MakeInverse();*/

            Color[,] TGMRetrieve = TerrainGrassMap.Retrieve();
            Color[,] TCMRetrieve = TerrainColourMap.Retrieve();
            Color[,] THMRetrieve = TerrainHeightMap.Retrieve();
            System.Collections.ArrayList tosave = new System.Collections.ArrayList();

            for (int i = 0; i < count; i++)
            {
                Particles[i].points = new Vector3D[4];

                float x = rand.Next(0, GRASS_PATCH_SIZE * 10) / 10f;
                float z = rand.Next(0, GRASS_PATCH_SIZE * 10) / 10f;

                x -= GRASS_PATCH_SIZE / 2f;
                z -= GRASS_PATCH_SIZE / 2f;

                Particles[i].pos.X = x;
                Particles[i].pos.Z = z;

                Particles[i].flex = rand.Next(0, 100) / 100f;
                Particles[i].sprite.Width = rand.Next(0, _imagecount.Width);

                if (i < 30)
                    Particles[i].sprite.Height = rand.Next(0, _imagecount.Height);
                else
                    Particles[i].sprite.Height = 0;

                Vector3D p = Position + Particles[i].pos;

                Vector3D xz = new Vector3D(p.X / Terrain.Scale.X, 0f, p.Z / Terrain.Scale.Z);

                int x1 = (int)Math.Floor(xz.X);
                int z1 = (int)Math.Floor(xz.Z);

                if (x1 < 1 ||
                   z1 < 1 ||
                   x1 > TerrainHeightMap.OriginalSize.Width - 1 ||
                   z1 > TerrainHeightMap.OriginalSize.Height - 1)
                    continue;

                Color cDensity = TGMRetrieve[x1, z1];
                if (rand.Next(0, 255) > cDensity.A || cDensity.A < 1)
                    continue;

                float ay = THMRetrieve[x1, z1].B * Terrain.Scale.Y;
                float by = THMRetrieve[x1 + 1, z1].B * Terrain.Scale.Y;
                float cy = THMRetrieve[x1, z1 + 1].B * Terrain.Scale.Y;
                float dy = THMRetrieve[x1 + 1, z1 + 1].B * Terrain.Scale.Y;
                float u1 = xz.X - x1;
                float v1 = xz.Z - z1;
                float height = ay * (1.0f - u1) * (1.0f - v1) + by * u1 * (1.0f - v1) + cy * (1.0f - u1) * v1 + dy * u1 * v1;

                Dimension2Df size = new Dimension2Df(rand.Next(40, 70), 100);
                size.Height *= cDensity.B / 200f;

                Particles[i].pos.Y = height + (size.Height * 0.5f);

                Particles[i].color = TCMRetrieve[x1, z1];
                Particles[i].startColor = TCMRetrieve[x1, z1];

                _bbox.AddInternalPoint(Particles[i].pos);

                Vector3D dimensions = new Vector3D(0.5f * size.Width,
                                                   -0.5f * size.Height,
                                                   0);

                /*float rotation = rand.Next(0, 3600) / 10f;
                Matrix4 m2 = new Matrix4();
                m2.RotationDegrees = new Vector3D(0, rotation, 0);
                m2.RotateVect(dimensions);*/

                //Vector3D h = new Vector3D(dimensions.X,0.0f,dimensions.Z);
                //Vector3D v = new Vector3D(0.0f,dimensions.Y,0.0f);
                Particles[i].points[0] = Particles[i].pos + new Vector3D(dimensions.X, dimensions.Y, dimensions.Z);
                Particles[i].points[1] = Particles[i].pos + new Vector3D(dimensions.X, -dimensions.Y, dimensions.Z);
                Particles[i].points[2] = Particles[i].pos - new Vector3D(dimensions.X, dimensions.Y, dimensions.Z);
                Particles[i].points[3] = Particles[i].pos - new Vector3D(dimensions.X, -dimensions.Y, dimensions.Z);
                tosave.Add(Particles[i]);
            }

            Particles = (GrassParticle[])tosave.ToArray(typeof(GrassParticle));
            tosave.Clear();
            if (save)
                return Save();

            return true;
        }
Exemplo n.º 13
0
 public abstract bool Hit(Box3D o);
Exemplo n.º 14
0
 /// <summary>
 /// Warning: randomly returns incorrect hit position (back side of box).
 /// </summary>
 /// <param name="box"></param>
 /// <param name="line"></param>
 /// <param name="hit"></param>
 /// <returns></returns>
 public static bool CheckLineBox(Box3D box, Line3D line, float[] hit)
 {
     return(CheckLineBox1(box.MinEdge, box.MaxEdge, line.Start, line.End, hit));
 }
Exemplo n.º 15
0
 internal static Box3D Create(int x, int y, int z, int size)
 {
     Box3D b = new Box3D();
     b.Set(x, y, z, size);
     return b;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Warning: randomly returns incorrect hit position (back side of box).
 /// </summary>
 /// <param name="box"></param>
 /// <param name="line"></param>
 /// <param name="hit"></param>
 /// <returns></returns>
 public static bool CheckLineBox(Box3D box, Line3D line, float[] hit)
 {
     return CheckLineBox1(box.MinEdge, box.MaxEdge, line.Start, line.End, hit);
 }
Exemplo n.º 17
0
        protected override void Draw()
        {
            if (Radar2D.Option.IsVisible)
            {
                Radar2D.Draw(Render2D, RenderSurface.Size);
            }

            foreach (Player player in _players)
            {
                if (player.IsValid() && player.Name != _localPlayer.Name)
                {
                    if (Name.Option.IsVisible)
                    {
                        if (!Name.Option.IsOnlyEnemyVisible || Name.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            Name.Draw_y(Render2D, player.Position, _localPlayer.ViewProj, new Size(1920, 1080), player.Name, player.Height, player.IsVisible, _localPlayer.TeamId == player.TeamId);
                        }
                    }

                    if (Health.Option.IsVisible)
                    {
                        if (!Health.Option.IsOnlyEnemyVisible || Health.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            Health.Draw_y(Render2D, player.Position, _localPlayer.ViewProj, new Size(1920, 1080), player.Health, player.MaxHealth, player.Height, player.IsVisible, _localPlayer.TeamId == player.TeamId);
                        }
                    }

                    if (Box2D.Option.IsVisible)
                    {
                        if (!Box2D.Option.IsOnlyEnemyVisible || Box2D.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            Box2D.Draw_y(Render2D, new Size(1920, 1080), _localPlayer.ViewProj, player.Position, player.Height, player.IsVisible, _localPlayer.TeamId == player.TeamId);
                        }
                    }

                    if (Box3D.Option.IsVisible)
                    {
                        if (!Box3D.Option.IsOnlyEnemyVisible || Box3D.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            Box3D.Draw_y(Render2D, player.BoundingBox(), player.Position, player.Yaw, _localPlayer.ViewProj, new Size(1920, 1080), player.IsVisible, _localPlayer.TeamId == player.TeamId);
                        }
                    }

                    if (SnapLine.Option.IsVisible)
                    {
                        if (!SnapLine.Option.IsOnlyEnemyVisible || SnapLine.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            SnapLine.Draw_y(Render2D, player.Position, _localPlayer.ViewProj, RenderSurface.Size, player.IsVisible, _localPlayer.TeamId == player.TeamId);
                        }
                    }

                    if (Radar2D.Option.IsVisible)
                    {
                        if (!Radar2D.Option.IsOnlyEnemyVisible || Radar2D.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            Radar2D.DrawPlayer(Render2D, player.Position, _localPlayer.Position, RenderSurface.Size, _localPlayer.Yaw, player.IsVisible, _localPlayer.TeamId == player.TeamId);

                            if (Radar2D.Option.IsVisibleName)
                            {
                                Radar2D.DrawName(Render2D, player.Position, _localPlayer.Position, RenderSurface.Size, player.Name, _localPlayer.Yaw, player.IsVisible, _localPlayer.TeamId == player.TeamId);
                            }
                        }
                    }

                    if (CrosshairRadar.Option.IsVisible)
                    {
                        if (!CrosshairRadar.Option.IsOnlyEnemyVisible || CrosshairRadar.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            CrosshairRadar.DrawPlayer(Render2D, player.Position, _localPlayer.Position, RenderSurface.Size, _localPlayer.Yaw, player.IsVisible, _localPlayer.TeamId == player.TeamId);

                            if (CrosshairRadar.Option.IsVisibleName)
                            {
                                CrosshairRadar.DrawName(Render2D, player.Position, _localPlayer.Position, RenderSurface.Size, player.Name, _localPlayer.Yaw, player.IsVisible, _localPlayer.TeamId == player.TeamId);
                            }
                        }
                    }

                    if (DisplayRadar.Option.IsVisible)
                    {
                        if (!DisplayRadar.Option.IsOnlyEnemyVisible || DisplayRadar.Option.IsOnlyEnemyVisible && _localPlayer.TeamId != player.TeamId)
                        {
                            DisplayRadar.DrawPlayer(Render2D, player.Position, _localPlayer.Position, RenderSurface.Size, _localPlayer.Yaw, player.IsVisible, _localPlayer.TeamId == player.TeamId);
                        }
                    }
                }
            }

            if (Crosshair.Option.IsVisible)
            {
                Crosshair.Draw(Render2D, RenderSurface.Size);
            }
        }
Exemplo n.º 18
0
    internal void NextBullet(Game game, int bulletsshot)
    {
        float one    = 1;
        bool  left   = game.mouseLeft;
        bool  middle = game.mouseMiddle;
        bool  right  = game.mouseRight;

        bool IsNextShot = bulletsshot != 0;

        if (!game.leftpressedpicking)
        {
            if (game.mouseleftclick)
            {
                game.leftpressedpicking = true;
            }
            else
            {
                left = false;
            }
        }
        else
        {
            if (game.mouseleftdeclick)
            {
                game.leftpressedpicking = false;
                left = false;
            }
        }
        if (!left)
        {
            game.currentAttackedBlock = null;
        }

        Packet_Item item          = game.d_Inventory.RightHand[game.ActiveMaterial];
        bool        ispistol      = (item != null && game.blocktypes[item.BlockId].IsPistol);
        bool        ispistolshoot = ispistol && left;
        bool        isgrenade     = ispistol && game.blocktypes[item.BlockId].PistolType == Packet_PistolTypeEnum.Grenade;

        if (ispistol && isgrenade)
        {
            ispistolshoot = game.mouseleftdeclick;
        }
        //grenade cooking
        if (game.mouseleftclick)
        {
            game.grenadecookingstartMilliseconds = game.platform.TimeMillisecondsFromStart();
            if (ispistol && isgrenade)
            {
                if (game.blocktypes[item.BlockId].Sounds.ShootCount > 0)
                {
                    game.AudioPlay(game.platform.StringFormat("{0}.ogg", game.blocktypes[item.BlockId].Sounds.Shoot[0]));
                }
            }
        }
        float wait = ((one * (game.platform.TimeMillisecondsFromStart() - game.grenadecookingstartMilliseconds)) / 1000);

        if (isgrenade && left)
        {
            if (wait >= game.grenadetime && isgrenade && game.grenadecookingstartMilliseconds != 0)
            {
                ispistolshoot         = true;
                game.mouseleftdeclick = true;
            }
            else
            {
                return;
            }
        }
        else
        {
            game.grenadecookingstartMilliseconds = 0;
        }

        if (ispistol && game.mouserightclick && (game.platform.TimeMillisecondsFromStart() - game.lastironsightschangeMilliseconds) >= 500)
        {
            game.IronSights = !game.IronSights;
            game.lastironsightschangeMilliseconds = game.platform.TimeMillisecondsFromStart();
        }

        IntRef pick2count = new IntRef();
        Line3D pick       = new Line3D();

        GetPickingLine(game, pick, ispistolshoot);
        BlockPosSide[] pick2 = game.Pick(game.s, pick, pick2count);

        if (left)
        {
            game.handSetAttackDestroy = true;
        }
        else if (right)
        {
            game.handSetAttackBuild = true;
        }

        if (game.overheadcamera && pick2count.value > 0 && left)
        {
            //if not picked any object, and mouse button is pressed, then walk to destination.
            if (game.Follow == null)
            {
                //Only walk to destination when not following someone
                game.playerdestination = Vector3Ref.Create(pick2[0].blockPos[0], pick2[0].blockPos[1] + 1, pick2[0].blockPos[2]);
            }
        }
        bool pickdistanceok = (pick2count.value > 0) && (!ispistol);

        if (pickdistanceok)
        {
            if (game.Dist(pick2[0].blockPos[0] + one / 2, pick2[0].blockPos[1] + one / 2, pick2[0].blockPos[2] + one / 2,
                          pick.Start[0], pick.Start[1], pick.Start[2]) > CurrentPickDistance(game))
            {
                pickdistanceok = false;
            }
        }
        bool playertileempty = game.IsTileEmptyForPhysics(
            game.platform.FloatToInt(game.player.position.x),
            game.platform.FloatToInt(game.player.position.z),
            game.platform.FloatToInt(game.player.position.y + (one / 2)));
        bool playertileemptyclose = game.IsTileEmptyForPhysicsClose(
            game.platform.FloatToInt(game.player.position.x),
            game.platform.FloatToInt(game.player.position.z),
            game.platform.FloatToInt(game.player.position.y + (one / 2)));
        BlockPosSide pick0 = new BlockPosSide();

        if (pick2count.value > 0 &&
            ((pickdistanceok && (playertileempty || (playertileemptyclose))) ||
             game.overheadcamera)
            )
        {
            game.SelectedBlockPositionX = game.platform.FloatToInt(pick2[0].Current()[0]);
            game.SelectedBlockPositionY = game.platform.FloatToInt(pick2[0].Current()[1]);
            game.SelectedBlockPositionZ = game.platform.FloatToInt(pick2[0].Current()[2]);
            pick0 = pick2[0];
        }
        else
        {
            game.SelectedBlockPositionX = -1;
            game.SelectedBlockPositionY = -1;
            game.SelectedBlockPositionZ = -1;
            pick0.blockPos    = new float[3];
            pick0.blockPos[0] = -1;
            pick0.blockPos[1] = -1;
            pick0.blockPos[2] = -1;
        }
        PickEntity(game, pick, pick2, pick2count);
        if (game.cameratype == CameraType.Fpp || game.cameratype == CameraType.Tpp)
        {
            int ntileX = game.platform.FloatToInt(pick0.Current()[0]);
            int ntileY = game.platform.FloatToInt(pick0.Current()[1]);
            int ntileZ = game.platform.FloatToInt(pick0.Current()[2]);
            if (game.IsUsableBlock(game.map.GetBlock(ntileX, ntileZ, ntileY)))
            {
                game.currentAttackedBlock = Vector3IntRef.Create(ntileX, ntileZ, ntileY);
            }
        }
        if (game.GetFreeMouse())
        {
            if (pick2count.value > 0)
            {
                OnPick_(pick0);
            }
            return;
        }

        if ((one * (game.platform.TimeMillisecondsFromStart() - lastbuildMilliseconds) / 1000) >= BuildDelay(game) ||
            IsNextShot)
        {
            if (left && game.d_Inventory.RightHand[game.ActiveMaterial] == null)
            {
                game.SendPacketClient(ClientPackets.MonsterHit(game.platform.FloatToInt(2 + game.rnd.NextFloat() * 4)));
            }
            if (left && !fastclicking)
            {
                //todo animation
                fastclicking = false;
            }
            if ((left || right || middle) && (!isgrenade))
            {
                lastbuildMilliseconds = game.platform.TimeMillisecondsFromStart();
            }
            if (isgrenade && game.mouseleftdeclick)
            {
                lastbuildMilliseconds = game.platform.TimeMillisecondsFromStart();
            }
            if (game.reloadstartMilliseconds != 0)
            {
                PickingEnd(left, right, middle, ispistol);
                return;
            }
            if (ispistolshoot)
            {
                if ((!(game.LoadedAmmo[item.BlockId] > 0)) ||
                    (!(game.TotalAmmo[item.BlockId] > 0)))
                {
                    game.AudioPlay("Dry Fire Gun-SoundBible.com-2053652037.ogg");
                    PickingEnd(left, right, middle, ispistol);
                    return;
                }
            }
            if (ispistolshoot)
            {
                float toX = pick.End[0];
                float toY = pick.End[1];
                float toZ = pick.End[2];
                if (pick2count.value > 0)
                {
                    toX = pick2[0].blockPos[0];
                    toY = pick2[0].blockPos[1];
                    toZ = pick2[0].blockPos[2];
                }

                Packet_ClientShot shot = new Packet_ClientShot();
                shot.FromX     = game.SerializeFloat(pick.Start[0]);
                shot.FromY     = game.SerializeFloat(pick.Start[1]);
                shot.FromZ     = game.SerializeFloat(pick.Start[2]);
                shot.ToX       = game.SerializeFloat(toX);
                shot.ToY       = game.SerializeFloat(toY);
                shot.ToZ       = game.SerializeFloat(toZ);
                shot.HitPlayer = -1;

                for (int i = 0; i < game.entitiesCount; i++)
                {
                    if (game.entities[i] == null)
                    {
                        continue;
                    }
                    if (game.entities[i].drawModel == null)
                    {
                        continue;
                    }
                    Entity p_ = game.entities[i];
                    if (p_.networkPosition == null)
                    {
                        continue;
                    }
                    if (!p_.networkPosition.PositionLoaded)
                    {
                        continue;
                    }
                    float feetposX = p_.position.x;
                    float feetposY = p_.position.y;
                    float feetposZ = p_.position.z;
                    //var p = PlayerPositionSpawn;
                    Box3D bodybox  = new Box3D();
                    float headsize = (p_.drawModel.ModelHeight - p_.drawModel.eyeHeight) * 2; //0.4f;
                    float h        = p_.drawModel.ModelHeight - headsize;
                    float r        = one * 35 / 100;

                    bodybox.AddPoint(feetposX - r, feetposY + 0, feetposZ - r);
                    bodybox.AddPoint(feetposX - r, feetposY + 0, feetposZ + r);
                    bodybox.AddPoint(feetposX + r, feetposY + 0, feetposZ - r);
                    bodybox.AddPoint(feetposX + r, feetposY + 0, feetposZ + r);

                    bodybox.AddPoint(feetposX - r, feetposY + h, feetposZ - r);
                    bodybox.AddPoint(feetposX - r, feetposY + h, feetposZ + r);
                    bodybox.AddPoint(feetposX + r, feetposY + h, feetposZ - r);
                    bodybox.AddPoint(feetposX + r, feetposY + h, feetposZ + r);

                    Box3D headbox = new Box3D();

                    headbox.AddPoint(feetposX - r, feetposY + h, feetposZ - r);
                    headbox.AddPoint(feetposX - r, feetposY + h, feetposZ + r);
                    headbox.AddPoint(feetposX + r, feetposY + h, feetposZ - r);
                    headbox.AddPoint(feetposX + r, feetposY + h, feetposZ + r);

                    headbox.AddPoint(feetposX - r, feetposY + h + headsize, feetposZ - r);
                    headbox.AddPoint(feetposX - r, feetposY + h + headsize, feetposZ + r);
                    headbox.AddPoint(feetposX + r, feetposY + h + headsize, feetposZ - r);
                    headbox.AddPoint(feetposX + r, feetposY + h + headsize, feetposZ + r);

                    float[] p;
                    float   localeyeposX = game.EyesPosX();
                    float   localeyeposY = game.EyesPosY();
                    float   localeyeposZ = game.EyesPosZ();
                    p = Intersection.CheckLineBoxExact(pick, headbox);
                    if (p != null)
                    {
                        //do not allow to shoot through terrain
                        if (pick2count.value == 0 || (game.Dist(pick2[0].blockPos[0], pick2[0].blockPos[1], pick2[0].blockPos[2], localeyeposX, localeyeposY, localeyeposZ)
                                                      > game.Dist(p[0], p[1], p[2], localeyeposX, localeyeposY, localeyeposZ)))
                        {
                            if (!isgrenade)
                            {
                                Entity entity = new Entity();
                                Sprite sprite = new Sprite();
                                sprite.positionX = p[0];
                                sprite.positionY = p[1];
                                sprite.positionZ = p[2];
                                sprite.image     = "blood.png";
                                entity.sprite    = sprite;
                                entity.expires   = Expires.Create(one * 2 / 10);
                                game.EntityAddLocal(entity);
                            }
                            shot.HitPlayer = i;
                            shot.IsHitHead = 1;
                        }
                    }
                    else
                    {
                        p = Intersection.CheckLineBoxExact(pick, bodybox);
                        if (p != null)
                        {
                            //do not allow to shoot through terrain
                            if (pick2count.value == 0 || (game.Dist(pick2[0].blockPos[0], pick2[0].blockPos[1], pick2[0].blockPos[2], localeyeposX, localeyeposY, localeyeposZ)
                                                          > game.Dist(p[0], p[1], p[2], localeyeposX, localeyeposY, localeyeposZ)))
                            {
                                if (!isgrenade)
                                {
                                    Entity entity = new Entity();
                                    Sprite sprite = new Sprite();
                                    sprite.positionX = p[0];
                                    sprite.positionY = p[1];
                                    sprite.positionZ = p[2];
                                    sprite.image     = "blood.png";
                                    entity.sprite    = sprite;
                                    entity.expires   = Expires.Create(one * 2 / 10);
                                    game.EntityAddLocal(entity);
                                }
                                shot.HitPlayer = i;
                                shot.IsHitHead = 0;
                            }
                        }
                    }
                }
                shot.WeaponBlock = item.BlockId;
                game.LoadedAmmo[item.BlockId] = game.LoadedAmmo[item.BlockId] - 1;
                game.TotalAmmo[item.BlockId]  = game.TotalAmmo[item.BlockId] - 1;
                float projectilespeed = game.DeserializeFloat(game.blocktypes[item.BlockId].ProjectileSpeedFloat);
                if (projectilespeed == 0)
                {
                    {
                        Entity entity = game.CreateBulletEntity(
                            pick.Start[0], pick.Start[1], pick.Start[2],
                            toX, toY, toZ, 150);
                        game.EntityAddLocal(entity);
                    }
                }
                else
                {
                    float vX      = toX - pick.Start[0];
                    float vY      = toY - pick.Start[1];
                    float vZ      = toZ - pick.Start[2];
                    float vLength = game.Length(vX, vY, vZ);
                    vX /= vLength;
                    vY /= vLength;
                    vZ /= vLength;
                    vX *= projectilespeed;
                    vY *= projectilespeed;
                    vZ *= projectilespeed;
                    shot.ExplodesAfter = game.SerializeFloat(game.grenadetime - wait);

                    {
                        Entity grenadeEntity = new Entity();

                        Sprite sprite = new Sprite();
                        sprite.image          = "ChemicalGreen.png";
                        sprite.size           = 14;
                        sprite.animationcount = 0;
                        sprite.positionX      = pick.Start[0];
                        sprite.positionY      = pick.Start[1];
                        sprite.positionZ      = pick.Start[2];
                        grenadeEntity.sprite  = sprite;

                        Grenade_ projectile = new Grenade_();
                        projectile.velocityX    = vX;
                        projectile.velocityY    = vY;
                        projectile.velocityZ    = vZ;
                        projectile.block        = item.BlockId;
                        projectile.sourcePlayer = game.LocalPlayerId;

                        grenadeEntity.expires = Expires.Create(game.grenadetime - wait);

                        grenadeEntity.grenade = projectile;
                        game.EntityAddLocal(grenadeEntity);
                    }
                }
                Packet_Client packet = new Packet_Client();
                packet.Id   = Packet_ClientIdEnum.Shot;
                packet.Shot = shot;
                game.SendPacketClient(packet);

                if (game.blocktypes[item.BlockId].Sounds.ShootEndCount > 0)
                {
                    game.pistolcycle = game.rnd.Next() % game.blocktypes[item.BlockId].Sounds.ShootEndCount;
                    game.AudioPlay(game.platform.StringFormat("{0}.ogg", game.blocktypes[item.BlockId].Sounds.ShootEnd[game.pistolcycle]));
                }

                bulletsshot++;
                if (bulletsshot < game.DeserializeFloat(game.blocktypes[item.BlockId].BulletsPerShotFloat))
                {
                    NextBullet(game, bulletsshot);
                }

                //recoil
                game.player.position.rotx -= game.rnd.NextFloat() * game.CurrentRecoil();
                game.player.position.roty += game.rnd.NextFloat() * game.CurrentRecoil() * 2 - game.CurrentRecoil();

                PickingEnd(left, right, middle, ispistol);
                return;
            }
            if (ispistol && right)
            {
                PickingEnd(left, right, middle, ispistol);
                return;
            }
            if (pick2count.value > 0)
            {
                if (middle)
                {
                    int newtileX = game.platform.FloatToInt(pick0.Current()[0]);
                    int newtileY = game.platform.FloatToInt(pick0.Current()[1]);
                    int newtileZ = game.platform.FloatToInt(pick0.Current()[2]);
                    if (game.map.IsValidPos(newtileX, newtileZ, newtileY))
                    {
                        int  clonesource  = game.map.GetBlock(newtileX, newtileZ, newtileY);
                        int  clonesource2 = game.d_Data.WhenPlayerPlacesGetsConvertedTo()[clonesource];
                        bool gotoDone     = false;
                        //find this block in another right hand.
                        for (int i = 0; i < 10; i++)
                        {
                            if (game.d_Inventory.RightHand[i] != null &&
                                game.d_Inventory.RightHand[i].ItemClass == Packet_ItemClassEnum.Block &&
                                game.d_Inventory.RightHand[i].BlockId == clonesource2)
                            {
                                game.ActiveMaterial = i;
                                gotoDone            = true;
                            }
                        }
                        if (!gotoDone)
                        {
                            IntRef freehand = game.d_InventoryUtil.FreeHand(game.ActiveMaterial);
                            //find this block in inventory.
                            for (int i = 0; i < game.d_Inventory.ItemsCount; i++)
                            {
                                Packet_PositionItem k = game.d_Inventory.Items[i];
                                if (k == null)
                                {
                                    continue;
                                }
                                if (k.Value_.ItemClass == Packet_ItemClassEnum.Block &&
                                    k.Value_.BlockId == clonesource2)
                                {
                                    //free hand
                                    if (freehand != null)
                                    {
                                        game.WearItem(
                                            game.InventoryPositionMainArea(k.X, k.Y),
                                            game.InventoryPositionMaterialSelector(freehand.value));
                                        break;
                                    }
                                    //try to replace current slot
                                    if (game.d_Inventory.RightHand[game.ActiveMaterial] != null &&
                                        game.d_Inventory.RightHand[game.ActiveMaterial].ItemClass == Packet_ItemClassEnum.Block)
                                    {
                                        game.MoveToInventory(
                                            game.InventoryPositionMaterialSelector(game.ActiveMaterial));
                                        game.WearItem(
                                            game.InventoryPositionMainArea(k.X, k.Y),
                                            game.InventoryPositionMaterialSelector(game.ActiveMaterial));
                                    }
                                }
                            }
                        }
                        string[] sound = game.d_Data.CloneSound()[clonesource];
                        if (sound != null)            // && sound.Length > 0)
                        {
                            game.AudioPlay(sound[0]); //todo sound cycle
                        }
                    }
                }
                if (left || right)
                {
                    BlockPosSide tile = pick0;
                    int          newtileX;
                    int          newtileY;
                    int          newtileZ;
                    if (right)
                    {
                        newtileX = game.platform.FloatToInt(tile.Translated()[0]);
                        newtileY = game.platform.FloatToInt(tile.Translated()[1]);
                        newtileZ = game.platform.FloatToInt(tile.Translated()[2]);
                    }
                    else
                    {
                        newtileX = game.platform.FloatToInt(tile.Current()[0]);
                        newtileY = game.platform.FloatToInt(tile.Current()[1]);
                        newtileZ = game.platform.FloatToInt(tile.Current()[2]);
                    }
                    if (game.map.IsValidPos(newtileX, newtileZ, newtileY))
                    {
                        //Console.WriteLine(". newtile:" + newtile + " type: " + d_Map.GetBlock(newtileX, newtileZ, newtileY));
                        if (!(pick0.blockPos[0] == -1 &&
                              pick0.blockPos[1] == -1 &&
                              pick0.blockPos[2] == -1))
                        {
                            int blocktype;
                            if (left)
                            {
                                blocktype = game.map.GetBlock(newtileX, newtileZ, newtileY);
                            }
                            else
                            {
                                blocktype = ((game.BlockInHand() == null) ? 1 : game.BlockInHand().value);
                            }
                            if (left && blocktype == game.d_Data.BlockIdAdminium())
                            {
                                PickingEnd(left, right, middle, ispistol);
                                return;
                            }
                            string[] sound = left ? game.d_Data.BreakSound()[blocktype] : game.d_Data.BuildSound()[blocktype];
                            if (sound != null)            // && sound.Length > 0)
                            {
                                game.AudioPlay(sound[0]); //todo sound cycle
                            }
                        }
                        //normal attack
                        if (!right)
                        {
                            //attack
                            int posx = newtileX;
                            int posy = newtileZ;
                            int posz = newtileY;
                            game.currentAttackedBlock = Vector3IntRef.Create(posx, posy, posz);
                            if (!game.blockHealth.ContainsKey(posx, posy, posz))
                            {
                                game.blockHealth.Set(posx, posy, posz, game.GetCurrentBlockHealth(posx, posy, posz));
                            }
                            game.blockHealth.Set(posx, posy, posz, game.blockHealth.Get(posx, posy, posz) - game.WeaponAttackStrength());
                            float health = game.GetCurrentBlockHealth(posx, posy, posz);
                            if (health <= 0)
                            {
                                if (game.currentAttackedBlock != null)
                                {
                                    game.blockHealth.Remove(posx, posy, posz);
                                }
                                game.currentAttackedBlock = null;
                                OnPick(game, game.platform.FloatToInt(newtileX), game.platform.FloatToInt(newtileZ), game.platform.FloatToInt(newtileY),
                                       game.platform.FloatToInt(tile.Current()[0]), game.platform.FloatToInt(tile.Current()[2]), game.platform.FloatToInt(tile.Current()[1]),
                                       tile.collisionPos,
                                       right);
                            }
                            PickingEnd(left, right, middle, ispistol);
                            return;
                        }
                        if (!right)
                        {
                            game.particleEffectBlockBreak.StartParticleEffect(newtileX, newtileY, newtileZ);//must be before deletion - gets ground type.
                        }
                        if (!game.map.IsValidPos(newtileX, newtileZ, newtileY))
                        {
                            game.platform.ThrowException("");
                        }
                        OnPick(game, game.platform.FloatToInt(newtileX), game.platform.FloatToInt(newtileZ), game.platform.FloatToInt(newtileY),
                               game.platform.FloatToInt(tile.Current()[0]), game.platform.FloatToInt(tile.Current()[2]), game.platform.FloatToInt(tile.Current()[1]),
                               tile.collisionPos,
                               right);
                        //network.SendSetBlock(new Vector3((int)newtile.X, (int)newtile.Z, (int)newtile.Y),
                        //    right ? BlockSetMode.Create : BlockSetMode.Destroy, (byte)MaterialSlots[activematerial]);
                    }
                }
            }
        }
        PickingEnd(left, right, middle, ispistol);
    }
Exemplo n.º 19
0
    void PickEntity(Game game, Line3D pick, BlockPosSide[] pick2, IntRef pick2count)
    {
        game.SelectedEntityId        = -1;
        game.currentlyAttackedEntity = -1;
        float one = 1;

        for (int i = 0; i < game.entitiesCount; i++)
        {
            if (game.entities[i] == null)
            {
                continue;
            }
            if (i == game.LocalPlayerId)
            {
                continue;
            }
            if (game.entities[i].drawModel == null)
            {
                continue;
            }
            Entity p_ = game.entities[i];
            if (p_.networkPosition == null)
            {
                continue;
            }
            if (!p_.networkPosition.PositionLoaded)
            {
                continue;
            }
            if (!p_.usable)
            {
                continue;
            }
            float feetposX = p_.position.x;
            float feetposY = p_.position.y;
            float feetposZ = p_.position.z;

            float dist = game.Dist(feetposX, feetposY, feetposZ, game.player.position.x, game.player.position.y, game.player.position.z);
            if (dist > 5)
            {
                continue;
            }

            //var p = PlayerPositionSpawn;
            Box3D bodybox = new Box3D();
            float h       = p_.drawModel.ModelHeight;
            float r       = one * 35 / 100;

            bodybox.AddPoint(feetposX - r, feetposY + 0, feetposZ - r);
            bodybox.AddPoint(feetposX - r, feetposY + 0, feetposZ + r);
            bodybox.AddPoint(feetposX + r, feetposY + 0, feetposZ - r);
            bodybox.AddPoint(feetposX + r, feetposY + 0, feetposZ + r);

            bodybox.AddPoint(feetposX - r, feetposY + h, feetposZ - r);
            bodybox.AddPoint(feetposX - r, feetposY + h, feetposZ + r);
            bodybox.AddPoint(feetposX + r, feetposY + h, feetposZ - r);
            bodybox.AddPoint(feetposX + r, feetposY + h, feetposZ + r);

            float[] p;
            float   localeyeposX = game.EyesPosX();
            float   localeyeposY = game.EyesPosY();
            float   localeyeposZ = game.EyesPosZ();
            p = Intersection.CheckLineBoxExact(pick, bodybox);
            if (p != null)
            {
                //do not allow to shoot through terrain
                if (pick2count.value == 0 || (game.Dist(pick2[0].blockPos[0], pick2[0].blockPos[1], pick2[0].blockPos[2], localeyeposX, localeyeposY, localeyeposZ)
                                              > game.Dist(p[0], p[1], p[2], localeyeposX, localeyeposY, localeyeposZ)))
                {
                    game.SelectedEntityId = i;
                    if (game.cameratype == CameraType.Fpp || game.cameratype == CameraType.Tpp)
                    {
                        game.currentlyAttackedEntity = i;
                    }
                }
            }
        }
    }
Exemplo n.º 20
0
 public abstract bool Hit(Box3D o);
Exemplo n.º 21
0
    ListBox3d Children(Box3D box)
    {
        ListBox3d l = newListBox3d();
        l.count = 8;
        Box3D[] c = l.arr;
        for (int i = 0; i < 8; i++)
        {
            c[i] = newBox3d();
        }
        float x = box.MinEdge[0];
        float y = box.MinEdge[1];
        float z = box.MinEdge[2];
        float size = box.LengthX() / 2;
        c[0].Set(x, y, z, size);
        c[1].Set(x + size, y, z, size);
        c[2].Set(x, y, z + size, size);
        c[3].Set(x + size, y, z + size, size);

        c[4].Set(x, y + size, z, size);
        c[5].Set(x + size, y + size, z, size);
        c[6].Set(x, y + size, z + size, size);
        c[7].Set(x + size, y + size, z + size, size);
        return l;
    }
Exemplo n.º 22
0
    internal void NextBullet(Game game, int bulletsshot)
    {
        float one = 1;
        bool left = game.mouseLeft;
        bool middle = game.mouseMiddle;
        bool right = game.mouseRight;

        bool IsNextShot = bulletsshot != 0;

        if (!game.leftpressedpicking)
        {
            if (game.mouseleftclick)
            {
                game.leftpressedpicking = true;
            }
            else
            {
                left = false;
            }
        }
        else
        {
            if (game.mouseleftdeclick)
            {
                game.leftpressedpicking = false;
                left = false;
            }
        }
        if (!left)
        {
            game.currentAttackedBlock = null;
        }

        Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial];
        bool ispistol = (item != null && game.blocktypes[item.BlockId].IsPistol);
        bool ispistolshoot = ispistol && left;
        bool isgrenade = ispistol && game.blocktypes[item.BlockId].PistolType == Packet_PistolTypeEnum.Grenade;
        if (ispistol && isgrenade)
        {
            ispistolshoot = game.mouseleftdeclick;
        }
        //grenade cooking - TODO: fix instant explosion when closing ESC menu
        if (game.mouseleftclick)
        {
            game.grenadecookingstartMilliseconds = game.platform.TimeMillisecondsFromStart();
            if (ispistol && isgrenade)
            {
                if (game.blocktypes[item.BlockId].Sounds.ShootCount > 0)
                {
                    game.AudioPlay(game.platform.StringFormat("{0}.ogg", game.blocktypes[item.BlockId].Sounds.Shoot[0]));
                }
            }
        }
        float wait = ((one * (game.platform.TimeMillisecondsFromStart() - game.grenadecookingstartMilliseconds)) / 1000);
        if (isgrenade && left)
        {
            if (wait >= game.grenadetime && isgrenade && game.grenadecookingstartMilliseconds != 0)
            {
                ispistolshoot = true;
                game.mouseleftdeclick = true;
            }
            else
            {
                return;
            }
        }
        else
        {
            game.grenadecookingstartMilliseconds = 0;
        }

        if (ispistol && game.mouserightclick && (game.platform.TimeMillisecondsFromStart() - game.lastironsightschangeMilliseconds) >= 500)
        {
            game.IronSights = !game.IronSights;
            game.lastironsightschangeMilliseconds = game.platform.TimeMillisecondsFromStart();
        }

        IntRef pick2count = new IntRef();
        Line3D pick = new Line3D();
        GetPickingLine(game, pick, ispistolshoot);
        BlockPosSide[] pick2 = game.Pick(game.s, pick, pick2count);

        if (left)
        {
            game.handSetAttackDestroy = true;
        }
        else if (right)
        {
            game.handSetAttackBuild = true;
        }

        if (game.overheadcamera && pick2count.value > 0 && left)
        {
            //if not picked any object, and mouse button is pressed, then walk to destination.
            if (game.Follow == null)
            {
                //Only walk to destination when not following someone
                game.playerdestination = Vector3Ref.Create(pick2[0].blockPos[0], pick2[0].blockPos[1] + 1, pick2[0].blockPos[2]);
            }
        }
        bool pickdistanceok = (pick2count.value > 0); //&& (!ispistol);
        if (pickdistanceok)
        {
            if (game.Dist(pick2[0].blockPos[0] + one / 2, pick2[0].blockPos[1] + one / 2, pick2[0].blockPos[2] + one / 2,
                pick.Start[0], pick.Start[1], pick.Start[2]) > CurrentPickDistance(game))
            {
                pickdistanceok = false;
            }
        }
        bool playertileempty = game.IsTileEmptyForPhysics(
                  game.platform.FloatToInt(game.player.position.x),
                  game.platform.FloatToInt(game.player.position.z),
                  game.platform.FloatToInt(game.player.position.y + (one / 2)));
        bool playertileemptyclose = game.IsTileEmptyForPhysicsClose(
                  game.platform.FloatToInt(game.player.position.x),
                  game.platform.FloatToInt(game.player.position.z),
                  game.platform.FloatToInt(game.player.position.y + (one / 2)));
        BlockPosSide pick0 = new BlockPosSide();
        if (pick2count.value > 0 &&
            ((pickdistanceok && (playertileempty || (playertileemptyclose)))
            || game.overheadcamera)
            )
        {
            game.SelectedBlockPositionX = game.platform.FloatToInt(pick2[0].Current()[0]);
            game.SelectedBlockPositionY = game.platform.FloatToInt(pick2[0].Current()[1]);
            game.SelectedBlockPositionZ = game.platform.FloatToInt(pick2[0].Current()[2]);
            pick0 = pick2[0];
        }
        else
        {
            game.SelectedBlockPositionX = -1;
            game.SelectedBlockPositionY = -1;
            game.SelectedBlockPositionZ = -1;
            pick0.blockPos = new float[3];
            pick0.blockPos[0] = -1;
            pick0.blockPos[1] = -1;
            pick0.blockPos[2] = -1;
        }
        PickEntity(game, pick, pick2, pick2count);
        if (game.cameratype == CameraType.Fpp || game.cameratype == CameraType.Tpp)
        {
            int ntileX = game.platform.FloatToInt(pick0.Current()[0]);
            int ntileY = game.platform.FloatToInt(pick0.Current()[1]);
            int ntileZ = game.platform.FloatToInt(pick0.Current()[2]);
            if (game.IsUsableBlock(game.map.GetBlock(ntileX, ntileZ, ntileY)))
            {
                game.currentAttackedBlock = Vector3IntRef.Create(ntileX, ntileZ, ntileY);
            }
        }
        if (game.GetFreeMouse())
        {
            if (pick2count.value > 0)
            {
                OnPick_(pick0);
            }
            return;
        }

        if ((one * (game.platform.TimeMillisecondsFromStart() - lastbuildMilliseconds) / 1000) >= BuildDelay(game)
            || IsNextShot)
        {
            if (left && game.d_Inventory.RightHand[game.ActiveMaterial] == null)
            {
                game.SendPacketClient(ClientPackets.MonsterHit(game.platform.FloatToInt(2 + game.rnd.NextFloat() * 4)));
            }
            if (left && !fastclicking)
            {
                //todo animation
                fastclicking = false;
            }
            if ((left || right || middle) && (!isgrenade))
            {
                lastbuildMilliseconds = game.platform.TimeMillisecondsFromStart();
            }
            if (isgrenade && game.mouseleftdeclick)
            {
                lastbuildMilliseconds = game.platform.TimeMillisecondsFromStart();
            }
            if (game.reloadstartMilliseconds != 0)
            {
                PickingEnd(left, right, middle, ispistol);
                return;
            }
            if (ispistolshoot)
            {
                if ((!(game.LoadedAmmo[item.BlockId] > 0))
                    || (!(game.TotalAmmo[item.BlockId] > 0)))
                {
                    game.AudioPlay("Dry Fire Gun-SoundBible.com-2053652037.ogg");
                    PickingEnd(left, right, middle, ispistol);
                    return;
                }
            }
            if (ispistolshoot)
            {
                float toX = pick.End[0];
                float toY = pick.End[1];
                float toZ = pick.End[2];
                if (pick2count.value > 0)
                {
                    toX = pick2[0].blockPos[0];
                    toY = pick2[0].blockPos[1];
                    toZ = pick2[0].blockPos[2];
                }

                Packet_ClientShot shot = new Packet_ClientShot();
                shot.FromX = game.SerializeFloat(pick.Start[0]);
                shot.FromY = game.SerializeFloat(pick.Start[1]);
                shot.FromZ = game.SerializeFloat(pick.Start[2]);
                shot.ToX = game.SerializeFloat(toX);
                shot.ToY = game.SerializeFloat(toY);
                shot.ToZ = game.SerializeFloat(toZ);
                shot.HitPlayer = -1;

                for (int i = 0; i < game.entitiesCount; i++)
                {
                    if (game.entities[i] == null)
                    {
                        continue;
                    }
                    if (game.entities[i].drawModel == null)
                    {
                        continue;
                    }
                    Entity p_ = game.entities[i];
                    if (p_.networkPosition == null)
                    {
                        continue;
                    }
                    if (!p_.networkPosition.PositionLoaded)
                    {
                        continue;
                    }
                    float feetposX = p_.position.x;
                    float feetposY = p_.position.y;
                    float feetposZ = p_.position.z;
                    //var p = PlayerPositionSpawn;
                    Box3D bodybox = new Box3D();
                    float headsize = (p_.drawModel.ModelHeight - p_.drawModel.eyeHeight) * 2; //0.4f;
                    float h = p_.drawModel.ModelHeight - headsize;
                    float r = one * 35 / 100;

                    bodybox.AddPoint(feetposX - r, feetposY + 0, feetposZ - r);
                    bodybox.AddPoint(feetposX - r, feetposY + 0, feetposZ + r);
                    bodybox.AddPoint(feetposX + r, feetposY + 0, feetposZ - r);
                    bodybox.AddPoint(feetposX + r, feetposY + 0, feetposZ + r);

                    bodybox.AddPoint(feetposX - r, feetposY + h, feetposZ - r);
                    bodybox.AddPoint(feetposX - r, feetposY + h, feetposZ + r);
                    bodybox.AddPoint(feetposX + r, feetposY + h, feetposZ - r);
                    bodybox.AddPoint(feetposX + r, feetposY + h, feetposZ + r);

                    Box3D headbox = new Box3D();

                    headbox.AddPoint(feetposX - r, feetposY + h, feetposZ - r);
                    headbox.AddPoint(feetposX - r, feetposY + h, feetposZ + r);
                    headbox.AddPoint(feetposX + r, feetposY + h, feetposZ - r);
                    headbox.AddPoint(feetposX + r, feetposY + h, feetposZ + r);

                    headbox.AddPoint(feetposX - r, feetposY + h + headsize, feetposZ - r);
                    headbox.AddPoint(feetposX - r, feetposY + h + headsize, feetposZ + r);
                    headbox.AddPoint(feetposX + r, feetposY + h + headsize, feetposZ - r);
                    headbox.AddPoint(feetposX + r, feetposY + h + headsize, feetposZ + r);

                    float[] p;
                    float localeyeposX = game.EyesPosX();
                    float localeyeposY = game.EyesPosY();
                    float localeyeposZ = game.EyesPosZ();
                    p = Intersection.CheckLineBoxExact(pick, headbox);
                    if (p != null)
                    {
                        //do not allow to shoot through terrain
                        if (pick2count.value == 0 || (game.Dist(pick2[0].blockPos[0], pick2[0].blockPos[1], pick2[0].blockPos[2], localeyeposX, localeyeposY, localeyeposZ)
                            > game.Dist(p[0], p[1], p[2], localeyeposX, localeyeposY, localeyeposZ)))
                        {
                            if (!isgrenade)
                            {
                                Entity entity = new Entity();
                                Sprite sprite = new Sprite();
                                sprite.positionX = p[0];
                                sprite.positionY = p[1];
                                sprite.positionZ = p[2];
                                sprite.image = "blood.png";
                                entity.sprite = sprite;
                                entity.expires = Expires.Create(one * 2 / 10);
                                game.EntityAddLocal(entity);
                            }
                            shot.HitPlayer = i;
                            shot.IsHitHead = 1;
                        }
                    }
                    else
                    {
                        p = Intersection.CheckLineBoxExact(pick, bodybox);
                        if (p != null)
                        {
                            //do not allow to shoot through terrain
                            if (pick2count.value == 0 || (game.Dist(pick2[0].blockPos[0], pick2[0].blockPos[1], pick2[0].blockPos[2], localeyeposX, localeyeposY, localeyeposZ)
                                > game.Dist(p[0], p[1], p[2], localeyeposX, localeyeposY, localeyeposZ)))
                            {
                                if (!isgrenade)
                                {
                                    Entity entity = new Entity();
                                    Sprite sprite = new Sprite();
                                    sprite.positionX = p[0];
                                    sprite.positionY = p[1];
                                    sprite.positionZ = p[2];
                                    sprite.image = "blood.png";
                                    entity.sprite = sprite;
                                    entity.expires = Expires.Create(one * 2 / 10);
                                    game.EntityAddLocal(entity);
                                }
                                shot.HitPlayer = i;
                                shot.IsHitHead = 0;
                            }
                        }
                    }
                }
                shot.WeaponBlock = item.BlockId;
                game.LoadedAmmo[item.BlockId] = game.LoadedAmmo[item.BlockId] - 1;
                game.TotalAmmo[item.BlockId] = game.TotalAmmo[item.BlockId] - 1;
                float projectilespeed = game.DeserializeFloat(game.blocktypes[item.BlockId].ProjectileSpeedFloat);
                if (projectilespeed == 0)
                {
                    {
                        Entity entity = game.CreateBulletEntity(
                          pick.Start[0], pick.Start[1], pick.Start[2],
                          toX, toY, toZ, 150);
                        game.EntityAddLocal(entity);
                    }
                }
                else
                {
                    float vX = toX - pick.Start[0];
                    float vY = toY - pick.Start[1];
                    float vZ = toZ - pick.Start[2];
                    float vLength = game.Length(vX, vY, vZ);
                    vX /= vLength;
                    vY /= vLength;
                    vZ /= vLength;
                    vX *= projectilespeed;
                    vY *= projectilespeed;
                    vZ *= projectilespeed;
                    shot.ExplodesAfter = game.SerializeFloat(game.grenadetime - wait);

                    {
                        Entity grenadeEntity = new Entity();

                        Sprite sprite = new Sprite();
                        sprite.image = "ChemicalGreen.png";
                        sprite.size = 14;
                        sprite.animationcount = 0;
                        sprite.positionX = pick.Start[0];
                        sprite.positionY = pick.Start[1];
                        sprite.positionZ = pick.Start[2];
                        grenadeEntity.sprite = sprite;

                        Grenade_ projectile = new Grenade_();
                        projectile.velocityX = vX;
                        projectile.velocityY = vY;
                        projectile.velocityZ = vZ;
                        projectile.block = item.BlockId;
                        projectile.sourcePlayer = game.LocalPlayerId;

                        grenadeEntity.expires = Expires.Create(game.grenadetime - wait);

                        grenadeEntity.grenade = projectile;
                        game.EntityAddLocal(grenadeEntity);
                    }
                }
                Packet_Client packet = new Packet_Client();
                packet.Id = Packet_ClientIdEnum.Shot;
                packet.Shot = shot;
                game.SendPacketClient(packet);

                if (game.blocktypes[item.BlockId].Sounds.ShootEndCount > 0)
                {
                    game.pistolcycle = game.rnd.Next() % game.blocktypes[item.BlockId].Sounds.ShootEndCount;
                    game.AudioPlay(game.platform.StringFormat("{0}.ogg", game.blocktypes[item.BlockId].Sounds.ShootEnd[game.pistolcycle]));
                }

                bulletsshot++;
                if (bulletsshot < game.DeserializeFloat(game.blocktypes[item.BlockId].BulletsPerShotFloat))
                {
                    NextBullet(game, bulletsshot);
                }

                //recoil
                game.player.position.rotx -= game.rnd.NextFloat() * game.CurrentRecoil();
                game.player.position.roty += game.rnd.NextFloat() * game.CurrentRecoil() * 2 - game.CurrentRecoil();

                PickingEnd(left, right, middle, ispistol);
                return;
            }
            if (ispistol && right)
            {
                PickingEnd(left, right, middle, ispistol);
                return;
            }
            if (pick2count.value > 0)
            {
                if (middle)
                {
                    int newtileX = game.platform.FloatToInt(pick0.Current()[0]);
                    int newtileY = game.platform.FloatToInt(pick0.Current()[1]);
                    int newtileZ = game.platform.FloatToInt(pick0.Current()[2]);
                    if (game.map.IsValidPos(newtileX, newtileZ, newtileY))
                    {
                        int clonesource = game.map.GetBlock(newtileX, newtileZ, newtileY);
                        int clonesource2 = game.d_Data.WhenPlayerPlacesGetsConvertedTo()[clonesource];
                        bool gotoDone = false;
                        //find this block in another right hand.
                        for (int i = 0; i < 10; i++)
                        {
                            if (game.d_Inventory.RightHand[i] != null
                                && game.d_Inventory.RightHand[i].ItemClass == Packet_ItemClassEnum.Block
                                && game.d_Inventory.RightHand[i].BlockId == clonesource2)
                            {
                                game.ActiveMaterial = i;
                                gotoDone = true;
                            }
                        }
                        if (!gotoDone)
                        {
                            IntRef freehand = game.d_InventoryUtil.FreeHand(game.ActiveMaterial);
                            //find this block in inventory.
                            for (int i = 0; i < game.d_Inventory.ItemsCount; i++)
                            {
                                Packet_PositionItem k = game.d_Inventory.Items[i];
                                if (k == null)
                                {
                                    continue;
                                }
                                if (k.Value_.ItemClass == Packet_ItemClassEnum.Block
                                    && k.Value_.BlockId == clonesource2)
                                {
                                    //free hand
                                    if (freehand != null)
                                    {
                                        game.WearItem(
                                            game.InventoryPositionMainArea(k.X, k.Y),
                                            game.InventoryPositionMaterialSelector(freehand.value));
                                        break;
                                    }
                                    //try to replace current slot
                                    if (game.d_Inventory.RightHand[game.ActiveMaterial] != null
                                        && game.d_Inventory.RightHand[game.ActiveMaterial].ItemClass == Packet_ItemClassEnum.Block)
                                    {
                                        game.MoveToInventory(
                                            game.InventoryPositionMaterialSelector(game.ActiveMaterial));
                                        game.WearItem(
                                            game.InventoryPositionMainArea(k.X, k.Y),
                                            game.InventoryPositionMaterialSelector(game.ActiveMaterial));
                                    }
                                }
                            }
                        }
                        string[] sound = game.d_Data.CloneSound()[clonesource];
                        if (sound != null) // && sound.Length > 0)
                        {
                            game.AudioPlay(sound[0]); //todo sound cycle
                        }
                    }
                }
                if (left || right)
                {
                    BlockPosSide tile = pick0;
                    int newtileX;
                    int newtileY;
                    int newtileZ;
                    if (right)
                    {
                        newtileX = game.platform.FloatToInt(tile.Translated()[0]);
                        newtileY = game.platform.FloatToInt(tile.Translated()[1]);
                        newtileZ = game.platform.FloatToInt(tile.Translated()[2]);
                    }
                    else
                    {
                        newtileX = game.platform.FloatToInt(tile.Current()[0]);
                        newtileY = game.platform.FloatToInt(tile.Current()[1]);
                        newtileZ = game.platform.FloatToInt(tile.Current()[2]);
                    }
                    if (game.map.IsValidPos(newtileX, newtileZ, newtileY))
                    {
                        //Console.WriteLine(". newtile:" + newtile + " type: " + d_Map.GetBlock(newtileX, newtileZ, newtileY));
                        if (!(pick0.blockPos[0] == -1
                             && pick0.blockPos[1] == -1
                            && pick0.blockPos[2] == -1))
                        {
                            int blocktype;
                            if (left) { blocktype = game.map.GetBlock(newtileX, newtileZ, newtileY); }
                            else { blocktype = ((game.BlockInHand() == null) ? 1 : game.BlockInHand().value); }
                            if (left && blocktype == game.d_Data.BlockIdAdminium())
                            {
                                PickingEnd(left, right, middle, ispistol);
                                return;
                            }
                            string[] sound = left ? game.d_Data.BreakSound()[blocktype] : game.d_Data.BuildSound()[blocktype];
                            if (sound != null) // && sound.Length > 0)
                            {
                                game.AudioPlay(sound[0]); //todo sound cycle
                            }
                        }
                        //normal attack
                        if (!right)
                        {
                            //attack
                            int posx = newtileX;
                            int posy = newtileZ;
                            int posz = newtileY;
                            game.currentAttackedBlock = Vector3IntRef.Create(posx, posy, posz);
                            if (!game.blockHealth.ContainsKey(posx, posy, posz))
                            {
                                game.blockHealth.Set(posx, posy, posz, game.GetCurrentBlockHealth(posx, posy, posz));
                            }
                            game.blockHealth.Set(posx, posy, posz, game.blockHealth.Get(posx, posy, posz) - game.WeaponAttackStrength());
                            float health = game.GetCurrentBlockHealth(posx, posy, posz);
                            if (health <= 0)
                            {
                                if (game.currentAttackedBlock != null)
                                {
                                    game.blockHealth.Remove(posx, posy, posz);
                                }
                                game.currentAttackedBlock = null;
                                OnPick(game, game.platform.FloatToInt(newtileX), game.platform.FloatToInt(newtileZ), game.platform.FloatToInt(newtileY),
                                    game.platform.FloatToInt(tile.Current()[0]), game.platform.FloatToInt(tile.Current()[2]), game.platform.FloatToInt(tile.Current()[1]),
                                    tile.collisionPos,
                                    right);
                            }
                            PickingEnd(left, right, middle, ispistol);
                            return;
                        }
                        if (!right)
                        {
                            game.particleEffectBlockBreak.StartParticleEffect(newtileX, newtileY, newtileZ);//must be before deletion - gets ground type.
                        }
                        if (!game.map.IsValidPos(newtileX, newtileZ, newtileY))
                        {
                            game.platform.ThrowException("Error in picking - NextBullet()");
                        }
                        OnPick(game, game.platform.FloatToInt(newtileX), game.platform.FloatToInt(newtileZ), game.platform.FloatToInt(newtileY),
                            game.platform.FloatToInt(tile.Current()[0]), game.platform.FloatToInt(tile.Current()[2]), game.platform.FloatToInt(tile.Current()[1]),
                            tile.collisionPos,
                            right);
                        //network.SendSetBlock(new Vector3((int)newtile.X, (int)newtile.Z, (int)newtile.Y),
                        //    right ? BlockSetMode.Create : BlockSetMode.Destroy, (byte)MaterialSlots[activematerial]);
                    }
                }
            }
        }
        PickingEnd(left, right, middle, ispistol);
    }
Exemplo n.º 23
0
 void recycleBox3d(Box3D l)
 {
     pool_i--;
     pool[pool_i] = l;
 }
Exemplo n.º 24
0
        public P3DSimplexNoiseTerrain(SceneNode parent, SceneManager mgr, int id, int vertsPerRow, int vertsPerCol, int cellSpacing, float heightScale)
            : base(parent, mgr, id)
        {
            _mgr = mgr;
            _driver = _mgr.VideoDriver;

            Material = new Material();
            Material.Lighting = false;

            _numVertsPerRow = vertsPerRow;
            _numVertsPerCol = vertsPerCol;
            _cellSpacing = cellSpacing;
            _heightScale = heightScale;

            _numCellsPerRow = _numVertsPerRow - 1;
            _numCellsPerCol = _numVertsPerCol - 1;
            _width = _numCellsPerRow * _cellSpacing;
            _depth = _numCellsPerCol * _cellSpacing;
            NumVertices = _numVertsPerRow * _numVertsPerCol;
            _numIndices = (_numCellsPerRow * _numCellsPerCol) * 6;
            _numTriangles = (_numCellsPerRow * _numCellsPerCol) * 2;
            _indices = new ushort[_numIndices];

            int startX = -_width / 2;
            int startZ = _depth / 2;

            int endX = _width / 2;
            int endZ = -_depth / 2;

            Box3D = new Box3D(new Vector3D(startX, -_heightScale, startZ), new Vector3D(endX, _heightScale, endZ));

            const float uCoordIncrementSize = 1.0f;
            const float vCoordIncrementSize = 1.0f;

            _heights = new float[NumVertices];

            int i = 0;
            for (int z = startZ; z >= endZ; z -= _cellSpacing)
            {
                int j = 0;
                for (int x = startX; x <= endX; x += _cellSpacing)
                {

                    int index = i * _numVertsPerRow + j;
                    // large noise.
                    float height = PerlinSimplexNoise.noise(x * 0.0001f, z * 0.0001f) * _heightScale;
                    // detail noise.
                    height += PerlinSimplexNoise.noise(x * 0.001f, z * 0.001f) * _heightScale / 10;
                    Vertex3D v = new Vertex3D(
                        new Vector3D(x, height, z),
                        new Vector3D(0, 1, 0),
                        Color.Black,
                        new Vector2D(j * uCoordIncrementSize, i * vCoordIncrementSize)
                        );
                    _buffer.SetVertex((uint)index, v);
                    j++;
                }
                i++;
            }

            uint baseIndex = 0;

            for (uint k = 0; k < _numCellsPerRow; k++)
            {
                for (uint j = 0; j < _numCellsPerCol; j++)
                {
                    _buffer.SetIndex(baseIndex + 0, (ushort)(k * _numVertsPerRow + j));
                    _buffer.SetIndex(baseIndex + 1, (ushort)(k * _numVertsPerRow + j + 1));
                    _buffer.SetIndex(baseIndex + 2, (ushort)((k + 1) * _numVertsPerRow + j));
                    _buffer.SetIndex(baseIndex + 3, (ushort)((k + 1) * _numVertsPerRow + j));
                    _buffer.SetIndex(baseIndex + 4, (ushort)(k * _numVertsPerRow + j + 1));
                    _buffer.SetIndex(baseIndex + 5, (ushort)((k + 1) * _numVertsPerRow + j + 1));

                    baseIndex += 6;
                }
            }
        }
Exemplo n.º 25
0
 void recycleBox3d(Box3D l)
 {
     pool_i--;
     pool[pool_i] = l;
 }