www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: yindroid on August 21, 2012, 12:14:22 PM

Title: How to get vertex from animated mesh?
Post by: yindroid 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)...


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:

public void onDrawFrame(GL10 gl) {

    // player animation code

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


Maybe there is some other way to handle it?
Title: Re: How to get vertex from animated mesh?
Post by: EgonOlsen 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?