Animation shows the bending process of the pipe

Hi all

I want to show the bending process of the pipe like a animation.But I don't know how to make the process more smooth,just like a continuous process. But I don't know how to implement this process

Greatly appreciate any help

Kirill Gavrilov's picture

What have you tried so far (how your animation works right now) and what is the problem with the current approach?

lu yu's picture

Thanks Kirill,
But my animation don't work right now,because l don't know the method.
Such as I want to bend a 90 degree pipe, I can just subdivide 90 degrees, like 10 degrees, 20 degrees, 30 degrees..... 90 degrees, and each degree builds a model separately. Use BRepOffsetAPI_MakePipe class.
What I think was show each of these models at a very high speed, so that the end result was like an animation. And When I show a model, I clear the viewer and show the next model.But the result is very bad.
So I don't know if my idea is right, and if is right, how can I present every model at a very fast speed, so that it can like a smooth and continuous animation, or is there some other solution?

Kirill Gavrilov's picture

BRepOffsetAPI_MakePipe is designed to perform direct modeling, not animation, so that you cannot trivially compare shapes computed with different algorithm parameters.
In general, a smooth transition between two shapes can be implemented as:

  • Object transformation defined by two locations (gp_Trsf) - initial and final.
    This could be defined for entire object or to it's parts (like several joint/links of a robotic arm).
    • Animation could be defined as a linear interpolation (gp_TrsfNLerp) between two gp_Trsf.
      This is what AIS_AnimationObject allows to do out of the box.
    • This is very simple and fast approach,
      but it cannot be trivially applied to algorithms like BRepOffsetAPI_MakePipe.
      In such cases, object animation can be defined on simpler shapes as a "preview".
  • Blended transition between two arbitrary shapes.
    Two shapes are displayed simultaneously in the viewer with different transparency levels.
    • Animation could be defined as a linear interpolation (NCollection_Lerp<double>) of transparency levels.
      This logic could be easily defined within AIS_Animation subclass.
    • Blended transition might show unsatisfactory results.
      In addition, complex transformation of a shape would require a lot of transient precomputed shape states consuming memory.
  • Direct modeling between two sets of algorithm inputs.
    • Animation could be defined as a linear interpolation (NCollection_Lerp<double>) of algorithm input parameters.
      AIS_Animation subclass will execute BRepOffsetAPI_MakePipe algorithm for each drawn frame with interpolated parameters
      and create TopoDS_Shape as well as triangulation for it's presentation anew.
    • This could be rather slow depending on the algorithm.
  • Mesh morphing defined by two states of the same mesh.
    Each mesh state defines the same number of nodes and the same indexation, with different nodal positions in initial and final states.
    • Animation could be defined as a linear interpolation (NCollection_Lerp<gp_XYZ>) between two nodes applied to each mesh node individually.
    • Reuploading of entire mesh data on each animation frame or caching multiple states at once could be expensive.
  • Skeletal animation defined by two states of skeleton weights.
    This approach is used often for animating characters in games
    • Animation could be defined as a linear interpolation between two sets of skeletal weights.
    • This requires a special structure defining a skeleton for a mesh and weight factors applied to skeleton nodes to perform morphing (so that it is similar to Mesh morphing, but defined in a more compact and flexible way).
      There is no straightforward way implementing this approach from results of algorithms like BRepOffsetAPI_MakePipe.

Any of these approaches could be extrapolated from just two states to a series of states (animation keyframes) to define a complex animation.
Each animation frame is defined by PTS (presentation timestamp), which is used as a factor for linear interpolation between two states (animation keyframes).