Exemplo n.º 1
0
    void UpdateBuilderInput()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Vector3 mousePos = Input.mousePosition;

            // Test hide click tile
            Ray ray = Camera.main.ScreenPointToRay(mousePos);

            RaycastHit hit;
            int        mask = (int)App.Mask.Piece;
            if (Physics.Raycast(ray, out hit, 1000f, mask))
            {
                Vox vx = hit.transform.GetComponent <Vox>();
                if (vx != null)
                {
                    OnClick(vx, hit);
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.F1))
        {
            App.Inst.CurrentCubie.SaveVoxels();
        }

        if (Input.GetKeyDown(KeyCode.F2))
        {
            App.Inst.CurrentCubie.LoadVoxels();
        }
    }
 /// <summary>
 /// Creates a new Batch entry for the given client in the table. The combination of BatchNumber and Client must be unique, if not a InvalidBatchException will
 /// be thrown. In addition existing batches must be closed first.
 /// </summary>
 /// <param name="entity">Batch which will be added.</param>
 /// <returns>True if the batch was succesfully added, otherwise false. If the batch is invalid an InvalidBatchException will be thrown</returns>
 public bool Add(Vox.Auditing.Model.Batch entity)
 {
     if (entity == null) { throw new ArgumentNullException("entity"); }
       if (entity.ID != 0) { throw new InvalidBatchException("Cannot add a batch which has already been added!"); }
       if (entity.ClientID == 0) { throw new InvalidBatchException("Cannot add a batch with no valid client!"); }
       bool added = false;
       // Check if the batch is valid first
       using (DataModel.VoxAuditingEntities context = new DataModel.VoxAuditingEntities(connectionString)) {
     // Check that no existing batches are open for the current client ID
     var validBatch = from m in context.Batches
                  where m.MessageClientID == entity.ClientID && m.FinishDate == null
                  select m;
     if (validBatch.Count() == 0) {
       // Try and add the new batch
       context.Batches.AddObject(new DataModel.Batch() {
     BatchID = entity.ID,
     BatchNumber = entity.Number,
     MessageClientID = entity.ClientID,
     StartDate = entity.StartDate
       });
       added = context.SaveChanges() != 0;
     } else {
       throw new InvalidBatchException(string.Format("Batch '{0}' is still open for the given client", validBatch.First().BatchNumber));
     }
       }
       return added;
 }
Exemplo n.º 3
0
    void Awake()
    {
        player = Vox.LoadModel("Assets/models/player_stand.vox", "object");
        player.obj.transform.position = new Vector3(150, 11, 150);
        player.obj.name = "Player";

        GameObject lightGameObject = new GameObject("LightAbovePlayer");

        pLight            = lightGameObject.AddComponent <Light>();
        pLight.type       = LightType.Point;
        pLight.color      = Color.grey;
        pLight.range      = 200;
        pLight.intensity  = 1.0f;
        pLight.renderMode = LightRenderMode.ForceVertex;

        GameObject lightGameObject2 = new GameObject("LightBelowPlayer");

        pUnder            = lightGameObject2.AddComponent <Light>();
        pUnder.type       = LightType.Point;
        pUnder.color      = Color.white;
        pUnder.range      = 200;
        pUnder.intensity  = 3.4f;
        pUnder.renderMode = LightRenderMode.ForceVertex;

        //player.obj.AddComponent<MeshCollider> ();
        player.obj.AddComponent <Rigidbody> ();
        player.obj.GetComponent <MeshCollider> ().convex      = true;
        player.obj.GetComponent <Rigidbody> ().sleepThreshold = 1.0f;
        player.obj.GetComponent <Rigidbody> ().mass           = 10;
        player.obj.GetComponent <Rigidbody> ().isKinematic    = true;
        player.obj.GetComponent <Rigidbody> ().angularDrag    = 0.09f;

        // Add player as target for the smoothfollow camera script.
        //SmoothFollow sf = Camera.main.GetComponent<SmoothFollow> ();
        //SmoothCamera sf = Camera.main.GetComponent<SmoothCamera>();
        SmoothFollow script = Camera.main.GetComponent <SmoothFollow>();

        script.target = player.obj.transform;
        //sf.target = player.obj.transform;
        //GameObject.Find("Camera").GetComponent("SmoothFollow").target = player.obj.transform;

//        playerJet1 = (GameObject)Instantiate(jet, player.obj.transform.position, Quaternion.identity);
//        playerJet1.transform.parent = player.obj.transform;
//        playerJet1.transform.localRotation = Quaternion.Euler (new Vector3(90, 0, 0));
//        playerJet1.transform.localPosition = new Vector3 (0.5f, 1.89f, -0.7f);
//        playerJet1.GetComponent<ParticleSystem> ().loop = false;
//        playerJet1.GetComponent<ParticleSystem> ().startSize = 5;
//        playerJet1.GetComponent<ParticleSystem> ().Pause ();
//
//
//        playerJet2 = (GameObject)Instantiate(jet, player.obj.transform.position, Quaternion.identity);
//        playerJet2.transform.parent = player.obj.transform;
//        playerJet2.transform.localRotation = Quaternion.Euler (new Vector3(90, 0, 0));
//        playerJet2.transform.localPosition = new Vector3 (2.5f, 1.89f, -0.7f);
//        playerJet2.GetComponent<ParticleSystem> ().loop = false;
//        playerJet2.GetComponent<ParticleSystem> ().startSize = 5;
//        playerJet2.GetComponent<ParticleSystem> ().Pause ();
    }
Exemplo n.º 4
0
    void OnClick(Vox vx, RaycastHit hit)
    {
        // Get the side
        Vector3 normal = hit.normal;
        Vector3 newpos = vx.transform.position + normal;

        // Add another Vox
        Vox vox = App.Inst.CurrentCubie.BuildVox(vx, (int)newpos.x, (int)newpos.y, (int)newpos.z, vx.V.C);
    }
Exemplo n.º 5
0
    public Vox BuildVox(Vox template, int x, int y, int z, int c)
    {
        Voxel v   = AddVoxel(x, y, z, c);
        Vox   vox = BuildVox(template, v);
        int   key = Key(x, y, z);

        Voxs[key] = vox;
        return(vox);
    }
Exemplo n.º 6
0
        private static void Vox2Wav(string voxFile, string wavFile, int samplesPerSec)
        {
            BinaryReader br     = new BinaryReader(File.OpenRead(voxFile));
            IntPtr       format = AudioCompressionManager.GetPcmFormat(1, 16, samplesPerSec);
            WaveWriter   ww     = new WaveWriter(File.Create(wavFile), AudioCompressionManager.FormatBytes(format));

            Vox.Vox2Wav(br, ww);
            br.Close();
            ww.Close();
        }
Exemplo n.º 7
0
    public Vox BuildVox(Vox template, Voxel v)
    {
        GameObject go = Instantiate(template.gameObject);

        go.SetActive(true);
        Vox vox = go.GetComponent <Vox>();

        go.transform.position = new Vector3(v.X, v.Y, v.Z);

        return(vox);
    }
Exemplo n.º 8
0
        private static IAudioReader GetVoxReader(string fileName, int sampleRate)
        {
            BinaryReader br     = new BinaryReader(File.OpenRead(fileName));
            MemoryStream ms     = new MemoryStream();
            IntPtr       format = AudioCompressionManager.GetPcmFormat(1, 16, sampleRate);
            WaveWriter   ww     = new WaveWriter(ms, AudioCompressionManager.FormatBytes(format));

            Vox.Vox2Wav(br, ww);
            br.Close();
            return(new WaveReader(ms));
        }
Exemplo n.º 9
0
    void Awake()
    {
        chunk = Vox.LoadModel("models/player_stand.vox", "object");
        chunk.obj.transform.position = new Vector3(30, 10, 100);
        chunk.obj.name = "Enemy";

        //chunk.obj.AddComponent<MeshCollider> ();
        chunk.obj.AddComponent <Rigidbody> ();
        chunk.obj.GetComponent <MeshCollider> ().convex      = true;
        chunk.obj.GetComponent <Rigidbody> ().sleepThreshold = 1.0f;
        chunk.obj.GetComponent <Rigidbody> ().mass           = 10;
        chunk.obj.GetComponent <Rigidbody> ().isKinematic    = true;
        chunk.obj.GetComponent <Rigidbody> ().angularDrag    = 0.09f;
    }
Exemplo n.º 10
0
        private void btnVox2Mp3_Click(object sender, EventArgs e)
        {
            string voxFile = tbVox.Text;

            if (voxFile == string.Empty)
            {
                MessageBox.Show("Please, select file for converting");
                return;
            }
            string mp3File = Path.ChangeExtension(voxFile, ".mp3");

            Vox.Vox2Mp3(voxFile, mp3File, (int)cbSamplesPerSec.SelectedValue);
            MessageBox.Show(string.Format("The result is stored in the file '{0}'. Choose next file for the converting.", mp3File), "The conversion was executed successfully");
            OpenContainingFolder(mp3File);
        }
Exemplo n.º 11
0
        public Embedding Extract(Vox vox)
        {
            var voiceTensor = new TFTensor(vox.Values);

            this.runner.AddInput(this.tfGraph[this.inputLayerName][0], voiceTensor);
            this.runner.Fetch(this.tfGraph[this.outputLayerName][0]);

            var output    = this.runner.Run();
            var result    = output[0];
            var embedding = ((float[][])result.GetValue(true))[0];

            return(new Embedding()
            {
                Length = embedding.Length, Values = embedding
            });
        }
Exemplo n.º 12
0
        public void Extract_should_extract_voice()
        {
            var values = new[]
            {
                TestsExtensions.RandomArray(512).Select(array =>
                                                        TestsExtensions.RandomArray(300).Select(value => new[] { value }).ToArray()).ToArray()
            };

            var vox = new Vox {
                Values = values
            };

            var embedding = this.embeddingExtractor.Extract(vox);

            Assert.AreEqual(128, embedding.Length);
            Assert.AreEqual(128, embedding.Values.Length);
        }
Exemplo n.º 13
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        GUILayout.Space(30);

        Vox myScript = (Vox)target;

        if (GUILayout.Button("Select File"))
        {
            myScript.file = EditorUtility.OpenFilePanel("Select Vox file", "", "vox");
        }


        GUILayout.Space(30);
        if (GUILayout.Button("Reload"))
        {
            myScript.Reload();
        }
    }
Exemplo n.º 14
0
        private static void Wav2Vox(string inFile, string outFile, int samplesPerSec, bool isResample)
        {
            WaveReader wr     = new WaveReader(File.OpenRead(inFile));
            IntPtr     format = wr.ReadFormat();

            byte[] data = wr.ReadData();
            wr.Close();
            WaveFormat wf = AudioCompressionManager.GetWaveFormat(format);

            if (wf.wFormatTag != AudioCompressionManager.PcmFormatTag)//Decode if not PCM data
            {
                Decode2Pcm(ref format, ref data, ref wf);
            }
            if (isResample && wf.nSamplesPerSec != samplesPerSec)
            {
                Resample(ref format, ref data, ref wf, samplesPerSec);
            }
            BinaryWriter bw = new BinaryWriter(File.OpenWrite(outFile));
            BinaryReader br = new BinaryReader(new MemoryStream(data));

            Vox.Raw2Vox(br, bw, wf.wBitsPerSample);
            br.Close();
            bw.Close();
        }
Exemplo n.º 15
0
 public void generateVoxels(Vox.VoxelEditor editor)
 {
     editor.wipe();
     generationParameters.setTo(editor);
     editor.initialize();
     switch (selectedGenerationMode) {
     case 0:
         editor.setToHeight();
         break;
     case 1:
         editor.setToSphere();
         break;
     case 2:
         editor.setToProcedural();
         break;
     case 3:
         editor.heightmaps = generationParameters.heightmaps;
         editor.heightmapSubstances = generationParameters.heightmapSubstances;
         editor.setToHeightmap();
         break;
     }
     editor.generateRenderers();
     setupGeneration = false;
 }
Exemplo n.º 16
0
 public void VoxInvoke()
 {
     Vox?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 17
0
    protected void doSculptGUI(Vox.VoxelEditor editor)
    {
        // brush ghost
        editor.ghostBrushAlpha = doSliderFloatField("Brush Ghost Opacity", editor.ghostBrushAlpha, 0, 1);

        editor.gridEnabled = EditorGUILayout.Toggle("Snap to Grid", editor.gridEnabled);
        if (editor.gridEnabled) {
            ++EditorGUI.indentLevel;
            editor.gridUseVoxelUnits = EditorGUILayout.Toggle("Use Voxel Units", editor.gridUseVoxelUnits);
            if (editor.gridUseVoxelUnits) {
                float voxelSize = editor.baseSize / (1 << editor.maxDetail);
                editor.gridSize = EditorGUILayout.FloatField("Grid Spacing (Voxels)", editor.gridSize /voxelSize) *voxelSize;
            } else {
                editor.gridSize = EditorGUILayout.FloatField("Grid Spacing (Meters)", editor.gridSize);
            }
            --EditorGUI.indentLevel;
        }

        // brush list
        GUILayout.Label("Brush", labelBigFont);
        editor.selectedBrush = GUILayout.Toolbar(editor.selectedBrush, brushes, GUILayout.MinHeight(20));

        // brush substance type
        string[] substances = new string[editor.voxelSubstances.Length];
        for(int i=0; i<substances.Length; ++i)
            substances[i] = editor.voxelSubstances[i].name;

        // brush size
        switch(editor.selectedBrush) {
        case 0:
            GUILayout.Label("Hold 'Shift' to subtract.");
            editor.sphereBrushSize = doSliderFloatField("Sphere Radius (m)", editor.sphereBrushSize, 0, maxBrushSize(editor));
            editor.sphereSubstanceOnly = GUILayout.Toggle(editor.sphereSubstanceOnly, "Change Substance Only");
            GUILayout.Label("Substance", labelBigFont);
            editor.sphereBrushSubstance = (byte)GUILayout.SelectionGrid(editor.sphereBrushSubstance, substances, 1);
            break;

        case 1:
            GUILayout.Label("Hold 'Shift' to subtract.");
            GUILayout.BeginHorizontal();
            GUILayout.Label("Dimensions (m)");
            editor.cubeBrushDimensions.x = EditorGUILayout.FloatField(editor.cubeBrushDimensions.x);
            editor.cubeBrushDimensions.y = EditorGUILayout.FloatField(editor.cubeBrushDimensions.y);
            editor.cubeBrushDimensions.z = EditorGUILayout.FloatField(editor.cubeBrushDimensions.z);
            GUILayout.EndHorizontal();

            editor.cubeSubstanceOnly = GUILayout.Toggle(editor.cubeSubstanceOnly, "Change Substance Only");
            GUILayout.Label("Substance", labelBigFont);
            editor.cubeBrushSubstance = (byte)GUILayout.SelectionGrid(editor.cubeBrushSubstance, substances, 1);
            break;

        case 2:
            editor.smoothBrushSize = doSliderFloatField("Radius (m)", editor.smoothBrushSize, 0, maxBrushSize(editor));
            editor.smoothBrushStrength = doSliderFloatField("Strength", editor.smoothBrushStrength, 0, 5);
            editor.smoothBrushBlurRadius = EditorGUILayout.IntField("Blur Radius", editor.smoothBrushBlurRadius);
            break;
        }

        // PATH GUI
        if(editor.selectedBrush != 0 && editor.selectedBrush != 1)
            return;
        GUILayout.Label("Path Tool", labelBigFont);

        if(editor.pathPoints != null && editor.pathPoints.Length > 0) {
            GUILayout.Label("Hold 'Control' to place another point.");
            editor.showPositionHandles = GUILayout.Toggle(editor.showPositionHandles, "Show drag handles (disable click to complete).");
            SerializedProperty prop = serializedObject.FindProperty("pathPoints");
            InspectorList.doArrayGUISimple(ref prop);
            serializedObject.ApplyModifiedProperties();
            if (GUILayout.Button("Clear Path")) {
                editor.pathPoints = null;
            } else if (GUILayout.Button("Apply Path")) {
                Vox.LocalMutator mut = (Vox.LocalMutator)buildMutator(editor, editor.pathPoints[0]);
                if (editor.pathPoints.Length > 1) {
                    new Vox.LineMutator(editor.pathPoints, mut).apply(editor);
                } else {
                    mut.apply(editor);
                }
            }
        } else {
            GUILayout.Label("Hold 'Control' to start a path.");
            if (GUILayout.Button("Start Path"))
                editor.addPathPoint(editor.transform.position);
        }
    }
Exemplo n.º 18
0
    protected Vox.Mutator buildMutator(Vox.VoxelEditor editor, Vector3 point)
    {
        // check for subtraction mode
        byte opacity = byte.MaxValue;
        if (editor.isSubtracting()) {
            opacity = byte.MinValue;
        }

        // create mutator (and maybe apply)
        switch (editor.selectedBrush) {
            case 0:
                Vox.SphereMutator sphereMod = new Vox.SphereMutator(point, editor.sphereBrushSize, new Vox.Voxel(editor.sphereBrushSubstance, opacity));
                sphereMod.overwriteShape = !editor.sphereSubstanceOnly;
                return sphereMod;
            case 1:
                Vox.CubeMutator cubeMod = new Vox.CubeMutator(editor, point, editor.cubeBrushDimensions, new Vox.Voxel(editor.cubeBrushSubstance, opacity), true);
                cubeMod.overwriteShape = !editor.cubeSubstanceOnly;
                return cubeMod;
            default:
                Vox.BlurMutator blurMod = new Vox.BlurMutator(editor, point, editor.smoothBrushSize, editor.smoothBrushStrength);
                blurMod.blurRadius = editor.smoothBrushBlurRadius;
                return blurMod;
        }
    }
Exemplo n.º 19
0
    protected void doMaskGUI(Vox.VoxelEditor editor)
    {
        editor.maskDisplayAlpha = doSliderFloatField("Mask Display Transparency", editor.maskDisplayAlpha, 0, 1);

        // mask list
        showMasks = doBigFoldout(showMasks, "Masks");
        if (showMasks) {
            SerializedProperty voxelMasks = serializedObject.FindProperty("masks");
            // EditorGUILayout.PropertyField(voxelMasks, new GUIContent("Sculpting Masks"), true);
            InspectorList.doArrayGUISimple(ref voxelMasks);
        }
    }
Exemplo n.º 20
0
        private List <MidiEvent> CreateVoxTrack(List <ZObject> voxTracks)
        {
            const int VOX_SPREAD      = 124;
            const int VOX_PUSH_PHRASE = 107;

            List <MidiEvent> track = new List <MidiEvent>();

            track.Add(new NAudio.Midi.TextEvent("PART VOCALS", MetaEventType.SequenceTrackName, 0));

            // Vox
            Vox vox = voxTracks.FirstOrDefault(x => x is Vox) as Vox;

            if (vox != null)
            {
                foreach (VoxEntry entry in vox.Events)
                {
                    long start = GetAbsoluteTime(entry.Start);
                    long end   = GetAbsoluteTime(entry.End);

                    track.Add(new NAudio.Midi.TextEvent(entry.Lyric, MetaEventType.Lyric, start));
                    track.Add(new NoteEvent(start, 1, MidiCommandCode.NoteOn, entry.Pitch, 100));
                    track.Add(new NoteEvent(end, 1, MidiCommandCode.NoteOff, entry.Pitch, 100));
                }
            }

            // VoxPushPhrase
            VoxPushPhrase pushPhrase = voxTracks.FirstOrDefault(x => x is VoxPushPhrase) as VoxPushPhrase;

            if (pushPhrase != null)
            {
                foreach (TimeEvent entry in pushPhrase.Events)
                {
                    long start = GetAbsoluteTime(entry.Start);
                    long end   = GetAbsoluteTime(entry.End);

                    track.Add(new NoteEvent(start, 1, MidiCommandCode.NoteOn, VOX_PUSH_PHRASE, 100));
                    track.Add(new NoteEvent(end, 1, MidiCommandCode.NoteOff, VOX_PUSH_PHRASE, 100));
                }
            }

            // VoxSpread
            VoxSpread spread = voxTracks.FirstOrDefault(x => x is VoxSpread) as VoxSpread;

            if (spread != null)
            {
                foreach (SpreadEntry entry in spread.Events)
                {
                    long start = GetAbsoluteTime(entry.Start);
                    long end   = GetAbsoluteTime(entry.End);

                    // Should be increments of 0.25f
                    int value = (int)((entry.Speed - 1.0f) / 0.25f);

                    track.Add(new NoteEvent(start, 1, MidiCommandCode.NoteOn, VOX_SPREAD, 100 + value));
                    track.Add(new NoteEvent(end, 1, MidiCommandCode.NoteOff, VOX_SPREAD, 100 + value));
                }
            }

            // Sort by absolute time (And ensure track name is first event)
            track.Sort((x, y) => (int)(x is NAudio.Midi.TextEvent &&
                                       ((NAudio.Midi.TextEvent)x).MetaEventType == MetaEventType.SequenceTrackName
                                       ? int.MinValue : x.AbsoluteTime - y.AbsoluteTime));

            // Adds end track
            track.Add(new MetaEvent(MetaEventType.EndTrack, 0, track.Last().AbsoluteTime));
            return(track);
        }
Exemplo n.º 21
0
    protected void doGenerationGUI(Vox.VoxelEditor editor)
    {
        GUILayout.Label ("Properties", labelBigFont);
        doTreeSizeGUI(generationParameters);

        // general properties
        doGeneralPropertiesGUI(generationParameters);

        // substances
        doSubstancesGUI(serializedObject);

        // generation mode
        GUILayout.Label("Generation Mode", labelBigFont);
        selectedGenerationMode = GUILayout.Toolbar(selectedGenerationMode, generationModes);
        switch(selectedGenerationMode) {
        case 0:
            doFlatGenerationGUI();
            break;
        case 1:
            doSphereGenerationGUI();
            break;
        case 2:
            doProceduralGenerationGUI();
            break;
        case 3:
            doHeightmapGenerationGUI();
            break;
        }

        // confirmation
        GUILayout.Label ("Confirmation", labelBigFont);
        if (GUILayout.Button("Generate", buttonBigFont) && validateSubstances(editor)) {
            if (EditorUtility.DisplayDialog("Generate Voxels?", "Are you sure you want to generate the voxel terain from scratch?  Any previous work will be overriden.", "Generate", "Cancel")) {
                generateVoxels(editor);
            }
        }
        if (GUILayout.Button("Cancel Generation", buttonBigFont)) {
            setupGeneration = false;
        }
        EditorGUILayout.Separator();
    }
Exemplo n.º 22
0
    private void exportToXML(XmlDocument xmlDoc, Transform currentObject, XmlNode parent)
    {
        XmlNode node = null;

        if (currentObject.GetComponent <CommentElement>() != null)
        {
            CommentElement commentElement = (CommentElement)currentObject.GetComponent <CommentElement>();

            node = xmlDoc.CreateComment(commentElement.comment);
        }
        else if (currentObject.GetComponent <Scene>() != null)
        {
            Scene tag = (Scene)currentObject.GetComponent <Scene>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "scene", "");

            enrichXmlWithGeneralAttributes(xmlDoc, tag, node);

            XmlAttribute version = xmlDoc.CreateAttribute("version");
            version.Value = tag.version.ToString().Replace(",", ".");;
            node.Attributes.Append(version);

            XmlAttribute shadowvolume = xmlDoc.CreateAttribute("shadowVolume");
            shadowvolume.Value = $"{tag.shadowVolume.x} {tag.shadowVolume.y} {tag.shadowVolume.z}".Replace(",", ".");;
            node.Attributes.Append(shadowvolume);
        }
        else if (currentObject.GetComponent <TeardownEnvironment>() != null)
        {
            TeardownEnvironment tag = (TeardownEnvironment)currentObject.GetComponent <TeardownEnvironment>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "environment", "");
            enrichXmlWithGeneralAttributes(xmlDoc, tag, node);

            XmlAttribute attribute = xmlDoc.CreateAttribute("template");
            attribute.Value = tag.template.ToString().ToLower();
            node.Attributes.Append(attribute);

            attribute       = xmlDoc.CreateAttribute("skyboxrot");
            attribute.Value = tag.skyboxrot.ToString().Replace(",", ".");;
            node.Attributes.Append(attribute);

            if (tag.sunDir != null && !$"{tag.sunDir.x} {tag.sunDir.y} {tag.sunDir.z}".Equals("0 0 0"))
            {
                attribute       = xmlDoc.CreateAttribute("sunDir");
                attribute.Value = $"{tag.sunDir.x} {tag.sunDir.y} {tag.sunDir.z}".Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (tag.sunBrightness >= 0)
            {
                attribute       = xmlDoc.CreateAttribute("sunBrightness");
                attribute.Value = tag.sunBrightness.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (tag.sunFogScale >= 0)
            {
                attribute       = xmlDoc.CreateAttribute("sunFogScale");
                attribute.Value = tag.sunFogScale.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            attribute       = xmlDoc.CreateAttribute("sunColorTint");
            attribute.Value = $"{tag.sunColorTint.r} {tag.sunColorTint.g} {tag.sunColorTint.b}".Replace(",", ".");
            node.Attributes.Append(attribute);
        }
        else if (currentObject.GetComponent <Body>() != null)
        {
            Body tag = (Body)currentObject.GetComponent <Body>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "body", "");
            enrichXmlWithGameObjectAttributes(xmlDoc, tag, node);

            XmlAttribute attribute = xmlDoc.CreateAttribute("dynamic");
            attribute.Value = tag.dynamic ? "true" : "false";
            node.Attributes.Append(attribute);
        }
        else if (currentObject.GetComponent <Boundary>() != null)
        {
            Boundary tag = (Boundary)currentObject.GetComponent <Boundary>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "boundary", "");
            enrichXmlWithGeneralAttributes(xmlDoc, tag, node);
        }
        else if (currentObject.GetComponent <Vertex>() != null)
        {
            Vertex tag = (Vertex)currentObject.GetComponent <Vertex>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "vertex", "");
            enrichXmlWithGeneralAttributes(xmlDoc, tag, node);

            XmlAttribute attribute = xmlDoc.CreateAttribute("pos");
            attribute.Value = $"{tag.pos.x} {tag.pos.y}".Replace(",", ".");;
            node.Attributes.Append(attribute);
        }
        else if (currentObject.GetComponent <Script>() != null)
        {
            Script tag = (Script)currentObject.GetComponent <Script>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "script", "");
            enrichXmlWithGeneralAttributes(xmlDoc, tag, node);

            XmlAttribute attribute = xmlDoc.CreateAttribute("file");
            attribute.Value = tag.file.Replace(XmlImporter.getLevelFolder(tag.file), "LEVEL");
            node.Attributes.Append(attribute);
        }
        else if (currentObject.GetComponent <Instance>() != null)
        {
            Instance tag = (Instance)currentObject.GetComponent <Instance>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "instance", "");
            enrichXmlWithGeneralAttributes(xmlDoc, tag, node);

            XmlAttribute attribute = xmlDoc.CreateAttribute("file");
            attribute.Value = tag.file.Replace(XmlImporter.getLevelFolder(tag.file), "LEVEL");
            node.Attributes.Append(attribute);
        }
        else if (currentObject.GetComponent <SpawnPoint>() != null)
        {
            SpawnPoint tag = (SpawnPoint)currentObject.GetComponent <SpawnPoint>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "spawnpoint", "");
            enrichXmlWithTransformAttributes(xmlDoc, tag, node);
        }
        else if (currentObject.GetComponent <Location>() != null)
        {
            Location tag = (Location)currentObject.GetComponent <Location>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "location", "");
            enrichXmlWithTransformAttributes(xmlDoc, tag, node);
        }
        else if (currentObject.GetComponent <Group>() != null)
        {
            Group tag = (Group)currentObject.GetComponent <Group>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "group", "");
            enrichXmlWithTransformAttributes(xmlDoc, tag, node);
        }
        else if (currentObject.GetComponent <Water>() != null)
        {
            Water tag = (Water)currentObject.GetComponent <Water>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "water", "");
            enrichXmlWithTransformAttributes(xmlDoc, tag, node);

            XmlAttribute attribute = xmlDoc.CreateAttribute("size");
            attribute.Value = $"{tag.size.x} {tag.size.y}".Replace(",", ".");
            node.Attributes.Append(attribute);

            if (tag.wave > -1)
            {
                attribute       = xmlDoc.CreateAttribute("wave");
                attribute.Value = tag.wave.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (tag.ripple > -1)
            {
                attribute       = xmlDoc.CreateAttribute("ripple");
                attribute.Value = tag.ripple.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (tag.foam > -1)
            {
                attribute       = xmlDoc.CreateAttribute("foam");
                attribute.Value = tag.foam.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (tag.motion > -1)
            {
                attribute       = xmlDoc.CreateAttribute("motion");
                attribute.Value = tag.motion.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (!String.IsNullOrEmpty(tag.type))
            {
                attribute       = xmlDoc.CreateAttribute("type");
                attribute.Value = tag.type.ToString().ToLower();
                node.Attributes.Append(attribute);
            }
        }
        else if (currentObject.GetComponent <Screen>() != null)
        {
            Screen tag = (Screen)currentObject.GetComponent <Screen>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "water", "");
            enrichXmlWithTransformAttributes(xmlDoc, tag, node);

            XmlAttribute attribute = xmlDoc.CreateAttribute("size");
            attribute.Value = $"{tag.size.x} {tag.size.y}".Replace(",", ".");
            node.Attributes.Append(attribute);

            if (!tag.resolution.Equals(Vector2.zero))
            {
                attribute       = xmlDoc.CreateAttribute("resolution");
                attribute.Value = $"{tag.resolution.x} {tag.resolution.y}".Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (!tag.bulge.Equals(Vector2.zero))
            {
                attribute       = xmlDoc.CreateAttribute("bulge");
                attribute.Value = $"{tag.bulge.x} {tag.bulge.y}".Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (!String.IsNullOrEmpty(tag.script))
            {
                attribute       = xmlDoc.CreateAttribute("script");
                attribute.Value = tag.script;
                node.Attributes.Append(attribute);
            }

            attribute       = xmlDoc.CreateAttribute("color");
            attribute.Value = $"{tag.color.r} {tag.color.g} {tag.color.b}".Replace(",", ".");
            node.Attributes.Append(attribute);

            attribute       = xmlDoc.CreateAttribute("enabled");
            attribute.Value = tag.enabled ? "true" : "false";
            node.Attributes.Append(attribute);

            attribute       = xmlDoc.CreateAttribute("interactive");
            attribute.Value = tag.interactive ? "true" : "false";
            node.Attributes.Append(attribute);

            if (tag.emissive > -1)
            {
                attribute       = xmlDoc.CreateAttribute("resolution");
                attribute.Value = tag.emissive.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }
        }
        else if (currentObject.GetComponent <Light>() != null)
        {
            Light tag = (Light)currentObject.GetComponent <Light>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "light", "");
            enrichXmlWithTransformAttributes(xmlDoc, tag, node);

            XmlAttribute attribute = xmlDoc.CreateAttribute("type");
            attribute.Value = tag.type.ToString().ToLower();
            node.Attributes.Append(attribute);

            if (tag.glare > -1)
            {
                attribute       = xmlDoc.CreateAttribute("glare");
                attribute.Value = tag.glare.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            attribute       = xmlDoc.CreateAttribute("angle");
            attribute.Value = tag.angle.ToString().Replace(",", ".");
            node.Attributes.Append(attribute);

            if (tag.penumbra > -1)
            {
                attribute       = xmlDoc.CreateAttribute("penumbra");
                attribute.Value = tag.penumbra.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (tag.unshadowed > -1)
            {
                attribute       = xmlDoc.CreateAttribute("unshadowed");
                attribute.Value = tag.unshadowed.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            attribute       = xmlDoc.CreateAttribute("color");
            attribute.Value = $"{tag.color.r} {tag.color.g} {tag.color.b}".Replace(",", ".");
            node.Attributes.Append(attribute);
        }
        else if (currentObject.GetComponent <Rope>() != null)
        {
            Rope tag = (Rope)currentObject.GetComponent <Rope>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "rope", "");
            enrichXmlWithTransformAttributes(xmlDoc, tag, node);

            if (tag.slack > -1)
            {
                XmlAttribute attribute = xmlDoc.CreateAttribute("friction");
                attribute.Value = tag.slack.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (tag.strength > -1)
            {
                XmlAttribute attribute = xmlDoc.CreateAttribute("steerassist");
                attribute.Value = tag.strength.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }
        }
        else if (currentObject.GetComponent <Wheel>() != null)
        {
            Wheel tag = (Wheel)currentObject.GetComponent <Wheel>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "wheel", "");
            enrichXmlWithTransformAttributes(xmlDoc, tag, node);

            XmlAttribute attribute = xmlDoc.CreateAttribute("drive");
            attribute.Value = tag.drive.ToString().Replace(",", ".");
            node.Attributes.Append(attribute);

            attribute       = xmlDoc.CreateAttribute("steer");
            attribute.Value = tag.steer.ToString().Replace(",", ".");
            node.Attributes.Append(attribute);

            attribute       = xmlDoc.CreateAttribute("travel");
            attribute.Value = $"{tag.travel.x} {tag.travel.y}".Replace(",", ".");
            node.Attributes.Append(attribute);
        }
        else if (currentObject.GetComponent <Vehicle>() != null)
        {
            Vehicle tag = (Vehicle)currentObject.GetComponent <Vehicle>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "vehicle", "");
            enrichXmlWithGameObjectAttributes(xmlDoc, tag, node);

            XmlAttribute attribute = xmlDoc.CreateAttribute("driven");
            attribute.Value = tag.driven ? "true" : "false";
            node.Attributes.Append(attribute);

            if (tag.friction > -1)
            {
                attribute       = xmlDoc.CreateAttribute("friction");
                attribute.Value = tag.friction.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (tag.steerassist > -1)
            {
                attribute       = xmlDoc.CreateAttribute("steerassist");
                attribute.Value = tag.steerassist.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (tag.difflock > -1)
            {
                attribute       = xmlDoc.CreateAttribute("difflock");
                attribute.Value = tag.difflock.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (tag.antiroll > -1)
            {
                attribute       = xmlDoc.CreateAttribute("antiroll");
                attribute.Value = tag.antiroll.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (tag.antispin > -1)
            {
                attribute       = xmlDoc.CreateAttribute("antispin");
                attribute.Value = tag.antispin.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }


            if (tag.acceleration > -1)
            {
                attribute       = xmlDoc.CreateAttribute("acceleration");
                attribute.Value = tag.acceleration.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (tag.spring > -1)
            {
                attribute       = xmlDoc.CreateAttribute("spring");
                attribute.Value = tag.spring.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (tag.damping > -1)
            {
                attribute       = xmlDoc.CreateAttribute("damping");
                attribute.Value = tag.damping.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            if (tag.topspeed > -1)
            {
                attribute       = xmlDoc.CreateAttribute("topspeed");
                attribute.Value = tag.topspeed.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            attribute       = xmlDoc.CreateAttribute("sound");
            attribute.Value = tag.sound;
            node.Attributes.Append(attribute);
        }
        else if (currentObject.GetComponent <Vox>() != null)
        {
            Vox tag = (Vox)currentObject.GetComponent <Vox>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "vox", "");
            enrichXmlWithGameObjectAttributes(xmlDoc, tag, node);

            XmlAttribute attribute = xmlDoc.CreateAttribute("file");
            attribute.Value = tag.file.Replace(XmlImporter.getLevelFolder(tag.file), "LEVEL");
            node.Attributes.Append(attribute);

            if (!String.IsNullOrEmpty(tag.voxObject))
            {
                attribute       = xmlDoc.CreateAttribute("object");
                attribute.Value = tag.voxObject;
                node.Attributes.Append(attribute);
            }


            attribute       = xmlDoc.CreateAttribute("prop");
            attribute.Value = tag.dynamic ? "true" : "false";
            node.Attributes.Append(attribute);
        }
        else if (currentObject.GetComponent <VoxBox>() != null)
        {
            VoxBox tag = (VoxBox)currentObject.GetComponent <VoxBox>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "voxbox", "");
            enrichXmlWithGameObjectAttributes(xmlDoc, tag, node);
            Debug.Log(tag.position);

            XmlAttribute attribute = xmlDoc.CreateAttribute("color");
            attribute.Value = $"{tag.color.r} {tag.color.g} {tag.color.b}".Replace(",", ".");
            node.Attributes.Append(attribute);

            attribute       = xmlDoc.CreateAttribute("prop");
            attribute.Value = tag.dynamic ? "true" : "false";
            node.Attributes.Append(attribute);
        }
        else if (currentObject.GetComponent <TeardownJoint>() != null)
        {
            TeardownJoint tag = (TeardownJoint)currentObject.GetComponent <TeardownJoint>();
            node = xmlDoc.CreateNode(XmlNodeType.Element, "joint", "");
            enrichXmlWithTransformAttributes(xmlDoc, tag, node);

            XmlAttribute attribute = xmlDoc.CreateAttribute("type");
            attribute.Value = tag.type.ToString().ToLower();
            node.Attributes.Append(attribute);

            if (tag.limits != null && !$"{tag.limits.x} {tag.limits.y}".Replace(",", ".").Equals("0 0"))
            {
                attribute       = xmlDoc.CreateAttribute("limits");
                attribute.Value = $"{tag.limits.x} {tag.limits.y}".Replace(",", ".");
                node.Attributes.Append(attribute);
            }

            attribute       = xmlDoc.CreateAttribute("size");
            attribute.Value = tag.size.ToString().Replace(",", ".");
            node.Attributes.Append(attribute);

            if (tag.rotstrength >= 0)
            {
                attribute       = xmlDoc.CreateAttribute("rotstrength");
                attribute.Value = tag.rotstrength.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }
            if (tag.rotspring >= 0)
            {
                attribute       = xmlDoc.CreateAttribute("rotspring");
                attribute.Value = tag.rotspring.ToString().Replace(",", ".");
                node.Attributes.Append(attribute);
            }
        }

        if (node != null)
        {
            foreach (Transform child in currentObject)
            {
                exportToXML(xmlDoc, child, node);
            }

            if (parent == null)
            {
                xmlDoc.AppendChild(node);
            }
            else
            {
                parent.AppendChild(node);
            }
        }
    }
Exemplo n.º 23
0
    GameObject readXmlNode(XmlNode xmlNode, GameObject parent, string fileName)
    {
        GameObject go = new GameObject(xmlNode.Name);

        if (parent != null)
        {
            go.transform.parent = parent.transform;
        }

        if (xmlNode.NodeType == XmlNodeType.Comment)
        {
            CommentElement comment = go.AddComponent <CommentElement>();
            go.transform.parent = parent.transform;

            comment.comment = xmlNode.InnerText;
        }
        else if (xmlNode.Name == "vehicle")
        {
            Vehicle tag = go.AddComponent <Vehicle>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.sound        = readString(xmlNode, "sound");
            tag.spring       = readFloat(xmlNode, "spring");
            tag.acceleration = readFloat(xmlNode, "acceleration");
            tag.antiroll     = readFloat(xmlNode, "antiroll");
            tag.damping      = readFloat(xmlNode, "damping");
            tag.friction     = readFloat(xmlNode, "friction");
            tag.difflock     = readFloat(xmlNode, "difflock");
            tag.steerassist  = readFloat(xmlNode, "steerassist");
            tag.topspeed     = readFloat(xmlNode, "topspeed");
            tag.driven       = readBool(xmlNode, "driven", false);
            tag.antispin     = readFloat(xmlNode, "antispin");
            tag.soundVolume  = readFloat(xmlNode, "soundvolume");

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "wheel")
        {
            Wheel tag = go.AddComponent <Wheel>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.steer  = readFloat(xmlNode, "steer");
            tag.drive  = readFloat(xmlNode, "drive");
            tag.travel = readVec2(xmlNode, "travel");
            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "spawnpoint")
        {
            SpawnPoint tag = go.AddComponent <SpawnPoint>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "location")
        {
            Location tag = go.AddComponent <Location>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "group")
        {
            Group tag = go.AddComponent <Group>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "rope")
        {
            Rope tag = go.AddComponent <Rope>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;

            tag.strength = readFloat(xmlNode, "strength");
            tag.slack    = readFloat(xmlNode, "slack");

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "screen")
        {
            Screen tag = go.AddComponent <Screen>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;

            tag.size        = readVec2(xmlNode, "size");
            tag.isEnabled   = readBool(xmlNode, "enabled", false);
            tag.interactive = readBool(xmlNode, "interactive", false);
            tag.emissive    = readFloat(xmlNode, "emissive");
            tag.color       = readColor(xmlNode, "color");
            tag.resolution  = readVec2(xmlNode, "resolution");
            tag.bulge       = readVec2(xmlNode, "bulge");
            tag.script      = readString(xmlNode, "script");
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "vox")
        {
            Vox tag = go.AddComponent <Vox>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            tag.file      = readString(xmlNode, "file").Replace("LEVEL", getLevelFolder(fileName));;
            tag.voxObject = readString(xmlNode, "object");
            tag.dynamic   = readBool(xmlNode, "prop", false);

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;

            tag.Reload();

            if (tag.scale > 0)
            {
                go.transform.localScale *= tag.scale;
            }

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "joint")
        {
            TeardownJoint tag = go.AddComponent <TeardownJoint>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.type        = (TeardownJoint.Type)Enum.Parse(typeof(TeardownJoint.Type), readString(xmlNode, "type", "ball"), false);
            tag.size        = readFloat(xmlNode, "size");
            tag.rotspring   = readFloat(xmlNode, "rotspring");
            tag.rotstrength = readFloat(xmlNode, "rotstrength");
            tag.limits      = readVec2(xmlNode, "limits");

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "voxbox")
        {
            VoxBox tag = go.AddComponent <VoxBox>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.color   = readColor(xmlNode, "color");
            tag.dynamic = readBool(xmlNode, "prop", false);
            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;

            GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            cube.transform.parent        = go.transform;
            cube.transform.localPosition = new Vector3(0.5f, 0.5f, -0.5f);
            cube.transform.localRotation = Quaternion.identity;
            cube.GetComponent <MeshRenderer>().sharedMaterial = new Material(Shader.Find("Standard"));
            go.transform.localScale = tag.size / 10;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "body")
        {
            Body tag = go.AddComponent <Body>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.dynamic = readBool(xmlNode, "dynamic", false);
            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "water")
        {
            go.name = "<" + xmlNode.Name + ">";
            Water tag = go.AddComponent <Water>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "environment")
        {
            TeardownEnvironment tag = go.AddComponent <TeardownEnvironment>();
            go.transform.parent = parent.transform;

            attachGeneralProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.skyboxrot     = readFloat(xmlNode, "skyboxrot");
            tag.sunBrightness = readFloat(xmlNode, "sunBrightness");
            tag.sunFogScale   = readFloat(xmlNode, "sunFogScale");
            tag.sunDir        = readVec3(xmlNode, "sunDir");
            tag.sunColorTint  = readColor(xmlNode, "sunColorTint");

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "scene")
        {
            Scene tag = go.AddComponent <Scene>();

            go.transform.parent = parent.transform;
            attachGeneralProperties(tag, xmlNode);

            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.shadowVolume = readVec3(xmlNode, "shadowVolume");
            tag.version      = readInt(xmlNode, "version");

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "boundary")
        {
            Boundary tag = go.AddComponent <Boundary>();
            attachGeneralProperties(tag, xmlNode);
            go.transform.parent = parent.transform;
            go.name             = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "script")
        {
            Script tag = go.AddComponent <Script>();
            attachGeneralProperties(tag, xmlNode);
            go.transform.parent = parent.transform;

            tag.file = readString(xmlNode, "file");
            go.name  = "<" + xmlNode.Name + " " + tag.teardownName + " " + tag.file + ">";

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "instance")
        {
            Instance tag = go.AddComponent <Instance>();
            go.transform.parent = parent.transform;
            attachGeneralProperties(tag, xmlNode);

            tag.file = readString(xmlNode, "file");
            go.name  = "<" + xmlNode.Name + " " + tag.teardownName + " " + tag.file + ">";

            if (!fileName.Contains("create") && tag.file.StartsWith("LEVEL"))
            {
                Debug.LogError("Your source file has no create folder in its path but an instance is referencing the level folder. Cannot import!");
            }
            else if (!tag.file.StartsWith("LEVEL"))
            {
                GameObject xmlRoot = readXML(tag.file);
                xmlRoot.GetComponentInChildren <Prefab>().gameObject.transform.transform.parent = go.transform;
                DestroyImmediate(xmlRoot);
            }
            else
            {
                GameObject xmlRoot = readXML(tag.file.Replace("LEVEL", getLevelFolder(fileName)));
                xmlRoot.GetComponentInChildren <Prefab>().gameObject.transform.transform.parent = go.transform;
                DestroyImmediate(xmlRoot);
            }
            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "prefab")
        {
            Prefab tag = go.AddComponent <Prefab>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "vertex")
        {
            Vertex tag = go.AddComponent <Vertex>();
            go.transform.parent = parent.transform;
            attachGeneralProperties(tag, xmlNode);
            tag.pos = readVec2(xmlNode, "pos");

            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";
            go.transform.localPosition = new Vector3(tag.pos.x, 0, tag.pos.y);

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "light")
        {
            Light tag = go.AddComponent <Light>();
            go.transform.parent = parent.transform;

            attachGeneralProperties(tag, xmlNode);
            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.penumbra   = readFloat(xmlNode, "penumbra");
            tag.unshadowed = readFloat(xmlNode, "unshadowed");
            tag.angle      = readFloat(xmlNode, "angle");
            tag.glare      = readFloat(xmlNode, "glare");
            tag.color      = readColor(xmlNode, "color");
            tag.type       = (Light.Type)Enum.Parse(typeof(Light.Type), readString(xmlNode, "type", "area"), false);

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }

        foreach (XmlNode child in xmlNode.ChildNodes)
        {
            GameObject childGameObject = readXmlNode(child, go, fileName);
        }

        return(go);
    }
Exemplo n.º 24
0
 protected static void addBrush(Vox.VoxelEditor editor, Ray mouseLocation)
 {
     Vector3 point = Vox.VoxelEditor.getRayCollision(mouseLocation).point;
     switch(editor.selectedBrush) {
     case 0:
         new Vox.SphereModifier(editor, point, editor.sphereBrushSize, new Vox.Voxel(editor.sphereBrushSubstance, byte.MaxValue), true);
         break;
     case 1:
         new Vox.CubeModifier(editor, point, editor.cubeBrushDimensions, new Vox.Voxel(editor.cubeBrushSubstance, byte.MaxValue), true);
         break;
     }
 }
 /// <summary>
 /// Cannot remove a existing batch via the repository
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public bool Remove(Vox.Auditing.Model.Batch entity)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Updates an existing batch entity (Normally this will be to set the end date on the batch)
 /// </summary>
 /// <param name="entity">Batch to update</param>
 /// <returns>True if the batch was altered</returns>
 public bool Update(Vox.Auditing.Model.Batch entity)
 {
     if (entity == null) { throw new ArgumentNullException("entity"); }
       if (entity.ID == 0) { throw new InvalidBatchException("Cannot updated a batch which has not been added!"); }
       if (entity.ClientID == 0) { throw new InvalidBatchException("Cannot update a batch with no valid client!"); }
       bool updated = false;
       // Check if the batch is valid first
       using (DataModel.VoxAuditingEntities context = new DataModel.VoxAuditingEntities(connectionString)) {
     // Check that no existing batches are open for the current client ID
     var validBatch = from m in context.Batches
                  where m.BatchID == entity.ID
                  select m;
     if (validBatch.Count() == 1) {
       DataModel.Batch selectBatch = validBatch.First();
       selectBatch.FinishDate = entity.FinishDate;
       updated = context.SaveChanges() != 0;
     } else {
       throw new InvalidBatchException(string.Format("Batch '{0}' does not exist", entity.Number));
     }
       }
       return updated;
 }
Exemplo n.º 27
0
 protected static void applyBrush(Vox.VoxelEditor editor, Ray mouseLocation)
 {
     byte opacity = byte.MaxValue;
     if (UnityEngine.Event.current.shift) {
         opacity = byte.MinValue;
     }
     Vector3 point = editor.getBrushPoint(mouseLocation);
     switch(editor.selectedBrush) {
     case 0:
         Vox.SphereModifier sphereMod = new Vox.SphereModifier(editor, point, editor.sphereBrushSize, new Vox.Voxel(editor.sphereBrushSubstance, opacity), true);
         sphereMod.overwriteShape = !editor.sphereSubstanceOnly;
         sphereMod.apply();
         break;
     case 1:
         Vox.CubeModifier cubeMod = new Vox.CubeModifier(editor, point, editor.cubeBrushDimensions, new Vox.Voxel(editor.cubeBrushSubstance, opacity), true);
         cubeMod.overwriteShape = !editor.cubeSubstanceOnly;
         cubeMod.apply();
         break;
     case 2:
         Vox.BlurModifier blur = new Vox.BlurModifier(editor, point, editor.smoothBrushSize, editor.smoothBrushStrength, true);
         blur.blurRadius = editor.smoothBrushBlurRadius;
         blur.apply();
         break;
     }
 }
 public void setTo(Vox.VoxelEditor editor)
 {
     editor.width = baseSize;
     editor.maximumDetail = maxDetail;
     editor.maxChange = maxChange;
     editor.proceduralSeed = proceduralSeed;
     editor.createColliders = createColliders;
     editor.useStaticMeshes = useStaticMeshes;
     editor.saveMeshes = saveMeshes;
     editor.reduceMeshes = reduceMeshes;
     editor.reductionAmount = reductionAmount;
     editor.heightPercentage = heightPercentage;
     editor.spherePercentage = spherePercentage;
 }
Exemplo n.º 29
0
 protected void doGeneralPropertiesGUI(Vox.VoxelEditor editor)
 {
     editor.createColliders = EditorGUILayout.Toggle(new GUIContent("Generate Colliders"), editor.createColliders);
     editor.useStaticMeshes = EditorGUILayout.Toggle(new GUIContent("Use Static Meshes"), editor.useStaticMeshes);
     editor.saveMeshes = EditorGUILayout.Toggle(new GUIContent("Save Meshes To Scene"), editor.saveMeshes);
     editor.reduceMeshes = EditorGUILayout.Toggle(new GUIContent("Reduce Meshes"), editor.reduceMeshes);
     if (editor.reduceMeshes) {
         editor.reductionAmount = doSliderFloatField("Mesh Reduction Level", editor.reductionAmount, 0, 0.5f);
     }
     //editor.maxDetail = (byte)EditorGUILayout.IntField(new GUIContent("Voxel Power"), editor.maxDetail);
     // if (createColliders != editor.createColliders || useStaticMeshes != editor.useStaticMeshes) {
     // 	editor.createColliders = createColliders;
     // 	editor.useStaticMeshes = useStaticMeshes;
     //     editor.generateRenderers();
     // }
 }
Exemplo n.º 30
0
 protected bool validateSubstances(Vox.VoxelEditor editor)
 {
     if (editor.voxelSubstances == null || editor.voxelSubstances.Length < 1) {
         EditorUtility.DisplayDialog("Invalid Substances", "There must be at least one voxel substance defined to generate the voxel object.", "OK");
         return false;
     }
     int i = 1;
     foreach(Vox.VoxelSubstance sub in editor.voxelSubstances) {
         if (sub.renderMaterial == null || sub.blendMaterial == null) {
             EditorUtility.DisplayDialog("Invalid Substance", "Substance " +i +", " +sub.name +", must have a render material and a blend material set.", "OK");
             return false;
         }
         ++i;
     }
     return true;
 }
Exemplo n.º 31
0
    protected void doManageGUI(Vox.VoxelEditor editor)
    {
        // actions
        GUILayout.Label ("Actions", labelBigFont);
        if (GUILayout.Button("Generate New")) {
            setupGeneration = true;
            generationParameters = new VoxelEditorParameters();
            generationParameters.setFrom(editor);
        }
        if (editor.hasVoxelData()) {
            if (GUILayout.Button("Erase")) {
                if (EditorUtility.DisplayDialog("Erase Voxels?", "Are you sure you want to erase all voxel data?", "Erase", "Cancel")) {
                    editor.wipe();
                }
            }
            if (GUILayout.Button(editor.hasRenderers()? "Reskin": "Skin", buttonBigFont) && validateSubstances(editor)) {
                editor.generateRenderers();
            }
            if (editor.hasRenderers() && GUILayout.Button("Clear Skin") && validateSubstances(editor)) {
                editor.clearRenderers();
            }
            if (GUILayout.Button("Export")) {
                editor.export(EditorUtility.SaveFilePanel("Choose File to Export To", "", "Voxels", "vox"));
            }
        }
        if (GUILayout.Button("Import")) {
            if (!editor.import(EditorUtility.OpenFilePanel("Choose File to Import From", "", "vox"))) {
                EditorUtility.DisplayDialog("Wrong Voxel Format", "The file you chose was an unknown or incompatible voxel format version.", "OK");
            }
        }

        if (!editor.hasVoxelData())
            return;

        GUILayout.Label("Properties", labelBigFont);

        doGeneralPropertiesGUI(editor);

        // TODO: implement LOD and uncomment this
        //		// LOD
        //		SerializedProperty useLod = ob.FindProperty("useLod");
        //		EditorGUILayout.PropertyField(useLod, new GUIContent("Use Level of Detail"));
        //		if (useLod.boolValue) {
        //			++EditorGUI.indentLevel;
        //			SerializedProperty lodDetail = ob.FindProperty("lodDetail");
        //			EditorGUILayout.PropertyField(lodDetail, new GUIContent("Target Level of Detail"));
        //			if (lodDetail.floatValue > 1000)
        //				lodDetail.floatValue = 1000;
        //			else if (lodDetail.floatValue < 0.1f)
        //				lodDetail.floatValue = 0.1f;
        //
        //			SerializedProperty curLodDetail = ob.FindProperty("curLodDetail");
        //			if (Application.isPlaying) {
        //				EditorGUILayout.PropertyField(curLodDetail, new GUIContent("Current Level of Detail"));
        //			} else {
        //				EditorGUILayout.PropertyField(curLodDetail, new GUIContent("Starting Level of Detail"));
        //			}
        //
        //			if (curLodDetail.floatValue > 1000)
        //				curLodDetail.floatValue = 1000;
        //			else if (curLodDetail.floatValue < 0.1f)
        //				curLodDetail.floatValue = 0.1f;
        //			--EditorGUI.indentLevel;
        //		}

        // do substances
        doSubstancesGUI(serializedObject);

        // show statistics
        showStatistics = doBigFoldout(showStatistics, "Statistics");
        if (showStatistics) {
            EditorGUILayout.LabelField("Chunk Count: " + editor.renderers.Count);
            doTreeSizeGUI(editor);
            EditorGUILayout.LabelField("Vertex Count: " + editor.vertexCount);
            EditorGUILayout.LabelField("Triangle Count: " + editor.triangleCount);
        }
    }
Exemplo n.º 32
0
 public void setTo(Vox.VoxelEditor editor)
 {
     editor.baseSize = baseSize;
     editor.maxDetail = maxDetail;
     editor.createColliders = createColliders;
     editor.useStaticMeshes = useStaticMeshes;
     editor.saveMeshes = saveMeshes;
     editor.reduceMeshes = reduceMeshes;
     editor.reductionAmount = reductionAmount;
     editor.heightPercentage = heightPercentage;
     editor.spherePercentage = spherePercentage;
 }
Exemplo n.º 33
0
    protected void doSculptGUI(Vox.VoxelEditor editor)
    {
        // brush ghost
        editor.ghostBrushAlpha = doSliderFloatField("Brush Ghost Opacity", editor.ghostBrushAlpha, 0, 1);

        editor.gridEnabled = EditorGUILayout.Toggle("Snap to Grid", editor.gridEnabled);
        if (editor.gridEnabled) {
            ++EditorGUI.indentLevel;
            editor.gridUseVoxelUnits = EditorGUILayout.Toggle("Use Voxel Units", editor.gridUseVoxelUnits);
            if (editor.gridUseVoxelUnits) {
                float voxelSize = editor.baseSize / (1 << editor.maxDetail);
                editor.gridSize = EditorGUILayout.FloatField("Grid Spacing (Voxels)", editor.gridSize /voxelSize) *voxelSize;
            } else {
                editor.gridSize = EditorGUILayout.FloatField("Grid Spacing (Meters)", editor.gridSize);
            }
            --EditorGUI.indentLevel;
        }

        // brush list
        GUILayout.Label("Brush", labelBigFont);
        editor.selectedBrush = GUILayout.Toolbar(editor.selectedBrush, brushes, GUILayout.MinHeight(20));

        // brush substance type
        string[] substances = new string[editor.voxelSubstances.Length];
        for(int i=0; i<substances.Length; ++i)
            substances[i] = editor.voxelSubstances[i].name;

        // brush size
        switch(editor.selectedBrush) {
        case 0:
            GUILayout.Label("Hold 'Shift' to subtract.");
            editor.sphereBrushSize = doSliderFloatField("Sphere Radius (m)", editor.sphereBrushSize, 0, 100);
            editor.sphereSubstanceOnly = GUILayout.Toggle(editor.sphereSubstanceOnly, "Change Substance Only");
            GUILayout.Label("Substance", labelBigFont);
            editor.sphereBrushSubstance = (byte)GUILayout.SelectionGrid(editor.sphereBrushSubstance, substances, 1);
            break;

        case 1:
            GUILayout.Label("Hold 'Shift' to subtract.");
            GUILayout.BeginHorizontal();
            GUILayout.Label("Dimensions (m)");
            editor.cubeBrushDimensions.x = EditorGUILayout.FloatField(editor.cubeBrushDimensions.x);
            editor.cubeBrushDimensions.y = EditorGUILayout.FloatField(editor.cubeBrushDimensions.y);
            editor.cubeBrushDimensions.z = EditorGUILayout.FloatField(editor.cubeBrushDimensions.z);
        //			SerializedProperty cubeBrushDimensions = ob.FindProperty("cubeBrushDimensions");
        //			EditorGUILayout.PropertyField(cubeBrushDimensions, new GUIContent("Rectangle Brush Dimensions"), true);
            GUILayout.EndHorizontal();

            editor.cubeSubstanceOnly = GUILayout.Toggle(editor.cubeSubstanceOnly, "Change Substance Only");
            GUILayout.Label("Substance", labelBigFont);
            editor.cubeBrushSubstance = (byte)GUILayout.SelectionGrid(editor.cubeBrushSubstance, substances, 1);
            break;

        case 2:
            editor.smoothBrushSize = doSliderFloatField("Radius (m)", editor.smoothBrushSize, 0, 100);
            editor.smoothBrushStrength = doSliderFloatField("Strength", editor.smoothBrushStrength, 0, 5);
            editor.smoothBrushBlurRadius = EditorGUILayout.IntField("Blur Radius", editor.smoothBrushBlurRadius);
            break;
        }
    }
Exemplo n.º 34
0
 protected void doGeneralPropertiesGUI(Vox.VoxelEditor editor)
 {
     editor.createColliders = EditorGUILayout.Toggle(new GUIContent("Generate Colliders"), editor.createColliders);
     editor.useStaticMeshes = EditorGUILayout.Toggle(new GUIContent("Use Static Meshes"), editor.useStaticMeshes);
     editor.saveMeshes = EditorGUILayout.Toggle(new GUIContent("Save Meshes To Scene"), editor.saveMeshes);
     //editor.maxDetail = (byte)EditorGUILayout.IntField(new GUIContent("Voxel Power"), editor.maxDetail);
     // if (createColliders != editor.createColliders || useStaticMeshes != editor.useStaticMeshes) {
     // 	editor.createColliders = createColliders;
     // 	editor.useStaticMeshes = useStaticMeshes;
     //     editor.generateRenderers();
     // }
 }
Exemplo n.º 35
0
    protected void doTreeSizeGUI(Vox.VoxelEditor editor)
    {
        // world detail
        EditorGUILayout.LabelField("Voxel Power", editor.maxDetail.ToString());

        long dimension = 1 << editor.maxDetail;
        ++EditorGUI.indentLevel;
        EditorGUILayout.LabelField("Voxels Per Side", dimension.ToString(numFormInt));
        EditorGUILayout.LabelField("Max Voxel Count", Mathf.Pow(dimension, 3).ToString(numFormInt));
        --EditorGUI.indentLevel;
        EditorGUILayout.Separator();

        // world dimension
        EditorGUILayout.LabelField("World Size (m)", editor.baseSize.ToString());
        ++EditorGUI.indentLevel;
        EditorGUILayout.LabelField("World Area", Mathf.Pow(editor.baseSize / 1000, 2).ToString(numForm) + " square km");
        EditorGUILayout.LabelField("World Volume", Mathf.Pow(editor.baseSize / 1000, 3).ToString(numForm) + " cubic km");
        --EditorGUI.indentLevel;
        EditorGUILayout.Separator();

        EditorGUILayout.LabelField("Voxel Size", (editor.baseSize / dimension).ToString(numForm) + " m");
        EditorGUILayout.Separator();
    }
Exemplo n.º 36
0
	protected void doGeneralPropertiesGUI(Vox.VoxelEditor editor) {
		bool createColliders = EditorGUILayout.Toggle(new GUIContent("Generate Colliders"), editor.createColliders);
		bool useStaticMeshes = EditorGUILayout.Toggle(new GUIContent("Use Static Meshes"), editor.useStaticMeshes);
		bool saveMeshes = EditorGUILayout.Toggle(new GUIContent("Save Meshes To Scene"), editor.saveMeshes);
		bool reduceMeshes = EditorGUILayout.Toggle(new GUIContent("Reduce Meshes"), editor.reduceMeshes);
		float reductionAmount = editor.reductionAmount;
		if (editor.reduceMeshes) {
			reductionAmount = doSliderFloatField("Mesh Reduction Level", editor.reductionAmount, 0, 0.5f);
		}
		byte maxDetail = (byte)EditorGUILayout.IntField(new GUIContent("Voxel Power"), editor.maxDetail);
		if (maxDetail != editor.maxDetail || createColliders != editor.createColliders ||
			saveMeshes != editor.saveMeshes || reductionAmount != editor.reductionAmount ||
			useStaticMeshes != editor.useStaticMeshes || reduceMeshes != editor.reduceMeshes) {
			if (maxDetail != editor.maxDetail) {
				editor.maxDetail = maxDetail;
				editor.setupLookupTables();
			}
			editor.createColliders = createColliders;
			editor.useStaticMeshes = useStaticMeshes;
			editor.saveMeshes = saveMeshes;
            editor.reduceMeshes = reduceMeshes;
			editor.reductionAmount = reductionAmount;
			editor.clearRenderers();
		}
	}
Exemplo n.º 37
0
 public void setFrom(Vox.VoxelEditor editor)
 {
     baseSize = editor.baseSize;
     maxDetail = editor.maxDetail;
     maxChange = editor.maxChange;
     proceduralSeed = editor.proceduralSeed;
     createColliders = editor.createColliders;
     useStaticMeshes = editor.useStaticMeshes;
     saveMeshes = editor.saveMeshes;
     reduceMeshes = editor.reduceMeshes;
     reductionAmount = editor.reductionAmount;
     heightPercentage = editor.heightPercentage;
     spherePercentage = editor.spherePercentage;
 }
Exemplo n.º 38
0
 protected static float maxBrushSize(Vox.VoxelEditor editor)
 {
     return Mathf.Max(editor.voxelSize() *20, 50);
 }
Exemplo n.º 39
0
	public static float getGenerationProgress(Vox.Tree editor) {
		return 1 -(float)(editor.getJobCount() +Vox.VoxelThread.getJobCount()) /jobCount *2;
	}
Exemplo n.º 40
0
    protected void applyBrush(Vox.VoxelEditor editor, Ray mouseLocation)
    {
        // get point clicked on
        System.Nullable<Vector3> point = editor.getBrushPoint(mouseLocation);
        if (point == null)
            return;

        // check if control pressed.  If so, add point to pathList
        if(editor.isPathing()) {
            editor.addPathPoint(point.Value);
            return;
        }

        // check for showPositionHandles
        if (editor.showPositionHandles && editor.isSelectedBrushPathable()
            && editor.pathPoints != null && editor.pathPoints.Length > 0)
            return;

        // create mutator
        Vox.Mutator mutator = buildMutator(editor, point.Value);

        // apply mutator
        if (mutator == null)
            return;
        Vox.LocalMutator localMutator = mutator as Vox.LocalMutator;
        if (localMutator != null && editor.pathPoints != null && editor.pathPoints.Length > 0) {
            editor.addPathPoint(point.Value);
            mutator = new Vox.LineMutator(editor.pathPoints, localMutator);
            editor.pathPoints = null;
        }
        mutator.apply(editor);
    }