Polygon Flow

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 27/08/2008 at 12:58, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   r10.1 
Platform:   Windows  ;   
Language(s) :   C.O.F.F.E.E  ;

---------
   Hi, i am currently facing a problem with creating a proper polygonflow for an object. Generally it would help me if i could see how for example the "ebenen"-object is created with c.o.f.f.e.e.

my current snippet is this, btw, the
if (op#ID_USERDATA:1==1) is just a boole userdata to start the script:

> `

  
\>  main(doc,op)  
\>  {  
\>  var random = new(Random);  
\>  random->Init(time());  
\>    
\>       if (op#ID_USERDATA:1==1)  
\>       {  
\>            op#ID_USERDATA:1=0;  
\>            op#ID_USERDATA:2="Gestartet";  
\>            var newObj = new(PolygonObject);  
\>            newObj->SetName("terra");  
\>    
\>            doc->InsertObject(newObj,NULL,NULL);  
\>            GeEventAdd(DOCUMENT_CHANGED);       
\>              
\>            var vc = new(VariableChanged); if (!vc) return FALSE;  
\>    
\>            var cnt;  
\>            var ok;  
\>            var _xCnt,_yCnt,_xPos,_yPos,_vPos;  
\>            var _p1,_p2,_p3,_p4;  
\>            var _xMax = op#ID_USERDATA:3; var _yMax = op#ID_USERDATA:4;  
\>            var _pNum;  
\>    
\>            var pArr = new(array,_xMax*_yMax);  
\>    
\>            for (_xCnt=0;_xCnt<_xMax;_xCnt++)  
\>            {  
\>                 for (_yCnt=0;_yCnt<_yMax;_yCnt++)  
\>                 {  
\>                      cnt = newObj->GetPointCount();  
\>                      vc->Init(cnt,cnt+1);  
\>                      ok =newObj->MultiMessage(MSG_POINTS_CHANGED,vc);  
\>                      _pNum = cnt;//_xCnt*_yMax + _yCnt;  
\>                      _xPos = (_xCnt-_xMax/2)*200;  
\>                      _yPos = (_yCnt-_yMax/2)*200;  
\>                      _vPos = 512*random->Get01();  
\>                      newObj->SetPoint(_pNum,vector(_xPos-100,_vPos,_yPos+100));  
\>                 }  
\>            }  
\>    
\>            for(_xCnt=0;_xCnt<_xMax;_xCnt++)  
\>            {  
\>                 for(_yCnt=0;_yCnt<_yMax-1;_yCnt++)  
\>                 {  
\>                      cnt = newObj->GetPolygonCount();  
\>                      vc->Init(cnt,cnt+1);  
\>                      ok =newObj->MultiMessage(MSG_POLYGONS_CHANGED,vc);  
\>                      _pNum = cnt;//_xCnt*_yMax + _yCnt;//  
\>                      _p1 = _pNum;  
\>                      _p2 = _pNum + 1;  
\>                      _p3 = _pNum + _yMax + 1;  
\>                      _p4 = _pNum + _yMax;  
\>                      newObj->SetPolygon(_pNum, _p1,_p2,_p3,_p4);  
\>                 }  
\>            }  
\>            var t = AllocTag(Tphong);  
\>            newObj->InsertTag(t,NULL);  
\>            newObj->Message(MSG_UPDATE);  
\>         
\>            doc->SetActiveObject(newObj);  
\>            op#ID_USERDATA:2+="\nFertitsch";  
\>       }  
\>  }  
\>  

`

but it creates a big polygon when one row is finished and the other starts.

it would be cool if someone points me to the solution
thanks in advance,
ello

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/08/2008 at 01:44, xxxxxxxx wrote:

here you go:

> \> var x = 10; //x resolution \> var y = 10; //y resolution \> \> var op = doc->GetActiveObject(); \> \> if (!op || !instanceof(op,PolygonObject)) return; \> \> var vc = new(VariableChanged); if (!vc) return; \> \> var vcnt = op->GetPointCount(); \> vc->Init(vcnt, (x+1)\*(y+1)); \>                                                                                  \> if(!op->MultiMessage(MSG_POINTS_CHANGED,vc)) return; \> println("points changed"); \> \> var fcnt = op->GetPolygonCount(); \> vc->Init(fcnt, x\*y); \> \> if(!op->MultiMessage(MSG_POLYGONS_CHANGED,vc)) return; \> println("polygons changed"); \> \> println("set points"); \> \> var i,j,k=0; \> for(i=0; i<(y+1); i++) \> { \>      for(j=0; j<(x+1); j++) \>      { \>           op->SetPoint(k,vector(j\*20,0,i\*20)); \>           k++; \>      } \> } \> \> k=0; \> for(i=0; i<y; i++) \> { \>      for(j=0; j<x; j++) \>      { \>           var poly = new(Polygon); \>           poly->a = j+(i\*(x+1)); \>           poly->b = j+(i\*(x+1))+x+1; \>           poly->c = j+(i\*(x+1))+x+2; \>           poly->d = j+(i\*(x+1))+1; \>           op->SetPolygon(k,poly); \>           k++; \>      } \> } \> \> op->Message(MSG_UPDATE); \>

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/08/2008 at 02:04, xxxxxxxx wrote:

thank you very,very much!

best greetings,
christian