Esempio n. 1
0
        protected override void _draw()
        {
            transform.position = layer.Position.Coordinates.Vector3();
            transform.Translate(AppState.instance.map.transform.TransformVector((Vector3)layer.Transform.Position));
            Dictionary <string, Unit> symbology = layer.Properties.Units;

            model = Instantiate(pointCloud, transform, false);



            BakedPointCloud cloud = ScriptableObject.CreateInstance <BakedPointCloud>();
            ParticleData    data  = features as ParticleData;

            cloud.Initialize(data.vertices, data.colors);
            VisualEffect vfx = model.GetComponent <VisualEffect>();

            vfx.SetTexture("_Positions", cloud.positionMap);
            vfx.SetTexture("_Colors", cloud.colorMap);
            vfx.SetInt("_pointCount", cloud.pointCount);
            vfx.SetVector3("_size", symbology["point"].Transform.Scale);
            vfx.Play();

            transform.rotation   = layer.Transform.Rotate;
            transform.localScale = layer.Transform.Scale;
            vfx.SetVector3("_scale", layer.Transform.Scale);
            GameObject centreHandle = Instantiate(handle, transform.position, Quaternion.identity);

            centreHandle.transform.localScale = AppState.instance.map.transform.TransformVector((Vector3)symbology["handle"].Transform.Scale);
            centreHandle.GetComponent <Datapoint>().SetMaterial(mainMat, selectedMat);
            centreHandle.transform.parent = transform;
        }
Esempio n. 2
0
    public override void OnImportAsset(UnityEditor.AssetImporters.AssetImportContext ctx)
    {
        BakedPointCloud data = ImportAsBakedPointCloud(ctx.assetPath);

        if (data != null)
        {
            ctx.AddObjectToAsset("container", data);
            ctx.AddObjectToAsset("position", data.PositionMap);
            ctx.AddObjectToAsset("color", data.ColorMap);
            ctx.SetMainObject(data);
        }
    }
Esempio n. 3
0
    BakedPointCloud ImportAsBakedPointCloud(string path)
    {
        VoxReader voxReader = new VoxReader();
        VoxModel  model     = voxReader.LoadModel(path);

        if (model == null)
        {
            return(null);
        }

        List <Vector3> positions     = new List <Vector3>();
        List <Color>   colors        = new List <Color>();
        var            colorsPalette = model.Palette;

        for (int i = 0; i < model.VoxelFrames.Count; i++)
        {
            VoxelData data = model.VoxelFrames[i];
            FileToVoxCore.Schematics.Tools.Vector3 worldPositionFrame = model.TransformNodeChunks[i + 1].TranslationAt();

            if (worldPositionFrame == FileToVoxCore.Schematics.Tools.Vector3.zero)
            {
                continue;
            }

            for (int y = 0; y < data.VoxelsTall; y++)
            {
                for (int z = 0; z < data.VoxelsDeep; z++)
                {
                    for (int x = 0; x < data.VoxelsWide; x++)
                    {
                        int indexColor = data.Get(x, y, z);
                        var color      = colorsPalette[indexColor];
                        if (color != FileToVoxCore.Drawing.Color.Empty)
                        {
                            positions.Add(new Vector3(z + worldPositionFrame.X, y + worldPositionFrame.Z, x + worldPositionFrame.Y));
                            colors.Add(color.ToUnityColor());
                        }
                    }
                }
            }
        }

        BakedPointCloud bakedPointCloud = ScriptableObject.CreateInstance <BakedPointCloud>();

        bakedPointCloud.Initialize(positions, colors);
        bakedPointCloud.name = Path.GetFileNameWithoutExtension(path);
        return(bakedPointCloud);
    }