Inheritance: _DXRenderableObject
コード例 #1
0
        public StaticMeshComponent(PCCPackage Pcc, int index, Matrix transform)
        {
            pcc     = Pcc;
            MyIndex = index;
            byte[] buff = pcc.GetObjectData(index);
            Props        = PropertyReader.getPropList(pcc, buff);
            ParentMatrix = transform;
            foreach (PropertyReader.Property p in Props)
            {
                string s = pcc.GetName(p.Name);
                switch (s)
                {
                case "StaticMesh":
                    idxSTM = p.Value.IntValue;
                    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;

                default:
                    break;
                }
            }
            MyMatrix  = Matrix.Identity;
            MyMatrix *= Matrix.Scaling(Scale3D);
            MyMatrix *= Matrix.Scaling(new Vector3(Scale, Scale, Scale));
            Vector3 rot = DXHelper.RotatorToDX(Rotation);

            MyMatrix *= Matrix.RotationYawPitchRoll(rot.X, rot.Y, rot.Z);
            MyMatrix *= Matrix.Translation(Translation);
            Matrix t = MyMatrix * ParentMatrix;

            if (idxSTM > 0 && !pcc.getObjectName(idxSTM).ToLower().Contains("volumetric") && !pcc.getObjectName(idxSTM).ToLower().Contains("spheremesh"))
            {
                STM = new StaticMesh(pcc, idxSTM - 1, t);
            }
        }
コード例 #2
0
 public StaticMeshComponent(PCCPackage Pcc, int index, Matrix transform)
 {
     pcc = Pcc;
     MyIndex = index;
     byte[] buff = pcc.GetObjectData(index);
     Props = PropertyReader.getPropList(pcc, buff);
     ParentMatrix = transform;
     foreach (PropertyReader.Property p in Props)
     {
         string s = pcc.GetName(p.Name);
         switch (s)
         {
             case "StaticMesh":
                 idxSTM = p.Value.IntValue;
                 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;
             default:
                 break;
         }
     }
     MyMatrix = Matrix.Identity;
     MyMatrix *= Matrix.Scaling(Scale3D);
     MyMatrix *= Matrix.Scaling(new Vector3(Scale, Scale, Scale));
     Vector3 rot = DXHelper.RotatorToDX(Rotation);
     MyMatrix *= Matrix.RotationYawPitchRoll(rot.X, rot.Y, rot.Z);
     MyMatrix *= Matrix.Translation(Translation);
     Matrix t = MyMatrix * ParentMatrix;
     if (idxSTM > 0 && !pcc.getObjectName(idxSTM).ToLower().Contains("volumetric") && !pcc.getObjectName(idxSTM).ToLower().Contains("spheremesh"))
         STM = new StaticMesh(pcc, idxSTM - 1, t);
 }