public EntityData(DREntity dREntity, DRAssetsPath dRAssetsPath, EntityGroupData entityGroupData)
 {
     this.dREntity        = dREntity;
     this.dRAssetsPath    = dRAssetsPath;
     this.entityGroupData = entityGroupData;
 }
示例#2
0
        public static void ExportSceneData(EntityData entityData, string vfsOutputFilename, AssetManager assetManager, string effectName = null, string exportType = "entity", bool generateAEN = false)
        {
            object exportedObject;

            if (exportType == "animation")
            {
                throw new InvalidOperationException("Deprecated?");
                //var animationData = ((AnimationComponentData)entityData.Components[AnimationComponent.Key]).Animations[0].AnimationData;
                //exportedObject = animationData;
            }
            else if (exportType == "scenedata")
            {
                exportedObject = entityData;
            }
            else if (exportType == "entity")
            {
                var entityGroup = new EntityGroupData();

                // Additional processing
                foreach (var node in EnumerateChildren(entityData))
                {
                    entityGroup.Entities.Add(node);

                    var modelComponent = node.Components.Values.OfType <ModelComponentData>().FirstOrDefault();
                    if (modelComponent == null)
                    {
                        continue;
                    }

                    foreach (var effectMeshData in modelComponent.Model.Value.Meshes)
                    {
                        //if (effectMeshData.Value.DrawData != null)
                        //{
                        //    //// Generate AEN adjacency index buffer (if requested)
                        //    //if (generateAEN)
                        //    //{
                        //    //    var subMeshDataAEN = effectMeshData.DrawData.Value.SubMeshDatas[Mesh.StandardSubMeshData].Clone();
                        //    //    subMeshDataAEN.GenerateIndexBufferAEN();
                        //    //    effectMeshData.DrawData.Value.SubMeshDatas["TessellationAEN"] = subMeshDataAEN;
                        //    //}
                        //    //
                        //    //// Compact index buffer from 32 bits to 16 bits per index (if possible)
                        //    //foreach (var subMeshData in effectMeshData.DrawData.Value.SubMeshDatas)
                        //    //{
                        //    //    subMeshData.Value.CompactIndexBuffer();
                        //    //}

                        //    // Force effect name (if requested)
                        //    if (effectName != null)
                        //    {
                        //        effectMeshData.Value.EffectData.Value.Name = effectName;
                        //    }
                        //}
                    }
                }

                // Convert to Entity
                exportedObject = entityGroup;
            }
            else
            {
                throw new InvalidOperationException("Unknown export type.");
            }

            //contentManager = new ContentManager(new ContentSerializerContextGenerator(vfs, packageManager, ParameterContainerExtensions.DefaultSceneSerializer));
            assetManager.Save(VirtualFileSystem.Drive.RootPath + vfsOutputFilename + "#/root", exportedObject);
        }