3D-Coat development process

I am Andrew Shpagin, the developer of 3D-Coat. This is my personal blog devoted to the development of 3D-Coat. This blog is created to give fast and non-official information about 3D-Coat. I will post there daily news, what I am doing now, what features are under development this moment. It could be really interesting for everyone who is interested in 3D-Coat.

Friday, May 16, 2008

3D-Coat SDK

I have published 3D-Coat SDK. It allows to create plugins for export/import of different 3D-files. To start you should download and unpack

http://www.3d-coat.com/files/3D-CoatSDK.rar

Then you shoud open soluton ExportImport.sln. It requires at least MS VisualStudio 2008 Standart Edition to be properly compiled. Compile project. It is better to use “Release” configuration. You will get Odj.DLL file on output. This simple plugin is a sample for importing OBJ files. Obj.DLL should be copied to

$3D-CoatInstallationFolder\Plugins\MeshCodecs\

To understand how plugins work open files cMeshObj.h. You will see there class that is derived from cMeshCodec (It is defined in cIO.h).

class cMeshCodec {

public:

cMeshCodec() {}

       virtual ~cMeshCodec() {}

       virtual cRawMesh * Decode(const cData &Fm) = 0;

       virtual void Encode(const cRawMesh &Mesh, cData *To) = 0;

       virtual bool CanEncode(){return true;}

       virtual bool CanDecode(){return true;}

};

To create new codec you should derive your class from cMeshCodec and re-define functions Encode and Decode. Decode should return filled object cRawMesh and Encode should fill Data structure cData using cRawMesh. You can look and discover objects cData and cRawMesh. After redefining functions you should change class name in ExportImport.cpp. I think it is very easy. The only not so easy task is filling/reading structure cRawMesh. It is mesh that consists of:

uv-sets (see GetUVSets() )

Matrials(surfaces) (see GetMaterials() )

Objects (see GetObjects() )

PositionVertices (see GetPositions() )

UV-vertices (see GetTexCoords() )

Normals (see GetNormals() )

Faces (see GetRaw() )

To understand how it works it is better to discover how cMeshObj.cpp encodes/decodes obj – files. I will explain slightly how Faces list is organised.

Faces are array of cVec3i – 3 integer values

Count, - amount of polygones in face

idMtl = MaterialIndex + (UV-set index<<16) – index of material and uv-set

idObj - index of object

Next “Count” values are 3-indices of vertices that are part of face

PositionIndex (index in array of position vertices)

TexturevertexIndex (index in array of texture vertices, can be -1)

NormalIndex (index in array of normals, can be -1)

The best method to learn is to ask in forum and discover how cMeshObj is done.

No comments: