Unique Identifier for BaseObject



  • On 22/02/2013 at 13:45, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R14 
    Platform:      
    Language(s) :     C++  ;

    ---------
    Hi!

    I was wondering if there is a way to obtain a unique identifier for a given BaseObject. I'm looking something like a unique number or hash, that unmistakably identifies that object. I've tried to use GetUniqueIP() for this, but it just produces the exact same number for all the objects I've tried(Oddly that number is always -2147483647).

    I read in another thread, that using the GetMarker() function could be an option for this, but I couldn't quiet figure out, how the Marker could be used beyond comparing two objects.

    The last idea I had was to simply use the memory location of the object as a hash, but I'm too unfamiliar with C4Ds internal memory management to be sure that the objects address will remain constant throughout it's lifetime.

    Hope someone can help me out.



  • On 22/02/2013 at 13:55, xxxxxxxx wrote:

    First you have to SetUniqueIP().  You could use an incrementing long or some hash code to make each one unique (to avoid applying the same number to two different objects).

    As an alternative, you could use a BaseLink which stores a reference to a specific object (tag, etc.).  You can create arrays of BaseLinks if need be.



  • On 22/02/2013 at 14:31, xxxxxxxx wrote:

    Okay, I understand. At least that explains, why GetUniqueIP() wasn't working for me. What I was looking for though is some ID that is already in place without me having to define it first.
    The reason for this is, that I want to use that ID from within a shader plugin and I can't consistently maintain the different values for all the objects from within the shader (At least it seems impractical to me).
    Maybe there is another way.



  • On 23/02/2013 at 08:08, xxxxxxxx wrote:

    There is no such id to my knowledge (beside the mentioned one). BaseLinks are meant to provide a safe way of linking to a specific object.



  • On 24/02/2013 at 01:34, xxxxxxxx wrote:

    Try LULONG BaseObject::GetGUID(). That should work in all cases, even when GetUniqueIP() doesn't.



  • On 24/02/2013 at 01:56, xxxxxxxx wrote:

    Couldn't you just use the object's memory address?



  • On 24/02/2013 at 09:21, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Try LULONG BaseObject::GetGUID(). That should work in all cases, even when GetUniqueIP() doesn't.

    Interesting. But that only works in R14 right?



  • On 24/02/2013 at 11:06, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Try LULONG BaseObject::GetGUID(). That should work in all cases, even when GetUniqueIP() doesn't.

    Awesome, that looks like exactly what I was looking for. Wouldn't mind if it just works in R14 for that's what I'm using anyways. :)

    @Kuroyume: In my case it's not so much about the linking to the object, but having a unique value for each object, that I can feed to the shader.

    @Niklas: I think using the memory address would give me different values for the same object every time I start Cinema. For my purposes would be best to have consistent IDs.


Log in to reply