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 public enum ViewAttributeScreenUnit
{ {
PIXEL, PIXEL,
PERCENTAGE PERCENT
} }
/* Types for the "MODEL RESOURCE_LIST" */ /* Types for the "MODEL RESOURCE_LIST" */

View File

@ -201,8 +201,8 @@ namespace IDTF.Net
public void WriteOutput(StreamWriter toStream) public void WriteOutput(StreamWriter toStream)
{ {
toStream.WriteLine("\tVIEW_DATA {"); 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_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)); toStream.WriteLine("\t\tVIEW_PROJECTION {0}", this.Projection.ToString(Format.SixDecPlFormat));
//TODO - More View settings //TODO - More View settings

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq;
namespace IDTF.Net namespace IDTF.Net
{ {
@ -24,11 +25,11 @@ namespace IDTF.Net
public abstract class Resource public abstract class Resource
{ {
public string Name { get; set; } public string Name { get; set; }
public abstract ResourceListType ResourceType {get; } public abstract ResourceListType ResourceType { get; }
public abstract void Export(StreamWriter toStream); public abstract void Export(StreamWriter toStream);
} }
public class LightResource: Resource public class LightResource : Resource
{ {
public LightType Type { get; set; } public LightType Type { get; set; }
public Color Color { get; set; } public Color Color { get; set; }
@ -52,7 +53,7 @@ namespace IDTF.Net
get { return ResourceListType.LIGHT; } get { return ResourceListType.LIGHT; }
} }
} }
public class ModelResource: Resource public class ModelResource : Resource
{ {
public ModelResource(ModelType type) public ModelResource(ModelType type)
: base() : base()
@ -64,7 +65,7 @@ namespace IDTF.Net
public MeshData Mesh { get; set; } public MeshData Mesh { get; set; }
public LineSetData LineSet { get; set; } public LineSetData LineSet { get; set; }
public PointSetData PointSet {get; set;} public PointSetData PointSet { get; set; }
public override void Export(StreamWriter toStream) public override void Export(StreamWriter toStream)
{ {
@ -92,7 +93,7 @@ namespace IDTF.Net
get { return ResourceListType.MODEL; } get { return ResourceListType.MODEL; }
} }
} }
public class ShaderResource: Resource public class ShaderResource : Resource
{ {
public string ShaderMaterialName { get; set; } public string ShaderMaterialName { get; set; }
@ -140,7 +141,7 @@ namespace IDTF.Net
get { return ResourceListType.SHADER; } get { return ResourceListType.SHADER; }
} }
} }
public class MaterialResource: Resource public class MaterialResource : Resource
{ {
public bool? AttributeAmbientEnabled { get; set; } //optional public bool? AttributeAmbientEnabled { get; set; } //optional
public bool? AttributeDiffuseEnabled { get; set; } //optional public bool? AttributeDiffuseEnabled { get; set; } //optional
@ -229,14 +230,18 @@ namespace IDTF.Net
} }
} }
/* NOT IMPLEMENTED */
public class ViewResource : Resource public class ViewResource : Resource
{ {
//NOT IMPLEMENTED
public override void Export(StreamWriter toStream) 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 public override ResourceListType ResourceType

View File

@ -68,8 +68,8 @@ namespace IDTF.Net
} }
private Dictionary<string,LightResource> _lightResources; private Dictionary<string, LightResource> _lightResources;
public Dictionary<string,LightResource> LightResources public Dictionary<string, LightResource> LightResources
{ {
get get
{ {
@ -96,7 +96,7 @@ namespace IDTF.Net
{ {
get get
{ {
if (_viewResources == null) { _viewResources = new Dictionary<string,ViewResource>(); } if (_viewResources == null) { _viewResources = new Dictionary<string, ViewResource>(); }
return _viewResources; return _viewResources;
} }
set { _viewResources = value; } set { _viewResources = value; }
@ -201,6 +201,21 @@ namespace IDTF.Net
m.WriteOutput(output); m.WriteOutput(output);
} }
//<RESOURCE_LISTS> - View
if (this.ViewResources.Any())
{
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();
}
//<RESOURCE_LISTS> - Light //<RESOURCE_LISTS> - Light
if (this.LightResources.Count() > 0) if (this.LightResources.Count() > 0)