Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search

Instances dropped on Document::Polygonize

Author
Message
  Topic Search Topic Search
bjone View Drop Down
Member
Member


Joined: 2007 Jul 02
Location: France
Online Status: Offline
Posts: 11
Direct Link To This Post Topic: Instances dropped on Document::Polygonize
    Posted: 2007 Jul 26 at 3:12am

User Information:

Cinema 4D Version:   10.1 
Platform:   Windows  ;   
Language(s):     C++  ;  

---------

Hello, I am working on an exporter for C4D.

I need to export instances, since our format is intended for real-time purposes, I let C4D polygonize object through the use of BaseDocument::Polygonize().

The problem, is that Oinstances seems to be dropped by this function.
Is there any way to recover Instances, or to do a stable match of the hiearchy between the original document, and the polygonized one ?

Thanks :)
Back to Top
Matthias Bober View Drop Down
Forum Moderator
Forum Moderator


Joined: 2006 Oct 16
Location: Germany
Online Status: Offline
Posts: 2204
Direct Link To This Post Posted: 2007 Jul 26 at 5:55am
Maybe it's better to get your polygon objects on a per object basis. You can do this with GetDeformCache() and GetCache(). Here is a helper function to get the deformed polygon object of a selected object (it's from the upcoming SDK docu update).


static void DoRecursion(BaseObject *op)
{
     BaseObject *tp = op->GetDeformCache();
     if (tp)
     {
          DoRecursion(tp);
     }
     else
     {
          tp = op->GetCache(NULL);
          if (tp)
          {
               DoRecursion(tp);
          }
          else
          {
               if (!op->GetBit(BIT_CONTROLOBJECT))
               {
                    if (op->IsInstanceOf(Opolygon))
                    {
                         // --------------------------
                         // HERE IS THE DEFORMED POLYGON OBJECT
                         // --------------------------
                    }
               }
          }
     }
     for (tp = op->GetDown(); tp; tp=tp->GetNext())
     {
          DoRecursion(tp);
     }
}


cheers,
Matthias
MAXON
developer support
Back to Top
bjone View Drop Down
Member
Member


Joined: 2007 Jul 02
Location: France
Online Status: Offline
Posts: 11
Direct Link To This Post Posted: 2007 Jul 26 at 6:00am
Ok !!! I will try this immediately

Thanks :)
Back to Top
bjone View Drop Down
Member
Member


Joined: 2007 Jul 02
Location: France
Online Status: Offline
Posts: 11
Direct Link To This Post Posted: 2007 Jul 27 at 2:24am
Arghhh, hell is in details :D

It seems that the texture tag is "lost" when processing a the last "op" level.

One of the situation where the problem arises:
- Make a landscape
- Texture it basically (UVW mapping)
- So that the object has only: a Texture Tag, and a Phong Tag

When processing, the Texture Tag has gone (but it seems i have the UVW Tag).

When using Polygonize(), i used to got everybody (TextureTag, UVWTag, PhongTag).

I suppose that the TextureTag is on the previous recusion, i will dig onto this.

But i will take any hints :)
Back to Top
bjone View Drop Down
Member
Member


Joined: 2007 Jul 02
Location: France
Online Status: Offline
Posts: 11
Direct Link To This Post Posted: 2007 Jul 27 at 2:27am
BTW, i moved processing of sub objects to just after the polyobject generation.
(i have a general hiearchy tracking outside of the equivalent of this recursive routine)
Back to Top
bjone View Drop Down
Member
Member


Joined: 2007 Jul 02
Location: France
Online Status: Offline
Posts: 11
Direct Link To This Post Posted: 2007 Aug 07 at 8:40am
arghh, I hit another wall, so I have ended with a temporary solution involving just this (taken from Document::Polygonize() routine):


BaseObject *PolygonizeBaseObject( BaseObject *Src )
{
BaseContainer Ctr;
     
ModelingCommandData CData;
CData.doc = Src->GetDocument();
CData.bc = &Ctr;     

Ctr.SetBool(MDATA_CURRENTSTATETOOBJECT_KEEPANIMATION,TRUE);

CData.op = Src;

if( !SendModelingCommand( MCOMMAND_CURRENTSTATETOOBJECT, CData ) || !CData.result )
return NULL;     

BaseObject *CollapsedObject = (BaseObject*)CData.result->GetIndex(0);

AtomArray::Free( CData.result );

return CollapsedObject;
}


So I just collapse a hierarchy branch with this call:


AutoFree<BaseObject> PolyObject = PolygonizeBaseObject( Object );

if( PolyObject )
    MyObjectProcessor( PolyObject.... );     


I just wanted to know if the sequence above would disrupt or leak C4D ressources.
Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.125 seconds.