Esempio n. 1
0
  /**
   * This method retuns the bone tracks for animation for blender version 2.50 and higher.
   *
   * @param actionStructure the structure containing the tracks
   * @param blenderContext the blender context
   * @return a list of tracks for the specified animation
   * @throws BlenderFileException an exception is thrown when there are problems with the blend file
   */
  private BlenderAction getTracks250(Structure actionStructure, BlenderContext blenderContext)
      throws BlenderFileException {
    LOGGER.log(Level.FINE, "Getting tracks!");
    Structure groups = (Structure) actionStructure.getFieldValue("groups");
    List<Structure> actionGroups = groups.evaluateListBase(); // bActionGroup
    BlenderAction blenderAction =
        new BlenderAction(actionStructure.getName(), blenderContext.getBlenderKey().getFps());
    int lastFrame = 1;
    for (Structure actionGroup : actionGroups) {
      String name = actionGroup.getFieldValue("name").toString();
      List<Structure> channels =
          ((Structure) actionGroup.getFieldValue("channels")).evaluateListBase();
      BezierCurve[] bezierCurves = new BezierCurve[channels.size()];
      int channelCounter = 0;
      for (Structure c : channels) {
        int type = this.getCurveType(c, blenderContext);
        Pointer pBezTriple = (Pointer) c.getFieldValue("bezt");
        List<Structure> bezTriples = pBezTriple.fetchData();
        bezierCurves[channelCounter++] = new BezierCurve(type, bezTriples, 2);
      }

      Ipo ipo = new Ipo(bezierCurves, fixUpAxis, blenderContext.getBlenderVersion());
      lastFrame = Math.max(lastFrame, ipo.getLastFrame());
      blenderAction.featuresTracks.put(name, ipo);
    }
    blenderAction.stopFrame = lastFrame;
    return blenderAction;
  }
Esempio n. 2
0
  /**
   * This method creates an ipo object used for interpolation calculations.
   *
   * @param ipoStructure the structure with ipo definition
   * @param blenderContext the blender context
   * @return the ipo object
   * @throws BlenderFileException this exception is thrown when the blender file is somehow
   *     corrupted
   */
  public Ipo fromIpoStructure(Structure ipoStructure, BlenderContext blenderContext)
      throws BlenderFileException {
    Structure curvebase = (Structure) ipoStructure.getFieldValue("curve");

    // preparing bezier curves
    Ipo result = null;
    List<Structure> curves = curvebase.evaluateListBase(); // IpoCurve
    if (curves.size() > 0) {
      BezierCurve[] bezierCurves = new BezierCurve[curves.size()];
      int frame = 0;
      for (Structure curve : curves) {
        Pointer pBezTriple = (Pointer) curve.getFieldValue("bezt");
        List<Structure> bezTriples = pBezTriple.fetchData();
        int type = ((Number) curve.getFieldValue("adrcode")).intValue();
        bezierCurves[frame++] = new BezierCurve(type, bezTriples, 2);
      }
      curves.clear();
      result = new Ipo(bezierCurves, fixUpAxis, blenderContext.getBlenderVersion());
      Long ipoOma = ipoStructure.getOldMemoryAddress();
      blenderContext.addLoadedFeatures(ipoOma, LoadedDataType.STRUCTURE, ipoStructure);
      blenderContext.addLoadedFeatures(ipoOma, LoadedDataType.FEATURE, result);
    }
    return result;
  }