Example #1
0
        public Renderer(GraphicSettings graphicSettings, ServerSettings serverSettings)
        {
            var resolution = GetResolution(graphicSettings);

            var rendererName = serverSettings.Dedicated ? "Null" : graphicSettings.Renderer;
            var rendererPath = Platform.ResolvePath(".", "OpenRA.Platforms." + rendererName + ".dll");

            Device = CreateDevice(Assembly.LoadFile(rendererPath), resolution.Width, resolution.Height, graphicSettings.Mode);

            if (!serverSettings.Dedicated)
            {
                TempBufferSize = graphicSettings.BatchSize;
                SheetSize      = graphicSettings.SheetSize;
            }

            WorldSpriteRenderer     = new SpriteRenderer(this, Device.CreateShader("shp"));
            WorldRgbaSpriteRenderer = new SpriteRenderer(this, Device.CreateShader("rgba"));
            WorldRgbaColorRenderer  = new RgbaColorRenderer(this, Device.CreateShader("color"));
            WorldVoxelRenderer      = new VoxelRenderer(this, Device.CreateShader("vxl"));
            RgbaColorRenderer       = new RgbaColorRenderer(this, Device.CreateShader("color"));
            RgbaSpriteRenderer      = new SpriteRenderer(this, Device.CreateShader("rgba"));
            SpriteRenderer          = new SpriteRenderer(this, Device.CreateShader("shp"));

            tempBuffer = Device.CreateVertexBuffer(TempBufferSize);
        }
Example #2
0
        private void CreateVoxWorld()
        {
            dVox  = new Dictionary <string, VoxData>();
            state = new VoxState();
            state.World.worldMin.X = 0;
            state.World.worldMin.Y = 0;
            CreateVoxTypes();

            voxContent = new ContentManager(game.Services);
            voxContent.RootDirectory = @"Content";
            renderer = new VoxelRenderer(game.Graphics, voxContent);
            renderer.Hook(state);
            renderer.LoadEffect(@"FX\VoxelLE");
            renderer.LoadVMap(@"LevelEditor\VoxMap.png");

            vManager = new WorldManager(state);
            for (int z = 0; z < VoxWorld.DEPTH; z++)
            {
                for (int x = 0; x < VoxWorld.WIDTH; x++)
                {
                    state.AddEvent(new VEWorldMod(state.World.worldMin.X + x, state.World.worldMin.Y + z, VEWMType.RegionAdd));
                }
            }
            state.VWorkPool.Start(2);
            state.World.OnRegionAddition += (w, r) => {
                if (r.loc.X == 0 && r.loc.Y == 0)
                {
                    r.AddVoxel(1, Region.HEIGHT - 2, 1, (ushort)0x06u);
                }
            };
        }
 public void Render(Vector3 position)
 {
     //Loop through the voxels
     for (int i = 0; i < voxels.Length; i++)
     {
         //Pass the voxels to the voxel renderer
         VoxelRenderer.RenderVoxel(voxels[i]);
     }
 }
Example #4
0
        public override void LoadContent()
        {
            InputManager.LockMouseToCenter = true;
            game.IsMouseVisible            = false;

            VoxelRenderer.Init(Game);
            Voxelizer.Init();

            cameraPosition = new Vector3(25, 50, 150);
            chunk          = Voxelizer.CreateChunk(0.5f);
            marker         = new SpherePrimitive(8, 16);
        }
Example #5
0
 void ExplodeAndPaint()
 {
     GameObject[] allShapes = GameObject.FindGameObjectsWithTag("Shape");
     foreach (var shape in allShapes)
     {
         if (shape != null)
         {
             VoxelRenderer vR = shape.GetComponent <VoxelRenderer>();
             vR.theEndOfTheGame = true;
             vR.MoveTowordsTheSun();
         }
     }
 }
Example #6
0
 public void Build(GraphicsDeviceManager gdm, ContentManager cm, VoxMapConfig vc)
 {
     vRenderer = new VoxelRenderer(gdm, cm);
     vRenderer.LoadEffect(vc.FXFile);
     vRenderer.LoadVMap(Path.Combine(vc.RootPath, vc.TexVoxMap));
     vRenderer.Hook(vc.VoxState);
     foreach (var r in vc.VoxState.World.regions)
     {
         if (r != null)
         {
             vc.VoxState.VWorkPool.AddWork(new RegionTesselator(r, vRenderer));
         }
     }
 }
    private int ProcessX(
        int x,
        int y,
        int z,
        List <Vector3> vertices,
        List <int> triangles,
        List <Vector2> uvs,
        int t,
        VoxelRenderer container,
        bool currentLeft,
        bool[] voxels
        )
    {
        if (x == 0)
        {
            if (currentLeft == true)
            {
                t += BuildLeftFace(x, y, z, vertices, triangles, uvs, t);
            }
        }
        else
        {
            int previousCell = (x - 1) + container.Width * (y + container.Height * z);

            bool previousLeft = voxels[previousCell];

            if (currentLeft == true)
            {
                if (previousLeft == false)
                {
                    t += BuildLeftFace(x, y, z, vertices, triangles, uvs, t);
                }

                if (x == container.Width - 1)
                {
                    t += BuildRightFace(x + 1, y, z, vertices, triangles, uvs, t);
                }
            }
            else if (currentLeft == false)
            {
                if (previousLeft == true)
                {
                    t += BuildRightFace(x, y, z, vertices, triangles, uvs, t);
                }
            }
        }

        return(t);
    }
    private int ProcessY(
        int x,
        int y,
        int z,
        List <Vector3> vertices,
        List <int> triangles,
        List <Vector2> uvs,
        int t,
        VoxelRenderer container,
        bool currentBottom,
        bool[] voxels
        )
    {
        if (y == 0)
        {
            if (currentBottom == true)
            {
                t += BuildBottomFace(x, y, z, vertices, triangles, uvs, t);
            }
        }
        else
        {
            int previousCell = x + container.Width * ((y - 1) + container.Height * z);

            bool previousBottom = voxels[previousCell];

            if (currentBottom == true)
            {
                if (previousBottom == false)
                {
                    t += BuildBottomFace(x, y, z, vertices, triangles, uvs, t);
                }

                if (y == container.Height - 1)
                {
                    t += BuildTopFace(x, y + 1, z, vertices, triangles, uvs, t);
                }
            }
            else if (currentBottom == false)
            {
                if (previousBottom == true)
                {
                    t += BuildTopFace(x, y, z, vertices, triangles, uvs, t);
                }
            }
        }

        return(t);
    }
    private int ProcessZ(
        int x,
        int y,
        int z,
        List <Vector3> vertices,
        List <int> triangles,
        List <Vector2> uvs,
        int t,
        VoxelRenderer container,
        bool currentForward,
        bool[] voxels
        )
    {
        if (z == 0)
        {
            if (currentForward == true)
            {
                t += BuildFrontFace(x, y, z, vertices, triangles, uvs, t);
            }
        }
        else
        {
            int previousCell = x + container.Width * (y + container.Height * (z - 1));

            bool previousForward = voxels[previousCell];

            if (currentForward == true)
            {
                if (previousForward == false)
                {
                    t += BuildFrontFace(x, y, z, vertices, triangles, uvs, t);
                }

                if (z == container.Depth - 1)
                {
                    t += BuildBackFace(x, y, z + 1, vertices, triangles, uvs, t);
                }
            }
            else if (currentForward == false)
            {
                if (previousForward == true)
                {
                    t += BuildBackFace(x, y, z, vertices, triangles, uvs, t);
                }
            }
        }

        return(t);
    }
Example #10
0
        public override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            projection = Matrix.PerspectiveFovRH(MathUtil.PiOverFour, GraphicsDevice.Viewport.AspectRatio, .1f, 10000f);

            VoxelRenderer.Begin(view, projection);
            VoxelRenderer.Draw(chunk);
            VoxelRenderer.End();

            VoxelRenderer.Begin(view, projection);
            VoxelRenderer.Draw(marker);
            VoxelRenderer.End();

            spriteBatch.Begin();
            spriteBatch.DrawString(Engine.DefaultFont, "Vertices: " + chunk.VertexCount.ToString(), new Vector2(10, 10), Color.White);
            spriteBatch.End();
        }
Example #11
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        VoxelRenderer voxelRenderer = (VoxelRenderer)target;

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Random Perlin Position", EditorStyles.boldLabel);
        randPosMin = EditorGUILayout.Vector3Field("Random Position Min", randPosMin);
        randPosMax = EditorGUILayout.Vector3Field("Random Position Max", randPosMax);
        if (GUILayout.Button("Randomize Perlin Position"))
        {
            voxelRenderer.perlinPosition = new Vector3(
                Random.Range(randPosMin.x, randPosMax.x),
                Random.Range(randPosMin.y, randPosMax.y),
                Random.Range(randPosMin.z, randPosMax.z)
                );
            voxelRenderer.GenerateMap(voxelRenderer.perlinPosition);
        }
    }
Example #12
0
    private void CreateRenderers()
    {
        renderers = new VoxelRenderer[materials.Length + 1];
        for (int i = 0; i < materials.Length; i++)
        {
            VoxelGridSurface surface =
                Instantiate(surfacePrefab) as VoxelGridSurface;
            surface.transform.parent        = transform;
            surface.transform.localPosition = Vector3.zero;
            surface.Initialize(resolution, materials[i].surfaceMaterial);

            VoxelGridWall wall = Instantiate(wallPrefab) as VoxelGridWall;
            wall.transform.parent        = transform;
            wall.transform.localPosition = Vector3.zero;
            wall.Initialize(resolution, materials[i].wallMaterial);

            renderers[i + 1] = new VoxelRenderer(surface, wall);
        }
    }
Example #13
0
        public Renderer(IPlatform platform, GraphicSettings graphicSettings)
        {
            var resolution = GetResolution(graphicSettings);

            Device = platform.CreateGraphics(new Size(resolution.Width, resolution.Height), graphicSettings.Mode);

            TempBufferSize = graphicSettings.BatchSize;
            SheetSize      = graphicSettings.SheetSize;

            WorldSpriteRenderer     = new SpriteRenderer(this, Device.CreateShader("shp"));
            WorldRgbaSpriteRenderer = new SpriteRenderer(this, Device.CreateShader("rgba"));
            WorldRgbaColorRenderer  = new RgbaColorRenderer(this, Device.CreateShader("color"));
            WorldVoxelRenderer      = new VoxelRenderer(this, Device.CreateShader("vxl"));
            RgbaColorRenderer       = new RgbaColorRenderer(this, Device.CreateShader("color"));
            RgbaSpriteRenderer      = new SpriteRenderer(this, Device.CreateShader("rgba"));
            SpriteRenderer          = new SpriteRenderer(this, Device.CreateShader("shp"));

            tempBuffer = Device.CreateVertexBuffer(TempBufferSize);
        }
 public void StartGame()
 {
     if (started == false)
     {
         this.GetComponent <Testing>().start = true;
         Cursor.lockState = CursorLockMode.Locked;
         tooth            = new VoxelRenderer();
         GameObject.Find("Main Camera").GetComponent <SmoothMouseLook>().enabled = true;
         GameObject.Find("Main Camera").GetComponent <SmoothMouseLook>().SetClamp(tooth.X, tooth.Y, tooth.Z);
         GameObject.Find("Main Camera").GetComponent <SmoothMouseLook>().SetStartPosition(tooth.X, tooth.Y, tooth.Z);
         EnableUI();
         playing = true;
         SetActiveTools();
         started = true;
         gameObject.GetComponent <AudioSource>().Play();
     }
     else
     {
         InstructionsToggle();
     }
 }
Example #15
0
        public override void OnCreate()
        {
            try
            {
                Console.WriteLine(ShaderPreprocessor.Execute(@"res\shaders\raytracing\fragment.glsl"));

                Shader voxelVertexShader   = new Shader(ShaderType.VertexShader, ShaderPreprocessor.Execute(@"res\shaders\raytracing\vertex.glsl"));
                Shader voxelFragmentShader = new Shader(ShaderType.FragmentShader, ShaderPreprocessor.Execute(@"res\shaders\raytracing\fragment.glsl"));
                Shader scaleFragmentShader = new Shader(ShaderType.FragmentShader, ShaderPreprocessor.Execute(@"res\shaders\raytracing\scale.glsl"));
                _voxelRenderer = new VoxelRenderer(new ShaderProgram(new[] { voxelVertexShader, voxelFragmentShader }), new ShaderProgram(new[] { voxelVertexShader, scaleFragmentShader }));

                Shader spriteVertexShader   = new Shader(ShaderType.VertexShader, ShaderPreprocessor.Execute(@"res\shaders\ui\vertex.glsl"));
                Shader spriteFragmentShader = new Shader(ShaderType.FragmentShader, ShaderPreprocessor.Execute(@"res\shaders\ui\fragment.glsl"));
                _spriteRenderer = new SpriteRenderer(new ShaderProgram(new[] { spriteVertexShader, spriteFragmentShader }));
            } catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw;
            }

            _voxelRenderer.GenerateFramebuffer(window);

            //List<Material> materials = new List<Material>();
            //for (int i = 0; i < 256; i++)
            //    materials.Add(new Material(Vector3.One, 1.5f));

            //_voxelRenderer.Materials = materials;

            Console.WriteLine("Shader compiled <o/"); //epic it work

            _model = _voxelRenderer.CreateModel(32, 32, 32,
                                                new Transform(new Vector3(24.0f, 0.0f, 0.0f), Vector3.Zero, new Vector3(0.5f)));

            for (int x = 0; x < 32; x++)
            {
                for (int y = 0; y < 32; y++)
                {
                    for (int z = 0; z < 32; z++)
                    {
                        _model[x, y, z] = (byte)((x + y + z) & 1);//new Voxel((ushort) ((x + y + z) & 1));
                    }
                }
            }
            MyVoxLoader CastleVox = new MyVoxLoader();
            VoxReader r           = new VoxReader(@"res\maps\map.vox", CastleVox);
            r.Read();

            //Use palette of castlevox
            List <Material> materials = new List <Material>();
            for (int i = 0; i < 256; i++)
            {
                Vector3 color = new Vector3((float)CastleVox._materials[i].r / 255f, (float)CastleVox._materials[i].g / 255f, (float)CastleVox._materials[i].b / 255f);
                float   ior   = 1.01f;
                if (i == 252)
                {
                    ior = 1.1f;
                }
                if (i == 254)
                {
                    ior = 1.1f;
                }
                //Vector3 color = new Vector3(1f, 0f, 0f);
                materials.Add(new Material(color, ior));
            }
            _voxelRenderer.Materials.Set(materials);

            _model2 = _voxelRenderer.CreateModel(CastleVox.Width, CastleVox.Height, CastleVox.Depth,
                                                 new Transform(new Vector3(-24.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.1f, 0.0f), new Vector3(0.5f)));

            //for (int x = -16; x < 16; x++)
            //for (int y = -16; y < 16; y++)
            //for (int z = -16; z < 16; z++)
            //    _model2[x + 16, y + 16, z + 16] = (x * x + y * y + z * z < 16 * 16) ? (byte)1 : (byte)0;
            for (int x = 0; x < CastleVox.Width; x++)
            {
                for (int y = 0; y < CastleVox.Height; y++)
                {
                    for (int z = 0; z < CastleVox.Depth; z++)
                    {
                        _model2[x, y, z] = CastleVox._data[x, y, z];
                    }
                }
            }

            Console.WriteLine("Epic");


            //int s = 512;
            //VoxelModel model3 = _voxelRenderer.CreateModel(s,1,s,
            //    new Transform(new Vector3(0.0f, -48.0f, 0.0f), Vector3.Zero, new Vector3(1.0f)));

            //for (int x = 0; x < s; x++)
            //for (int y = 0; y < 1; y++)
            //for (int z = 0; z < s; z++)
            //    model3[x,y,z] = (byte)1;

            Console.WriteLine("Epic");

            Sprite crosshair = new Sprite(new Texture("res/textures/crosshair.png", TextureMinFilter.Linear, TextureMagFilter.Linear));
            _spriteRenderer.Add(crosshair);
            crosshair.Colour          = new Colour(1.0f, 1.0f, 1.0f, 1.0f);
            crosshair.Transform.Scale = new Vector3(128.0f, 128.0f, 0.25f);

            List <DirectionalLight> dirLights = new List <DirectionalLight>();
            var sun = new DirectionalLight();
            sun.direction = new Vector3(-0.5f, 1.5f, -1.0f);
            sun.intensity = 0.8f;
            sun.colour    = new Vector3(1f, 1f, 1f);
            dirLights.Add(sun);

            var sun2 = new DirectionalLight();
            sun2.direction = new Vector3(-0.4f, 1.5f, 0.8f);
            sun2.intensity = 0.6f;
            sun2.colour    = new Vector3(0.7f, 0.8f, 1f);
            dirLights.Add(sun2);

            var sun3 = new DirectionalLight();
            sun3.direction = new Vector3(0.4f, 0.1f, 0.2f);
            sun3.intensity = 0.6f;
            sun3.colour    = new Vector3(0.4f, 0.8f, 1f);
            dirLights.Add(sun3);
            _voxelRenderer.DirectionalLights = dirLights;

            List <PointLight> pointLights = new List <PointLight>();
            var pointlight = new PointLight();
            pointlight.position  = new Vector3(0f, 0f, -20f);
            pointlight.intensity = 0.5f;
            pointlight.colour    = new Vector3(1f, 0.0f, 0.0f);
            pointLights.Add(pointlight);
            _voxelRenderer.PointLights = pointLights;

            MyVoxLoader CharBodyVox = new MyVoxLoader();
            VoxReader rCharBody     = new VoxReader(@"res\char1_body.vox", CharBodyVox);
            rCharBody.Read();

            //Use palette of castlevox
            //List<Material> materialsChar = new List<Material>();
            //for (int i = 0; i < 256; i++)
            //{
            //    Vector3 color = new Vector3((float)CharBodyVox._materials[i].r / 255f, (float)CharBodyVox._materials[i].g / 255f, (float)CharBodyVox._materials[i].b / 255f);
            //    float ior = 1.01f;
            //    if (i == 252) ior = 1.1f;
            //    if (i == 254) ior = 1.1f;
            //    //Vector3 color = new Vector3(1f, 0f, 0f);
            //    materialsChar.Add(new Material(color, ior));
            //}
            //_voxelRenderer.Materials.Set(materialsChar);

            TcpConnection connection = new TcpConnection(IPAddress.Parse("127.0.0.1"), 42069, (IConnection c, byte[] data) =>
            {
                //Console.WriteLine("Received packet...");
                if (data.Length > 1)
                {
                    if (data[0] == 1)
                    {
                        Console.WriteLine("Received our player id!");
                        _playerId              = BitConverter.ToUInt64(data, 1);
                        _mainPlayer            = new Player(data[1], _playerId, true);
                        _mainPlayer._world     = _model2;
                        _mainPlayer._modelBody = _voxelRenderer.CreateModel(CharBodyVox.Width, CharBodyVox.Height, CharBodyVox.Depth,
                                                                            new Transform(new Vector3(-24.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.1f, 0.0f), new Vector3(0.5f)));

                        //for (int x = 0; x < CharBodyVox.Width; x++)
                        //    for (int y = 0; y < CharBodyVox.Height; y++)
                        //        for (int z = 0; z < CharBodyVox.Depth; z++)
                        //            _mainPlayer._modelBody[x, y, z] = CharBodyVox._data[x, y, z];

                        //Commenting this line out will give you access to the FreeCamera
                        //_camera = _mainPlayer.camera;
                        _entityManager.Add(_mainPlayer);
                    }
                    else if (data[0] == 0)
                    {
                        //Not sure if myId should be data[5] or _playerId
                        if (NetworkEntity.HandlePacket(_entityManager, data, _playerId) == false)
                        {
                            //Player doesn't exist yet
                            Console.WriteLine("Adding new player");
                            Player player     = new Player(data[1], data[5], false);
                            player._modelBody = _voxelRenderer.CreateModel(CharBodyVox.Width, CharBodyVox.Height, CharBodyVox.Depth,
                                                                           new Transform(new Vector3(-24.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.1f, 0.0f), new Vector3(0.5f)));

                            for (int x = 0; x < CharBodyVox.Width; x++)
                            {
                                for (int y = 0; y < CharBodyVox.Height; y++)
                                {
                                    for (int z = 0; z < CharBodyVox.Depth; z++)
                                    {
                                        player._modelBody[x, y, z] = CharBodyVox._data[x, y, z];
                                    }
                                }
                            }
                            _entityManager.Add(player);
                        }
                    }
                }
            });

            _packetSender.AddReceiver(connection);
        }
Example #16
0
 void OnDestroy()
 {
     instance = null;
 }
Example #17
0
 void Awake()
 {
     instance     = this;
     octree_datas = new Dictionary <TextAsset, VoxelObject.Octree>();
     voxel_objs   = new List <VoxelObject>();
 }
Example #18
0
    private void UpdateLaser()
    {
        Camera camera = CameraExtensions.FindCameraUnderMouse();

        if (camera == null)
        {
            return;
        }

        Vector3 mousePosition = Input.mousePosition;

        mousePosition.z = 50;

        Vector3 target = camera.ScreenToWorldPoint(mousePosition);
        Vector3 delta  = target - laser.transform.position;

        if (delta.magnitude > 30)
        {
            delta  = delta.normalized * 30.0f;
            target = laser.transform.position + delta;
        }

        // First check if the mouse pointer is over a mesh
        Ray           ray = camera.ScreenPointToRay(Input.mousePosition);
        RaycastHit    hitInfo;
        bool          hit           = false;
        VoxelRenderer voxelRenderer = null;

        if (Physics.Raycast(ray, out hitInfo, 50.0f))
        {
            target        = hitInfo.point;
            voxelRenderer = hitInfo.collider.gameObject.GetComponentInParent <VoxelRenderer>();

            // Protect a second ray to see if the point we are aiming at would collide first
            ray = new Ray(laser.transform.position, target - laser.transform.position);
            if (Physics.Raycast(ray, out hitInfo, 50.0f))
            {
                target        = hitInfo.point;
                voxelRenderer = hitInfo.collider.gameObject.GetComponentInParent <VoxelRenderer>();
            }

            hit = true;
        }

        if (!hit)
        {
            // If not protect a ray from the origin to the target
            ray = new Ray(laser.transform.position, delta);
            if (Physics.Raycast(ray, out hitInfo, delta.magnitude))
            {
                target        = hitInfo.point;
                voxelRenderer = hitInfo.collider.gameObject.GetComponentInParent <VoxelRenderer>();

                hit = true;
            }
        }

        if (hit && voxelRenderer != null)
        {
            VoxelMap voxelMap      = voxelRenderer.VoxelMap;
            Vector3  localPosition = target - voxelRenderer.gameObject.transform.position;

            Vector3 point;
            point.x = localPosition.x / voxelMap.Scale - voxelMap.Offset.x;
            point.y = localPosition.y / voxelMap.Scale - voxelMap.Offset.y;
            point.z = localPosition.z / voxelMap.Scale - voxelMap.Offset.z;

            // Clamp to the bounds of the map
            int x = Mathf.Clamp(Mathf.RoundToInt(point.x), 0, voxelMap.Columns);
            int y = Mathf.Clamp(Mathf.RoundToInt(point.y), 0, voxelMap.Rows);
            int z = Mathf.Clamp(Mathf.RoundToInt(point.z), 0, voxelMap.Pages);

            IntVector3 nearestVoxel;
            if (voxelMap.FindNearestVoxel(localPosition, out nearestVoxel))
            {
                if (!lastVoxel.Equals(nearestVoxel))
                {
                    lastVoxel      = nearestVoxel;
                    lastVoxelTimer = 0;
                }
                else
                {
                    lastVoxelTimer += Time.deltaTime;
                    if (lastVoxelTimer > 0.1)
                    {
                        Vector3 position = nearestVoxel;
                        position *= voxelMap.Scale;
                        position += voxelMap.Offset;
                        position += voxelRenderer.gameObject.transform.position;

                        DebugUI.DrawCubeCentred(position, new Vector3(voxelMap.Scale, voxelMap.Scale, voxelMap.Scale), voxelRenderer.gameObject.transform.rotation, Color.red);

                        voxelRenderer.RemoveVoxel(nearestVoxel);
                        lastVoxel = IntVector3.UNDEFINED;
                    }
                }
            }
            else
            {
                lastVoxel = IntVector3.UNDEFINED;
            }
        }
        else
        {
            lastVoxel = IntVector3.UNDEFINED;
        }

        delta = target - laser.transform.position;
        Vector3 scale = laser.transform.localScale;

        scale.z = delta.magnitude;

        laser.transform.localScale = scale;
        laser.transform.LookAt(target);

        delta = delta.normalized * (delta.magnitude - 0.1f);

        collision.transform.position = laser.transform.position + delta;
        ParticleSystem[] particles = collision.GetComponentsInChildren <ParticleSystem>();
        foreach (var ps in particles)
        {
            var emission = ps.emission;
            emission.enabled = hit;
        }
    }
Example #19
0
 public VoxelRenderComponent()
 {
     renderer   = MasterRenderer.Instance.GetRenderer3D <VoxelRenderer>();
     IsDrawable = true;
 }
Example #20
0
 public RegionTesselator(Region r, VoxelRenderer vg)
 {
     region   = r;
     renderer = vg;
 }