LDCad Detecting current editing plane using API?


RE: Detecting current editing plane using API?
#4
(2021-12-30, 8:17)David Manley Wrote: From some preliminary script fiddling, presumably just based just on the Tilt and Yaw values, with the toggle point being at the +/- 45 degree angle and +/-135 degree angle. The Roll doesn't appear to influence the current editing plane. Is this interpretation along the correct lines?

Seems ok, in case you want the exact same value here's the relevant LDCad source:
Code:
void TEditWindowSession::applyAutoEditPlane() {

  ldcAssert(perspective);

  const double minAngle=deg2Rad(40);
  const double nearZero=deg2Rad(1);

  TGLMatrixd matrix(getRotCtrl()->getRotationMatrix());
  matrix.mulOriWithGL(editSes->getGrid()->getOri());

  TGLVector3d dir(1.0, 0.0, 0.0), frusZ(0.0, 0.0, 1.0);
  dir.transform(matrix);
  double angleX=dir.unitAngleWith(frusZ);if (angleX>0.5*M_PI) angleX=M_PI-angleX; if (angleX<nearZero) angleX=minAngle;

  dir.init(0.0, 1.0, 0.0);
  dir.transform(matrix);
  double angleY=dir.unitAngleWith(frusZ);if (angleY>0.5*M_PI) angleY=M_PI-angleY; if (angleY<nearZero) angleY=minAngle;

  dir.init(0.0, 0.0, 1.0);
  dir.transform(matrix);
  double angleZ=dir.unitAngleWith(frusZ);if (angleZ>0.5*M_PI) angleZ=M_PI-angleZ; if (angleZ<nearZero) angleZ=minAngle;

  //Beste vlak kiezen dmv kleinste hoek tov z
  if (angleX<minAngle || angleY<minAngle || angleZ<minAngle)
  {
    if (angleX<angleZ)
    {
      if (angleX<angleY)
        setEditPlane(EP_YZ); //x
      else
        setEditPlane(EP_XZ); //y
    }
    else if (angleZ<angleY)
      setEditPlane(EP_XY); //z
    else
      setEditPlane(EP_XZ); //x
  }
  else
  {
    //90 deg (rounded) ori, gebruik de globale methode
    // dit kan niet altijd daar je een dode zone wilt (minAngle)
    matrix.orthoRoundRotation();
    setEditPlane(EPS2EP(roundedOrthoOri2EPS(matrix)));
  }
};

It basically does the same but it applies a 'dead-zone' so it won't jump around too match.
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: Detecting current editing plane using API? - by Roland Melkert - 2021-12-30, 19:45

Forum Jump:


Users browsing this thread: 1 Guest(s)