still question about object axis
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/06/2009 at 13:55, xxxxxxxx wrote:
User Information:
Cinema 4D Version:
Platform: Windows ;
Language(s) : C++ ;---------
hi there,i am totally struggling now.. i need to set the axis of an object to a specific value and i have absolutely no clue how to do this. not even a shade of knowledge...
for example i want to set it to the global (0,0,0) coordinate..
maybe someone can help me solve this? i've got the first tip here, but i must admit that i dont understand that matrix stuff good enough to use it...
thanks in advance,
ello
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/06/2009 at 15:29, xxxxxxxx wrote:
could it really be that it is that simple???
> `
\> void setAxis(BaseDocument *doc, BaseObject *op, Vector pos) \> { \> Matrix m; \> Matrix tm; \> m.off = pos; \> while(op) \> { \> if (op->GetType()==Opolygon) \> { \> tm = op->GetMl(); \> PointObject *pobj = static_cast<PointObject*>(op); \> Vector *parr = pobj->GetPointW(); \> LONG pcnt = pobj->GetPointCount(); \> GePrint(LongToString(pcnt)); \> for(int i=0;i<pcnt;i++) \> { \> parr[i]*=tm; \> } \> \> op->SetMl(m,FALSE); \> } \> setAxis(doc,op->GetDown(),pos); \> op = op->GetNext(); \> } \> } \>
`
in my first tests it seems that this is it??
thanks for checking,
ello
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/06/2009 at 15:55, xxxxxxxx wrote:
hm, now i face another problem.. what is wrong with my code? i am trying to calculate the center of a polygonobject, but it doesnt work:
> `
\> Vector cpos = Vector(0); \> PointObject *pobj = static_cast<PointObject*>(op); \> Vector *parr = pobj->GetPointW(); \> LONG pcnt = pobj->GetPointCount(); \> if (pcnt>0) \> { \> for(int i=0;i<pcnt;i++) \> { \> cpos += parr[i]; \> } \> cpos /= pcnt; \> } \>
`
where's my fault?
thanks and cheers,
ello
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/06/2009 at 13:44, xxxxxxxx wrote:
hmm, somehow the axis is not centered correctly, nearby, but not exactly where it should be..
> `
\> void setAxisSingleObject(BaseObject *op, Vector pos) \> { \> Matrix m; \> m.off = -pos; \> if (op->GetType()==Opolygon) \> { \> PointObject *pobj = static_cast<PointObject*>(op); \> Vector *parr = pobj->GetPointW(); \> LONG pcnt = pobj->GetPointCount(); \> for(int i=0;i<pcnt;i++) \> { \> parr[i]*=m; \> } \> m.off = pos; \> op->SetMl(m,FALSE); \> } \> } \> \> void centerAxis(BaseObject *op) \> { \> if (op->GetType()==Opolygon) \> { \> Vector cpos = Vector(0); \> PointObject *pobj = static_cast<PointObject*>(op); \> Vector *parr = pobj->GetPointW(); \> LONG pcnt = pobj->GetPointCount(); \> if (pcnt>0) \> { \> for(int i=0;i<pcnt;i++) \> { \> cpos += parr[i]; \> } \> cpos /= pcnt; \> setAxisSingleObject(op, cpos+op->GetPos()); \> } \> } \> } \>
`
anyone sees where i am wrong here?
thanks in advance.
cheers,
ello