Skip to content

Commit

Permalink
Added basic FbxNodeAttribute support
Browse files Browse the repository at this point in the history
  • Loading branch information
returnString committed Jul 10, 2012
1 parent 0f4d194 commit 9b7cda0
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 6 deletions.
12 changes: 12 additions & 0 deletions ManagedFbx.Samples/FbxForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion ManagedFbx.Samples/FbxForm.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.IO;
using System.Linq;
using System.Windows.Forms;
using ManagedFbx;

Expand Down Expand Up @@ -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;
}
}
}
3 changes: 3 additions & 0 deletions ManagedFbx.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions ManagedFbx/Manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
13 changes: 13 additions & 0 deletions ManagedFbx/SceneNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,33 @@ using namespace ManagedFbx;
SceneNode::SceneNode(FbxNode *node)
{
m_nativeNode = node;

m_children = gcnew List<SceneNode^>();
m_attributes = gcnew List<SceneNodeAttribute^>();

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^>^ SceneNode::ChildNodes::get()
{
return m_children->AsReadOnly();
}

IEnumerable<SceneNodeAttribute^>^ SceneNode::Attributes::get()
{
return m_attributes->AsReadOnly();
}

string ^SceneNode::Name::get()
{
return gcnew string(m_nativeNode->GetName());
Expand Down
4 changes: 3 additions & 1 deletion ManagedFbx/SceneNode.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "Properties.h"
#include "SceneNodeAttribute.h"

using namespace System::Collections::Generic;

Expand All @@ -11,6 +11,7 @@ namespace ManagedFbx
public:
property_rw(string^, Name);
property_r(IEnumerable<SceneNode^>^, ChildNodes);
property_r(IEnumerable<SceneNodeAttribute^>^, Attributes);

property_rw(Vector3, Position);
property_rw(Vector3, Rotation);
Expand All @@ -24,5 +25,6 @@ namespace ManagedFbx
private:
FbxNode *m_nativeNode;
List<SceneNode^> ^m_children;
List<SceneNodeAttribute^> ^m_attributes;
};
}
24 changes: 23 additions & 1 deletion ManagedFbx/SceneNodeAttribute.cpp
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
#include "stdafx.h"
#include "SceneNodeAttribute.h"
#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));
}
34 changes: 34 additions & 0 deletions ManagedFbx/SceneNodeAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};


}

0 comments on commit 9b7cda0

Please sign in to comment.