private static Entity CreateTrackingEntity(EntityAsset entityAsset, Entity rootEntityAsset, ModelAsset modelAsset, string nodeName)
        {
            var childEntity = new Entity {
                Name = nodeName
            };

            // Add TransformComponent
            childEntity.Add(TransformComponent.Key, new TransformComponent());

            // Add ModelNodeLinkComponent
            childEntity.Add(ModelNodeLinkComponent.Key, new ModelNodeLinkComponent
            {
                NodeName = nodeName,
                Target   = rootEntityAsset.Get(ModelComponent.Key),
            });

            // Add this asset to the list
            entityAsset.Hierarchy.Entities.Add(childEntity);

            // Get or create transformation component
            var transformationComponent = rootEntityAsset.GetOrCreate(TransformComponent.Key);

            // Mark node as preserved
            modelAsset.PreserveNodes(new List <string> {
                nodeName
            });

            // Add as children of model entity
            transformationComponent.Children.Add(childEntity.GetOrCreate(TransformComponent.Key));

            return(childEntity);
        }
Beispiel #2
0
        private static AssetItem CreateTrackingEntity(AssetItem rootEntityAsset, AssetItem modelAsset, UFile cameraUrl, string nodeName)
        {
            var entity = new EntityData {
                Name = nodeName
            };

            // Add TransformationComponent
            entity.Components.Add(TransformationComponent.Key, new TransformationComponentData());


            // Add ModelNodeLinkComponent
            entity.Components.Add(ModelNodeLinkComponent.Key, new ModelNodeLinkComponentData
            {
                NodeName = nodeName,
                Target   = EntityComponentReference.New(rootEntityAsset.Id, rootEntityAsset.Location, ModelComponent.Key),
            });

            var asset = new EntityAsset {
                Data = entity
            };
            var entityAsset = new AssetItem(cameraUrl, asset);

            var parentEntity = (EntityAsset)rootEntityAsset.Asset;

            // Get or create transformation component
            EntityComponentData entityComponentData;

            if (!parentEntity.Data.Components.TryGetValue(TransformationComponent.Key, out entityComponentData))
            {
                entityComponentData = new TransformationComponentData();
                parentEntity.Data.Components.Add(TransformationComponent.Key, entityComponentData);
            }

            // Mark node as preserved
            ((ModelAsset)modelAsset.Asset).PreserveNodes(new List <string> {
                nodeName
            });

            // Add as children of model entity
            ((TransformationComponentData)entityComponentData).Children.Add(
                EntityComponentReference.New(entityAsset.Id, entityAsset.Location, TransformationComponent.Key));


            return(entityAsset);
        }
Beispiel #3
0
        private static AssetItem ImportEntity(List <AssetItem> assetReferences, UFile localPath, AssetItem modelItem, EntityInfo entityInfo)
        {
            var entityUrl = new UFile(localPath.GetFileName(), null);

            var asset = new EntityAsset();

            asset.Data.Name = entityUrl;
            // Use modelUrl.Path to get the url without the extension
            asset.Data.Components.Add(ModelComponent.Key, new ModelComponentData {
                Model = new ContentReference <ModelData>(modelItem.Id, modelItem.Location), Enabled = true
            });

            var assetReference = new AssetItem(entityUrl, asset);

            assetReferences.Add(assetReference);

            return(assetReference);
        }
Beispiel #4
0
        private static AssetItem ImportEntity(List <AssetItem> assetReferences, UFile localPath, AssetItem modelItem)
        {
            var entityUrl = new UFile(localPath.GetFileName(), null);

            var asset = new EntityAsset {
                Source = localPath
            };
            var rootEntityData = new Entity();

            asset.Hierarchy.Entities.Add(rootEntityData);
            asset.Hierarchy.RootEntity = rootEntityData.Id;

            rootEntityData.Name = entityUrl;
            // Use modelUrl.Path to get the url without the extension
            rootEntityData.Add(ModelComponent.Key, new ModelComponent {
                Model = AttachedReferenceManager.CreateSerializableVersion <Rendering.Model>(modelItem.Id, modelItem.Location)
            });

            var assetReference = new AssetItem(entityUrl, asset);

            assetReferences.Add(assetReference);

            return(assetReference);
        }