Ejemplo n.º 1
0
        public void WriteIntoNativeData(NativeTurtleData nativeData, TurtleNativeDataWriter writer)
        {
            var vertexSlice = new JaggedIndexing
            {
                index  = writer.indexInVertexes,
                length = (ushort)draft.vertexCount
            };

            for (int i = 0; i < vertexSlice.length; i++)
            {
                var vertexDatum = new NativeVertexDatum
                {
                    vertex  = draft.vertices[i],
                    normal  = draft.normals[i],
                    uv      = draft.uvs[i],
                    tangent = draft.tangents[i]
                };
                nativeData.vertexData[i + writer.indexInVertexes] = vertexDatum;
            }
            writer.indexInVertexes += vertexSlice.length;

            var triangleCount = new JaggedIndexing
            {
                index  = writer.indexInTriangles,
                length = (ushort)draft.triangles.Length
            };

            for (int i = 0; i < triangleCount.length; i++)
            {
                nativeData.triangleData[i + writer.indexInTriangles] = draft.triangles[i];
            }
            writer.indexInTriangles += triangleCount.length;

            var existingMaterialIndex = writer.materialsInOrder.IndexOf(material);

            if (existingMaterialIndex == -1)
            {
                existingMaterialIndex = writer.materialsInOrder.Count;
                writer.materialsInOrder.Add(material);
            }
            var blittable = new Blittable
            {
                translation   = translation,
                alsoMove      = alsoMove,
                vertexes      = vertexSlice,
                trianges      = triangleCount,
                materialIndex = (byte)existingMaterialIndex
            };

            nativeData.allOrganData[writer.indexInOrganTemplates] = blittable;
            writer.indexInOrganTemplates++;
        }
Ejemplo n.º 2
0
        public TurtleInterpretor(
            List <TurtleOperationSet> operationSets,
            TurtleState defaultState,
            LinkedFileSet linkedFiles,
            CustomRuleSymbols customSymbols,
            OrganVolumetricWorld volumetricWorld,
            VoxelCapReachedTimestampEffect damageCapFlags,
            char startChar = '[', char endChar = ']')
        {
            foreach (var operationSet in operationSets)
            {
                operationSet.InternalCacheOperations();
            }

            var totalRequirements = operationSets.Select(x => x.DataReqs).Aggregate(new TurtleDataRequirements(), (agg, req) => agg + req);
            var nativeData        = new NativeTurtleData(totalRequirements);
            var nativeWriter      = new TurtleNativeDataWriter();

            foreach (var operationSet in operationSets)
            {
                operationSet.WriteIntoNativeData(nativeData, nativeWriter);
            }

            submeshMaterials = nativeWriter.materialsInOrder.ToArray();

            nativeData.operationsByKey = new NativeHashMap <int, TurtleOperation>(nativeWriter.operators.Count(), Allocator.Persistent);
            foreach (var ops in nativeWriter.operators)
            {
                var realSymbol = linkedFiles.GetSymbolFromRoot(ops.characterInRootFile);
                nativeData.operationsByKey[realSymbol] = ops.operation;
            }

            branchStartChar    = linkedFiles.GetSymbolFromRoot(startChar);
            branchEndChar      = linkedFiles.GetSymbolFromRoot(endChar);
            this.customSymbols = customSymbols;


            nativeDataTracker = new DependencyTracker <NativeTurtleData>(nativeData);
            this.defaultState = defaultState;

            this.volumetricWorld = volumetricWorld;
            this.damageCapFlags  = damageCapFlags;
            RefreshVolumetricWriters();
        }
Ejemplo n.º 3
0
 public abstract void WriteIntoNativeData(NativeTurtleData nativeData, TurtleNativeDataWriter writer);