Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/08/2010 at 03:01, xxxxxxxx wrote:
User Information: Cinema 4D Version: 9.5-11 Platform: Windows ; Language(s) : C++ ;
--------- Hi,
I'm trying to create a C++ object/generator plugin for Cinema 4D. Vertices and polygons are displayed correctly, but I have problems with tags that I have not been able to solve over several days:
TextureTag* textTag = obj->MakeTag(Ttexture) UVWTag* uvwTag = (UVWTag* )obj->MakeVariableTag (Tuvw, vertexCount); obj->InsertTag(uvwTag); VariableTag* nTag = obj->MakeVariableTag(Tnormal, vertexCount, uvwTag); obj->InsertTag(nTag);
Is GetVirtualObjects really a suitable place to generate tags that are supposed to show up in the GUI?
I cannot convert my object plugin into a polygon object
If understand correctly, TextureTag accesses texture data through GetParameter/SetParameter. Where do I find documentation on the format of this data? Is it RGB, BGR, RGBA, BGRA, ..., bytes, floats, ...? Is it possible to set the format?
The documentation on UVWTags says "When assigning a UVW tag to an object ensure you set the texture to UVW." (C4DR95SDKHTML/pages/c4d_basetag/class_UVWTag1049.html and C4DR115SDKHTML/pages/c4d_basetag/class_UVWTag1332.html). Does that mean that i need to create a TextureTag before creating a UVWTag? Well, RoundedTUbe does not create a texture tag ...
I did set the UVW coordinates per polygon rather than per vertex, as explained in this thread: http://www.plugincafe.com/%5Cforum/forum_posts.asp?TID=362&PID=1231
Any help is appreciated.
On 28/08/2010 at 23:13, xxxxxxxx wrote:
I found the following threads hinting to use MCOMMAND_MAKEEDITABLE to convert into a polygon object: https://plugincafe.maxon.net/topic/5109/5057_how-to-convert-cube-or-sphere-into-mesh https://plugincafe.maxon.net/topic/4948/4858_strange-problem-c-doesnt-work-with-pluginobject
I still don't know how to tell Cinema 4D to render my objects with textures ...
On 29/08/2010 at 07:50, xxxxxxxx wrote:
I create a number of tags in GetVirtualObjects, but they do not show up in the editor:
I'm pretty sure that obj->InsertTag is not needed.
No. These tags wont show up. All the objects and tags you create are hidden inside the generator object. If you really need a tag visible in the OM you can create a command plugin which creates a generator object and then adds the tag to the generator.
What happens? I.e. the current state to object command should replace your generator with the objects which it actually creates.
No. The TextureTag has a link to a material (use Get/SetMaterial). In order to give your object a texture you must create a Bitmapshader and link it to a BaseChannel of your material.
The problem is that you are not supposed to create materials from within GetVirtualObjects. I never tried this, but there should usefull info on this here in the forum.
This just means that you should set the projection type of your texture tag to UVW. It is just a LONG valued parameter.
On 30/08/2010 at 06:11, xxxxxxxx wrote:
Thank you for the explanation.
On 02/09/2010 at 03:38, xxxxxxxx wrote:
Some additional info about creating materials can be found in this thread.
https://plugincafe.maxon.net/topic/5051/4975_question
Basically materials have to be created before the object is created. This can be done by polling the MSG_MENUPREPARE message. Special care is needed to keep the material link valid, for instance if you copy object from one document to another. See MSG_MULTI_MARKMATERIALS. There is an example in the mentioned thread.
cheers, Matthias
On 05/09/2010 at 03:50, xxxxxxxx wrote:
Thanks for the help so far. I am making progress, but so far have not been able to reach my goal. I want my generator to display textured geometry. I have been able to assign a material, so a texture cannot be far away. I probably need a BaseBitmap rather than a TextureTag for that.
This thread attempts to obtain a BaseBitmap from a BaseMaterial using channels: https://plugincafe.maxon.net/topic/1695/1040_basebitmap-from-a-material&PID=3705 The approach seems to be almost sound, as I would expect texture data to be split into channels and I would be able to load the (bitmap) texture from a file and access its pixels.
I scanned CHANNEL_COLOR ... CHANNEL_NORMAL, but none of these had a Bitmap. So I decided to create one using channel->InitTexture. This thread explains how to initialize the InitRenderStruct: http://www.plugincafe.com/\forum/forum_posts.asp?TID=5001
Then I use:
InitRenderStruct is; is.version = GetC4DVersion(); is.time = doc->GetTime(); is.fps = doc->GetFps(); Filename docpath = doc->GetDocumentPath(); is.docpath = &docpath; String matname = mat->GetName(); is.matname = &matname; is.errorlist = NULL; is.vd = NULL; is.doc = doc; is.thread = NULL; is.flags = INITRENDERFLAG_TEXTURES; LONG loadRes = channel->InitTexture(&is); switch (loadRes) { case LOAD_OK: GePrint("InitTexture: No error"); break; case LOAD_NOMEM: GePrint("InitTexture: Not enough memory."); break; case LOAD_NOTFOUND: GePrint("InitTexture: Texture not found."); break; case LOAD_UNKNOWN: GePrint("InitTexture: Unknown format."); break; case LOAD_DOUBLENAME: GePrint("InitTexture: Duplicate names."); break; } BaseBitmap* bitmap = channel->GetBitmap(); if (bitmap != NULL) { GePrint ("Got my bitmap"); } else { GePrint ("Cannot get bitmap"); }
After "InitTexture: No error", I get "Cannot get bitmap". Is it necessary to initialize the texture for a channel differently?
Michael Welter proposed to "create a Bitmapshader and link it to a BaseChannel of your material". I cannot find information on an object called Bitmapshader, and I don't know how to access bitmaps/textures from a shader. Or do I need to set up a shader to use the texture after I create it?