Toxiclibs WingedEdge

Hi all,

I am slowly getting familiar with toxiclibs. I am using the WindgedEdge class.

I have this forloop at some point:

  for (WingedEdge e : custom.edges.values ()) {
    VerletParticle a = physics.particles.get(((WEVertex) e.a).id);
    VerletParticle b = physics.particles.get(((WEVertex) e.b).id);
    physics.addSpring(new VerletSpring(a, b, a.distanceTo(b), 0.005f));   
  }

What I want to do is to add an if condition to add a spring to certain edges (not all of them). So I need to get certain items. But I don't figure out how to do it, even by checking the API. http://toxiclibs.org/docs/core/toxi/geom/mesh/WingedEdge.html

Any help would be greatly appreciated.

Best

Answers

  • edited December 2014

    add an if condition to add a spring to certain edges (not all of them). So I need to get certain items.

    Is the If-clause the problem? What property do you want to check? What have you tried? What happened?

  • No, the if condition is not the problem, I just cannot figure out how to get specific indexes with this class

  • I append all the Verletspring in an empty arraylist and tried to get certain item from this list to add a new spring... But then I got the following error: "The method addSpring(VerletSpring) in the type VerletPhysics is not applicable for the arguments (Object)".

    Here is the updated code:

      ArrayList springness;
      springness = new ArrayList();
    
      for (WingedEdge e : custom.edges.values ()) {
        VerletParticle a = physics.particles.get(((WEVertex) e.a).id);
        VerletParticle b = physics.particles.get(((WEVertex) e.b).id);
        physics.addSpring(new VerletSpring(a, b, a.distanceTo(b), 0.005f));
    
        springness.add(new VerletSpring(a, b, a.distanceTo(b), 0.005f));
      }
    
      for (int i=0; i<springness.size (); i++) {
        if (i < 20) {
          physics.addSpring(springness.get(i));
        }
      }
    
  • edited December 2014

    If you specify what is going into the ArrayList, like this:

    springness = new ArrayList<VerletSpring>();

    the compiler shouldn't be confused about what should be coming out when you use get(...).

  • like

    ArrayList<VerletSpring> springness= new ArrayList<VerletSpring>();
    
  • thank you guys, it worked :)

Sign In or Register to comment.