Accessing primitive object geometry [SOLVED]
-
On 12/05/2015 at 01:37, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 15
Platform: Mac ;
Language(s) : C++ ;---------
Hello folks,
Is there any way to obtain the geometry (faces and vertices) of a primitive object without making it editable?If I have a primitive object (a cube) and made it editable (right click + "Make Editable") I can get the geometry of that object with these methods:
const CPolygon* polys = object->GetPolygonR(); const Vector* vertices = object->GetPointR(); const Int32 numPolys = object->GetPolygonCount(); const Int32 numVertices = object->GetPointCount();
They return valid results. I can also see that the type of the object has been changed to OBJECT_POLYGONOBJECT after making it editable.
If I try to access these same values with a primitive object (i.e. a cube) without making it editable I see that the type of the object is OBJECT_GENERATOR but those methods return NULL and 0.
so, does anybody know the correct way to access that information?
-
On 12/05/2015 at 01:47, xxxxxxxx wrote:
Hi,
It is simply not possible.
The only way to do that, is to make it editable.
What you could do, is make an object-generator plugin and add the methods yourself (GetPolygonR()), but I don't know if that's what you want.If you have more questions, just ask.
Greetings,
Casimir Smets -
On 12/05/2015 at 02:00, xxxxxxxx wrote:
Thanks for your reply Casimir,
I am not completely sure it is impossible, if you take a look at the X-particles plugin, you can make an emitter that collides with a primitive cube with a collider tag on it, and the cube is not even editable. The only way to simulate this correctly is having access to the object geometry inside X-particles... somehow X-particles is doing it.
cheers.
-
On 12/05/2015 at 02:14, xxxxxxxx wrote:
I do this inside my plugin and it works fine. Although my plugin is an ObjectData plugin with the OBJECT_MODIFIER flag..
What i do is just cast the object as a polygonal object and go from there..
So you can use:
ToPoly(op)->GetPolygonR();
or:
static_cast<PolygonObject*>(op)->GetPolygonR();
Something like that..
-
On 12/05/2015 at 02:17, xxxxxxxx wrote:
Hi Enrique,
You can get the geometry information for a primitive object with BaseObject::GetCache().
Check the type of the returned object and cast it to the appropriate type i.e. PolygonObject in most cases. -
On 12/05/2015 at 02:30, xxxxxxxx wrote:
Hi,
Well, I guess I was wrong, sorry for my bad information!
I didn't think of casting itGreetings,
Casimir Smets -
On 12/05/2015 at 02:41, xxxxxxxx wrote:
Hi Casimir,
Originally posted by xxxxxxxx
I didn't think of casting it
Casting the primitive object, does not work. Casting the cache object returned by GetCache() does work.
-
On 12/05/2015 at 02:58, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Hi Casimir,
Originally posted by xxxxxxxx
I didn't think of casting it
Casting the primitive object, does not work. Casting the cache object returned by GetCache() does work.
Am i missing something? As i said in my post above it works fine for me without using the Cache at all.. But again, that is with an ObjectData OBJECT_MODIFIER plugin..
-
On 12/05/2015 at 03:14, xxxxxxxx wrote:
Is it an FFD deformer object? You can cast any object to a PointObject if it has a Tpoint Tag on it. Same goes for a PolygonObject if it has a Tpolygon tag on it (and a Tpoint tag).
-
On 12/05/2015 at 04:32, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Hi Enrique,
You can get the geometry information for a primitive object with BaseObject::GetCache().
Check the type of the returned object and cast it to the appropriate type i.e. PolygonObject in most cases.Thank you very much Yannick, you are absolutely right. It works!
However, now that we talk about deformers, if I have the very same cube deformed, the geometry I get with those methods is the original geometry, not the deformed one. do you know how to get the modified one? -
On 12/05/2015 at 04:42, xxxxxxxx wrote:
From GetCache(), scroll down just a little bit and you will find it
-
On 12/05/2015 at 07:12, xxxxxxxx wrote:
Originally posted by xxxxxxxx
From GetCache(), scroll down just a little bit and you will find it
Thanks Niklas, I forgot to mention that I was already using that . I don't know what the problem was at first that it didn't work, but now it is working.
Everything is correctly imported now