• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Voxel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Voxel的典型用法代码示例。如果您正苦于以下问题:C# Voxel类的具体用法?C# Voxel怎么用?C# Voxel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Voxel类属于命名空间,在下文中一共展示了Voxel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Initialize

    public void Initialize(int resolution, float size)
    {
        this.m_resolution = resolution;
        m_gridSize = size;
        m_voxelSize = size / resolution;
        m_voxels = new Voxel[resolution * resolution];
        m_voxelMaterials = new Material[m_voxels.Length];

        for (int i = 0, y = 0; y < resolution; y++)
        {
            for (int x = 0; x < resolution; x++, i++)
            {
                CreateVoxel(i, x, y);
            }
        }

        m_dummyX = new Voxel();
        m_dummyY = new Voxel();
        m_dummyT = new Voxel();

        //offset the grid to center it inside the screen
        Vector3 gridPosition = new Vector3(-0.5f * size, -0.5f * size, 0);
        this.transform.localPosition = gridPosition;

        GetComponent<MeshFilter>().mesh = m_mesh = new Mesh();
        m_mesh.name = "VoxelGrid Mesh";
        m_vertices = new List<Vector3>();
        m_triangles = new List<int>();
        Refresh();
    }
开发者ID:ParalyzeStudio,项目名称:MarchingSquares,代码行数:30,代码来源:VoxelGrid.cs


示例2: Add

 public static VoxelCommand Add(Voxel voxel)
 {
     VoxelCommand cmd = new VoxelCommand ();
     cmd._type = Type.Add;
     cmd._voxel = voxel;
     return cmd;
 }
开发者ID:BluBambu,项目名称:MultiVoxel,代码行数:7,代码来源:VoxelCommand.cs


示例3: detector_Collided

    void detector_Collided(Volume collisonObject, Voxel voxel, Vector3 worldPosition)
    {
        // If the bullet hits an invader and is owned by the player, explode and destroy the invader - and deactivate the bullet
        if (collisonObject.name == "Invader" && Owner is InvadersPlayerShip)
        {
            collisonObject.Destruct(3f, true);
            Destroy(collisonObject.gameObject);
            gameObject.SetActive(false);
        }

        // If we hit a shield, just explode and deactivate the bullet
        if (collisonObject.name == "Shield")
        {
            exploder.ExplosionRadius = 1f;
            exploder.Explode();
            gameObject.SetActive(false);
        }

        // If we hit the player ship
        if (collisonObject.name == "Player Ship")
        {
            collisonObject.Destruct(3f, true);
            collisonObject.GetComponent<InvadersPlayerShip>().Die();
            gameObject.SetActive(false);
        }
    }
开发者ID:arancauchi,项目名称:Mini-Games,代码行数:26,代码来源:InvadersBullet.cs


示例4: GetDataFromString

    static Voxel[] GetDataFromString(int width, int height, int depth, string dataString)
    {
        string[] layers = dataString.Split ('-');
                int size = height * depth * width;
                Voxel[] data = new Voxel[size];
                int c = 0;
                foreach (string layer in layers) {
                        string[] lines = layer.Split ('\n');
                        foreach (string line in lines) {
                                string row = line.Trim ();
                                for (int i = 0; i < row.Length; i++) {
                                        Voxel v = new Voxel();
                                        int j;
                                        if (int.TryParse (row [i] + "", out j)) {
                                                v.id = (byte)j;
                                        } else {
                                                v.id = 0;
                                        }
                                        // cut in the middle of processing
                                        if (c == size) {
                                                return data;
                                        }
                                        data [c++] = v;
                                }
                        }
                }

                if (c != size) {
                        throw new Exception ("insuficient voxel data");
                }

                return data;
    }
开发者ID:pboechat,项目名称:VoxelEngine,代码行数:33,代码来源:VoxelChunkInspector.cs


示例5: DetectVoxels

	void DetectVoxels ()
	{
		if (currentVoxel == null)
			currentVoxel = new Voxel ();


	}
开发者ID:nigelDaMan,项目名称:WeCanTango,代码行数:7,代码来源:AIBehaviour.cs


示例6: RemoveVoxelAnimation

    public void RemoveVoxelAnimation(bool hasPreviousBlock, Voxel voxel, Action finishCallback)
    {
        if (_animDic.ContainsKey(voxel.Pos))
        {
            AnimTuple anim = _animDic[voxel.Pos];
            anim.Trans.GetComponent<MeshRenderer>().material.color = voxel.Color;
            anim.Trans.GetComponent<DummyBehavior>().StopAllCoroutines();
            anim.Cor = anim.Trans.GetComponent<DummyBehavior>().StartCoroutine(RemoveVoxelAnimationCor(voxel.Pos, anim.Trans, () =>
            {
                finishCallback();
            }));
        }
        else
        {
            if (hasPreviousBlock)
            {
                AnimTuple anim = new AnimTuple();
                _animDic[voxel.Pos] = anim;
                anim.Trans = CreateAnimTransform(voxel);
                anim.Trans.localScale = Vector3.one;
                anim.Cor = anim.Trans.GetComponent<DummyBehavior>().StartCoroutine(RemoveVoxelAnimationCor(voxel.Pos, anim.Trans, () =>
                {
                    finishCallback();
                }));

            }
        }
    }
开发者ID:BluBambu,项目名称:MultiVoxel,代码行数:28,代码来源:VoxelAnimation.cs


示例7: InstantiateVoxels

    public void InstantiateVoxels(int startx, int starty, int startz, int width, int height, int depth)
    {
        Width = width;
        Height = height;
        Depth = depth;

        Voxels = new Voxel[Width, Height, Depth];

        float voxelSize = VoxelWorld.Inst.PhysicalVoxelSize;
        float halfVoxel = voxelSize * 0.5f;

        for (int x = 0; x < Width; ++x)
        {
            for (int y = 0; y < Height; ++y)
            {
                for (int z = 0; z < Depth; ++z)
                {
                    IntVec3 pos = new IntVec3(startx + x, starty + y, startz + z);
                    BoxCollider collider = gameObject.AddComponent<BoxCollider>();
                    collider.center = new Vector3(pos.X + halfVoxel, pos.Y + halfVoxel, pos.Z + halfVoxel);
                    collider.size = new Vector3(voxelSize, voxelSize, voxelSize);
                    Voxel voxel = new Voxel(this, VoxelType.Air, pos, collider);
                    Voxels[x, y, z] = voxel;
                    ColliderToVoxel[collider] = voxel;
                }
            }
        }
    }
开发者ID:lizlabelle,项目名称:MinecraftTest,代码行数:28,代码来源:VoxelWorldChunk.cs


示例8: Add

        public void Add(Voxel voxel)
        {
            voxel.position -= this.Position;
            if (Voxels[(int)voxel.position.X, (int)voxel.position.Y, (int)voxel.position.Z] != null) return;
            //if (!inChunk(voxel.position)) return;
            //this.Remove(voxel);
            Voxels[(int)voxel.position.X, (int)voxel.position.Y, (int)voxel.position.Z] = voxel;

            if (((int)voxel.position.X + 1 < this.Size.X && Voxels[(int)voxel.position.X + 1, (int)voxel.position.Y, (int)voxel.position.Z] == null) || (int)voxel.position.X == this.Size.X - 1)
                vertices.AddRange(Face.getFace( Face.Facing.Right, voxel.position, voxel.color));

            if (((int)voxel.position.X - 1 >= 0 && Voxels[(int)voxel.position.X - 1, (int)voxel.position.Y, (int)voxel.position.Z] == null) || (int)voxel.position.X == 0)
                vertices.AddRange(Face.getFace( Face.Facing.Left, voxel.position, voxel.color));

            if (((int)voxel.position.Y + 1 < this.Size.Y && Voxels[(int)voxel.position.X, (int)voxel.position.Y + 1, (int)voxel.position.Z] == null) || (int)voxel.position.Y == this.Size.Y - 1)
                vertices.AddRange(Face.getFace( Face.Facing.Up, voxel.position, voxel.color));

            if (((int)voxel.position.Y - 1 >= 0 && Voxels[(int)voxel.position.X, (int)voxel.position.Y - 1, (int)voxel.position.Z] == null) || (int)voxel.position.Y == 0)
                vertices.AddRange(Face.getFace( Face.Facing.Down, voxel.position, voxel.color));

            if (((int)voxel.position.Z + 1 < this.Size.Z && Voxels[(int)voxel.position.X, (int)voxel.position.Y, (int)voxel.position.Z + 1] == null) || (int)voxel.position.Z == this.Size.Z - 1)
                vertices.AddRange(Face.getFace( Face.Facing.Forward, voxel.position, voxel.color));

            if (((int)voxel.position.Z - 1 >= 0 && Voxels[(int)voxel.position.X, (int)voxel.position.Y, (int)voxel.position.Z - 1] == null) || (int)voxel.position.Z == 0)
                vertices.AddRange(Face.getFace( Face.Facing.Backward, voxel.position, voxel.color));

            this.Build();
        }
开发者ID:asarudick,项目名称:Soapvox,代码行数:28,代码来源:Chunk.cs


示例9: GetNeighbours

 public static Voxel[] GetNeighbours(Point3 worldCoord)
 {
     Voxel[] neighbours = new Voxel[6];
     for (int i=0; i<checkSides.Length; i++) {
         neighbours[i] = ChunkManager.GetBlock(worldCoord + checkSides[i]);
     }
     return neighbours;
 }
开发者ID:mandarinx,项目名称:buildahouse,代码行数:8,代码来源:BlockManager.cs


示例10: AddVoxel

 public void AddVoxel(Voxel voxel)
 {
     _voxelAnimation.AddVoxelAnimation(_voxelData.HasVoxelAtPos(voxel.Pos), voxel, () =>
     {
         _voxelData.AddVoxel(voxel);
         _voxelRenderer.RenderMesh(_voxelData);
     });
 }
开发者ID:BluBambu,项目名称:MultiVoxel,代码行数:8,代码来源:VoxelController.cs


示例11: detector_Collided

 private void detector_Collided(Volume collisonObject, Voxel voxel, Vector3 worldPosition)
 {
     if (collisonObject.name.StartsWith("Plane") && Owner is ShmupChopper)
     {
         collisonObject.GetComponent<ShmupPlane>().Die();
         gameObject.SetActive(false);
     }
 }
开发者ID:arancauchi,项目名称:Mini-Games,代码行数:8,代码来源:ShmupBullet.cs


示例12: Set

 public void Set(int x, int y, int z, Voxel voxel)
 {
     if (voxels.GetLength(0) < x ||
         voxels.GetLength(1) < y ||
         voxels.GetLength(2) < z) {
         return;
     }
     voxels[x, y, z] = voxel;
 }
开发者ID:mandarinx,项目名称:buildahouse,代码行数:9,代码来源:Chunk.cs


示例13: SeralizeVoxel

 // TODO: Cache all the binary formatters
 public static byte[] SeralizeVoxel(Voxel voxel)
 {
     BinaryFormatter formatter = new BinaryFormatter();
     using (MemoryStream stream = new MemoryStream())
     {
         formatter.Serialize(stream, voxel);
         return stream.ToArray();
     }
 }
开发者ID:BluBambu,项目名称:MultiVoxel,代码行数:10,代码来源:VoxelSerializer.cs


示例14: BecomeYDummyOf

	public void BecomeYDummyOf (Voxel voxel, float offset) {
		state = voxel.state;
		position = voxel.position;
		xEdgePosition = voxel.xEdgePosition;
		yEdgePosition = voxel.yEdgePosition;
		position.y += offset;
		xEdgePosition.y += offset;
		yEdgePosition.y += offset;
	}
开发者ID:AVUIs,项目名称:probe,代码行数:9,代码来源:Voxel.cs


示例15: Apply

 public override Voxel.State Apply(int x, int y, Voxel.State voxel)
 {
     x -= centerX;
     y -= centerY;
     if (x * x + y * y <= sqrRadius)
     {
         return fillType;
     }
     return voxel;
 }
开发者ID:JapaMala,项目名称:armok-vision,代码行数:10,代码来源:VoxelStencilCircle.cs


示例16: SetVoxel

	public void SetVoxel (Voxel vox, Vector3 pos){
		pos = new Vector3((int)pos.x, (int)pos.y, (int)pos.z);
		if (grid.ContainsKey (pos)) {
//			Debug.Log ("voxel " + vox + " overwriting space " + pos + ", previously occupied by " + grid[pos]);
			grid[pos] = vox;
		}
		else{
			grid.Add (pos, vox);
		}
	}
开发者ID:mbhuet,项目名称:MastersProject,代码行数:10,代码来源:Level.cs


示例17: BecomeYDummyOf

 public void BecomeYDummyOf(Voxel voxel, float offset)
 {
     m_state = voxel.m_state;
     m_position = voxel.m_position;
     m_xEdgePosition = voxel.m_xEdgePosition;
     m_yEdgePosition = voxel.m_yEdgePosition;
     m_position.y += offset;
     m_xEdgePosition.y += offset;
     m_yEdgePosition.y += offset;
 }
开发者ID:ParalyzeStudio,项目名称:MarchingSquares,代码行数:10,代码来源:Voxel.cs


示例18: GetID

 // Requires neighbours to be listed in correct order.
 // Returns the sum of each neighbour's ID.
 public static int GetID(Voxel[] neighbours)
 {
     int id = 0;
     for (int i=0; i<neighbours.Length; i++) {
         if (neighbours[i] == null) {
             continue;
         }
         id += neighbourIDs[i];
     }
     return id;
 }
开发者ID:mandarinx,项目名称:buildahouse,代码行数:13,代码来源:SurfaceManager.cs


示例19: BecomeYDummyOf

 public void BecomeYDummyOf(Voxel voxel, float offset)
 {
     state = voxel.state;
     position = voxel.position;
     eastEdge = voxel.eastEdge;
     southEdge = voxel.southEdge;
     cornerPosition = voxel.cornerPosition;
     position.z -= offset;
     eastEdge.z -= offset;
     southEdge.z -= offset;
     cornerPosition.z -= offset;
 }
开发者ID:JapaMala,项目名称:armok-vision,代码行数:12,代码来源:Voxel.cs


示例20: UseVoxels

    // Given new chunk of voxels, reset and rebuild mesh
    public void UseVoxels(Voxel[] src_voxels, int chunkx, int chunky)
    {
        // If this chunk already displays given voxels, do nothing
        if (this.voxels == src_voxels) {
            return;
        }

        this.chunkX = chunkx;
        this.chunkY = chunky;
        this.voxels = src_voxels;
        RebuildMesh();
    }
开发者ID:kvakvs,项目名称:playable_alpha2,代码行数:13,代码来源:TerrainChunk.cs



注:本文中的Voxel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# VoyageNumber类代码示例发布时间:2022-05-24
下一篇:
C# VowpalWabbit类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap