Basic Objects
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/05/2008 at 13:50, xxxxxxxx wrote:
0L is 'zero - long value'. This just guarantees that the (LONG) flags variable is cleared.
Don't know about your crashing situation - would need to see the code or it may be that you can't do this in Execute() (?).
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/05/2008 at 16:13, xxxxxxxx wrote:
Using your code above does not work for me either in Execute() nor GetVirtualObjects() nor any self defined method.
I just have no idea where it comes from, perhaps because I create an object by code... but that make no sense...An further question, is it possible mcd.result_ex does not return a "real" polyobject ? I get crashes getting the Array start from the resulting poly...
I even don't get it using some terms from "roundedTube.cpp"
like
>\> BaseObject \*obj = BaseObject::Alloc(Osphere); // or any (\*obj) assigned by method call... \> PointObject \*pointObject = ToPoint(obj); \> const Vector \*pt = pointObject->GetPointR(); \>
Roundet tube is setting
>
Vector \*vector = obj->GetPointW();
But that should make no difference (for me)...
Of this usage is incorrect -> how is it used correctly with a
>PolygonObject \*obj = static_cast<PolygonObject\*>(mcd.result->GetIndex(0L))
or
>
PolygonObject \*obj = static_cast<PolygonObject\*>(mcd.result_ex)
Cheers
Sascha -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/05/2008 at 16:51, xxxxxxxx wrote:
'roundedTube.cpp' doesn't have that at all.
It has:
PolygonObject* op = NULL;
...
op = PolygonObject::Alloc(pcnt,vcnt);You have to consider class derivation here:
BaseObject
--PointObject
----PolygonObjectAn Osphere is a BaseObject (and a procedural primitive) where as a PolygonObject is a BaseObject class extended with points and polygons support. These are not the same which is why you need to make the procedural primitive (Osphere) editable - which turns it into an Opolygon. Again, doing ToPoint(obj) or ToPoly(obj) just casts the pointer to another type - it doesn't actually change the BaseObject into a PolygonObject.
I have no idea why mcd.result->GetIndex(0) crashes on you. You should verify the actual crash location by commenting out code until the crash disappears and uncommenting until it reappears. It may not be what you think it is.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/05/2008 at 17:00, xxxxxxxx wrote:
Jepp thats right. It justs casts the type of pointer. Somehow it runs in this example...
We are two, I also have no idea. I did that commenting out the code... either it crashes on casting the result from sendModelingCommand or when inserting into doc.
Cheers
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/05/2008 at 17:05, xxxxxxxx wrote:
You might want to check that mcd.result is not NULL (the AtomArray was allocated) as well as checking the retrieved object similarly.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/05/2008 at 17:08, xxxxxxxx wrote:
Thats a good idea to check...
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/05/2008 at 03:36, xxxxxxxx wrote:
I recently tried the following code, with three methods of object generation. Everyone crashes at the static_cast, no matter to what type the result is casted...
>
BaseObject \*CLODDY4D::GetVirtualObjects(BaseObject \*op, HierarchyHelp \*hh){ \> \> BaseContainer bc; \> ModelingCommandData mcd; \> bc.SetReal(PRIM_SPHERE_RAD,100.0); \> bc.SetLong(PRIM_SPHERE_SUB,4); \> \> //BaseObject \*sphere = GeneratePrimitive(NULL,Osphere,bc,1.0,FALSE,hh->GetThread()); \> //BaseObject \*sphere = BaseObject::Alloc(Osphere); \> AutoAlloc<BaseObject>sphere(Osphere); \> if(!sphere) return NULL; \> \> mcd.doc = GetActiveDocument(); \> mcd.bc = &bc; \> mcd.flags = 0L; \> mcd.op = sphere; \> if(!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd)) return NULL; \> PolygonObject\* poly = static_cast<PolygonObject\*>(mcd.result->GetIndex(0L)); \> //if(mcd.result->GetIndex(0L)->GetType()!=Opolygon) return NULL; \> if(!poly) return NULL; \> return poly; \> }
Perhaps I am really running into a dead end, with my vision of the need of a polygonal object (I am much more a c4d user ) to access its points and polygons.
At the end, all I need is access to the point array of my octa to perfom cutting operations on the edges by mid-point and merging vertex points.Cheers
Sascha -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/05/2008 at 03:45, xxxxxxxx wrote:
Hello again,
I just can't get rid of this converting. I cannot get it run properly when using code like this:
>
\> static PolygonObject \*PolyObject(BaseObject \*sphere) \> { \> PolygonObject \*polyOb = NULL; \> ModelingCommandData mcd; \> mcd.doc = GetActiveDocument(); \> mcd.bc = sphere->GetDataInstance(); \> mcd.op = sphere; \> if(!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT,mcd)) return NULL; \> polyOb = static_cast<PolygonObject\*>(mcd.result->GetIndex(0)); \> if(polyOb->GetType()!=Opolygon) return NULL; \> \> return polyOb; \> } \> \> PolygonObject \*CLODDY4D::GetVirtualObjects(PluginObject \*op, HierarchyHelp \*hh) \> { \> BaseObject \*sphere = BaseObject::Alloc(Osphere); \> if(!sphere) return NULL; \> \> BaseContainer \*bc = sphere->GetDataInstance(); \> bc->SetReal(PRIM_SPHERE_RAD,100); \> bc->SetLong(PRIM_SPHERE_SUB,4); \> \> return PolyObject(sphere); \> } \>
The debugger stops at polyOb = static_cast<..>;
If modelingcommand fails, it should return NULL, so there should be some result, but this cast does not work as it should! (According to documentation). I am running out of clues and time...*sigh*
Sascha -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/05/2008 at 05:22, xxxxxxxx wrote:
You can not use GetActiveDocument() in this case. Here some working code.
>
\> static PolygonObject \*PolyObject(BaseDocument \*doc, BaseObject \*sphere) \> { \> PolygonObject \*polyOb = NULL; \> ModelingCommandData mcd; \> mcd.doc = doc; \> mcd.op = sphere; \> if(!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd)) return NULL; \> polyOb = static_cast<PolygonObject\*>(mcd.result->GetIndex(0)); \> if(polyOb->GetType()!=Opolygon) return NULL; \> \> return polyOb; \> } \> \> // main routine: build virtual atom objects \> BaseObject \*AtomObject::GetVirtualObjects(PluginObject \*op, HierarchyHelp \*hh) \> { \> BaseObject \*sphere = NULL; \> sphere = BaseObject::Alloc(Osphere); \> if(!sphere) goto Error; \> \> BaseContainer \*bc = sphere->GetDataInstance(); \> bc->SetReal(PRIM_SPHERE_RAD,100); \> bc->SetLong(PRIM_SPHERE_SUB,4); \> \> PolygonObject \*polysphere = NULL; \> polysphere = PolyObject(op->GetDocument(), sphere); \> \> if(sphere) \> { \> BaseObject::Free(sphere); \> sphere = NULL; \> } \> \> return polysphere; \> \> Error: \> blDelete(sphere); \> return NULL; \> } \>
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/05/2008 at 07:45, xxxxxxxx wrote:
Hello Matthias,
thanks for this clearing.
I had no idea, that GetDocument(); retrieves the current opened document. Thought it was GetActiveDocument();... Think thats for more than one open doc's ?!Right now the function call "polysphere=polyObject(op->GetDocument(),sphere)" causes this exception:
>
\> Unhandled exception at 0x00bbc1ea in CINEMA 4D Demo.exe: 0xC0000005: Access violation reading location 0x00000000
I have no experience with this type of exception, what went wrong ?!
P.s.: I am developing under demo of r10.5, cause it starts up much faster than my full installation with lots of Plug-Ins installed...
Edit:
It seems the document is not retrived correctly...
I set up an ::Init()-Function, i hope that is correct for an ObjectData-Plugin... :>
\> Bool CLODDY4D::Init(GeListNode \*node) \> { \> BaseObject \*op = (BaseObject\* )node; \> BaseContainer \*data = op->GetDataInstance(); \> return TRUE; \> } \>
So op has to be "anything", where document can be retrieved from.
Wave
Sascha op -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/05/2008 at 03:43, xxxxxxxx wrote:
Nobody an idea ? *sigh*
Cheers
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/05/2008 at 00:57, xxxxxxxx wrote:
Does it work if you change the call to PolyObject() to something like this (use hh instead of op) :
polysphere = PolyObject(hh->GetDocument(), sphere);
Either way I don't get this exception here.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/05/2008 at 02:04, xxxxxxxx wrote:
Hi
Yes, I already changed it to hh->GetDocument(); earlier, getting the same result.
If I use BaseDocument *doc = op->GetDocument() or hh->GetDocument(); as very first statement (which is equivalent to the direct call) cinema4D crashes directly there.
Hmm, what could cause this exception ? IDE ? IDE-config ? Operating System ? I am running VS C++ 2008 EE on Vista x64. Perhaps this does not work with the express edition ?
Cheers
Sascha -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/05/2008 at 03:32, xxxxxxxx wrote:
Hey ahm right now, I revisited the documentation. It seems I have missed setting up /vmg /vms.
Thanks so far, now everything works and i can start manipulating vertexpoints and polygons
Just for safeness:
Shouln't be the sphere set NULL at first before freeing it ? Setting it NULL first before freeing it does not result a crash at
c4d_baseObject.cpp, line 841
void BaseObject::Free(BaseObject *&bl;)
{
C4DOS.Bl->Free(bl);
bl=NULL;
} -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/05/2008 at 03:53, xxxxxxxx wrote:
No, how should Cnema know what to free if the pointer is set to NULL.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/05/2008 at 04:06, xxxxxxxx wrote:
Yes, thats a good point. In that case (setting BaseObject::Free(sphere) first) my plugin breaks, because
bl from BaseObject::Free(BaseObject *&bl;) has the value "0" while sphere has 0x04f306dc... This is strange.Cheers
Sascha