public WallFloorPatternMaterial(EventHandler handler, byte materialType, uint unknown1, ushort unknown2,
                                 MaterialBlock mb, IEnumerable <TGIBlock> ltgib, uint unknown3, uint unknown4, uint unknown5,
                                 uint unknown6)
     : base(handler, materialType, unknown1, unknown2, mb, ltgib, unknown3)
 {
     this.unknown4 = unknown4; this.unknown5 = unknown5; this.unknown6 = unknown6;
 }
        public FactorLineLoadDialog(SlopeDefineCanvas canvas, LineLoad load)
        {
            InitializeComponent();

            this.canvas = canvas;
            this.load   = load;

            // get units dependent scaling factor and strings
            double factor;
            string coordUnits, loadUnits;

            switch (canvas.Units)
            {
            case Units.Metres: factor = 0.0254; coordUnits = "m"; loadUnits = "kN/m"; break;

            case Units.Millimetres: factor = 25.4; coordUnits = "mm"; loadUnits = "kN/m"; break;

            case Units.Feet: factor = 1.0 / 12.0; coordUnits = "ft"; loadUnits = "lbf/ft"; break;

            default: factor = 1.0; coordUnits = "in"; loadUnits = "lbf/ft"; break;
            }

            // set units labels
            node1Units.Content  = coordUnits;
            node2Units.Content  = coordUnits;
            nLoad1Units.Content = loadUnits;
            nLoad2Units.Content = loadUnits;
            tLoad1Units.Content = loadUnits;
            tLoad2Units.Content = loadUnits;

            // set node coordinates
            double xCoord, yCoord;

            xCoord          = (load.Nodes[0].Point.X - canvas.OriginOffsetX) / canvas.DpiX * factor * canvas.Scale;
            yCoord          = (canvas.ActualHeight - load.Nodes[0].Point.Y - canvas.OriginOffsetY) / canvas.DpiY * factor * canvas.Scale;
            coords1.Content = string.Format("({0}, {1})", Math.Round(xCoord, 2), Math.Round(yCoord, 2));
            xCoord          = (load.Nodes[1].Point.X - canvas.OriginOffsetX) / canvas.DpiX * factor * canvas.Scale;
            yCoord          = (canvas.ActualHeight - load.Nodes[1].Point.Y - canvas.OriginOffsetY) / canvas.DpiY * factor * canvas.Scale;
            coords2.Content = string.Format("({0}, {1})", Math.Round(xCoord, 2), Math.Round(yCoord, 2));

            // set existing load values (if present)
            MaterialBlock parent = canvas.Substructs.Find(delegate(MaterialBlock mb) { return(mb.Material.Name != "NULL" && mb.LineLoads.Contains(load)); });

            isLoadedN.IsEnabled = parent != null && load.IsLoadedN;
            isLoadedN.IsChecked = nFactor.IsEnabled = parent != null && load.IsActiveN;
            nFactor.Text        = string.Format("{0}", Math.Round(load.NFactor, 3));
            nLoad1.Text         = string.Format("{0}", Math.Round(load.NLoad1, 2));
            nLoad2.Text         = string.Format("{0}", Math.Round(load.NLoad2, 2));
            isLoadedT.IsEnabled = parent != null && load.IsLoadedT;
            isLoadedT.IsChecked = tFactor.IsEnabled = parent != null && load.IsActiveT;
            tFactor.Text        = string.Format("{0}", Math.Round(load.TFactor, 3));
            tLoad1.Text         = string.Format("{0}", Math.Round(load.TLoad1, 2));
            tLoad2.Text         = string.Format("{0}", Math.Round(load.TLoad2, 2));
        }
        public ActivateFixityDialog(SlopeDefineCanvas canvas, LineConstraint lc)
        {
            InitializeComponent();

            this.canvas = canvas;

            this.lc = lc;

            MaterialBlock parent = canvas.Substructs.Find(delegate(MaterialBlock mb) { return(mb.Material.Name != "NULL" && mb.LineConstraints.Contains(lc)); });

            isFixedX.IsEnabled = parent != null && lc.IsFixedX;
            isFixedY.IsEnabled = parent != null && lc.IsFixedY;
            isFixedX.IsChecked = parent != null && lc.IsActiveX;
            isFixedY.IsChecked = parent != null && lc.IsActiveY;
        }
Esempio n. 4
0
 private static bool CheckStuck(float x, float y, float z)
 {
     for (float k = y - 0.25f; k <= (y + 1f); k++)
     {
         for (float i = x - 0.25f; i <= (x + 0.25f); i++)
         {
             for (float j = z - 0.25f; j <= (z + 0.25f); j++)
             {
                 BlockValue    block     = GameManager.Instance.World.GetBlock(new Vector3i(i, k, j));
                 MaterialBlock _material = Block.list[block.type].blockMaterial;
                 if (block.type == BlockValue.Air.type || _material.IsLiquid || _material.IsPlant || block.Block.IsTerrainDecoration || block.Block.isMultiBlock)
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
        MaterialBlock CreateBlock(VertexCache cache, Material[] materials)
        {
            MaterialBlock block        = new MaterialBlock();
            int           packageCount = GetPackageCount(cache);

            block.instanceData = CreateInstanceData(packageCount);
            block.packageList  = new List <InstancingPackage> [packageCount];
            for (int i = 0; i != block.packageList.Length; ++i)
            {
                block.packageList[i] = new List <InstancingPackage>();

                InstancingPackage package = CreatePackage(block.instanceData,
                                                          cache.mesh,
                                                          materials,
                                                          i);
                block.packageList[i].Add(package);
                PreparePackageMaterial(package, cache, i);
                package.instancingCount = 1;
            }
            block.runtimePackageIndex = new int[packageCount];
            return(block);
        }
Esempio n. 6
0
        internal BasicEffect(string name, int id) : base(name, id)
        {
            m_MatricesBlock = new MatricesBlock();

            m_MatricesBlock.World = FreezingArcher.Math.Matrix.Identity;
            m_MatricesBlock.View = FreezingArcher.Math.Matrix.Identity;
            m_MatricesBlock.Projection = FreezingArcher.Math.Matrix.Identity;

            m_MatricesBlockUniformBuffer = null;

            m_LightBlock = new LightBlock1();
            m_LightBlock.LightColorA = 1.0f;
            m_LightBlock.LightColorB = 1.0f;
            m_LightBlock.LightColorG = 1.0f;
            m_LightBlock.LightColorR = 1.0f;

            m_MaterialBlock = new MaterialBlock();

            m_LightBlockUniformBuffer = null;

            m_MaterialBlockUniformBuffer = null;
        }
        private void SetupVertexCache(VertexCache vertexCache,
                                      MaterialBlock block,
                                      MeshRenderer render,
                                      Mesh mesh,
                                      Transform[] boneTransform,
                                      int bonePerVertex)
        {
            int boneIndex = -1;

            if (boneTransform != null)
            {
                for (int k = 0; k != boneTransform.Length; ++k)
                {
                    if (render.transform.parent.name.GetHashCode() == boneTransform[k].name.GetHashCode())
                    {
                        boneIndex = k;
                        break;
                    }
                }
            }
            if (boneIndex >= 0)
            {
                //todo
                BindAttachment(vertexCache, vertexCache, vertexCache.mesh, boneIndex);
            }
            if (vertexCache.materials == null)
            {
                vertexCache.materials = render.sharedMaterials;
            }
            SetupAdditionalData(vertexCache);
            for (int i = 0; i != block.packageList.Length; ++i)
            {
                InstancingPackage package = CreatePackage(block.instanceData, vertexCache.mesh, render.sharedMaterials, i);
                block.packageList[i].Add(package);
                PreparePackageMaterial(package, vertexCache, i);
            }
        }
        public ActivateFixityDialog(SlopeDefineCanvas canvas, DrawingPoint p)
        {
            InitializeComponent();

            this.canvas = canvas;

            this.p = p;

            MaterialBlock parent = canvas.Substructs.Find(delegate(MaterialBlock mb) { return(mb.Material.Name != "NULL" && mb.BoundaryPoints.Contains(p)); });

            isFixedX.IsEnabled = parent != null && p.IsFixedX;
            isFixedY.IsEnabled = parent != null && p.IsFixedY;
            isFixedX.IsChecked = parent != null && p.IsFixActiveX;
            isFixedY.IsChecked = parent != null && p.IsFixActiveY;

            List <LineConstraint> attachedLCs = new List <LineConstraint>();

            canvas.Substructs.ForEach(
                delegate(MaterialBlock mb)
            {
                attachedLCs.AddRange(mb.LineConstraints.FindAll(delegate(LineConstraint lc) { return(lc.Nodes.Contains(p)); }));
            });
            attachedLCs.ForEach(
                delegate(LineConstraint lc)
            {
                if (lc.IsActiveX)
                {
                    isFixedX.IsEnabled = false;
                }
                if (lc.IsActiveY)
                {
                    isFixedY.IsEnabled = false;
                }
            });
            attachedLCs.Clear();
        }
Esempio n. 9
0
        private float gen = 0.08f; // NB: 1% * 40*40 = 1%*1600 = 16 // Randomize !
        // private static int WaterId;

        private static bool IsWater(Block block)
        {
            MaterialBlock mat = block.blockMaterial;

            return(mat.IsLiquid && mat.SurfaceCategory == "water");
        }
Esempio n. 10
0
        public override void OnInspectorGUI()
        {
            // Get the target block world
            BlockWorld t = target as BlockWorld;

            int materialCount = t.BlockTypes.GetVisibleLength();

            // Material selection area
            {
                // Update texture cache size, if needed
                if (iconTextures == null || iconTextures.Length != materialCount)
                {
                    iconTextures = new Texture[materialCount];

                    // Cap the selected material index to the length of this list
                    // Selected index returns -1 if the material list is empty
                    if (t.selectedMaterialIndex >= iconTextures.Length || t.selectedMaterialIndex < 0)
                    {
                        t.selectedMaterialIndex = iconTextures.Length - 1;
                    }
                }

                // Render material list
                {
                    for (int i = 0; i < iconTextures.Length; i++)
                    {
                        MaterialBlock props = t.BlockTypes.GetVisibleAt(i);
                        iconTextures[i] = AssetPreview.GetAssetPreview(props.Material);

                        EditorGUILayout.BeginHorizontal();

                        bool selected = GUILayout.Toggle(t.selectedMaterialIndex == i, iconTextures[i], EditorStyles.miniButton,
                                                         GUILayout.Width(64), GUILayout.Height(64));
                        if (selected)
                        {
                            t.selectedMaterialIndex = i;
                        }

                        {
                            // Material Properties
                            EditorGUI.BeginChangeCheck();

                            EditorGUILayout.BeginVertical();
                            props.Transparent = GUILayout.Toggle(props.Transparent, "Transparent");
                            props.GroupBlocks = GUILayout.Toggle(props.GroupBlocks, "Group Blocks");
                            props.ViewInsides = GUILayout.Toggle(props.ViewInsides, "View Insides");
                            EditorGUILayout.EndVertical();

                            EditorGUILayout.BeginVertical();
                            props.DepthSort = GUILayout.Toggle(props.DepthSort, "Depth Sort");
                            EditorGUILayout.EndVertical();

                            if (EditorGUI.EndChangeCheck())
                            {
                                EditorUtility.SetDirty(t);
                                t.UpdateAllBlockStates(props.Id, props.BlockState);
                            }
                        }

                        if (GUILayout.Button("X", GUILayout.Width(30), GUILayout.Height(30)))
                        {
                            // Record undo point and remove material
                            Undo.RecordObject(t, "Removed Material from BlockWorld");
                            props.HiddenInInspector = true;
                            EditorUtility.SetDirty(t);
                        }

                        EditorGUILayout.EndHorizontal();
                    }

                    GUILayout.Space(20);
                }

                // If we are still loading asset previews, queue the inspector for another repaint
                if (AssetPreview.IsLoadingAssetPreviews())
                {
                    EditorUtility.SetDirty(t);
                }
            }

            // Add/Remove material area
            {
                // Show an object field for quickly adding new materials to the list
                Material newMaterial = EditorGUILayout.ObjectField("Add Material", null, typeof(Material), false) as Material;
                if (newMaterial != null)
                {
                    MaterialBlock matProps = t.BlockTypes.GetMaterialProperties(newMaterial);
                    if (matProps.HiddenInInspector)
                    {
                        // Record undo point and add material
                        Undo.RecordObject(t, "Added Material to BlockWorld");
                        matProps.HiddenInInspector = false;
                        EditorUtility.SetDirty(t);
                    }
                }

                GUILayout.Space(30);
            }

            // Regen and Clear buttons
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Regen") && materialCount > 0)
                {
                    t.Clear();
                    t.SetBlock(0, 0, 0, t.BlockTypes.GetVisibleAt(t.selectedMaterialIndex).Material);
                }
                if (GUILayout.Button("Clear"))
                {
                    t.Clear();
                }
                if (GUILayout.Button("Remesh"))
                {
                    t.RemeshAllChunks();
                }
                EditorGUILayout.EndHorizontal();
            }
        }
Esempio n. 11
0
 private void GetParticleCategory(MaterialBlock material) => Bin.Add("ParticleCategory", ParticleCategory = material.ParticleCategory);
Esempio n. 12
0
 private void GetStabilityGlue(MaterialBlock material) => Bin.Add("StabilityGlue", StabilityGlue = material.StabilityGlue);
        private void SetupVertexCache(VertexCache vertexCache,
                                      MaterialBlock block,
                                      SkinnedMeshRenderer render,
                                      Transform[] boneTransform,
                                      int bonePerVertex)
        {
            int[] boneIndex = null;
            if (render.bones.Length != boneTransform.Length)
            {
                if (render.bones.Length == 0)
                {
                    boneIndex = new int[1];
                    int hashRenderParentName = render.transform.parent.name.GetHashCode();
                    for (int k = 0; k != boneTransform.Length; ++k)
                    {
                        if (hashRenderParentName == boneTransform[k].name.GetHashCode())
                        {
                            boneIndex[0] = k;
                            break;
                        }
                    }
                }
                else
                {
                    boneIndex = new int[render.bones.Length];
                    for (int j = 0; j != render.bones.Length; ++j)
                    {
                        boneIndex[j] = -1;
                        Transform trans             = render.bones[j];
                        int       hashTransformName = trans.name.GetHashCode();
                        for (int k = 0; k != boneTransform.Length; ++k)
                        {
                            if (hashTransformName == boneTransform[k].name.GetHashCode())
                            {
                                boneIndex[j] = k;
                                break;
                            }
                        }
                    }

                    if (boneIndex.Length == 0)
                    {
                        boneIndex = null;
                    }
                }
            }

            UnityEngine.Profiling.Profiler.BeginSample("Copy the vertex data in SetupVertexCache()");
            Mesh m = render.sharedMesh;

            BoneWeight[] boneWeights = m.boneWeights;
            Debug.Assert(boneWeights.Length > 0);
            for (int j = 0; j != m.vertexCount; ++j)
            {
                vertexCache.weight[j].x = boneWeights[j].weight0;
                Debug.Assert(vertexCache.weight[j].x > 0.0f);
                vertexCache.weight[j].y = boneWeights[j].weight1;
                vertexCache.weight[j].z = boneWeights[j].weight2;
                vertexCache.weight[j].w = boneWeights[j].weight3;
                vertexCache.boneIndex[j].x
                    = boneIndex == null ? boneWeights[j].boneIndex0 : boneIndex[boneWeights[j].boneIndex0];
                vertexCache.boneIndex[j].y
                    = boneIndex == null ? boneWeights[j].boneIndex1 : boneIndex[boneWeights[j].boneIndex1];
                vertexCache.boneIndex[j].z
                    = boneIndex == null ? boneWeights[j].boneIndex2 : boneIndex[boneWeights[j].boneIndex2];
                vertexCache.boneIndex[j].w
                    = boneIndex == null ? boneWeights[j].boneIndex3 : boneIndex[boneWeights[j].boneIndex3];
                Debug.Assert(vertexCache.boneIndex[j].x >= 0);
                if (bonePerVertex == 3)
                {
                    float rate = 1.0f / (vertexCache.weight[j].x + vertexCache.weight[j].y + vertexCache.weight[j].z);
                    vertexCache.weight[j].x = vertexCache.weight[j].x * rate;
                    vertexCache.weight[j].y = vertexCache.weight[j].y * rate;
                    vertexCache.weight[j].z = vertexCache.weight[j].z * rate;
                    vertexCache.weight[j].w = -0.1f;
                }
                else if (bonePerVertex == 2)
                {
                    float rate = 1.0f / (vertexCache.weight[j].x + vertexCache.weight[j].y);
                    vertexCache.weight[j].x = vertexCache.weight[j].x * rate;
                    vertexCache.weight[j].y = vertexCache.weight[j].y * rate;
                    vertexCache.weight[j].z = -0.1f;
                    vertexCache.weight[j].w = -0.1f;
                }
                else if (bonePerVertex == 1)
                {
                    vertexCache.weight[j].x = 1.0f;
                    vertexCache.weight[j].y = -0.1f;
                    vertexCache.weight[j].z = -0.1f;
                    vertexCache.weight[j].w = -0.1f;
                }
            }
            UnityEngine.Profiling.Profiler.EndSample();

            if (vertexCache.materials == null)
            {
                vertexCache.materials = render.sharedMaterials;
            }
            SetupAdditionalData(vertexCache);
            for (int i = 0; i != block.packageList.Length; ++i)
            {
                InstancingPackage package = CreatePackage(block.instanceData, vertexCache.mesh, render.sharedMaterials, i);
                block.packageList[i].Add(package);
                //vertexCache.packageList[i].Add(package);
                PreparePackageMaterial(package, vertexCache, i);
            }
        }
        // alias is to use for attachment, it should be a bone name
        public void AddMeshVertex(string prefabName,
                                  AnimationInstancing.LodInfo[] lodInfo,
                                  Transform[] bones,
                                  List <Matrix4x4> bindPose,
                                  int bonePerVertex,
                                  string alias = null)
        {
            UnityEngine.Profiling.Profiler.BeginSample("AddMeshVertex()");
            for (int x = 0; x != lodInfo.Length; ++x)
            {
                AnimationInstancing.LodInfo lod = lodInfo[x];
                for (int i = 0; i != lod.skinnedMeshRenderer.Length; ++i)
                {
                    Mesh m = lod.skinnedMeshRenderer[i].sharedMesh;
                    if (m == null)
                    {
                        continue;
                    }

                    int         nameCode = lod.skinnedMeshRenderer[i].name.GetHashCode();
                    int         identify = GetIdentify(lod.skinnedMeshRenderer[i].sharedMaterials);
                    VertexCache cache    = null;
                    if (vertexCachePool.TryGetValue(nameCode, out cache))
                    {
                        MaterialBlock block = null;
                        if (!cache.instanceBlockList.TryGetValue(identify, out block))
                        {
                            block = CreateBlock(cache, lod.skinnedMeshRenderer[i].sharedMaterials);
                            cache.instanceBlockList.Add(identify, block);
                        }
                        lod.vertexCacheList[i]   = cache;
                        lod.materialBlockList[i] = block;
                        continue;
                    }

                    VertexCache vertexCache = CreateVertexCache(prefabName, nameCode, 0, m);
                    vertexCache.bindPose = bindPose.ToArray();
                    MaterialBlock matBlock = CreateBlock(vertexCache, lod.skinnedMeshRenderer[i].sharedMaterials);
                    vertexCache.instanceBlockList.Add(identify, matBlock);
                    SetupVertexCache(vertexCache, matBlock, lod.skinnedMeshRenderer[i], bones, bonePerVertex);
                    lod.vertexCacheList[i]   = vertexCache;
                    lod.materialBlockList[i] = matBlock;
                }

                for (int i = 0, j = lod.skinnedMeshRenderer.Length; i != lod.meshRenderer.Length; ++i, ++j)
                {
                    Mesh m = lod.meshFilter[i].sharedMesh;
                    if (m == null)
                    {
                        continue;
                    }

                    int         renderName = lod.meshRenderer[i].name.GetHashCode();
                    int         aliasName  = (alias != null ? alias.GetHashCode() : 0);
                    int         identify   = GetIdentify(lod.meshRenderer[i].sharedMaterials);
                    VertexCache cache      = null;
                    if (vertexCachePool.TryGetValue(renderName + aliasName, out cache))
                    {
                        MaterialBlock block = null;
                        if (!cache.instanceBlockList.TryGetValue(identify, out block))
                        {
                            block = CreateBlock(cache, lod.meshRenderer[i].sharedMaterials);
                            cache.instanceBlockList.Add(identify, block);
                        }
                        lod.vertexCacheList[j]   = cache;
                        lod.materialBlockList[j] = block;
                        continue;
                    }

                    VertexCache vertexCache = CreateVertexCache(prefabName, renderName, aliasName, m);
                    if (bindPose != null)
                    {
                        vertexCache.bindPose = bindPose.ToArray();
                    }
                    MaterialBlock matBlock = CreateBlock(vertexCache, lod.meshRenderer[i].sharedMaterials);
                    vertexCache.instanceBlockList.Add(identify, matBlock);
                    SetupVertexCache(vertexCache, matBlock, lod.meshRenderer[i], m, bones, bonePerVertex);
                    lod.vertexCacheList[lod.skinnedMeshRenderer.Length + i]   = vertexCache;
                    lod.materialBlockList[lod.skinnedMeshRenderer.Length + i] = matBlock;
                }
            }

            UnityEngine.Profiling.Profiler.EndSample();
        }
Esempio n. 15
0
 private void GetDestroyCategory(MaterialBlock material) => Bin.Add("DestroyCategory", DestroyCategory = material.ParticleDestroyCategory);
Esempio n. 16
0
 private void GetStepSound(MaterialBlock material) => Bin.Add("StepSound", StepSound = material.stepSound?.name);
Esempio n. 17
0
 private void GetMaxDamage(MaterialBlock material) => Bin.Add("MaxDamage", MaxDamage = material.MaxDamage);
Esempio n. 18
0
 private void GetMovementFactor(MaterialBlock material) => Bin.Add("MovementFactor", MovementFactor = Math.Round(material.MovementFactor, 2));
Esempio n. 19
0
 private void GetFertileLevel(MaterialBlock material) => Bin.Add("FertileLevel", FertileLevel = material.FertileLevel);
Esempio n. 20
0
 private void GetHardness(MaterialBlock material) => Bin.Add("Hardness", Hardness = material.Hardness.Value);
Esempio n. 21
0
 private void GetLightOpacity(MaterialBlock material) => Bin.Add("LightOpacity", LightOpacity = material.LightOpacity);
Esempio n. 22
0
 private void GetMass(MaterialBlock material) => Bin.Add("Mass", Mass = material.Mass.Value);
Esempio n. 23
0
        /// <summary>
        /// Gets substruct (material block data) from file
        /// </summary>
        public void LoadSubstructData()
        {
            if (!File.Exists(FilePath))
            {
                MessageBox.Show("Could not find input data file.", "Error");
                return;
            }

            // get canvas dimensions/properties
            double originX = OriginOffsetX,
                   originY = OriginOffsetY,
                   scale   = Scale,
                   yHeight = ActualHeight;
            Units units    = Units;

            // get units dependent scaling factor
            double factor;

            switch (units)
            {
            case Units.Metres: factor = 0.0254; break;

            case Units.Millimetres: factor = 25.4; break;

            case Units.Feet: factor = 1.0 / 12.0; break;

            default: factor = 1.0; break;
            }

            // Load material blocks from source canvas
            substructs = new List <MaterialBlock>();
            using (TextReader tr = new StreamReader(FilePath))
            {
                // advance to material block data
                while (!tr.ReadLine().Contains("MATERIAL BLOCK DATA"))
                {
                    ;
                }

                tr.ReadLine();
                tr.ReadLine();

                int numMaterialBlocks = int.Parse(tr.ReadLine().Split('=')[1]);

                tr.ReadLine();

                if (numMaterialBlocks > 0)
                {
                    MaterialBlock  block;
                    MaterialType   mtl;
                    DrawingPoint   p1, p2;
                    LineConstraint newLC, existingLC;
                    LineLoad       newLL, existingLL;
                    PointLoad      newPL, existingPL;
                    Point[]        materialBoundPoints;
                    bool[]         isFixedX;
                    bool[]         isFixedY;
                    bool[]         isPrintPoint;
                    string         materialName;
                    int            numMaterialBoundPoints, numLineConstraints, numLineLoads, numPointLoads;
                    double         xCoord, yCoord;
                    string[]       coords, lineConstraint, lineLoad, pointLoad;

                    for (int i = 0; i < numMaterialBlocks; i++)
                    {
                        tr.ReadLine();

                        materialName = tr.ReadLine().Split(new char[] { '\"' }, StringSplitOptions.RemoveEmptyEntries)[1];
                        mtl          = materialTypes.Find(delegate(MaterialType mt) { return(mt.Name == materialName); });

                        numMaterialBoundPoints = int.Parse(tr.ReadLine().Split('=')[1]);

                        materialBoundPoints = new Point[numMaterialBoundPoints];
                        isFixedX            = new bool[numMaterialBoundPoints];
                        isFixedY            = new bool[numMaterialBoundPoints];
                        isPrintPoint        = new bool[numMaterialBoundPoints];

                        for (int j = 0; j < numMaterialBoundPoints; j++)
                        {
                            coords = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                            xCoord = double.Parse(coords[0]);
                            yCoord = double.Parse(coords[1]);
                            materialBoundPoints[j].X = xCoord / (factor * Scale) * dpiX + OriginOffsetX;
                            materialBoundPoints[j].Y = ActualHeight - (yCoord / (factor * Scale) * dpiY + OriginOffsetY);
                            isFixedX[j]     = coords[2] == bool.TrueString;
                            isFixedY[j]     = coords[3] == bool.TrueString;
                            isPrintPoint[j] = coords[4] == bool.TrueString;
                        }

                        block = new MaterialBlock(this, mtl, materialBoundPoints);
                        for (int j = 0; j < numMaterialBoundPoints; j++)
                        {
                            block.BoundaryPoints[j].IsFixedX     = isFixedX[j];
                            block.BoundaryPoints[j].IsFixedY     = isFixedY[j];
                            block.BoundaryPoints[j].IsPrintPoint = isPrintPoint[j];
                        }

                        substructs.Add(block);

                        numLineConstraints = int.Parse(tr.ReadLine().Split('=')[1]);
                        for (int j = 0; j < numLineConstraints; j++)
                        {
                            lineConstraint = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                            p1 = block.BoundaryPoints[int.Parse(lineConstraint[0])];
                            p2 = block.BoundaryPoints[int.Parse(lineConstraint[1])];

                            existingLC = null;
                            foreach (MaterialBlock mb in substructs)
                            {
                                existingLC = mb.LineConstraints.Find(delegate(LineConstraint lc) { return(lc.Nodes.Contains(p1) && lc.Nodes.Contains(p2)); });
                                if (existingLC != null)
                                {
                                    break;
                                }
                            }

                            if (existingLC == null)
                            {
                                newLC = new LineConstraint(this, p1, p2,
                                                           //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[0] )] ,
                                                           //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[1] )] ,
                                                           lineConstraint[2] == bool.TrueString,
                                                           lineConstraint[3] == bool.TrueString);
                            }
                            else
                            {
                                block.LineConstraints.Add(existingLC);
                            }

                            //newLC = new LineConstraint( this ,
                            //    block.BoundaryPoints[int.Parse( lineConstraint[0] )] ,
                            //    block.BoundaryPoints[int.Parse( lineConstraint[1] )] ,
                            //    lineConstraint[2] == bool.TrueString ,
                            //    lineConstraint[3] == bool.TrueString );
                            //existingLC = null;
                            //foreach ( MaterialBlock mb in substructs )
                            //{
                            //    existingLC = mb.LineConstraints.Find(
                            //        delegate( LineConstraint lc )
                            //        {
                            //            return lc.Nodes.Contains( newLC.Nodes[0] ) && lc.Nodes.Contains( newLC.Nodes[1] );
                            //        } );
                            //    if ( existingLC != null ) break;
                            //}
                            //if ( existingLC != null )
                            //{
                            //    if ( !block.LineConstraints.Contains( existingLC ) )
                            //        block.LineConstraints.Add( existingLC );
                            //}
                            //else block.LineConstraints.Add( newLC );
                        }

                        numLineLoads = int.Parse(tr.ReadLine().Split('=')[1]);
                        for (int j = 0; j < numLineLoads; j++)
                        {
                            lineLoad = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                            p1 = block.BoundaryPoints[int.Parse(lineLoad[0])];
                            p2 = block.BoundaryPoints[int.Parse(lineLoad[1])];

                            existingLL = null;
                            foreach (MaterialBlock mb in substructs)
                            {
                                existingLL = mb.LineLoads.Find(delegate(LineLoad ll) { return(ll.Nodes.Contains(p1) && ll.Nodes.Contains(p2)); });
                                if (existingLL != null)
                                {
                                    break;
                                }
                            }

                            if (existingLL == null)
                            {
                                newLL = new LineLoad(this, p1, p2,
                                                     //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[0] )] ,
                                                     //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[1] )] ,
                                                     lineLoad[2] == bool.TrueString, double.Parse(lineLoad[3]), double.Parse(lineLoad[4]),
                                                     lineLoad[5] == bool.TrueString, double.Parse(lineLoad[6]), double.Parse(lineLoad[7]));
                            }
                            else
                            {
                                block.LineLoads.Add(existingLL);
                            }

                            //block.LineLoads.Add( new LineLoad( this ,
                            //    block.BoundaryPoints[int.Parse( lineLoad[0] )] ,
                            //    block.BoundaryPoints[int.Parse( lineLoad[1] )] ,
                            //    lineLoad[2] == bool.TrueString , double.Parse( lineLoad[3] ) , double.Parse( lineLoad[4] ) ,
                            //    lineLoad[5] == bool.TrueString , double.Parse( lineLoad[6] ) , double.Parse( lineLoad[7] ) ) );
                        }

                        numPointLoads = int.Parse(tr.ReadLine().Split('=')[1]);
                        for (int j = 0; j < numPointLoads; j++)
                        {
                            pointLoad = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                            p1 = block.BoundaryPoints[int.Parse(pointLoad[0])];

                            existingPL = null;
                            foreach (MaterialBlock mb in substructs)
                            {
                                existingPL = mb.PointLoads.Find(delegate(PointLoad pl) { return(pl.Node == p1); });
                                if (existingPL != null)
                                {
                                    break;
                                }
                            }

                            if (existingPL == null)
                            {
                                newPL = new PointLoad(this, p1,
                                                      //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[0] )] ,
                                                      //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[1] )] ,
                                                      pointLoad[1] == bool.TrueString, double.Parse(pointLoad[2]),
                                                      pointLoad[3] == bool.TrueString, double.Parse(pointLoad[4]));
                            }
                            else
                            {
                                block.PointLoads.Add(existingPL);
                            }

                            //block.PointLoads.Add( new PointLoad( this ,
                            //    block.BoundaryPoints[int.Parse( pointLoad[0] )] ,
                            //    pointLoad[1] == bool.TrueString , double.Parse( pointLoad[2] ) ,
                            //    pointLoad[3] == bool.TrueString , double.Parse( pointLoad[4] ) ) );
                        }



                        tr.ReadLine();
                    }
                }
            }

            // Set selected analysis phase to first (if present)
            if (source.AnalysisPhases.Count > 1)
            {
                ComboBox      phaseList = (ComboBox)((Grid)((GroupBox)((Grid)((ScrollViewer)((Grid)this.Parent).Children[2]).Content).Children[1]).Content).Children[1];
                AnalysisPhase initial   = source.AnalysisPhases[1];
                phaseList.SelectedItem = initial;
            }
        }
Esempio n. 24
0
 private void GetMaterials(MaterialBlock obj) => Bin = new BCMMaterial(obj, TypeStr, Options, StrFilter).Data();
Esempio n. 25
0
 private void GetId(MaterialBlock material) => Bin.Add("Id", Id = material.id);
        void ApplyBoneMatrix()
        {
            Vector3 cameraPosition = cameraTransform.position;

            for (int i = 0; i != aniInstancingList.Count; ++i)
            {
                AnimationInstancing instance = aniInstancingList[i];
                if (!instance.IsPlaying())
                {
                    continue;
                }
                if (instance.aniIndex < 0 && instance.parentInstance == null)
                {
                    continue;
                }

                if (instance.applyRootMotion)
                {
                    ApplyRootMotion(instance);
                }

                instance.UpdateAnimation();
                instance.boundingSpere.position = instance.transform.position;
                boundingSphere[i] = instance.boundingSpere;

                if (!instance.visible)
                {
                    continue;
                }
                instance.UpdateLod(cameraPosition);

                AnimationInstancing.LodInfo lod = instance.lodInfo[instance.lodLevel];
                int aniTextureIndex             = -1;
                if (instance.parentInstance != null)
                {
                    aniTextureIndex = instance.parentInstance.aniTextureIndex;
                }
                else
                {
                    aniTextureIndex = instance.aniTextureIndex;
                }

                for (int j = 0; j != lod.vertexCacheList.Length; ++j)
                {
                    VertexCache   cache = lod.vertexCacheList[j];
                    MaterialBlock block = lod.materialBlockList[j];
                    Debug.Assert(block != null);
                    int packageIndex = block.runtimePackageIndex[aniTextureIndex];
                    Debug.Assert(packageIndex < block.packageList[aniTextureIndex].Count);
                    InstancingPackage package = block.packageList[aniTextureIndex][packageIndex];
                    if (package.instancingCount + 1 > instancingPackageSize)
                    {
                        ++block.runtimePackageIndex[aniTextureIndex];
                        packageIndex = block.runtimePackageIndex[aniTextureIndex];
                        if (packageIndex >= block.packageList[aniTextureIndex].Count)
                        {
                            InstancingPackage newPackage = CreatePackage(block.instanceData,
                                                                         cache.mesh,
                                                                         cache.materials,
                                                                         aniTextureIndex);
                            block.packageList[aniTextureIndex].Add(newPackage);
                            PreparePackageMaterial(newPackage, cache, aniTextureIndex);
                            newPackage.instancingCount = 1;
                        }
                        block.packageList[aniTextureIndex][packageIndex].instancingCount = 1;
                    }
                    else
                    {
                        ++package.instancingCount;
                    }

                    {
                        VertexCache       vertexCache = cache;
                        InstanceData      data        = block.instanceData;
                        int               index       = block.runtimePackageIndex[aniTextureIndex];
                        InstancingPackage pkg         = block.packageList[aniTextureIndex][index];
                        int               count       = pkg.instancingCount - 1;
                        if (count >= 0)
                        {
                            Matrix4x4   worldMat = instance.worldTransform.localToWorldMatrix;
                            Matrix4x4[] arrayMat = data.worldMatrix[aniTextureIndex][index];
                            arrayMat[count].m00 = worldMat.m00;
                            arrayMat[count].m01 = worldMat.m01;
                            arrayMat[count].m02 = worldMat.m02;
                            arrayMat[count].m03 = worldMat.m03;
                            arrayMat[count].m10 = worldMat.m10;
                            arrayMat[count].m11 = worldMat.m11;
                            arrayMat[count].m12 = worldMat.m12;
                            arrayMat[count].m13 = worldMat.m13;
                            arrayMat[count].m20 = worldMat.m20;
                            arrayMat[count].m21 = worldMat.m21;
                            arrayMat[count].m22 = worldMat.m22;
                            arrayMat[count].m23 = worldMat.m23;
                            arrayMat[count].m30 = worldMat.m30;
                            arrayMat[count].m31 = worldMat.m31;
                            arrayMat[count].m32 = worldMat.m32;
                            arrayMat[count].m33 = worldMat.m33;
                            float frameIndex = 0, preFrameIndex = -1, transition = 0f;
                            if (instance.parentInstance != null)
                            {
                                frameIndex = instance.parentInstance.aniInfo[instance.parentInstance.aniIndex].animationIndex + instance.parentInstance.curFrame;
                                if (instance.parentInstance.preAniIndex >= 0)
                                {
                                    preFrameIndex = instance.parentInstance.aniInfo[instance.parentInstance.preAniIndex].animationIndex + instance.parentInstance.preAniFrame;
                                }
                                transition = instance.parentInstance.transitionProgress;
                            }
                            else
                            {
                                frameIndex = instance.aniInfo[instance.aniIndex].animationIndex + instance.curFrame;
                                if (instance.preAniIndex >= 0)
                                {
                                    preFrameIndex = instance.aniInfo[instance.preAniIndex].animationIndex + instance.preAniFrame;
                                }
                                transition = instance.transitionProgress;
                            }
                            data.frameIndex[aniTextureIndex][index][count]         = frameIndex;
                            data.preFrameIndex[aniTextureIndex][index][count]      = preFrameIndex;
                            data.transitionProgress[aniTextureIndex][index][count] = transition;
                        }
                    }
                }
            }
        }
Esempio n. 27
0
 private void GetDamageCatagory(MaterialBlock material) => Bin.Add("DamageCategory", DamageCategory = material.DamageCategory);
Esempio n. 28
0
 private void GetSurfaceCategory(MaterialBlock material) => Bin.Add("SurfaceCategory", SurfaceCategory = material.SurfaceCategory);
Esempio n. 29
0
 private void GetForgeCategory(MaterialBlock material) => Bin.Add("ForgeCategory", ForgeCategory = material.ForgeCategory);
Esempio n. 30
0
 private void GetExperience(MaterialBlock material) => Bin.Add("Experience", Experience = material.Experience);
Esempio n. 31
0
 private void GetStabilitySupport(MaterialBlock material) => Bin.Add("StabilitySupport", StabilitySupport = material.StabilitySupport);