Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions SDK/Extras/Textify3DMF/Source/RegisterHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@
#include "SpecularMapElement.h"
#include "TableOfContents.h"
#include "Reference.h"
#include "MeshCorners.h"
#include "MeshEdges.h"
#include "UnknownText.h"

#include "VertexAttributeSetList.h"

Expand Down Expand Up @@ -271,4 +274,7 @@ void RegisterHandlers( Controller* inController )
Register( NormalMapElement );
Register( TableOfContents );
Register( Reference );
Register( MeshCorners );
Register( MeshEdges );
Register( UnknownText );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Normal.cpp
* Textify3DMF
*
* Created by James Walker on 4/21/12.
* Copyright (c) 2012 James W. Walker.
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
*/

#include "MeshCorners.h"

MeshCorners::MeshCorners()
: TypeHandler( 'crnr', "MeshCorners" )
{
}

void MeshCorners::Process( size_t inStartOffset,
size_t inEndOffset )
{
// TODO: DataLengthExceptions

size_t offset = inStartOffset;

Out() << Indent() << Name() << " (\n";
int numCorners = FetchUInt32(offset); offset += 4;
Out() << Indent(1) << numCorners << " # numCorners\n\n";
for (int i = 0; i < numCorners; i++)
{
int vertexIndex = FetchUInt32(offset); offset += 4;
int numFaces = FetchUInt32(offset); offset += 4;
Out() <<
Indent(1) << "# Corner " << i << "\n" <<
Indent(1) << vertexIndex << " # vertexIndex\n" <<
Indent(1) << numFaces << " # numFaces\n" << Indent(1);
for (int j = 0; j < numFaces; j++)
{
int faceIndex = FetchUInt32(offset); offset += 4;
Out() << faceIndex << ((j + 1 == numFaces) ? " # face indices\n\n" : " ");
}
}
Out() << " )\n";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Normal.h
* Textify3DMF
*
* Created by James Walker on 4/21/12.
* Copyright (c) 2012 James W. Walker.
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
*/


class MeshCorners : public TypeHandler
{
public:
MeshCorners();

virtual void Process( size_t inStartOffset,
size_t inEndOffset );
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Normal.cpp
* Textify3DMF
*
* Created by James Walker on 4/21/12.
* Copyright (c) 2012 James W. Walker.
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
*/

#include "MeshEdges.h"

MeshEdges::MeshEdges()
: TypeHandler( 'edge', "MeshEdges" )
{
}

void MeshEdges::Process( size_t inStartOffset,
size_t inEndOffset )
{
// TODO: DataLengthExceptions

size_t offset = inStartOffset;

Out() << Indent() << Name() << " (\n";
int numEdges = FetchUInt32(offset); offset += 4;
Out() << Indent(1) << numEdges << " # numEdges\n";
for (int i = 0; i < numEdges; i++)
{
int v0 = FetchUInt32(offset); offset += 4;
int v1 = FetchUInt32(offset); offset += 4;
Out() << Indent(1) << v0 << " " << v1 << " # Corner " << i << " vertexIndices\n";
}
Out() << " )\n";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Normal.h
* Textify3DMF
*
* Created by James Walker on 4/21/12.
* Copyright (c) 2012 James W. Walker.
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
*/


class MeshEdges : public TypeHandler
{
public:
MeshEdges();

virtual void Process( size_t inStartOffset,
size_t inEndOffset );
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Normal.cpp
* Textify3DMF
*
* Created by James Walker on 4/21/12.
* Copyright (c) 2012 James W. Walker.
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
*/

#include "UnknownText.h"

UnknownText::UnknownText()
: TypeHandler( 'uktx', "UnknownText" )
{
}

static std::string QuoteStringFor3DMF( const std::string& inStr )
{
std::string result( 1, '"' );

for (std::string::const_iterator i = inStr.begin(); i != inStr.end(); ++i)
{
char theChar( *i );

switch (theChar)
{
case '"':
result += "\\\"";
break;

case '\t':
result += "\\t";
break;

case '\r':
result += "\\r";
break;

case '\n':
result += "\\n";
break;

case '\\':
result += "\\\\";
break;

default:
result += theChar;
break;
}
}

result += '"';

return result;
}

void UnknownText::Process( size_t inStartOffset,
size_t inEndOffset )
{
if (inEndOffset - inStartOffset < 4)
{
throw DataLengthException( Name(), inStartOffset, inEndOffset, 4 );
}

std::string asciiName;
std::string contents;
size_t nameBytesConsumed;
size_t contentsBytesConsumed;
bool didRead = Boss()->FetchString( inStartOffset, inEndOffset, asciiName,
nameBytesConsumed );

if (didRead)
{
didRead = Boss()->FetchString( inStartOffset + nameBytesConsumed, inEndOffset, contents,
contentsBytesConsumed );
}

if ( (not didRead) or (nameBytesConsumed + contentsBytesConsumed < inEndOffset - inStartOffset) )
{
throw DataLengthException( Name(), inStartOffset, inEndOffset,
inEndOffset - inStartOffset );
}

Out() << Indent() << Name() << " (\n";

Out() << Indent(1) << QuoteStringFor3DMF( asciiName ) << "\n";
Out() << Indent(1) << QuoteStringFor3DMF( contents ) << "\n";

Out() << Indent() << ")\n";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Normal.h
* Textify3DMF
*
* Created by James Walker on 4/21/12.
* Copyright (c) 2012 James W. Walker.
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
*/


class UnknownText : public TypeHandler
{
public:
UnknownText();

virtual void Process( size_t inStartOffset,
size_t inEndOffset );
};
Loading