public StaticMeshComponent (ME3Package Pcc, int Index)
        {
            pcc = Pcc;
            MyIndex = Index;
            if (pcc.isExport(Index))
                data = pcc.Exports[Index].Data;
            Props = PropertyReader.getPropList(pcc.Exports[Index]);
            
            foreach (PropertyReader.Property p in Props)
                switch (pcc.getNameEntry(p.Name))
                {
                    #region
                    case "LightMapEncoding":
						LightMapEncoding = p.Value.IntValue;
						break;
					case "RBChannel":
						RBChannel = p.Value.IntValue;
						break;
					case "DepthPriorityGroup":
						DepthPriorityGroup = p.Value.IntValue;
						break;
					case "TickGroup":
						TickGroup = p.Value.IntValue;
						break;
					case "bIgnoreInstanceForTextureStreaming":
						if (p.raw[p.raw.Length - 1] == 1)
						bIgnoreInstanceForTextureStreaming = true;
						break;
					case "CastShadow":
						if (p.raw[p.raw.Length - 1] == 1)
						CastShadow = true;
						break;
					case "CollideActors":
						if (p.raw[p.raw.Length - 1] == 1)
						CollideActors = true;
						break;
					case "BlockRigidBody":
						if (p.raw[p.raw.Length - 1] == 1)
						BlockRigidBody = true;
						break;
					case "bForceDirectLightMap":
						if (p.raw[p.raw.Length - 1] == 1)
						bForceDirectLightMap = true;
						break;
					case "bCastDynamicShadow":
						if (p.raw[p.raw.Length - 1] == 1)
						bCastDynamicShadow = true;
						break;
					case "bAcceptsDynamicDominantLightShadows":
						if (p.raw[p.raw.Length - 1] == 1)
						bAcceptsDynamicDominantLightShadows = true;
						break;
					case "bAcceptsLights":
						if (p.raw[p.raw.Length - 1] == 1)
						bAcceptsLights = true;
						break;
					case "bAcceptsDynamicLights":
						if (p.raw[p.raw.Length - 1] == 1)
						bAcceptsDynamicLights = true;
						break;
					case "bCullModulatedShadowOnBackfaces":
						if (p.raw[p.raw.Length - 1] == 1)
						bCullModulatedShadowOnBackfaces = true;
						break;
					case "bCullModulatedShadowOnEmissive":
						if (p.raw[p.raw.Length - 1] == 1)
						bCullModulatedShadowOnEmissive = true;
						break;
					case "bAllowAmbientOcclusion":
						if (p.raw[p.raw.Length - 1] == 1)
						bAllowAmbientOcclusion = true;
						break;
					case "bUsePrecomputedShadows":
						if (p.raw[p.raw.Length - 1] == 1)
						bUsePrecomputedShadows = true;
						break;
					case "CanBlockCamera":
						if (p.raw[p.raw.Length - 1] == 1)
						CanBlockCamera = true;
						break;
					case "bAllowShadowFade":
						if (p.raw[p.raw.Length - 1] == 1)
						bAllowShadowFade = true;
						break;
					case "bBioIsReceivingDecals":
						if (p.raw[p.raw.Length - 1] == 1)
						bBioIsReceivingDecals = true;
						break;
					case "BlockNonZeroExtent":
						if (p.raw[p.raw.Length - 1] == 1)
						BlockNonZeroExtent = true;
						break;
					case "bAcceptsStaticDecals":
						if (p.raw[p.raw.Length - 1] == 1)
						bAcceptsStaticDecals = true;
						break;
					case "bAcceptsDynamicDecals":
						if (p.raw[p.raw.Length - 1] == 1)
						bAcceptsDynamicDecals = true;
						break;
					case "bAcceptsFoliage":
						if (p.raw[p.raw.Length - 1] == 1)
						bAcceptsFoliage = true;
						break;
					case "HiddenGame":
						if (p.raw[p.raw.Length - 1] == 1)
						HiddenGame = true;
						break;
					case "bBioForcePrecomputedShadows":
						if (p.raw[p.raw.Length - 1] == 1)
						bBioForcePrecomputedShadows = true;
						break;
					case "bCastHiddenShadow":
						if (p.raw[p.raw.Length - 1] == 1)
						bCastHiddenShadow = true;
						break;
					case "bUseAsOccluder":
						if (p.raw[p.raw.Length - 1] == 1)
						bUseAsOccluder = true;
						break;
					case "BlockZeroExtent":
						if (p.raw[p.raw.Length - 1] == 1)
						BlockZeroExtent = true;
						break;
					case "bAllowCullDistanceVolume":
						if (p.raw[p.raw.Length - 1] == 1)
						bAllowCullDistanceVolume = true;
						break;
					case "bAllowApproximateOcclusion":
						if (p.raw[p.raw.Length - 1] == 1)
						bAllowApproximateOcclusion = true;
						break;
					case "bSelfShadowOnly":
						if (p.raw[p.raw.Length - 1] == 1)
						bSelfShadowOnly = true;
						break;
					case "OverridePhysMat":
						if (p.raw[p.raw.Length - 1] == 1)
						OverridePhysMat = true;
						break;
					case "bUseOnePassLightingOnTranslucency":
						if (p.raw[p.raw.Length - 1] == 1)
						bUseOnePassLightingOnTranslucency = true;
						break;
					case "bLockLightingCache":
						if (p.raw[p.raw.Length - 1] == 1)
						bLockLightingCache = true;
						break;
					case "bDisableAllRigidBody":
						if (p.raw[p.raw.Length - 1] == 1)
						bDisableAllRigidBody = true;
						break;
					case "BlockActors":
						if (p.raw[p.raw.Length - 1] == 1)
						BlockActors = true;
						break;
					case "bNotifyRigidBodyCollision":
						if (p.raw[p.raw.Length - 1] == 1)
						bNotifyRigidBodyCollision = true;
						break;
					case "bIgnoreRadialImpulse":
						if (p.raw[p.raw.Length - 1] == 1)
						bIgnoreRadialImpulse = true;
						break;
					case "bIgnoreRadialForce":
						if (p.raw[p.raw.Length - 1] == 1)
						bIgnoreRadialForce = true;
						break;
					case "HiddenEditor":
						if (p.raw[p.raw.Length - 1] == 1)
						HiddenEditor = true;
						break;
					case "StaticMesh":
						StaticMesh_ = p.Value.IntValue;
						break;
					case "ReplacementPrimitive":
						ReplacementPrimitive = p.Value.IntValue;
						break;
					case "LightEnvironment":
						LightEnvironment = p.Value.IntValue;
						break;
					case "ShadowParent":
						ShadowParent = p.Value.IntValue;
						break;
					case "PhysMaterialOverride":
						PhysMaterialOverride = p.Value.IntValue;
						break;
					case "MaxDrawDistance":
						MaxDrawDistance = BitConverter.ToSingle(p.raw, p.raw.Length - 4);
						break;
					case "CachedMaxDrawDistance":
						CachedMaxDrawDistance = BitConverter.ToSingle(p.raw, p.raw.Length - 4);
						break;
					case "MinDrawDistance":
						MinDrawDistance = BitConverter.ToSingle(p.raw, p.raw.Length - 4);
						break;
					case "AudioObstruction":
						AudioObstruction = BitConverter.ToSingle(p.raw, p.raw.Length - 4);
						break;
					case "AudioOcclusion":
						AudioOcclusion = BitConverter.ToSingle(p.raw, p.raw.Length - 4);
						break;
					case "OverriddenLODMaxRange":
						OverriddenLODMaxRange = BitConverter.ToSingle(p.raw, p.raw.Length - 4);
						break;
					case "Scale":
						Scale = BitConverter.ToSingle(p.raw, p.raw.Length - 4);
						break;
                    case "Scale3D":
                        Scale3D = new Vector3(BitConverter.ToSingle(p.raw, p.raw.Length - 12),
                                              BitConverter.ToSingle(p.raw, p.raw.Length - 8),
                                              BitConverter.ToSingle(p.raw, p.raw.Length - 4));
                        break;
                    case "Rotation":
                        Rotation = new Vector3(BitConverter.ToInt32(p.raw, p.raw.Length - 12),
                                              BitConverter.ToInt32(p.raw, p.raw.Length - 8),
                                              BitConverter.ToInt32(p.raw, p.raw.Length - 4));
                        break;
                    case "Translation":
                        Translation = new Vector3(BitConverter.ToSingle(p.raw, p.raw.Length - 12),
                                              BitConverter.ToSingle(p.raw, p.raw.Length - 8),
                                              BitConverter.ToSingle(p.raw, p.raw.Length - 4));
                        break;
					case "MassiveLODDistance":
						MassiveLODDistance = BitConverter.ToSingle(p.raw, p.raw.Length - 4);
						break;
					case "MotionBlurScale":
						MotionBlurScale = BitConverter.ToSingle(p.raw, p.raw.Length - 4);
						break;
					case "TranslucencySortPriority":
						TranslucencySortPriority = p.Value.IntValue;
						break;
					case "LocalTranslucencySortPriority":
						LocalTranslucencySortPriority = p.Value.IntValue;
						break;
					case "ForcedLodModel":
						ForcedLodModel = p.Value.IntValue;
						break;
                    #endregion
                }
            if (StaticMesh_ - 1 >= 0 && StaticMesh_ - 1 < pcc.Exports.Count)
                if (pcc.Exports[StaticMesh_ - 1].ClassName == "StaticMesh")
                {
                    STM = new StaticMesh(pcc, StaticMesh_ - 1);
                    STM.Mesh.Bounds.t = null;//save memory
                    STM.Mesh.Edges.t = null;
                    STM.Mesh.Buffers.t = null;
                    STM.Mesh.IdxBuf.t = null;
                    STM.Mesh.kDOPTree.t = null;
                    STM.Mesh.Mat.t = null;
                    STM.Mesh.RawTris.t = null;
                    STM.Mesh.UnknownPart.t = null;
                    STM.Mesh.Vertices.t = null;
                }
            MyMatrix = Matrix.Identity;
            MyMatrix *=  Matrix.Scaling(Scale3D);
            MyMatrix *=  Matrix.Scaling(Scale, Scale, Scale);
            Vector3 rot = RotatorToDX(Rotation);
            MyMatrix *= Matrix.RotationYawPitchRoll(rot.X, rot.Y, rot.Z);
            MyMatrix *= Matrix.Translation(Translation);
        }
Esempio n. 2
0
 private void listBox1_SelectedIndexChanged_1(object sender, EventArgs e)
 {
     int n = listBox1.SelectedIndex;
     if (n == -1)
         return;
     lODToolStripMenuItem.Visible = false;
     UnCheckLODs();
     stm = null;
     skm = null;
     skmold = null;
     Preview3D.SkelMesh = null;
     Preview3D.StatMesh = null;
     if (pcc.Exports[Objects[n].index].ClassName == "StaticMesh")
         LoadStaticMesh(Objects[n].index);
     if (pcc.Exports[Objects[n].index].ClassName == "SkeletalMesh")
         LoadSkeletalMesh(Objects[n].index);
 }
Esempio n. 3
0
 public override void handleUpdate(List<PackageUpdate> updates)
 {
     IEnumerable<PackageUpdate> relevantUpdates = updates.Where(x => x.change != PackageChange.Import &&
                                                                     x.change != PackageChange.ImportAdd &&
                                                                     x.change != PackageChange.Names);
     List<int> updatedExports = relevantUpdates.Select(x => x.index).ToList();
     if (skm != null && updatedExports.Contains(skm.MyIndex))
     {
         int index = skm.MyIndex;
         //loaded SkeletalMesh is no longer a SkeletalMesh
         if (pcc.getExport(index).ClassName != "SkeletalMesh")
         {
             skm = null;
             skmold = null;
             Preview3D.SkelMesh = null;
             treeView1.Nodes.Clear();
             hb1.ByteProvider = new DynamicByteProvider(new List<byte>());
             RefreshMeshList();
         }
         else
         {
             LoadSkeletalMesh(index);
         }
         updatedExports.Remove(index);
     }
     else if (stm != null && updatedExports.Contains(stm.index))
     {
         int index = stm.index;
         //loaded SkeletalMesh is no longer a SkeletalMesh
         if (pcc.getExport(index).ClassName != "StaticMesh")
         {
             stm = null;
             Preview3D.StatMesh = null;
             treeView1.Nodes.Clear();
             hb1.ByteProvider = new DynamicByteProvider(new List<byte>());
             RefreshMeshList();
         }
         else
         {
             LoadStaticMesh(index);
         }
         updatedExports.Remove(index);
     }
     if (updatedExports.Intersect(Materials).Count() > 0)
     {
         RefreshMaterialList();
     }
     else
     {
         foreach (var i in updatedExports)
         {
             string className = pcc.getExport(i).ClassName;
             if (className == "MaterialInstanceConstant" || className == "Material")
             {
                 RefreshMaterialList();
                 break;
             }
         }
     }
     if (updatedExports.Intersect(Objects).Count() > 0)
     {
         RefreshMeshList();
     }
     else
     {
         foreach (var i in updatedExports)
         {
             string className = pcc.getExport(i).ClassName;
             if (className == "SkeletalMesh" || className == "StaticMesh")
             {
                 RefreshMeshList();
                 break;
             }
         }
     }
 }
Esempio n. 4
0
 public void LoadStaticMesh(int index)
 {
     stm = new StaticMesh(pcc, index);
     Preview3D.StatMesh = stm;
     //Preview3D.SkelMesh = null;
     Preview3D.CamOffset = new Vector3(0, 0, 0);
     treeView1.Nodes.Clear();
     treeView1.Nodes.Add(stm.ToTree());
     treeView1.Nodes[0].Expand();
 }
Esempio n. 5
0
 public void LoadStaticMesh(int index)
 {
     stm = new StaticMesh(pcc as ME3Package, index);
     List<MaterialInstanceConstant> matInsts = stm.Mesh.Mat.MatInst;
     bool foundTex = false;
     try
     {
         for (int i = 0; i < matInsts.Count; i++)
         {
             for (int j = 0; j < matInsts[i].Textures.Count; j++)
             {
                 if (matInsts[i].Textures[j].Desc.Contains("Diffuse"))
                 {
                     Preview3D.setTex(matInsts[i].Textures[j].Texture);
                     foundTex = true;
                     break;
                 }
             }
         }
     }
     catch
     {
     }
     if (!foundTex)
     {
         Preview3D.setTex();
     }
     Preview3D.StatMesh = stm;
     //Preview3D.SkelMesh = null;
     Preview3D.CamOffset = new Vector3(0, 0, 0);
     treeView1.BeginUpdate();
     treeView1.Nodes.Clear();
     treeView1.Nodes.Add(stm.ToTree());
     treeView1.Nodes[0].Expand();
     treeView1.EndUpdate();
 }