void tglDrawRigidity(const TMeshImage &image, double minColor[4],
                     double maxColor[4], const PlasticDeformerDataGroup *group,
                     bool deformedDomain) {
  struct locals {
    static double returnRigidity(const LinearColorFunction *cf, int m, int v) {
      return cf->m_meshImg.meshes()[m]->vertex(v).P().rigidity;
    }
  };

  LinearVertexColorFunction colorFunction(image, group, 1.0, 1e4, minColor,
                                          maxColor, locals::returnRigidity);

  if (group && deformedDomain)
    tglDrawFaces(image, group, colorFunction);
  else
    tglDrawFaces(image, colorFunction);
}
Beispiel #2
0
CGShadingRef Gradient::platformGradient()
{
    if (m_gradient)
        return m_gradient;

    const CGFloat intervalRanges[2] = { 0, 1 };
    const CGFloat colorComponentRanges[4 * 2] = { 0, 1, 0, 1, 0, 1, 0, 1 };
    const CGFunctionCallbacks gradientCallbacks = { 0, gradientCallback, 0 };
    RetainPtr<CGFunctionRef> colorFunction(AdoptCF, CGFunctionCreate(this, 1, intervalRanges, 4, colorComponentRanges, &gradientCallbacks));

    static CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

    if (m_radial)
        m_gradient = CGShadingCreateRadial(colorSpace, m_p0, m_r0, m_p1, m_r1, colorFunction.get(), true, true);
    else
        m_gradient = CGShadingCreateAxial(colorSpace, m_p0, m_p1, colorFunction.get(), true, true);

    return m_gradient;
}
void tglDrawSO(const TMeshImage &image, double minColor[4], double maxColor[4],
               const PlasticDeformerDataGroup *group, bool deformedDomain) {
  struct locals {
    static double returnSO(const LinearColorFunction *cf, int m, int f) {
      return cf->m_group->m_datas[m].m_so[f];
    }
  };

  double min = 0.0, max = 0.0;
  if (group) min = group->m_soMin, max = group->m_soMax;

  LinearFaceColorFunction colorFunction(image, group, min, max, minColor,
                                        maxColor, locals::returnSO);

  if (group && deformedDomain)
    tglDrawFaces(image, group, colorFunction);
  else
    tglDrawFaces(image, colorFunction);
}