From 9b7cda0a3f23bf2db2e065dcf4af09cbd48bad7e Mon Sep 17 00:00:00 2001 From: Ruan PA Date: Tue, 10 Jul 2012 18:07:19 +0100 Subject: [PATCH] Added basic FbxNodeAttribute support --- ManagedFbx.Samples/FbxForm.Designer.cs | 12 +++++++++ ManagedFbx.Samples/FbxForm.cs | 8 +++++- ManagedFbx.sln | 3 +++ ManagedFbx/Manager.h | 4 +-- ManagedFbx/SceneNode.cpp | 13 ++++++++++ ManagedFbx/SceneNode.h | 4 ++- ManagedFbx/SceneNodeAttribute.cpp | 24 +++++++++++++++++- ManagedFbx/SceneNodeAttribute.h | 34 ++++++++++++++++++++++++++ 8 files changed, 96 insertions(+), 6 deletions(-) diff --git a/ManagedFbx.Samples/FbxForm.Designer.cs b/ManagedFbx.Samples/FbxForm.Designer.cs index 8b47336..7ffdd0a 100644 --- a/ManagedFbx.Samples/FbxForm.Designer.cs +++ b/ManagedFbx.Samples/FbxForm.Designer.cs @@ -28,6 +28,7 @@ private void InitializeComponent() { this.uxFbxTree = new System.Windows.Forms.TreeView(); this.uxTranslationLabel = new System.Windows.Forms.Label(); + this.uxAttrLabel = new System.Windows.Forms.Label(); this.SuspendLayout(); // // uxFbxTree @@ -47,11 +48,21 @@ private void InitializeComponent() this.uxTranslationLabel.TabIndex = 1; this.uxTranslationLabel.Text = "pos"; // + // uxAttrLabel + // + this.uxAttrLabel.AutoSize = true; + this.uxAttrLabel.Location = new System.Drawing.Point(421, 84); + this.uxAttrLabel.Name = "uxAttrLabel"; + this.uxAttrLabel.Size = new System.Drawing.Size(24, 13); + this.uxAttrLabel.TabIndex = 2; + this.uxAttrLabel.Text = "pos"; + // // FbxForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(839, 514); + this.Controls.Add(this.uxAttrLabel); this.Controls.Add(this.uxTranslationLabel); this.Controls.Add(this.uxFbxTree); this.Name = "FbxForm"; @@ -65,5 +76,6 @@ private void InitializeComponent() private System.Windows.Forms.TreeView uxFbxTree; private System.Windows.Forms.Label uxTranslationLabel; + private System.Windows.Forms.Label uxAttrLabel; } \ No newline at end of file diff --git a/ManagedFbx.Samples/FbxForm.cs b/ManagedFbx.Samples/FbxForm.cs index 06ce62b..88bf8a5 100644 --- a/ManagedFbx.Samples/FbxForm.cs +++ b/ManagedFbx.Samples/FbxForm.cs @@ -1,4 +1,4 @@ -using System.IO; +using System.Linq; using System.Windows.Forms; using ManagedFbx; @@ -35,5 +35,11 @@ private void OnTreeSelect(object sender, TreeViewEventArgs e) return; uxTranslationLabel.Text = string.Format("Position: {0}\nRotation: {1}\nScale: {2}", node.Position, node.Rotation, node.Scale); + uxAttrLabel.Text = string.Format("Found {0} attributes", node.Attributes.Count()); + + foreach(var attr in node.Attributes) + { + uxAttrLabel.Text += "\n" + attr.AttributeType; + } } } diff --git a/ManagedFbx.sln b/ManagedFbx.sln index cb20327..ceb9250 100644 --- a/ManagedFbx.sln +++ b/ManagedFbx.sln @@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ManagedFbx", "ManagedFbx\ManagedFbx.vcxproj", "{163D9B5E-1A69-4821-89DE-298736F2C14E}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManagedFbx.Samples", "ManagedFbx.Samples\ManagedFbx.Samples.csproj", "{78BA3050-B035-46F5-AAC2-4B9B8A3CFDDC}" + ProjectSection(ProjectDependencies) = postProject + {163D9B5E-1A69-4821-89DE-298736F2C14E} = {163D9B5E-1A69-4821-89DE-298736F2C14E} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/ManagedFbx/Manager.h b/ManagedFbx/Manager.h index 4590885..a44fe0d 100644 --- a/ManagedFbx/Manager.h +++ b/ManagedFbx/Manager.h @@ -4,12 +4,10 @@ namespace ManagedFbx { - public ref class Manager abstract sealed + ref class Manager abstract sealed { public: static Manager(); - - internal: static FbxManager *GetFbxManager(); static FbxImporter *GetFbxImporter(); diff --git a/ManagedFbx/SceneNode.cpp b/ManagedFbx/SceneNode.cpp index 774701d..94d274e 100644 --- a/ManagedFbx/SceneNode.cpp +++ b/ManagedFbx/SceneNode.cpp @@ -6,13 +6,21 @@ using namespace ManagedFbx; SceneNode::SceneNode(FbxNode *node) { m_nativeNode = node; + m_children = gcnew List(); + m_attributes = gcnew List(); for(int i = 0; i < m_nativeNode->GetChildCount(); i++) { auto sub = m_nativeNode->GetChild(i); m_children->Add(gcnew SceneNode(sub)); } + + for(int i = 0; i < m_nativeNode->GetNodeAttributeCount(); i++) + { + auto attr = m_nativeNode->GetNodeAttributeByIndex(i); + m_attributes->Add(gcnew SceneNodeAttribute(attr)); + } } IEnumerable^ SceneNode::ChildNodes::get() @@ -20,6 +28,11 @@ IEnumerable^ SceneNode::ChildNodes::get() return m_children->AsReadOnly(); } +IEnumerable^ SceneNode::Attributes::get() +{ + return m_attributes->AsReadOnly(); +} + string ^SceneNode::Name::get() { return gcnew string(m_nativeNode->GetName()); diff --git a/ManagedFbx/SceneNode.h b/ManagedFbx/SceneNode.h index e4fdd59..30f41e3 100644 --- a/ManagedFbx/SceneNode.h +++ b/ManagedFbx/SceneNode.h @@ -1,6 +1,6 @@ #pragma once -#include "Properties.h" +#include "SceneNodeAttribute.h" using namespace System::Collections::Generic; @@ -11,6 +11,7 @@ namespace ManagedFbx public: property_rw(string^, Name); property_r(IEnumerable^, ChildNodes); + property_r(IEnumerable^, Attributes); property_rw(Vector3, Position); property_rw(Vector3, Rotation); @@ -24,5 +25,6 @@ namespace ManagedFbx private: FbxNode *m_nativeNode; List ^m_children; + List ^m_attributes; }; } \ No newline at end of file diff --git a/ManagedFbx/SceneNodeAttribute.cpp b/ManagedFbx/SceneNodeAttribute.cpp index 4770aaa..6cebcc1 100644 --- a/ManagedFbx/SceneNodeAttribute.cpp +++ b/ManagedFbx/SceneNodeAttribute.cpp @@ -1,2 +1,24 @@ #include "stdafx.h" -#include "SceneNodeAttribute.h" \ No newline at end of file +#include "SceneNodeAttribute.h" + +using namespace ManagedFbx; + +SceneNodeAttribute::SceneNodeAttribute(FbxNodeAttribute *nativeAttr) +{ + m_nativeAttribute = nativeAttr; +} + +NodeAttributeType^ SceneNodeAttribute::AttributeType::get() +{ + return (NodeAttributeType)m_nativeAttribute->GetAttributeType(); +} + +string ^SceneNodeAttribute::Name::get() +{ + return gcnew string(m_nativeAttribute->GetName()); +} + +void SceneNodeAttribute::Name::set(string ^value) +{ + m_nativeAttribute->SetName(StringHelper::ToNative(value)); +} diff --git a/ManagedFbx/SceneNodeAttribute.h b/ManagedFbx/SceneNodeAttribute.h index 0c8c828..3a88c07 100644 --- a/ManagedFbx/SceneNodeAttribute.h +++ b/ManagedFbx/SceneNodeAttribute.h @@ -2,8 +2,42 @@ namespace ManagedFbx { + public enum class NodeAttributeType + { + Unknown = FbxNodeAttribute::eUnknown, + Null = FbxNodeAttribute::eNull, + Marker = FbxNodeAttribute::eMarker, + Skeleton = FbxNodeAttribute::eSkeleton, + Mesh = FbxNodeAttribute::eMesh, + Nurbs = FbxNodeAttribute::eNurbs, + Patch = FbxNodeAttribute::ePatch, + Camera = FbxNodeAttribute::eCamera, + CameraStereo = FbxNodeAttribute::eCameraStereo, + CameraSwitcher = FbxNodeAttribute::eCameraSwitcher, + Light = FbxNodeAttribute::eLight, + OpticalReference = FbxNodeAttribute::eOpticalReference, + OpticalMarker = FbxNodeAttribute::eOpticalMarker, + NurbsCurve = FbxNodeAttribute::eNurbsCurve, + TrimNurbsSurface = FbxNodeAttribute::eTrimNurbsSurface, + Boundary = FbxNodeAttribute::eBoundary, + NurbsSurface = FbxNodeAttribute::eNurbsSurface, + Shape = FbxNodeAttribute::eShape, + LodGroup = FbxNodeAttribute::eLODGroup, + Subdiv = FbxNodeAttribute::eSubDiv + }; + public ref class SceneNodeAttribute { + public: + property_r(NodeAttributeType^, AttributeType); + property_rw(string^, Name); + internal: + SceneNodeAttribute(FbxNodeAttribute *nativeAttr); + + private: + FbxNodeAttribute *m_nativeAttribute; }; + + } \ No newline at end of file