Skip to content

Commit

Permalink
add xref support
Browse files Browse the repository at this point in the history
  • Loading branch information
opencollada-sebastian committed Sep 9, 2008
1 parent c929ace commit 58b3b44
Show file tree
Hide file tree
Showing 25 changed files with 1,443 additions and 151 deletions.
21 changes: 18 additions & 3 deletions COLLADAMax/FEATURES
Expand Up @@ -8,24 +8,39 @@ Scene graph
- Geometries
- Materials
- Effects
- Cameras
- Light

Geometry
- Mesh:
- POSITION, VERTEX, NORMAL, TEXCOORD (multiple also), COLOR
- POLYLIST or TRIANGLES
- Extra tags for primitives (box, sphere, ...)
- Extra tags for primitives (box, sphere, ...)

Materials / Effects
- Texture and color materials
- Materials Phong and Blinn

Animation
- LINEAR, STEP, BEZIER
- Rotation / Transformation / Scale
- Animation types: LINEAR, STEP, BEZIER
- All kinds of node transformations
- Material parameters like color
- Morph controller weights
- Extra parameters of camera, light, primitives

Controller
- Skin and morph controller
- multiple controllers

Camera
- orthographic and perspective

Light
- ambient, point, spot, directional

XRefs
- Geometries
- Materials
- Transformations


2 changes: 1 addition & 1 deletion COLLADAMax/README
@@ -1,7 +1,7 @@
COLLADAMax is a new implementation of a 3ds Max plug-in to export a Max scene or
parts of it to a COLLADA file, released under an MIT-license.
In contrast to other existing 3ds Max to COLLADA exporters, this new plug-in does not store the
COLLADA document in an intermidiate data model by writes it directly to file. This leads to a dramatic
COLLADA document in an intermidiate data model but writes it directly to file. This leads to a dramatic
reduction of memory consumption and to much a better performance.


Expand Down
2 changes: 1 addition & 1 deletion COLLADAMax/include/COLLADAMaxControllerList.h
Expand Up @@ -71,7 +71,7 @@ namespace COLLADAMax
/** Resolves all the controllers of the node, represented by the exportNode and stores them in @a mControllers.
We iterate thru the modifier stack, starting with the last one that is applied, until we hit the first modifier
that is not support by COLLADA, i.e. is neither a skin nor a morph controller.*/
void resolveControllers(const ExportNode& exportNode, Object * object);
void resolveControllers(const ExportNode& exportNode);

protected:

Expand Down
71 changes: 48 additions & 23 deletions COLLADAMax/include/COLLADAMaxExportNode.h
Expand Up @@ -57,7 +57,8 @@ namespace COLLADAMax
LIGHT,
BONE,
HELPER,
MATERIAL
MATERIAL,
XREF_OBJECT
};

struct Symbol
Expand All @@ -72,6 +73,27 @@ namespace COLLADAMax
private:
typedef std::vector<ExportNode *> Children;

enum Flags
{
NONE = 0x0000,

/** Indicates if the node is a joint*/
ISJOINT = 0x0001,

/** Indicates if the node is in the visual scene, i.e. not hidden or selected if export selection only
is choosen.*/
ISINVISUALSCENE = 0x0002,

/** Indicates if the node is referenced some where.*/
ISREFERENCED = 0x0004,

/** Indicates if the nodes object is an XRef object.*/
ISXREFOBJECT = 0x0008,

/** Indicates if the nodes object is an XRef material.*/
ISXREFMATERIAL = 0x0010
};

private:
/** Maps max material to symbol name.*/
MeshSymbolMap mMeshSymbolMap;
Expand All @@ -87,17 +109,10 @@ namespace COLLADAMax
Children mChildren;

/** The type of the node.*/
mutable Type mType;
Type mType;

/** Indicates if the node is a joint*/
bool mIsJoint;

/** Indicates if the node is in the visual scene, i.e. not hidden or selected if export selection only
is choosen.*/
bool mIsInVisualScene;

/** Indicates if the node is referenced some where.*/
bool mIsReferenced;
/** Flags used to store properties of the export node*/
int mFlags;

/** The unique id of the node.*/
String mId;
Expand Down Expand Up @@ -145,13 +160,13 @@ namespace COLLADAMax
void setTypeToUnknown() {mType = UNKNOWN;}

/** Returns the type of the node.*/
Type getType() const;
Type getType() const { return mType; };

/** Returns if the node is a joint*/
bool getIsJoint()const {return mIsJoint; }
bool getIsJoint()const {return (mFlags & ISJOINT) != 0;}

/** Sets if the node is a joint*/
void setIsJoint(bool isJoint = true){mIsJoint=isJoint;}
void setIsJoint(bool isJoint = true){ isJoint ? mFlags |= ISJOINT : mFlags &= ~ISJOINT;}

/** Returns the INode associated with this Export Node.*/
INode * getINode() const
Expand All @@ -170,17 +185,29 @@ namespace COLLADAMax

/** Returns if the node is in the visual scene, i.e. not hidden or selected if export selection only
is choosen.*/
bool getIsInVisualScene()const {return mIsInVisualScene;}
bool getIsInVisualScene()const {return (mFlags & ISINVISUALSCENE) != 0;}

/** Sets if the node is in the visual scene, i.e. not hidden or selected if export selection only
is choosen.*/
void setIsInVisualScene(bool isInVisualScene){mIsInVisualScene = isInVisualScene;}
void setIsInVisualScene(bool isInVisualScene = true){isInVisualScene ? mFlags |= ISINVISUALSCENE : mFlags &= ~ISINVISUALSCENE;}

/** Returns if the node is referenced some where.*/
bool getIsReferenced()const {return mIsReferenced;}
bool getIsReferenced()const {return (mFlags & ISREFERENCED) != 0;}

/** Sets if the node is referenced some where.*/
void setIsReferenced(bool isReferenced){mIsReferenced = isReferenced;}
void setIsReferenced(bool isReferenced = true){isReferenced ? mFlags |= ISREFERENCED : mFlags &= ~ISREFERENCED;}

/** Returns if the nodes object is an XRef object.*/
bool getIsXRefObject()const {return (mFlags & ISXREFOBJECT) != 0;}

/** Sets if the nodes object is an XRef object.*/
void setIsXRefObject(bool isXRef = true){isXRef ? mFlags |= ISXREFOBJECT : mFlags &= ~ISXREFOBJECT;}

/** Returns if the nodes material is an XRef material.*/
bool getIsXRefMaterial()const {return (mFlags & ISXREFMATERIAL) != 0;}

/** Sets if the nodes material is an XRef material.*/
void setIsXRefMaterial(bool isXRef = true){isXRef ? mFlags |= ISXREFMATERIAL : mFlags &= ~ISXREFMATERIAL;}

/** Returns the parent or NULL if it has no parent.*/
ExportNode* getParent()const{return mParent;}
Expand Down Expand Up @@ -226,9 +253,6 @@ namespace COLLADAMax
/** Returns the final pose of the object, after all controllers are applied.*/
Object* getFinalPose()const;

/** Determines and returns the type of @a INode.*/
static Type determineType ( INode * iNode );

/** Adds channel @a channel with corresponding effect id @a effectId. The symbol is marked as unused.*/
void addSymbol ( Mtl * material, const String & symbol );

Expand All @@ -247,7 +271,6 @@ namespace COLLADAMax
return mMeshSymbolMap;
}


/** Sets the wire frame color.*/
void setWireFrameColor ( DWORD color )
{
Expand Down Expand Up @@ -283,9 +306,11 @@ namespace COLLADAMax
ExportNode ( INode * iNode, ExportNode* parent, Type type );

private:
/** Determines and returns the type of @a INode.*/
Type determineType ( INode * iNode );

/** Determines the type of the export node.*/
Type determineType() const;
void determineType();
};

}
Expand Down
6 changes: 3 additions & 3 deletions COLLADAMax/include/COLLADAMaxOptions.h
Expand Up @@ -56,7 +56,7 @@ namespace COLLADAMax
Interface* mMaxInterface;
bool mNormals; //!< export normals
bool mTriangulate; //!< convert Editable Polygons to triangles
bool mXrefs; //!< export external references
bool mIncludeXrefs; //!< export external references
bool mTangents; //!< export tangents and binormals
bool mAnimations; //!< export animations;
bool mSampleAnimation; //!< export sampled animation
Expand Down Expand Up @@ -96,9 +96,9 @@ namespace COLLADAMax
}

/** Returns, if XRef are exported.*/
bool getExportXRefs() const
bool getIncludeXRefs() const
{
return mXrefs;
return mIncludeXrefs;
}

/** Returns, if tangents are exported.*/
Expand Down
43 changes: 40 additions & 3 deletions COLLADAMax/include/COLLADAMaxPrerequisites.h
Expand Up @@ -21,18 +21,55 @@

#define UNUSED(a) /**< Removes a piece of code during the pre-process. This macro is useful for these pesky unused variable warnings. */

#include "maxversion.h"


#if ( MAX_VERSION_MAJOR >= 7 )
# define MAX_7_OR_NEWER
#endif
#if ( MAX_VERSION_MAJOR == 7 )
# define MAX_7
#endif

#if ( MAX_VERSION_MAJOR >= 8 )
# define MAX_8_OR_NEWER
#endif
#if ( MAX_VERSION_MAJOR == 8 )
# define MAX_8
#endif

#if ( MAX_VERSION_MAJOR >= 9 )
# define MAX_9_OR_NEWER
#endif
#if ( MAX_VERSION_MAJOR == 9 )
# define MAX_9
#endif

#if ( MAX_VERSION_MAJOR >= 10 )
# define MAX_2008_OR_NEWER
#endif
#if ( MAX_VERSION_MAJOR == 10 )
# define MAX_2008
#endif

#if ( MAX_VERSION_MAJOR >= 11 )
# define MAX_2009_OR_NEWER
#endif
#if ( MAX_VERSION_MAJOR == 11 )
# define MAX_2009
#endif


// Max 2009 requires RTTI to be enabled
#ifdef MAX_2009
#ifdef MAX_2009_OR_NEWER
#ifndef _CPPRTTI
#error "Max 2009 requires RTTI to be enabled. Please enable and try again..."
#error "Max 2009 or newer requires RTTI to be enabled. Please enable and try again..."
#endif
#endif


#define TIME_INITIAL_POSE 0
#define TIME_EXPORT_START 0//OPTS->AnimStart()
//#define TIME_EXPORT_START 0//OPTS->AnimStart()


#include <string>
Expand Down
8 changes: 6 additions & 2 deletions COLLADAMax/include/COLLADAMaxStableHeaders.h
Expand Up @@ -20,11 +20,13 @@
#define __COLLADAMAX_STABLE_HEADERS_H__


#include "COLLADAMaxPrerequisites.h"

#ifdef MAX_9
#pragma message ("Compling for Max9")
#elif MAX_2008
#elif defined MAX_2008
#pragma message ("Compling for Max2008")
#elif MAX_2009
#elif defined MAX_2009
#pragma message ("Compling for Max2009")
#endif

Expand All @@ -49,6 +51,8 @@

#include "MorphR3.h" //for morph controller MorphR3

#include "COLLADAMaxXRefIncludes.h"


//STL
#include <map>
Expand Down
67 changes: 67 additions & 0 deletions COLLADAMax/include/COLLADAMaxXRefExporter.h
@@ -0,0 +1,67 @@
/*
Copyright (c) 2008 NetAllied Systems GmbH
This file is part of COLLADAMax.
Portions of the code are:
Copyright (c) 2005-2007 Feeling Software Inc.
Copyright (c) 2005-2007 Sony Computer Entertainment America
Based on the 3dsMax COLLADA Tools:
Copyright (c) 2005-2006 Autodesk Media Entertainment
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/


#ifndef __COLLADAMAX_XREFEXPORTER_H__
#define __COLLADAMAX_XREFEXPORTER_H__

#include "COLLADAMaxPrerequisites.h"



namespace COLLADAMax
{
class ExportSceneGraph;
class ExportNode;
class DocumentExporter;

/** Base class to export extra tags in max.*/

class XRefExporter : public COLLADA::LibraryControllers
{

public:

private:
ExportSceneGraph* mExportSceneGraph;
DocumentExporter* mDocumentExporter;

public:
/** Constructor
@param streamWriter the stream the extra tags should be written to.*/
XRefExporter ( COLLADA::StreamWriter * streamWriter, ExportSceneGraph * exportSceneGraph, DocumentExporter * documentExporter );

/** Destructor*/
virtual ~XRefExporter()
{}

/** Exports all the controllers in the export scene graph.*/
void doExport();


private:

/** Exports all the controllers in @a node and all its child nodes.*/
void doExport ( ExportNode* exportNode );
};


}


#endif //__COLLADAMAX_XREFEXPORTER_H__

0 comments on commit 58b3b44

Please sign in to comment.