Author Topic: How to get vertex from animated mesh?  (Read 778 times)

Offline yindroid

  • byte
  • *
  • Posts: 21
    • View Profile
How to get vertex from animated mesh?
« on: August 21, 2012, 12:14:22 pm »
Hi!
I would like to try add(attach) some primitives (like spheres as eyes) to animated mesh. So I decide to get one verticle from mesh and use its coords and normal to attach some primitives.
there is my code, but there is one problem: the animation stoped to work(like set on pause or smth like that)...

Code: [Select]
public class Player extends Object3D{

    public Player(Context AppContext, World world, Resources res) {   
        // loading and setting stuff...
   
        vc = new VertexController(20);
        this.getMesh().setVertexController(vc, true);
        this.getMesh().applyVertexController();

        world.addObject(this);
    }

    /* VERTEX CONTROLLER */
    private static class VertexController extends GenericVertexController {
        private int vertexID;
       
        VertexController(int pVertexID) {                 
          this.vertexID = pVertexID;
        }

@Override
public void apply() {
    SimpleVector[] srcMesh = this.getSourceMesh();       
            int size = this.getMeshSize();
            if(vertexID < size){
        mVertexX = srcMesh[vertexID].x;
        mVertexY = srcMesh[vertexID].y;
        mVertexZ = srcMesh[vertexID].z;
            }
        }
}

In main update cycle:
Code: [Select]
public void onDrawFrame(GL10 gl) {

    // player animation code

    player.getMesh().applyVertexController();
    player.touch();
}

Maybe there is some other way to handle it?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: How to get vertex from animated mesh?
« Reply #1 on: August 21, 2012, 10:14:14 pm »
You can't mix an IVertexController with an animation...as you've already noticed. Maybe the getTransformedVertex()-method in the PolygonManager helps?