C4D Reader

On 11/08/2015 at 02:44, xxxxxxxx wrote:

User Information:
Cinema 4D Version:    
Language(s) :

Hello guys,

I'm creating a C4D reader for my software, essentially I want to be able to load models with their textures and animation.

I just got started with the work, I'm stuck with the texture retention bit:@
Basically what I could find through the SDK so far is this
      BaseTag* tag = object->GetTag(Ttexture);
      BaseMaterial* assignedMat = ((TextureTag* )tag)->GetMaterial();
      Int32 ColorChannel = 0;
      Vector RGB = assignedMat->GetAverageColor(ColorChannel);
      pGeneralMat->SetColor(RGB.x, RGB.y, RGB.z, 0);          // pGeneralMat is material in my software

Now I wanna get the Normals, Bump, Alpha .. of the material on the object
the only class I could find to provide these values are in BaseMaterial Get Calculations, but all the methods require an argument (VolumeData * )
I've been all over the internet and sdk trying to figure out how to set that parameter with no luck
Could somebody please help me figure this out, and it would be great if you could provide some code samples in C++


On 12/08/2015 at 02:40, xxxxxxxx wrote:


I'm not quite sure what you mean with "C4D reader". Do you want to open c4d files inside another application? You could use the Melange library to do this. Or do you want to export data into a custom file format?

What do you mean with "get the Normals, Bump, Alpha"? You can access the used textures or shaders of a channel using the BaseChannel system with GetChannel(). Or you could simply use GetParameter() to access the material's parameter.

VolumeData is the representation of a scene in the rendering pipeline and is only available inside a rendering process. CalcSurface() etc. are used inside the rendering process to sample the material. If you want to export the material render result you have to bake the material.

Best wishes,

On 20/08/2015 at 03:51, xxxxxxxx wrote:

Hello, thanks for replying

Yes, I want to open a C4D file using my application. Basically, I'm creating a C4D file reader for my application.

Thank you for the info, I used both options in fact. I used GetParameter() for some material values and I used GetChannel() to store Bitmaps of some textures.
Thanks for the help.

I wonder if you could help with something else though. I'm not sure if I should post another question about it though O.O
I am unable to extract geometry from my c4d project other than Polygons!
I checked the Melange sdk, and I'm aware that I can traverse my project objects and check their type using GetType() and work my way from there. But in my application I need to fill a Vertices table to create a geometry for my objects, and my problem is that in Cinema 4D I can only extract Vertices and Polygons from Polygon Object types, so if I had a cube for instance in my C4D project I don't really know how to extract vertex values from it :S

Can you provide any hints for that?
Thank you very much.

On 20/08/2015 at 04:41, xxxxxxxx wrote:

Procedural objects have any geometry created 'on the fly' in C4D (typically part of the document cache). There would be no point in storing the geometry of these objects in the C4D file since it is handled by C4D internally and procedurally. The end result is dependent upon the parameter settings and the input of deformers and such. You would basically need to reverse engineer each and every procedural object as well as deformers and generators (and anything associated with them) to replicate the resulting geometry.

On 20/08/2015 at 05:11, xxxxxxxx wrote:


using the Melange library one can only read what is stored inside the c4d file. The whole point of generators is that they generate geometry on demand so typically the created geometry is not stored inside the c4d file.

But you can enable "Preferences"->"Files"->"Save Polygons for Melange" to save the polygon caches of generator objects in the file. Then you can access the stored polygon data using Melange. Please be aware that this will increase the file size.

Best wishes,

On 20/08/2015 at 07:47, xxxxxxxx wrote:

That sounds like the best solution, Sebastian, despite the increased file size.

On 23/08/2015 at 07:05, xxxxxxxx wrote:

Ooh :dizzy_face: .. this complicates things a bit.

Alright then, thank you both for the answers, it should help me figure some things out now.
Really appreciate all the help provided :D

On 23/08/2015 at 10:27, xxxxxxxx wrote:

If you want to generate geometry on the fly, you would need to create a plugin that runs inside
Cinema 4D and communicates with your application during runtime.