Skip to content

Commit

Permalink
Added rough Light support (type, colour)
Browse files Browse the repository at this point in the history
  • Loading branch information
returnString committed Jul 11, 2012
1 parent 7d7413c commit 6e9a61e
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 15 deletions.
Binary file modified Build/samplefile.FBX
Binary file not shown.
20 changes: 14 additions & 6 deletions ManagedFbx.Samples/FbxForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ private void OnTreeSelect(object sender, TreeViewEventArgs e)

Action NewLine = () => builder.Append(Environment.NewLine);

builder.Append("Position: {0}", node.Position);
builder.Append("Rotation: {0}", node.Rotation);
builder.Append("Scale: {0}", node.Scale);
builder.Append("Position:\t{0}", node.Position);
builder.Append("Rotation:\t{0}", node.Rotation);
builder.Append("Scale:\t{0}", node.Scale);

NewLine();

Expand All @@ -49,13 +49,13 @@ private void OnTreeSelect(object sender, TreeViewEventArgs e)
foreach(var attr in node.Attributes)
{
NewLine();
builder.Append("Attribute type: {0}", attr.AttributeType.ToString());
builder.Append("Attribute type: {0}", attr.Type.ToString());

switch(attr.AttributeType)
switch(attr.Type)
{
case NodeAttributeType.Mesh:
{
var mesh = node.Model;
var mesh = node.Mesh;
builder.Append("Found {0} polygons", mesh.Polygons.Length);
NewLine();

Expand All @@ -79,6 +79,14 @@ private void OnTreeSelect(object sender, TreeViewEventArgs e)
}
}
break;

case NodeAttributeType.Light:
{
var light = node.Light;
builder.Append("Found light of type {0}", light.Type);
builder.Append("Colour is {0}", light.Colour);
}
break;
}
}

Expand Down
19 changes: 19 additions & 0 deletions ManagedFbx/Light.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "stdafx.h"
#include "Light.h"

using namespace ManagedFbx;

Light::Light(FbxLight *nativeLight)
{
m_nativeLight = nativeLight;
}

LightType Light::Type::get()
{
return (LightType)m_nativeLight->LightType.Get();
}

Vector3 Light::Colour::get()
{
return Vector3(m_nativeLight->Color.Get());
}
22 changes: 22 additions & 0 deletions ManagedFbx/Light.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

namespace ManagedFbx
{
public enum class LightType
{
Point = FbxLight::ePoint,
Spot = FbxLight::eSpot,
Directional = FbxLight::eDirectional
};

public ref class Light
{
public:
property_r(LightType, Type);
property_r(Vector3, Colour);
internal:
Light(FbxLight *nativeLight);
private:
FbxLight *m_nativeLight;
};
}
2 changes: 2 additions & 0 deletions ManagedFbx/ManagedFbx.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Light.h" />
<ClInclude Include="Manager.h" />
<ClInclude Include="Mesh.h" />
<ClInclude Include="NativeString.h" />
Expand All @@ -102,6 +103,7 @@
<ClInclude Include="Vector.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Light.cpp" />
<ClCompile Include="Manager.cpp" />
<ClCompile Include="Mesh.cpp" />
<ClCompile Include="Polygon.cpp" />
Expand Down
25 changes: 21 additions & 4 deletions ManagedFbx/ManagedFbx.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@
</ClCompile>
<ClCompile Include="SceneNode.cpp" />
<ClCompile Include="Manager.cpp" />
<ClCompile Include="NodeAttribute.cpp" />
<ClCompile Include="Mesh.cpp" />
<ClCompile Include="Polygon.cpp" />
<ClCompile Include="Mesh.cpp">
<Filter>Attributes</Filter>
</ClCompile>
<ClCompile Include="NodeAttribute.cpp">
<Filter>Attributes</Filter>
</ClCompile>
<ClCompile Include="Light.cpp">
<Filter>Attributes</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Scene.h" />
Expand All @@ -27,12 +34,19 @@
<Filter>Exceptions</Filter>
</ClInclude>
<ClInclude Include="Manager.h" />
<ClInclude Include="NodeAttribute.h" />
<ClInclude Include="Mesh.h" />
<ClInclude Include="NativeString.h">
<Filter>Helpers</Filter>
</ClInclude>
<ClInclude Include="Polygon.h" />
<ClInclude Include="Mesh.h">
<Filter>Attributes</Filter>
</ClInclude>
<ClInclude Include="NodeAttribute.h">
<Filter>Attributes</Filter>
</ClInclude>
<ClInclude Include="Light.h">
<Filter>Attributes</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Helpers">
Expand All @@ -44,5 +58,8 @@
<Filter Include="Exceptions">
<UniqueIdentifier>{b6172554-dbf5-4472-89ce-76f3920496e0}</UniqueIdentifier>
</Filter>
<Filter Include="Attributes">
<UniqueIdentifier>{c1ff9a53-89e7-4ffe-874e-83ed0729ee95}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion ManagedFbx/NodeAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ NodeAttribute::NodeAttribute(FbxNodeAttribute *nativeAttr)
m_nativeAttribute = nativeAttr;
}

NodeAttributeType NodeAttribute::AttributeType::get()
NodeAttributeType NodeAttribute::Type::get()
{
return (NodeAttributeType)m_nativeAttribute->GetAttributeType();
}
Expand Down
2 changes: 1 addition & 1 deletion ManagedFbx/NodeAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace ManagedFbx
public ref class NodeAttribute
{
public:
property_r(NodeAttributeType, AttributeType);
property_r(NodeAttributeType, Type);
property_rw(string^, Name);

internal:
Expand Down
9 changes: 7 additions & 2 deletions ManagedFbx/SceneNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ Vector3 SceneNode::Scale::get()
return Vector3(m_nativeNode->LclScaling.Get());
}

Mesh ^SceneNode::Model::get()
Mesh ^SceneNode::Mesh::get()
{
return gcnew Mesh(m_nativeNode->GetMesh());
return gcnew ManagedFbx::Mesh(m_nativeNode->GetMesh());
}

Light ^SceneNode::Light::get()
{
return gcnew ManagedFbx::Light(m_nativeNode->GetLight());
}
4 changes: 3 additions & 1 deletion ManagedFbx/SceneNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "NodeAttribute.h"
#include "Mesh.h"
#include "Light.h"

using namespace System::Collections::Generic;

Expand All @@ -18,7 +19,8 @@ namespace ManagedFbx
property_rw(Vector3, Rotation);
property_rw(Vector3, Scale);

property_r(Mesh^, Model);
property Mesh^ Mesh { ManagedFbx::Mesh ^get(); }
property Light^ Light { ManagedFbx::Light ^get(); }

void AddChild(SceneNode ^node);

Expand Down

0 comments on commit 6e9a61e

Please sign in to comment.