add view resource

This commit is contained in:
Zhuangkh 2023-05-08 18:06:07 +08:00
parent 1e340f2621
commit 4b960489c8
4 changed files with 474 additions and 454 deletions

View File

@ -49,7 +49,7 @@
public enum ViewAttributeScreenUnit
{
PIXEL,
PERCENTAGE
PERCENT
}
/* Types for the "MODEL RESOURCE_LIST" */

View File

@ -201,8 +201,8 @@ namespace IDTF.Net
public void WriteOutput(StreamWriter toStream)
{
toStream.WriteLine("\tVIEW_DATA {");
toStream.WriteLine("\t\tVIEW_TYPE \"{0}\"", this.ViewType.ToString());
toStream.WriteLine("\t\tVIEW_ATTRIBUTE_SCREEN_UNIT \"{0}\"", this.ViewAttributeScreenUnit.ToString());
toStream.WriteLine("\t\tVIEW_TYPE \"{0}\"", this.ViewType.ToString());
toStream.WriteLine("\t\tVIEW_PROJECTION {0}", this.Projection.ToString(Format.SixDecPlFormat));
//TODO - More View settings

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
namespace IDTF.Net
{
@ -24,228 +25,232 @@ namespace IDTF.Net
public abstract class Resource
{
public string Name { get; set; }
public abstract ResourceListType ResourceType {get; }
public abstract ResourceListType ResourceType { get; }
public abstract void Export(StreamWriter toStream);
}
public class LightResource: Resource
{
public LightType Type { get; set; }
public Color Color { get; set; }
public Point3 Attenuation { get; set; }
public float? SpotAngle { get; set; } // Optional - Applies to Spot lights only, Radians or Deg? Measured from where?
public float Intensity { get; set; }
public class LightResource : Resource
{
public LightType Type { get; set; }
public Color Color { get; set; }
public Point3 Attenuation { get; set; }
public float? SpotAngle { get; set; } // Optional - Applies to Spot lights only, Radians or Deg? Measured from where?
public float Intensity { get; set; }
public override void Export(StreamWriter toStream)
{
toStream.WriteLine(String.Format("\t\tRESOURCE_NAME \"{0}\"", this.Name));
toStream.WriteLine(String.Format("\t\tLIGHT_TYPE \"{0}\"", this.Type.ToString()));
toStream.WriteLine(String.Format("\t\tLIGHT_COLOR {0}", this.Color.ToIDTFStringRGB()));
toStream.WriteLine(String.Format("\t\tLIGHT_ATTENUATION {0}", this.Attenuation.ToString()));
if (this.SpotAngle != null)
toStream.WriteLine(String.Format("\t\tLIGHT_SPOT_ANGLE \"{0}\"", ((float)this.SpotAngle).ToString(Format.SixDecPlFormat)));
toStream.WriteLine(String.Format("\t\tLIGHT_INTENSITY {0}", this.Intensity.ToString(Format.SixDecPlFormat)));
}
public override void Export(StreamWriter toStream)
{
toStream.WriteLine(String.Format("\t\tRESOURCE_NAME \"{0}\"", this.Name));
toStream.WriteLine(String.Format("\t\tLIGHT_TYPE \"{0}\"", this.Type.ToString()));
toStream.WriteLine(String.Format("\t\tLIGHT_COLOR {0}", this.Color.ToIDTFStringRGB()));
toStream.WriteLine(String.Format("\t\tLIGHT_ATTENUATION {0}", this.Attenuation.ToString()));
if (this.SpotAngle != null)
toStream.WriteLine(String.Format("\t\tLIGHT_SPOT_ANGLE \"{0}\"", ((float)this.SpotAngle).ToString(Format.SixDecPlFormat)));
toStream.WriteLine(String.Format("\t\tLIGHT_INTENSITY {0}", this.Intensity.ToString(Format.SixDecPlFormat)));
}
public override ResourceListType ResourceType
{
get { return ResourceListType.LIGHT; }
}
}
public class ModelResource: Resource
{
public ModelResource(ModelType type)
: base()
{
Type = type;
}
public override ResourceListType ResourceType
{
get { return ResourceListType.LIGHT; }
}
}
public class ModelResource : Resource
{
public ModelResource(ModelType type)
: base()
{
Type = type;
}
public ModelType Type { get; set; }
public ModelType Type { get; set; }
public MeshData Mesh { get; set; }
public LineSetData LineSet { get; set; }
public PointSetData PointSet {get; set;}
public MeshData Mesh { get; set; }
public LineSetData LineSet { get; set; }
public PointSetData PointSet { get; set; }
public override void Export(StreamWriter toStream)
{
toStream.WriteLine(String.Format("\t\tRESOURCE_NAME \"{0}\"", this.Name));
toStream.WriteLine(String.Format("\t\tMODEL_TYPE \"{0}\"", this.Type.ToString()));
public override void Export(StreamWriter toStream)
{
toStream.WriteLine(String.Format("\t\tRESOURCE_NAME \"{0}\"", this.Name));
toStream.WriteLine(String.Format("\t\tMODEL_TYPE \"{0}\"", this.Type.ToString()));
switch (Type)
{
case ModelType.MESH:
if (Mesh != null)
Mesh.Export(toStream);
break;
case ModelType.LINE_SET:
if (LineSet != null)
LineSet.Export(toStream);
break;
case ModelType.POINT_SET:
if (PointSet != null)
PointSet.Export(toStream);
break;
}
}
public override ResourceListType ResourceType
{
get { return ResourceListType.MODEL; }
}
}
public class ShaderResource: Resource
{
public string ShaderMaterialName { get; set; }
switch (Type)
{
case ModelType.MESH:
if (Mesh != null)
Mesh.Export(toStream);
break;
case ModelType.LINE_SET:
if (LineSet != null)
LineSet.Export(toStream);
break;
case ModelType.POINT_SET:
if (PointSet != null)
PointSet.Export(toStream);
break;
}
}
public override ResourceListType ResourceType
{
get { return ResourceListType.MODEL; }
}
}
public class ShaderResource : Resource
{
public string ShaderMaterialName { get; set; }
private List<TextureLayer> _shaderTextureLayerList;
public List<TextureLayer> ShaderTextureLayerList
{
get
{
if (_shaderTextureLayerList == null) _shaderTextureLayerList = new List<TextureLayer>();
return _shaderTextureLayerList;
}
set
{
_shaderTextureLayerList = value;
}
}
private List<TextureLayer> _shaderTextureLayerList;
public List<TextureLayer> ShaderTextureLayerList
{
get
{
if (_shaderTextureLayerList == null) _shaderTextureLayerList = new List<TextureLayer>();
return _shaderTextureLayerList;
}
set
{
_shaderTextureLayerList = value;
}
}
public bool? AttributeLightingEnabled { get; set; } //optional
public bool? AttributeAlphaTestEnabled { get; set; } //optional
public bool? AttributeUseVertexColor { get; set; } //optional
public bool? AttributeUseFastSpecular { get; set; } //optional
public float? ShaderAlphaTestReference { get; set; } //optional
public bool? AttributeLightingEnabled { get; set; } //optional
public bool? AttributeAlphaTestEnabled { get; set; } //optional
public bool? AttributeUseVertexColor { get; set; } //optional
public bool? AttributeUseFastSpecular { get; set; } //optional
public float? ShaderAlphaTestReference { get; set; } //optional
public override void Export(StreamWriter toStream)
{
toStream.WriteLine(String.Format("\t\tRESOURCE_NAME \"{0}\"", this.Name));
public override void Export(StreamWriter toStream)
{
toStream.WriteLine(String.Format("\t\tRESOURCE_NAME \"{0}\"", this.Name));
if (this.AttributeLightingEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_LIGHTING_ENABLED \"{0}\"", this.ShaderMaterialName.ToString().ToUpper()));
if (this.AttributeAlphaTestEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_ALPHA_TEST_ENABLED \"{0}\"", this.AttributeAlphaTestEnabled.ToString().ToUpper()));
if (this.AttributeUseVertexColor != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_USE_VERTEX_COLOR \"{0}\"", this.AttributeUseVertexColor.ToString().ToUpper()));
if (this.AttributeUseFastSpecular != null)
toStream.WriteLine(String.Format("\t\tATRIBUTE_USE_FAST_SPECULAR \"{0}\"", this.AttributeUseFastSpecular.ToString().ToUpper()));
if (this.ShaderAlphaTestReference != null)
toStream.WriteLine(String.Format("\t\tSHADER_ALPHA_TEST_REFERENCE \"{0}\"", this.ShaderAlphaTestReference));
if (this.AttributeLightingEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_LIGHTING_ENABLED \"{0}\"", this.ShaderMaterialName.ToString().ToUpper()));
if (this.AttributeAlphaTestEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_ALPHA_TEST_ENABLED \"{0}\"", this.AttributeAlphaTestEnabled.ToString().ToUpper()));
if (this.AttributeUseVertexColor != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_USE_VERTEX_COLOR \"{0}\"", this.AttributeUseVertexColor.ToString().ToUpper()));
if (this.AttributeUseFastSpecular != null)
toStream.WriteLine(String.Format("\t\tATRIBUTE_USE_FAST_SPECULAR \"{0}\"", this.AttributeUseFastSpecular.ToString().ToUpper()));
if (this.ShaderAlphaTestReference != null)
toStream.WriteLine(String.Format("\t\tSHADER_ALPHA_TEST_REFERENCE \"{0}\"", this.ShaderAlphaTestReference));
toStream.WriteLine(String.Format("\t\tSHADER_MATERIAL_NAME \"{0}\"", this.ShaderMaterialName));
ListExtensions.ExportShaderTextureLayerListToStream(ShaderTextureLayerList, toStream);
}
toStream.WriteLine(String.Format("\t\tSHADER_MATERIAL_NAME \"{0}\"", this.ShaderMaterialName));
ListExtensions.ExportShaderTextureLayerListToStream(ShaderTextureLayerList, toStream);
}
public override ResourceListType ResourceType
{
get { return ResourceListType.SHADER; }
}
}
public class MaterialResource: Resource
{
public bool? AttributeAmbientEnabled { get; set; } //optional
public bool? AttributeDiffuseEnabled { get; set; } //optional
public bool? AttributeSpecularEnabled { get; set; } //optional
public bool? AttributeEmmisiveEnabled { get; set; } //optional
public bool? AttributeReflectivityEnabled { get; set; } //optional
public bool? AttributeOpacityEnabled { get; set; } //optional
public override ResourceListType ResourceType
{
get { return ResourceListType.SHADER; }
}
}
public class MaterialResource : Resource
{
public bool? AttributeAmbientEnabled { get; set; } //optional
public bool? AttributeDiffuseEnabled { get; set; } //optional
public bool? AttributeSpecularEnabled { get; set; } //optional
public bool? AttributeEmmisiveEnabled { get; set; } //optional
public bool? AttributeReflectivityEnabled { get; set; } //optional
public bool? AttributeOpacityEnabled { get; set; } //optional
public Color MaterialAmbient { get; set; }
public Color MaterialDiffuse { get; set; }
public Color MaterialSpecular { get; set; }
public Color MaterialEmmisive { get; set; }
public float MaterialReflectivity { get; set; }
public float MaterialOpacity { get; set; }
public Color MaterialAmbient { get; set; }
public Color MaterialDiffuse { get; set; }
public Color MaterialSpecular { get; set; }
public Color MaterialEmmisive { get; set; }
public float MaterialReflectivity { get; set; }
public float MaterialOpacity { get; set; }
public override void Export(StreamWriter toStream)
{
if (this.AttributeAmbientEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_AMBIENT_ENABLED \"{0}\"", this.AttributeAmbientEnabled.ToString().ToUpper()));
if (this.AttributeDiffuseEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_DIFFUSE_ENABLED \"{0}\"", this.AttributeDiffuseEnabled.ToString().ToUpper()));
if (this.AttributeSpecularEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_SPECULAR_ENABLED \"{0}\"", this.AttributeSpecularEnabled.ToString().ToUpper()));
if (this.AttributeEmmisiveEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_EMISSIVE_ENABLED \"{0}\"", this.AttributeEmmisiveEnabled.ToString().ToUpper()));
if (this.AttributeReflectivityEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_REFLECTIVITY_ENABLED \"{0}\"", this.AttributeReflectivityEnabled.ToString().ToUpper()));
if (this.AttributeOpacityEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_OPACITY_ENABLED \"{0}\"", this.AttributeOpacityEnabled.ToString().ToUpper()));
public override void Export(StreamWriter toStream)
{
if (this.AttributeAmbientEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_AMBIENT_ENABLED \"{0}\"", this.AttributeAmbientEnabled.ToString().ToUpper()));
if (this.AttributeDiffuseEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_DIFFUSE_ENABLED \"{0}\"", this.AttributeDiffuseEnabled.ToString().ToUpper()));
if (this.AttributeSpecularEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_SPECULAR_ENABLED \"{0}\"", this.AttributeSpecularEnabled.ToString().ToUpper()));
if (this.AttributeEmmisiveEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_EMISSIVE_ENABLED \"{0}\"", this.AttributeEmmisiveEnabled.ToString().ToUpper()));
if (this.AttributeReflectivityEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_REFLECTIVITY_ENABLED \"{0}\"", this.AttributeReflectivityEnabled.ToString().ToUpper()));
if (this.AttributeOpacityEnabled != null)
toStream.WriteLine(String.Format("\t\tATTRIBUTE_OPACITY_ENABLED \"{0}\"", this.AttributeOpacityEnabled.ToString().ToUpper()));
toStream.WriteLine(String.Format("\t\tRESOURCE_NAME \"{0}\"", this.Name));
toStream.WriteLine(String.Format("\t\tMATERIAL_AMBIENT {0}", this.MaterialAmbient.ToIDTFStringRGB()));
toStream.WriteLine(String.Format("\t\tMATERIAL_DIFFUSE {0}", this.MaterialDiffuse.ToIDTFStringRGB()));
toStream.WriteLine(String.Format("\t\tMATERIAL_SPECULAR {0}", this.MaterialSpecular.ToIDTFStringRGB()));
toStream.WriteLine(String.Format("\t\tMATERIAL_EMISSIVE {0}", this.MaterialEmmisive.ToIDTFStringRGB()));
toStream.WriteLine(String.Format("\t\tMATERIAL_REFLECTIVITY {0}", this.MaterialReflectivity.ToString(Format.SixDecPlFormat)));
toStream.WriteLine(String.Format("\t\tMATERIAL_OPACITY {0}", this.MaterialOpacity.ToString(Format.SixDecPlFormat)));
}
toStream.WriteLine(String.Format("\t\tRESOURCE_NAME \"{0}\"", this.Name));
toStream.WriteLine(String.Format("\t\tMATERIAL_AMBIENT {0}", this.MaterialAmbient.ToIDTFStringRGB()));
toStream.WriteLine(String.Format("\t\tMATERIAL_DIFFUSE {0}", this.MaterialDiffuse.ToIDTFStringRGB()));
toStream.WriteLine(String.Format("\t\tMATERIAL_SPECULAR {0}", this.MaterialSpecular.ToIDTFStringRGB()));
toStream.WriteLine(String.Format("\t\tMATERIAL_EMISSIVE {0}", this.MaterialEmmisive.ToIDTFStringRGB()));
toStream.WriteLine(String.Format("\t\tMATERIAL_REFLECTIVITY {0}", this.MaterialReflectivity.ToString(Format.SixDecPlFormat)));
toStream.WriteLine(String.Format("\t\tMATERIAL_OPACITY {0}", this.MaterialOpacity.ToString(Format.SixDecPlFormat)));
}
public override ResourceListType ResourceType
{
get { return ResourceListType.MATERIAL; }
}
}
public class TextureResource : Resource
{
public int? IdtfTextureHeight { get; set; } //optional
public int? IdtfTextureWidth { get; set; } //optional
public TextureImageType? ImageType { get; set; } //optional
public override ResourceListType ResourceType
{
get { return ResourceListType.MATERIAL; }
}
}
public class TextureResource : Resource
{
public int? IdtfTextureHeight { get; set; } //optional
public int? IdtfTextureWidth { get; set; } //optional
public TextureImageType? ImageType { get; set; } //optional
private List<TextureImageFormat> _texureImageFormatList; //optional
public List<TextureImageFormat> TexureImageFormatList
{
get
{
if (_texureImageFormatList == null) _texureImageFormatList = new List<TextureImageFormat>();
return _texureImageFormatList;
}
set
{
_texureImageFormatList = value;
}
} //optional
private List<TextureImageFormat> _texureImageFormatList; //optional
public List<TextureImageFormat> TexureImageFormatList
{
get
{
if (_texureImageFormatList == null) _texureImageFormatList = new List<TextureImageFormat>();
return _texureImageFormatList;
}
set
{
_texureImageFormatList = value;
}
} //optional
public string TexturePath { get; set; }
public string TexturePath { get; set; }
public override void Export(StreamWriter toStream)
{
toStream.WriteLine(String.Format("\t\tRESOURCE_NAME \"{0}\"", this.Name));
public override void Export(StreamWriter toStream)
{
toStream.WriteLine(String.Format("\t\tRESOURCE_NAME \"{0}\"", this.Name));
if (this.IdtfTextureHeight != null)
toStream.WriteLine(String.Format("\t\tIDTF_TEXTURE_HEIGHT \"{0}\"", this.IdtfTextureHeight.ToString()));
if (this.IdtfTextureWidth != null)
toStream.WriteLine(String.Format("\t\tIDTF_TEXTURE_WIDTH \"{0}\"", this.IdtfTextureWidth.ToString()));
if (this.ImageType != null)
toStream.WriteLine(String.Format("\t\tTEXTURE_IMAGE_TYPE \"{0}\"", this.ImageType.ToString()));
if (this.IdtfTextureHeight != null)
toStream.WriteLine(String.Format("\t\tIDTF_TEXTURE_HEIGHT \"{0}\"", this.IdtfTextureHeight.ToString()));
if (this.IdtfTextureWidth != null)
toStream.WriteLine(String.Format("\t\tIDTF_TEXTURE_WIDTH \"{0}\"", this.IdtfTextureWidth.ToString()));
if (this.ImageType != null)
toStream.WriteLine(String.Format("\t\tTEXTURE_IMAGE_TYPE \"{0}\"", this.ImageType.ToString()));
ListExtensions.ExportTextureImageFormatListToStream(this.TexureImageFormatList, toStream);
toStream.WriteLine(String.Format("\t\tTEXTURE_PATH \"{0}\"", this.TexturePath));
}
ListExtensions.ExportTextureImageFormatListToStream(this.TexureImageFormatList, toStream);
public override ResourceListType ResourceType
{
get { return ResourceListType.TEXTURE; }
}
}
/* NOT IMPLEMENTED */
public class ViewResource : Resource
{
toStream.WriteLine(String.Format("\t\tTEXTURE_PATH \"{0}\"", this.TexturePath));
}
public override ResourceListType ResourceType
{
get { return ResourceListType.TEXTURE; }
}
}
public override void Export(StreamWriter toStream)
{
public class ViewResource : Resource
{
//NOT IMPLEMENTED
public override void Export(StreamWriter toStream)
{
toStream.WriteLine(String.Format("\t\tRESOURCE_NAME \"{0}\"", this.Name));
toStream.WriteLine("\t\tVIEW_PASS_COUNT 1");
toStream.WriteLine("\t\tVIEW_ROOT_NODE_LIST {");
toStream.WriteLine("\t\t\tROOT_NODE 0 {");
toStream.WriteLine("\t\t\t\tROOT_NODE_NAME \"<NULL>\"");
toStream.WriteLine("\t\t\t}");
toStream.WriteLine("\t\t}");
}
}
public override ResourceListType ResourceType
{
get { return ResourceListType.VIEW; }
}
}
public class MotionResource
{
public override ResourceListType ResourceType
{
get { return ResourceListType.VIEW; }
}
}
public class MotionResource
{
}
}
}

View File

@ -4,300 +4,315 @@ using System.Linq;
namespace IDTF.Net
{
/// <summary>
/// The Scene is the root node in the IDTF file, all objects should be aded to the scene,
/// and then the scene is exported to a file
/// </summary>
public class IDTFScene
{
/// <summary>
/// The Scene is the root node in the IDTF file, all objects should be aded to the scene,
/// and then the scene is exported to a file
/// </summary>
public class IDTFScene
{
private List<View> _views;
/// <summary>
/// A list of the View nodes in the scene
/// </summary>
public List<View> Views
{
get
{
if (_views == null) { _views = new List<View>(); }
return _views;
}
set { _views = value; }
}
private List<View> _views;
/// <summary>
/// A list of the View nodes in the scene
/// </summary>
public List<View> Views
{
get
{
if (_views == null) { _views = new List<View>(); }
return _views;
}
set { _views = value; }
}
private List<Model> _models;
/// <summary>
/// A list of the Model nodes in this scene
/// </summary>
public List<Model> Models
{
get
{
if (_models == null) { _models = new List<Model>(); }
return _models;
}
set { _models = value; }
}
private List<Model> _models;
/// <summary>
/// A list of the Model nodes in this scene
/// </summary>
public List<Model> Models
{
get
{
if (_models == null) { _models = new List<Model>(); }
return _models;
}
set { _models = value; }
}
private List<Group> _groups;
/// <summary>
/// A list of the group nodes in this scene
/// </summary>
public List<Group> Groups
{
get
{
if (_groups == null) { _groups = new List<Group>(); }
return _groups;
}
set { _groups = value; }
}
private List<Group> _groups;
/// <summary>
/// A list of the group nodes in this scene
/// </summary>
public List<Group> Groups
{
get
{
if (_groups == null) { _groups = new List<Group>(); }
return _groups;
}
set { _groups = value; }
}
private List<Light> _lights;
/// <summary>
/// A list of lights in this scene
/// </summary>
public List<Light> Lights
{
get
{
if (_lights == null) { _lights = new List<Light>(); }
return _lights;
}
set { _lights = value; }
}
private List<Light> _lights;
/// <summary>
/// A list of lights in this scene
/// </summary>
public List<Light> Lights
{
get
{
if (_lights == null) { _lights = new List<Light>(); }
return _lights;
}
set { _lights = value; }
}
private Dictionary<string,LightResource> _lightResources;
public Dictionary<string,LightResource> LightResources
{
get
{
if (_lightResources == null) { _lightResources = new Dictionary<string, LightResource>(); }
return _lightResources;
}
set { _lightResources = value; }
}
private Dictionary<string, LightResource> _lightResources;
public Dictionary<string, LightResource> LightResources
{
get
{
if (_lightResources == null) { _lightResources = new Dictionary<string, LightResource>(); }
return _lightResources;
}
set { _lightResources = value; }
}
private Dictionary<string, ModelResource> _modelResources;
public Dictionary<string, ModelResource> ModelResources
{
get
{
if (_modelResources == null) { _modelResources = new Dictionary<string, ModelResource>(); }
return _modelResources;
}
set { _modelResources = value; }
}
private Dictionary<string, ModelResource> _modelResources;
public Dictionary<string, ModelResource> ModelResources
{
get
{
if (_modelResources == null) { _modelResources = new Dictionary<string, ModelResource>(); }
return _modelResources;
}
set { _modelResources = value; }
}
private Dictionary<string, ViewResource> _viewResources;
public Dictionary<string, ViewResource> ViewResources
{
get
{
if (_viewResources == null) { _viewResources = new Dictionary<string,ViewResource>(); }
return _viewResources;
}
set { _viewResources = value; }
}
private Dictionary<string, ViewResource> _viewResources;
public Dictionary<string, ViewResource> ViewResources
{
get
{
if (_viewResources == null) { _viewResources = new Dictionary<string, ViewResource>(); }
return _viewResources;
}
set { _viewResources = value; }
}
private Dictionary<string, ShaderResource> _shaderResources;
public Dictionary<string, ShaderResource> ShaderResources
{
get
{
if (_shaderResources == null) { _shaderResources = new Dictionary<string, ShaderResource>(); }
return _shaderResources;
}
set { _shaderResources = value; }
}
private Dictionary<string, ShaderResource> _shaderResources;
public Dictionary<string, ShaderResource> ShaderResources
{
get
{
if (_shaderResources == null) { _shaderResources = new Dictionary<string, ShaderResource>(); }
return _shaderResources;
}
set { _shaderResources = value; }
}
private Dictionary<string, MaterialResource> _materialResources;
public Dictionary<string, MaterialResource> MaterialResources
{
get
{
if (_materialResources == null) { _materialResources = new Dictionary<string, MaterialResource>(); }
return _materialResources;
}
set { _materialResources = value; }
}
private Dictionary<string, MaterialResource> _materialResources;
public Dictionary<string, MaterialResource> MaterialResources
{
get
{
if (_materialResources == null) { _materialResources = new Dictionary<string, MaterialResource>(); }
return _materialResources;
}
set { _materialResources = value; }
}
private Dictionary<string, TextureResource> _textureResources;
public Dictionary<string, TextureResource> TextureResources
{
get
{
if (_textureResources == null) { _textureResources = new Dictionary<string, TextureResource>(); }
return _textureResources;
}
set { _textureResources = value; }
}
private Dictionary<string, TextureResource> _textureResources;
public Dictionary<string, TextureResource> TextureResources
{
get
{
if (_textureResources == null) { _textureResources = new Dictionary<string, TextureResource>(); }
return _textureResources;
}
set { _textureResources = value; }
}
private Dictionary<string, MotionResource> _motionResources;
public Dictionary<string, MotionResource> MotionResources
{
get
{
if (_motionResources == null) { _motionResources = new Dictionary<string, MotionResource>(); }
return _motionResources;
}
set { _motionResources = value; }
}
private Dictionary<string, MotionResource> _motionResources;
public Dictionary<string, MotionResource> MotionResources
{
get
{
if (_motionResources == null) { _motionResources = new Dictionary<string, MotionResource>(); }
return _motionResources;
}
set { _motionResources = value; }
}
private List<ShadingModifier> _shadingModifiers;
public List<ShadingModifier> ShadingModifiers
{
get
{
if (_shadingModifiers == null) { _shadingModifiers = new List<ShadingModifier>(); }
return _shadingModifiers;
}
set { _shadingModifiers = value; }
}
public bool Export(string toFile)
{
// The IDTF file contains the following text blocks written in this order
//<FILE_HEADER>
//<SCENE_DATA>
//<FILE_REFERENCE>
//<NODES>
//<NODE_RESOURCES>
//<SHADER_RESOURCES>
//<MATERIAL_RESOURCES>
//<TEXTURE_RESOURCES>
//<MOTION_RESOURCES>
//<MODIFIERS>
using (var output = new StreamWriter(toFile))
{
private List<ShadingModifier> _shadingModifiers;
public List<ShadingModifier> ShadingModifiers
{
get
{
if (_shadingModifiers == null) { _shadingModifiers = new List<ShadingModifier>(); }
return _shadingModifiers;
}
set { _shadingModifiers = value; }
}
public bool Export(string toFile)
{
// The IDTF file contains the following text blocks written in this order
//<FILE_HEADER>
output.WriteLine("FILE_FORMAT \"IDTF\"");
output.WriteLine("FORMAT_VERSION 100");
output.WriteLine();
//<SCENE_DATA>
//<FILE_REFERENCE>
// NOT YET IMPLEMENTED
//<NODES>
//<NODE_RESOURCES>
//<SHADER_RESOURCES>
//<MATERIAL_RESOURCES>
//<TEXTURE_RESOURCES>
//<MOTION_RESOURCES>
//<MODIFIERS>
//<NODES> - groups
foreach (Group g in this.Groups)
using (var output = new StreamWriter(toFile))
{
g.WriteOutput(output);
}
//<NODES> - Views
foreach (View v in this.Views)
{
v.WriteOutput(output);
}
//<NODES> - Models
foreach (Model m in this.Models)
{
m.WriteOutput(output);
}
//<RESOURCE_LISTS> - Light
if (this.LightResources.Count() > 0)
{
output.WriteLine("RESOURCE_LIST \"LIGHT\" {");
output.WriteLine("\tRESOURCE_COUNT {0}", this.LightResources.Count().ToString());
for (int i = 0; i < this.LightResources.Count(); i++)
{
output.WriteLine("\tRESOURCE {0} {{", i.ToString());
this.LightResources.ElementAt(i).Value.Export(output);
output.WriteLine("\t}");
}
output.WriteLine("}");
//<FILE_HEADER>
output.WriteLine("FILE_FORMAT \"IDTF\"");
output.WriteLine("FORMAT_VERSION 100");
output.WriteLine();
}
//<RESOURCE_LISTS> - Shader
if (this.ShaderResources.Count() > 0)
{
output.WriteLine("RESOURCE_LIST \"SHADER\" {");
output.WriteLine("\tRESOURCE_COUNT {0}", this.ShaderResources.Count().ToString());
//<SCENE_DATA>
//<FILE_REFERENCE>
// NOT YET IMPLEMENTED
for (int i = 0; i < this.ShaderResources.Count(); i++)
//<NODES> - groups
foreach (Group g in this.Groups)
{
output.WriteLine("\tRESOURCE {0} {{", i.ToString());
this.ShaderResources.ElementAt(i).Value.Export(output);
output.WriteLine("\t}");
g.WriteOutput(output);
}
output.WriteLine("}");
output.WriteLine();
}
//<RESOURCE_LISTS> - Material
if (this.MaterialResources.Count() > 0)
{
output.WriteLine("RESOURCE_LIST \"MATERIAL\" {");
output.WriteLine("\tRESOURCE_COUNT {0}", this.MaterialResources.Count().ToString());
for (int i = 0; i < this.MaterialResources.Count(); i++)
//<NODES> - Views
foreach (View v in this.Views)
{
output.WriteLine("\tRESOURCE {0} {{", i.ToString());
this.MaterialResources.ElementAt(i).Value.Export(output);
output.WriteLine("\t}");
v.WriteOutput(output);
}
output.WriteLine("}");
output.WriteLine();
}
//<RESOURCE_LISTS> - Texture
if (this.TextureResources.Count() > 0)
{
output.WriteLine("RESOURCE_LIST \"TEXTURE\" {");
output.WriteLine("\tRESOURCE_COUNT {0}", this.TextureResources.Count().ToString());
for (int i = 0; i < this.TextureResources.Count(); i++)
//<NODES> - Models
foreach (Model m in this.Models)
{
output.WriteLine("\tRESOURCE {0} {{", i.ToString());
this.TextureResources.ElementAt(i).Value.Export(output);
output.WriteLine("\t}");
m.WriteOutput(output);
}
output.WriteLine("}");
output.WriteLine();
}
//<RESOURCE_LISTS> - Model
if (this.ModelResources.Count() > 0)
{
output.WriteLine("RESOURCE_LIST \"MODEL\" {");
output.WriteLine("\tRESOURCE_COUNT {0}", this.ModelResources.Count().ToString());
for (int i = 0; i < this.ModelResources.Count(); i++)
//<RESOURCE_LISTS> - View
if (this.ViewResources.Any())
{
output.WriteLine("\tRESOURCE {0} {{", i.ToString());
this.ModelResources.ElementAt(i).Value.Export(output);
output.WriteLine("\t}");
output.WriteLine("RESOURCE_LIST \"VIEW\" {");
output.WriteLine("\tRESOURCE_COUNT {0}", this.ViewResources.Count().ToString());
for (int i = 0; i < this.ViewResources.Count(); i++)
{
output.WriteLine("\tRESOURCE {0} {{", i.ToString());
this.ViewResources.ElementAt(i).Value.Export(output);
output.WriteLine("\t}");
}
output.WriteLine("}");
output.WriteLine();
}
output.WriteLine("}");
output.WriteLine();
//<RESOURCE_LISTS> - Light
if (this.LightResources.Count() > 0)
{
output.WriteLine("RESOURCE_LIST \"LIGHT\" {");
output.WriteLine("\tRESOURCE_COUNT {0}", this.LightResources.Count().ToString());
for (int i = 0; i < this.LightResources.Count(); i++)
{
output.WriteLine("\tRESOURCE {0} {{", i.ToString());
this.LightResources.ElementAt(i).Value.Export(output);
output.WriteLine("\t}");
}
output.WriteLine("}");
output.WriteLine();
}
//<RESOURCE_LISTS> - Shader
if (this.ShaderResources.Count() > 0)
{
output.WriteLine("RESOURCE_LIST \"SHADER\" {");
output.WriteLine("\tRESOURCE_COUNT {0}", this.ShaderResources.Count().ToString());
for (int i = 0; i < this.ShaderResources.Count(); i++)
{
output.WriteLine("\tRESOURCE {0} {{", i.ToString());
this.ShaderResources.ElementAt(i).Value.Export(output);
output.WriteLine("\t}");
}
output.WriteLine("}");
output.WriteLine();
}
//<RESOURCE_LISTS> - Material
if (this.MaterialResources.Count() > 0)
{
output.WriteLine("RESOURCE_LIST \"MATERIAL\" {");
output.WriteLine("\tRESOURCE_COUNT {0}", this.MaterialResources.Count().ToString());
for (int i = 0; i < this.MaterialResources.Count(); i++)
{
output.WriteLine("\tRESOURCE {0} {{", i.ToString());
this.MaterialResources.ElementAt(i).Value.Export(output);
output.WriteLine("\t}");
}
output.WriteLine("}");
output.WriteLine();
}
//<RESOURCE_LISTS> - Texture
if (this.TextureResources.Count() > 0)
{
output.WriteLine("RESOURCE_LIST \"TEXTURE\" {");
output.WriteLine("\tRESOURCE_COUNT {0}", this.TextureResources.Count().ToString());
for (int i = 0; i < this.TextureResources.Count(); i++)
{
output.WriteLine("\tRESOURCE {0} {{", i.ToString());
this.TextureResources.ElementAt(i).Value.Export(output);
output.WriteLine("\t}");
}
output.WriteLine("}");
output.WriteLine();
}
//<RESOURCE_LISTS> - Model
if (this.ModelResources.Count() > 0)
{
output.WriteLine("RESOURCE_LIST \"MODEL\" {");
output.WriteLine("\tRESOURCE_COUNT {0}", this.ModelResources.Count().ToString());
for (int i = 0; i < this.ModelResources.Count(); i++)
{
output.WriteLine("\tRESOURCE {0} {{", i.ToString());
this.ModelResources.ElementAt(i).Value.Export(output);
output.WriteLine("\t}");
}
output.WriteLine("}");
output.WriteLine();
}
//<MODIFIER> - Shading
foreach (ShadingModifier s in this.ShadingModifiers)
{
s.Export(output);
}
output.Flush();
output.Close();
}
//<MODIFIER> - Shading
foreach (ShadingModifier s in this.ShadingModifiers)
{
s.Export(output);
}
return false;
}
output.Flush();
output.Close();
}
return false;
}
}
}
}