반응형
public void MakeCylinder
{
API_BEGIN
BODY* headCylinder = nullptr;
BODY* bodyCylinder = nullptr;
SPAposition centerPosition(20,20,20);
SPAposition startPosition(0,0,0);
SPAposition endPosition(100,100,100);
double xdiff = centerPosition.x() - min._x;
double ydiff = (centerPosition.y() - min._y) + (endPosition.x() - startPosition.x());
SPAvector traslateVector(-xdiff, -ydiff, 0);
SPAposition middlePosition(endPosition.x() * 0.05, endPosition.y() , 0);
//Rotate 하기위한 Trasf 정보 만들기.
SPAtransf translateTransf = rotate_transf(degrees_to_radians(azimuthAngle), SPAvector(0, 0, 1));
translateTransf *= translate_transf(traslateVector);
double HeadRadius = xdiff*0.035;
double bodyRadius = xdiff*0.012;
api_solid_cylinder_cone(middlePosition, startPosition, HeadRadius , HeadRadius, 0, nullptr, headCylinder, nullptr);
api_solid_cylinder_cone(endPosition, middlePosition, bodyRadius , bodyRadius, bodyRadius, nullptr, bodyCylinder, nullptr);
//두 Body를 합치는 함수.
api_imprint_stitch(headCylinder, bodyCylinder);
api_transform_entity(headCylinder, translateTransf);
//Transform 적용을 위한 필수 호출 함수
api_change_body_trans(headCylinder, NULL);
rgb_color col(r / 255.0, g / 255.0, b / 255.0);
//Color 변경 함수.
result = api_rh_set_entity_rgb(headCylinder, col);
ENTITY_LIST* entityList = spaModeler->GetAllBodies();
id = entityList->add(headCylinder);
API_END
}