| |
|
| Script Points to Circle
Ein freies Script von David Wickenden um aus 4 Punkten einen Kreis zu erstellen. Eventuell braucht es ja jemand. Es muss in den Scriptmanager kopiert werden. Code: /***************************************************
Points to Circle
David Wickenden 2007
****************************************************/
main(doc,op)
{
var radius = 50; //Enter radius value here.
if(!doc->GetActiveObject()) return;
if(!instanceof(op, PolygonObject)) return;
var bc = new(BaseContainer);
bc->SetData(MDATA_CONVERTSELECTION_LEFT, 0);
bc->SetData(MDATA_CONVERTSELECTION_RIGHT, 1);
SendModelingCommand(MCOMMAND_CONVERTSELECTION, doc, op, bc, MODIFY_POINTSELECTION);
SendModelingCommand(MCOMMAND_EDGE_TO_SPLINE, doc, op, bc, MODIFY_EDGESELECTION);
if(!op->GetDown()) return;
if(op->GetDown()->GetType() != OBJECT_SPLINE) return;
var pointCnt = op->GetPointCount();
var pointSel = op->GetPointSelection();
var pointSelCnt = pointSel->GetCount();
var spline = op->GetDown();
var spPointCnt = spline->GetPointCount();
var spPointSel = spline->GetPointSelection();
var spPointSelCnt = spPointSel->GetCount();
if(spPointCnt != pointSelCnt) return;
var arr = new(array, pointCnt, 2);
var i, j, k = 0;
var found = 0;
for(i = 0; i < pointCnt; i++)
{
if(found >= pointSelCnt) break;
if(pointSel->IsSelected(i))
{
for(j = 0; j < spPointCnt; j++)
{
if(op->GetPoint(i) == spline->GetPoint(j))
{
arr[k][0] = i;
arr[k][1] = j;
}
}
k++;
found++;
}
}
var vectorSum = vector(0, 0, 0);
var found = 0;
for(i = 0; i < spPointCnt; i++)
{
vectorSum = vectorSum + spline->GetPoint(i);
}
var mSp = spline->GetMg();
var vectorAv = vectorSum / spPointCnt;
var vectorAv_g = mSp->GetMulP(vectorAv);
var refPointA = spline->GetPoint(0);
var refPointB = spline->GetPoint(1);
var refPointAg = mSp->GetMulP(refPointA);
var refPointBg = mSp->GetMulP(refPointB);
var m = new(Matrix);
m->SetV0(vectorAv_g);
m->SetV1(vnorm(refPointAg - vectorAv_g));
var mV1 = m->GetV1();
m->SetV3(vnorm(vcross(mV1, (refPointBg - vectorAv_g))));
var mV3 = m->GetV3();
m->SetV2(vnorm(vcross(mV3, mV1)));
var angle = 6.283 / spPointCnt;
var mOp = op->GetMg();
var k;
for(k = 0; k < pointSelCnt; k++)
{
var pointA = spline->GetPoint(arr[k][1]);
var pointAg = mSp->GetMulP(pointA);
m->Invert(); //Local
var pointAl = m->GetMulP(pointAg);
var posAl_x = cos(angle * (arr[k][1])) * radius;
var posAl_y = sin(angle * (arr[k][1])) * radius;
var pointAlMod = vector(posAl_x, posAl_y, pointAl.z);
m->Invert(); //Global
var pointAg2 = m->GetMulP(pointAlMod);
mOp->Invert(); //Local
var pointAl2 = mOp->GetMulP(pointAg2);
op->SetPoint(arr[k][0], pointAl2);
mOp->Invert(); //Global
}
spline->Remove();
op->Message(MSG_UPDATE);
}
|
| |
| Themen-Tools | Thema durchsuchen |
| |
| | ||||
| Thema | Themenstarter | Forum | Antworten | Letzte Beiträge |
| Tileable Texture Script | Icerockers | Scripts & Plugins | 2 | 13.10.2009 11:37 |
| Demolition Script | Icerockers | Blender | 1 | 05.04.2008 09:51 |
| (script?) - Probleme mit 3ds max 7 | yakima | Autodesk 3ds Max | 7 | 22.01.2008 21:36 |
| LinkBacks zu diesem Thema: http://pixelplausch.de/scripts-plugins/3436-cinema4d-script-points-circle.html | ||||
| Erstellt von | für | Art | Datum | Hits |
| Modeling-Problem - PSD-Tutorials.de - Forum | dieses Thema | Refback | 24.09.2010 22:35 | 7 |
| CGTalk - BSG Viper - Modelling help or guidance | dieses Thema | Refback | 02.10.2009 09:09 | 26 |
©2007-2012, PIXELPLAUSCH - Powered by vBulletin® Version 3.8.2 Copyright ©2000 - 2012, Jelsoft Enterprises Ltd. span>, Search Engine Friendly URLs by vBSEO 3.3.0