/** * 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; }
/** * This method retuns the bone tracks for animation for blender version 2.49 (and probably several * lower versions too). * * @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 getTracks249(Structure actionStructure, BlenderContext blenderContext) throws BlenderFileException { LOGGER.log(Level.FINE, "Getting tracks!"); Structure chanbase = (Structure) actionStructure.getFieldValue("chanbase"); List<Structure> actionChannels = chanbase.evaluateListBase(); // bActionChannel BlenderAction blenderAction = new BlenderAction(actionStructure.getName(), blenderContext.getBlenderKey().getFps()); int lastFrame = 1; for (Structure bActionChannel : actionChannels) { String animatedFeatureName = bActionChannel.getFieldValue("name").toString(); Pointer p = (Pointer) bActionChannel.getFieldValue("ipo"); if (!p.isNull()) { Structure ipoStructure = p.fetchData().get(0); Ipo ipo = this.fromIpoStructure(ipoStructure, blenderContext); if (ipo != null) { // this can happen when ipo with no curves appear in blender file lastFrame = Math.max(lastFrame, ipo.getLastFrame()); blenderAction.featuresTracks.put(animatedFeatureName, ipo); } } } blenderAction.stopFrame = lastFrame; return blenderAction; }