Skip to content

Commit

Permalink
Added support for Vertex Colors in OBJ export, enabled SMD export and
Browse files Browse the repository at this point in the history
fixed file creation bug. Does export basic armature info as well. Atm,
this fork needs to be run through Visual Studio in Debug Mode
  • Loading branch information
Casuallynoted committed Jan 17, 2019
1 parent 676c3be commit 848d9a5
Show file tree
Hide file tree
Showing 16 changed files with 234 additions and 64 deletions.
45 changes: 33 additions & 12 deletions StudioCCS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.IO, Version=2.6.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.dll</HintPath>
</Reference>
<Reference Include="System.Runtime, Version=2.6.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Bcl.1.1.10\lib\net40\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks, Version=2.6.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Bcl.1.1.10\lib\net40\System.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
Expand All @@ -73,19 +82,27 @@
<ItemGroup>
<Compile Include="ArcBallCamera.cs" />
<Compile Include="AxisMarker.cs" />
<Compile Include="frmEditBone.cs" />
<Compile Include="frmEditBone.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmEditBone.Designer.cs">
<DependentUpon>frmEditBone.cs</DependentUpon>
</Compile>
<Compile Include="frmExportToObj.cs" />
<Compile Include="frmExportToObj.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmExportToObj.Designer.cs">
<DependentUpon>frmExportToObj.cs</DependentUpon>
</Compile>
<Compile Include="frmInfo.cs" />
<Compile Include="frmInfo.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmInfo.Designer.cs">
<DependentUpon>frmInfo.cs</DependentUpon>
</Compile>
<Compile Include="FrmLoadScene.cs" />
<Compile Include="FrmLoadScene.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmLoadScene.Designer.cs">
<DependentUpon>FrmLoadScene.cs</DependentUpon>
</Compile>
Expand Down Expand Up @@ -123,10 +140,14 @@
<Compile Include="libCCS\IndexObject.cs" />
<Compile Include="libCCS\Util.cs" />
<Compile Include="TexturePreview.cs" />
<Compile Include="ViewportPicbox.cs" />
<Compile Include="ViewportPicbox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="WireHelper.cs" />
<Compile Include="Logger.cs" />
<Compile Include="MainForm.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
Expand Down Expand Up @@ -241,11 +262,11 @@
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="data" />
<Folder Include="data\bin" />
<Folder Include="data\shaders" />
<Folder Include="libCCS" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
</Project>
Binary file modified bin/Debug/StudioCCS.exe
Binary file not shown.
24 changes: 20 additions & 4 deletions bin/Debug/StudioCCS.exe.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
<system.windows.forms jitDebugging="true" />
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
<system.windows.forms jitDebugging="true" />
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Binary file modified bin/Debug/StudioCCS.pdb
Binary file not shown.
Binary file modified bin/Release/StudioCCS.exe
Binary file not shown.
24 changes: 20 additions & 4 deletions bin/Release/StudioCCS.exe.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
<system.windows.forms jitDebugging="true" />
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
<system.windows.forms jitDebugging="true" />
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
24 changes: 16 additions & 8 deletions libCCS/CCSClump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@ public void DumpToSMD(string outputPath, bool withNormals)
{
FrameForward();
string outputFileName = System.IO.Path.Combine(outputPath, ParentFile.GetSubObjectName(ObjectID)) + ".smd";
using(var fs = new FileStream(outputFileName, FileMode.Truncate))

using (var fs = new FileStream(outputFileName, FileMode.Create))
{
using(var outf = new StreamWriter(fs))
{
Expand Down Expand Up @@ -651,14 +652,20 @@ public void DumpToSMD(string outputPath, bool withNormals)
outf.WriteLine("time 0");
for(int i = 0; i < NodeCount; i++)
{
//float rad = 0.0174533f;
//Vector3 bRot = Util.FixAxisRotation(BindRotations[i]);
//
// float rad = 0.0174533f;
//
// Vector3 bRot = Util.FixAxisRotation(BindRotations[i]);
string pStr = string.Format("{0} {1} {2}", BindPositions[i].X, BindPositions[i].Y, BindPositions[i].Z);
string rStr = string.Format("{0} {1} {2}", BindRotations[i].X, BindRotations[i].Y, -BindRotations[i].Z);
//string rStr = string.Format("{0} {1} {2}", bRot.X, bRot.Y, bRot.Z);
//string rStr = string.Format("{2} {1} {0}", -(BindRotations[i].X * rad), -(BindRotations[i].Y * rad), -(BindRotations[i].Z * rad));
//string pStr = "0.0 0.0 0.0";
//string rStr = "0.0 0.0 0.0";
//
//string rStr = string.Format("{0} {1} {2}", bRot.X, bRot.Y, bRot.Z);
//
// string rStr = string.Format("{2} {1} {0}", -(BindRotations[i].X * rad), -(BindRotations[i].Y * rad), -(BindRotations[i].Z * rad));
//
//string pStr = "0.0 0.0 0.0";
//
//string rStr = "0.0 0.0 0.0";
outf.WriteLine(string.Format("{0} {1} {2}", i, pStr, rStr));
}

Expand All @@ -677,6 +684,7 @@ public void DumpToSMD(string outputPath, bool withNormals)
}
}
/*
*/
outputFileName = System.IO.Path.Combine(outputPath, ParentFile.GetSubObjectName(ObjectID)) + "_bind.smd";
Logger.LogInfo(string.Format("Dumping bind pose to {0} to {1}...\n", ParentFile.GetSubObjectName(ObjectID), outputFileName));
using(var fs = new FileStream(outputFileName, FileMode.OpenOrCreate))
Expand Down Expand Up @@ -705,7 +713,7 @@ public void DumpToSMD(string outputPath, bool withNormals)
outf.WriteLine("end");
}
}
*/
/**/
}

public int SearchNodeID(int _objectID)
Expand Down
91 changes: 55 additions & 36 deletions libCCS/CCSModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public override bool DeInit()
return true;
}

/*
/**/
private const int MODEL_SUBTYPE_RIGID = 0x0;
private const int MODEL_SUBTYPE_DEFORM = 0x1;
private const int MODEL_SUBTYPE_MORPH = 0x2;
Expand Down Expand Up @@ -497,7 +497,7 @@ private bool HasColors()
}
return false;
}
*/
/**/
public override bool Read(BinaryReader bStream, int sectionSize)
{
Debug.WriteLine("Parsing CCSModel 0x{0:X} at 0x{1:X}", ObjectID, bStream.BaseStream.Position);
Expand Down Expand Up @@ -629,7 +629,7 @@ public override bool Read(BinaryReader bStream, int sectionSize)

public string GetModelTypeStr()
{
/*
/**/
string modelTypeStr = "";
if(ModelType == 0 && SubModelCount == 0)
{
Expand Down Expand Up @@ -673,8 +673,8 @@ public string GetModelTypeStr()
}

return modelTypeStr;
*/
string modelTypeStr = "";
/**/
/*string modelTypeStr = "";
if(ModelType == 0 && SubModelCount == 0)
{
modelTypeStr = "None";
Expand Down Expand Up @@ -715,7 +715,7 @@ public string GetModelTypeStr()
{
modelTypeStr = string.Format("Unknown Model Type: 0x{0:X}", ActualModelType);
}
return modelTypeStr;
return modelTypeStr;*/
}

public override TreeNode ToNode()
Expand Down Expand Up @@ -1534,6 +1534,7 @@ public int DumpToObj(StreamWriter fStream, int vOffset, bool split, bool withNor
for(int v = 0; v < tmpSubModel.VertexCount; v++)
{
ModelVertex tmpVert = tmpSubModel.Vertices[v];

//Vector3 vPos = Vector3.TransformPosition(tmpVert.Position, finalMtx);

/*
Expand All @@ -1544,37 +1545,55 @@ public int DumpToObj(StreamWriter fStream, int vOffset, bool split, bool withNor
*/

Vector3 vPos = SoftSkinVertex(tmpVert);
//write Position
fStream.WriteLine(string.Format("v\t{0}\t{1}\t{2}", -vPos.X, vPos.Y, -vPos.Z));
//write texture coordinates
//TODO: CCSModel::DumpToObj() Export texture coordinates with material's texture coordinate offset.
CCSTexture tmpTexture = tmpSubModel.ParentTextureRef;
if(tmpTexture != null)
{
if(tmpTexture.TextureType == CCSTexture.CCS_TEXTURE_DXT1 || tmpTexture.TextureType == CCSTexture.CCS_TEXTURE_DXT5)
{
fStream.WriteLine(string.Format("vt\t{0}\t{1}", tmpVert.TexCoords.X, tmpVert.TexCoords.Y));
}
else
{
fStream.WriteLine(string.Format("vt\t{0}\t{1}", tmpVert.TexCoords.X, 1.0 - tmpVert.TexCoords.Y));
}
}
else
{
fStream.WriteLine(string.Format("vt\t{0}\t{1}", tmpVert.TexCoords.X, 1.0 - tmpVert.TexCoords.Y));
}
/*
_subModel.Vertices[i].Color = Util.ReadVec4RGBA32(bStream);
*/

Vector4 VCol = tmpSubModel.Vertices[v].Color;

//write Position
fStream.WriteLine(string.Format("v\t{0}\t{1}\t{2}\t{3}\t{4}\t{5}", -vPos.X, vPos.Y, -vPos.Z, VCol.X, VCol.Y, VCol.Z));



//write normal
fStream.WriteLine(string.Format("vn\t{0}\t{1}\t{2}", tmpVert.Normal.X, tmpVert.Normal.Y, tmpVert.Normal.Z));
}
/*
}
*/
//bool writeNormals = true;
//Write triangles
for(int t = 0; t < tmpSubModel.TriangleCount; t++)
{
for (int v = 0; v < tmpSubModel.VertexCount; v++)
{
ModelVertex tmpVert = tmpSubModel.Vertices[v];

//write texture coordinates
//TODO: CCSModel::DumpToObj() Export texture coordinates with material's texture coordinate offset.
CCSTexture tmpTexture = tmpSubModel.ParentTextureRef;
if (tmpTexture != null)
{
if (tmpTexture.TextureType == CCSTexture.CCS_TEXTURE_DXT1 || tmpTexture.TextureType == CCSTexture.CCS_TEXTURE_DXT5)
{
fStream.WriteLine(string.Format("vt\t{0}\t{1}", tmpVert.TexCoords.X, tmpVert.TexCoords.Y));
}
else
{
fStream.WriteLine(string.Format("vt\t{0}\t{1}", tmpVert.TexCoords.X, 1.0 - tmpVert.TexCoords.Y));
}
}
else
{
fStream.WriteLine(string.Format("vt\t{0}\t{1}", tmpVert.TexCoords.X, 1.0 - tmpVert.TexCoords.Y));
}
}
for (int v = 0; v < tmpSubModel.VertexCount; v++)
{
ModelVertex tmpVert2 = tmpSubModel.Vertices[v];

//write normal
fStream.WriteLine(string.Format("vn\t{0}\t{1}\t{2}", tmpVert2.Normal.X, tmpVert2.Normal.Y, tmpVert2.Normal.Z));
}


/**/
//bool writeNormals = true;
//Write triangles
for (int t = 0; t < tmpSubModel.TriangleCount; t++)
{
ModelTriangle tmpTri = tmpSubModel.Triangles[t];
//write triangle line
if(withNormals)
Expand All @@ -1585,7 +1604,7 @@ public int DumpToObj(StreamWriter fStream, int vOffset, bool split, bool withNor
{
fStream.WriteLine(string.Format("f {0}/{0}\t{1}/{1}\t{2}/{2}", tmpTri.ID1 + totalVertCount, tmpTri.ID2 + totalVertCount, tmpTri.ID3 + totalVertCount));
}
}
}

totalVertCount += tmpSubModel.VertexCount;
}
Expand Down
44 changes: 44 additions & 0 deletions obj/Debug/StudioCCS.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,47 @@ E:\prj\dothack\StudioCCS\StudioCCS\obj\Debug\StudioCCS.exe
E:\prj\dothack\StudioCCS\StudioCCS\obj\Debug\StudioCCS.pdb
D:\prj\dothack\StudioCCS\StudioCCS\bin\Debug\OpenTK.GLControl.dll
D:\prj\dothack\StudioCCS\StudioCCS\bin\Debug\OpenTK.GLControl.xml
D:\DotHack\StudioCCS-master\bin\Debug\blenderDummyImport.py
D:\DotHack\StudioCCS-master\bin\Debug\data\bin\axisMarker.bin
D:\DotHack\StudioCCS-master\bin\Debug\data\bin\WireHelpers.bin
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\AxisMarker.fsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\AxisMarker.vsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\BoundingBox.fsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\BoundingBox.gsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\BoundingBox.vsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\CCSClump.fsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\CCSClump.gsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\CCSClump.vsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\CCSHitMesh.fsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\CCSHitMesh.vsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\CCSModel.fsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\CCSModel.vsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\Grid.fsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\Grid.vsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\TexturePreview.fsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\TexturePreview.vsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\WireHelper.fsh
D:\DotHack\StudioCCS-master\bin\Debug\data\shaders\WireHelper.vsh
D:\DotHack\StudioCCS-master\bin\Debug\OpenTK.dll.config
D:\DotHack\StudioCCS-master\bin\Debug\Readme.md
D:\DotHack\StudioCCS-master\bin\Debug\StudioCCS.exe.config
D:\DotHack\StudioCCS-master\bin\Debug\StudioCCS.exe
D:\DotHack\StudioCCS-master\bin\Debug\StudioCCS.pdb
D:\DotHack\StudioCCS-master\bin\Debug\System.IO.dll
D:\DotHack\StudioCCS-master\bin\Debug\System.Runtime.dll
D:\DotHack\StudioCCS-master\bin\Debug\System.Threading.Tasks.dll
D:\DotHack\StudioCCS-master\bin\Debug\System.IO.xml
D:\DotHack\StudioCCS-master\bin\Debug\System.Runtime.xml
D:\DotHack\StudioCCS-master\bin\Debug\System.Threading.Tasks.xml
D:\DotHack\StudioCCS-master\obj\Debug\StudioCCS.csproj.App.config
D:\DotHack\StudioCCS-master\obj\Debug\StudioCCS.csprojAssemblyReference.cache
D:\DotHack\StudioCCS-master\obj\Debug\StudioCCS.frmEditBone.resources
D:\DotHack\StudioCCS-master\obj\Debug\StudioCCS.frmExportToOBJ.resources
D:\DotHack\StudioCCS-master\obj\Debug\StudioCCS.frmInfo.resources
D:\DotHack\StudioCCS-master\obj\Debug\StudioCCS.FrmLoadScene.resources
D:\DotHack\StudioCCS-master\obj\Debug\StudioCCS.MainForm.resources
D:\DotHack\StudioCCS-master\obj\Debug\StudioCCS.csproj.GenerateResource.cache
D:\DotHack\StudioCCS-master\obj\Debug\StudioCCS.csproj.CoreCompileInputs.cache
D:\DotHack\StudioCCS-master\obj\Debug\StudioCCS.csproj.CopyComplete
D:\DotHack\StudioCCS-master\obj\Debug\StudioCCS.exe
D:\DotHack\StudioCCS-master\obj\Debug\StudioCCS.pdb
Binary file modified obj/Debug/StudioCCS.csproj.GenerateResource.Cache
Binary file not shown.
Binary file modified obj/Debug/StudioCCS.exe
Binary file not shown.
Binary file modified obj/Debug/StudioCCS.pdb
Binary file not shown.
Loading

0 comments on commit 848d9a5

Please sign in to comment.