Navigation

    • Register
    • Login
    • Search
    • Categories
    1. Home
    2. C4DS
    C
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    C4DS

    @C4DS

    55
    Reputation
    328
    Posts
    360
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online
    Website toolspixels.be Location Rupelmonde Age 50

    C4DS Follow

    Posts made by C4DS

    • RE: SceneHook and object caches

      @ferdinand said in SceneHook and object caches:

      so we talked a bit about it and there is unfortunately no way to do this ...

      Thanks for having taken the time to further investigate and discuss.

      ... depending on what you are trying to do, a general shift of design might be necessary when you run into major problems.

      I wouldn't mind a shift of design, unfortunately at this point in time I am out of ideas how to proceed.
      Maybe I am too focused on trying to reach my goal using the available cache. If there would be any other possibility to obtain the information I need to use ... I am all ears.

      The goal I am trying to reach might have been lost with all the technical details, so let me recap it with an example here:
      Let's say I have a regular polygon cube with 6 faces, 8 points.
      I put this cube into a subdivision-surface, resulting in the cube being smoothed, modifying the points' coordinates.
      What I would like to achieve is to know the modified coordinates of the 8 points.

      So, traversing the cache of the SDS and getting the particular cached object is one thing ...
      But since the SDS will subdivide the input object, the resulting cube (in the cache) will have more than 6 faces, 8 points.
      Second step is then to find out which original point index matches which point index in the modified object.

      Cinema4D does seem to have a way to know that relation.
      With the example of the cube under an SDS, enable islone editing, switch to point mode and select any of the 8 points of the cube.
      Cinema4D will display to original point as selected, but also the modified point.
      The one point has the original coordinates, the other has the modified coordinates.

      My goal is thus to find a similar way to obtain the modified coordinates of a point.

      posted in Cinema 4D Development
      C
      C4DS
    • RE: SceneHook and object caches

      I spent some time looking for a way to obtain the cache of a particular object.
      Not sure if this will work for every possible scenario, but for now I am trying following concept:

      1. start from the selected (input) object
      2. traverse the scene up, doing so I built up a "tree-address" for the object, and keep track of the parent-most Subdivision Surface.
      3. I get the cache of the parent-most SDS, and traverse the cache tree down, using the obtained tree-address to reach the cache object.

      This technique will probably fail when a generator, like cloner/array/... is located in the tree between SDS and input object. Since then the tree address of the input will not match with the tree of the cache.

      The other issue is that when selecting polygons/edges/points on the input object the cache doesn't get rebuilt ... so if the goal is to do something with selected and unselected polygons/edges/points the cache doesn't get updated with the change of selection of the input object.

      posted in Cinema 4D Development
      C
      C4DS
    • RE: SceneHook and object caches

      @ferdinand said in SceneHook and object caches:

      well, in scenario two the sds IS your cache parent, so this is kind of to be expected

      Yes, indeed. I didn't want to imply that was not the expected cache parent.
      I only meant to say that going that route I wasn't able to reach the input object, to get it's active state.

      Correct, building my own logic will quickly turn into something messy, but I am afraid there isn't another way.
      I 'll think about it some more ... have a nice weekend.

      posted in Cinema 4D Development
      C
      C4DS
    • RE: SceneHook and object caches

      @ferdinand
      I have been playing with your script to walk the cache of different hierarchy scenarios I have built.
      I now have a better understanding of what to expect from the GetCache and GetDeformCache.
      However, I am still missing one bit of information.

      For purpose of explanation, let's assume the main idea is to draw a line from the first point of an object to the first point of the "modified" object.
      Where modification is done via a deformer or subdivision surface, or combination of both.
      To draw that line I thus need the coordinates of the "original" object, and the coordinates of the modified one.

      Scenario1:

      + Sphere (active)
        + Twist
      

      Assume I have a polygon object "Sphere", and a Twist deformer as child.
      I can get the deformcache from Sphere, perform a DoRecursion to obtain the deformed polygon object, and access its points.

      Scenario2:

      + Subdivision Surface
         + Cube (active)
      

      Here I get the cache of the subdivision surface and perform a DoRecursion to get obtain the "deformed" polygon object. Using the term "deformed object" might be a bit misleading, so let's use "generated object" instead.

      In both scenarios I could then draw the line from the original coordinate to the modified coordinate.

      Now, let's assume I have an option (checkbox):

      • when checkbox on, I want to only draw the line when the object is active (=selected in OM)
      • when checkbox off, the line is always drawn, independent of the active state of the object

      In both scenarios the BIT_ACTIVE flag is only set on the original object. In both cache as in deformcache the flag is always false.
      However, in case of scenario 1, I can perform a GetCacheParent on the obtained modified object, which will give me the original object, from which I can check the BIT_ACTIVE.
      In case of scenario 2, performing a GetCacheParent will get me the Subdivision Surface.

      How to have a common solution to find out if the original object of a cached object (from GetCache or from GetDeformCache) is active?

      posted in Cinema 4D Development
      C
      C4DS
    • RE: SceneHook and object caches

      @ferdinand
      Thanks for the info.

      I didn't know what I was doing, and I didn't quite get what the documentation was saying.
      Now at least I understand that GetCache is related to generators, and GetDeformCache is related to deformers.
      That wasn't quite clear at all from the docs ... at least to me.

      Also, a big thank you for that script to walk the cache. Quite useful.

      I now think to have the basics to proceed.

      posted in Cinema 4D Development
      C
      C4DS
    • SceneHook and object caches

      Hi,
      I have a SceneHook which I use to draw some information related to Opolygon objects in the scene.
      Up to now, I was only looking at the "original" objects in de scene, but am now looking how to add support for deformed objects.
      I have looked through the documentation and found BaseObject::GetCache, GetDeformedCache, and cannot really wrap my head around the explanation.
      Would there be any example available that demonstrates how to access the cache?

      There are different scenarios I have in mind:

      Scenario 1:
      I iterate over all objects in a scene, and want to collect all deformed objects' cache, ignoring any other object, including the original input object for the deformation/SDS

      	BaseObject* obj = doc->GetFirstObject();
      	while (obj)
      	{
      		if (obj->IsInstanceOf(Opolygon))
      		{
      			// ignore
      		}
      		else
      		{
      			maxon::BaseArray<BaseObject*> deformed;
      			DoRecursion(obj, deformed);
      
      			for (const auto& defobj : deformed)
      			{
      				// process these
      			}
      		}
      
      
      		// get next object
      		if (obj->GetDown())
      		{
      			obj = obj->GetDown();
      		}
      		else
      		{
      			while (!obj->GetNext() && obj->GetUp())
      				obj = obj->GetUp();
      			obj = obj->GetNext();
      		}
      	}
      
      void DoRecursion(BaseObject *op, maxon::BaseArray<BaseObject*>& deformed)
      {
      	BaseObject* tp = op->GetDeformCache();
      	if (tp)
      	{
      		DoRecursion(tp, deformed);
      	}
      	else
      	{
      		tp = op->GetCache(nullptr);
      		if (tp)
      		{
      			DoRecursion(tp, deformed);
      		}
      		else
      		{
      			if (!op->GetBit(BIT_CONTROLOBJECT))
      			{
      				if (op->IsInstanceOf(Opolygon))
      				{
      					// --------------------------  
      					// HERE IS THE DEFORMED POLYGON OBJECT  
      					// --------------------------  
      					iferr(deformed.Append(op))
      					{ return; }
      				}
      			}
      		}
      	}
      	for (tp = op->GetDown(); tp; tp = tp->GetNext())
      	{
      		DoRecursion(tp, deformed);
      	}
      }
      

      This seems to work, except that I ignore any polygon object which is not an input of a deform/SDS.
      So, how to distinguish between a polygon object which is an input and one which isn't an input for deform/SDS?

      Scenario 2:
      Assume I want to iterate over each object in the scene, and want to collect the pair of polygon object and it's deformed cache. This in order to draw a line form each of the deformed points to the original points of the object.
      How to find back the relation "original object" <-> "deformed object".

      Thanks in advance,
      Daniel

      posted in Cinema 4D Development
      C
      C4DS
    • RE: Custom ColorField?

      @zipit
      Thanks for the detailed info.
      Much appreciated!

      posted in Cinema 4D Development
      C
      C4DS
    • RE: Custom ColorField?

      @zipit
      Thanks for the info.
      I went with using:

      	Int32 flags = DR_COLORFIELD_NO_MODE_BUTTONS | DR_COLORFIELD_NO_PICTURE | DR_COLORFIELD_NO_BRIGHTNESS | 
      		DR_COLORFIELD_NO_KELVIN | DR_COLORFIELD_NO_RGB | DR_COLORFIELD_NO_HSV |
      		DR_COLORFIELD_NO_MIXER | DR_COLORFIELD_NO_SWATCHES | DR_COLORFIELD_NO_SCREENPICKER |
      		DR_COLORFIELD_ENABLE_SPECTRUM | DR_COLORFIELD_RGB_HIDE_HEX;
      	AddColorChooser(IDC_COLOR_CHOOSER, BFH_LEFT, 10, 10, flags, BaseContainer());
      
      

      and ended up with:

      ColorChooser.jpg

      Almost what I am looking for.
      However, I noticed that when right-mouse clicking the color gradient box, a popup allows to choose between small, medium, large size. By default the medium size is shown. How to control this.
      Is this done with the settings BaseContainer in some way? I couldn't find detailed information what these settings are, and how to control them.

      Also, is it possible to hide/remove the top color rectangle?
      Thanks again.

      posted in Cinema 4D Development
      C
      C4DS
    • Custom ColorField?

      Hi,
      I have a GeUserArea drawing different objects, and would like to allow the user to specify a name and color for each of the objects.

      To avoid many user actions, I would like to open a single dialog box, which would contain an edit field for the name, and some ColorField components to specify the color.
      I would prefer not to have the user enter name via separate text edit field in one dialog, and a ColorField, opening another dialog.

      Is there a way to obtain ColorField components and use them as gadgets in a dialog box? Or other ways to combine color-gadgets with edit fields, checkboxes, buttons, etc... ?
      Or is the only solution to provide my own RGB, HSV color sliders, and/or colorwheel?

      Thanks,
      Daniel

      posted in Cinema 4D Development
      C
      C4DS
    • Best Wishes to the team

      I am less active since a few months, and this will probably not change any time soon, but let that not restrict me for sending Best Wishes for 2021 to everyone of the SDK team.
      Not only to those more present and visible in the forums, but also to those behind the scenes that keep everything running.

      Thank you for your 2020 support and best wishes for 2021.

      posted in Information & Resources
      C
      C4DS