www.jpct.net
jPCT-AE - a 3d engine for Android => Support => Topic started by: guillaume on November 25, 2011, 09:55:33 am
-
hi,
I am experimenting Animation with the following code:
private class MyVertexController extends GenericVertexController{
/**
*
*/
private static final long serialVersionUID = 1L;
private float mOff = 0.0f;
public MyVertexController(float off){
mOff = off;
}
@Override
public void apply() {
// TODO Auto-generated method stub
SimpleVector[] src = this.getSourceMesh();
SimpleVector[] dst = this.getDestinationMesh();
Logger.log("src length: "+src.length+" dst length: "+dst.length);
for(int i=0; i<src.length && i<dst.length; i++){
dst[i].x = src[i].x + mOff;
}
}
}
private void setupAnimate(Object3D obj){
obj.build();
Mesh mesh = obj.getMesh();
Object3D obj1 = obj.cloneObject();
Object3D obj2 = obj.cloneObject();
//world.addObject(obj1);
//world.addObject(obj2);
Mesh mesh1 = mesh.cloneMesh(true);
obj1.setMesh(mesh1);
//obj1.rotateX(1.4f);
//obj1.rotateMesh();
obj1.build();
if(mesh1.setVertexController(new MyVertexController(0.0f), true))
Logger.log("vertex controller set for mesh1");
mesh1.applyVertexController();
Mesh mesh2 = mesh.cloneMesh(true);
obj2.setMesh(mesh2);
obj2.build();
if(mesh2.setVertexController(new MyVertexController(10.0f), true))
Logger.log("vertex controller set for mesh2");
mesh2.applyVertexController();
Animation ani = new Animation(2);
ani.createSubSequence("main");
ani.addKeyFrame(mesh1);
ani.addKeyFrame(mesh2);
ani.setInterpolationMethod(Animation.LINEAR);
obj.setAnimationSequence(ani);
obj.setMesh(mesh1.cloneMesh(true));
obj.build();
}
the setupAnimate() would setup animation for my object. in the rendering loop, I call obj.animation(index) to do animation, but the object stay still always. do I doing something wrong in the setup code ? thanks.
-
Can you please post the complete log output?
-
thanks. here is the log
D/AndroidRuntime( 593): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime( 593): CheckJNI is ON
D/AndroidRuntime( 593): --- registering native functions ---
I/ActivityManager( 60): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCH
ER] flg=0x10000000 cmp=com.tpv.ui.tri_d/.TriDUIActivity }
D/AndroidRuntime( 593): Shutting down VM
D/dalvikvm( 593): Debugger has detached; object registry had 1 entries
I/AndroidRuntime( 593): NOTE: attach of thread 'Binder Thread #3' failed
I/ActivityManager( 60): Start proc com.tpv.ui.tri_d for activity com.tpv.ui.tri_d/.TriDUIActivity: pid=600 uid=10041 g
ids={}
D/libEGL ( 600): egl.cfg not found, using default config
D/libEGL ( 600): loaded /system/lib/egl/libGLES_android.so
D/dalvikvm( 600): GC_EXTERNAL_ALLOC freed 968 objects / 67160 bytes in 47ms
I/jPCT-AE ( 600): OpenGL vendor: Android
I/jPCT-AE ( 600): OpenGL renderer: Android PixelFlinger 1.3
I/jPCT-AE ( 600): OpenGL version: OpenGL ES-CM 1.0
I/jPCT-AE ( 600): OpenGL renderer initialized (using 2 texture stages)
I/jPCT-AE ( 600): Loading Texture...
I/jPCT-AE ( 600): Loading Texture...
D/dalvikvm( 600): GC_FOR_MALLOC freed 319 objects / 16592 bytes in 44ms
I/dalvikvm-heap( 600): Grow heap (frag case) to 4.730MB for 2097168-byte allocation
D/dalvikvm( 600): GC_FOR_MALLOC freed 43 objects / 1680 bytes in 90ms
I/jPCT-AE ( 600): Loading Texture...
I/jPCT-AE ( 600): Loading Texture...
I/jPCT-AE ( 600): Loading Texture...
D/dalvikvm( 600): GC_EXPLICIT freed 5 objects / 184 bytes in 46ms
D/dalvikvm( 600): GC_EXPLICIT freed 8 objects / 296 bytes in 49ms
I/jPCT-AE ( 600): Loading Texture...
I/jPCT-AE ( 600): Normal vectors calculated in 2ms!
I/jPCT-AE ( 600): Normal vectors calculated in 1ms!
I/jPCT-AE ( 600): vertex controller set for mesh1
I/jPCT-AE ( 600): src length: 4 dst length: 4
I/jPCT-AE ( 600): Normal vectors calculated in 1ms!
I/jPCT-AE ( 600): vertex controller set for mesh2
I/jPCT-AE ( 600): src length: 4 dst length: 4
I/jPCT-AE ( 600): Normal vectors calculated in 0ms!
I/jPCT-AE ( 600): total user object in world: 1
I/jPCT-AE ( 600): mCylinder: (5.0,5.0,1.0)
I/jPCT-AE ( 600): Adding Lightsource: 0
I/jPCT-AE ( 600): Memory usage before compacting: 5599 KB used out of 6023 KB
D/dalvikvm( 600): GC_EXPLICIT freed 661 objects / 31824 bytes in 47ms
D/dalvikvm( 600): GC_EXPLICIT freed 17 objects / 568 bytes in 59ms
I/jPCT-AE ( 600): Memory usage after compacting: 5568 KB used out of 6023 KB
I/jPCT-AE ( 600): Saving master Activity!
I/jPCT-AE ( 600): Subobject of object 0/actor compiled to flat fixed point data using 6 vertices in 1ms!
I/jPCT-AE ( 600): Object 0/actor compiled to 1 subobjects in 4ms!
I/jPCT-AE ( 600): VBO created for object 'actor'
I/ARMAssembler( 600): generated scanline__000000B7:03010144_00009501_00000000 [126 ipp] (207 ins) at [0x2545f8:0x254934
] in 2021858 ns
I/ActivityManager( 60): Displayed activity com.tpv.ui.tri_d/.TriDUIActivity: 2434 ms (total 2434 ms)
W/KeyCharacterMap( 600): No keyboard for id 0
W/KeyCharacterMap( 600): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
D/dalvikvm( 253): GC_EXPLICIT freed 216 objects / 14192 bytes in 1027ms
D/dalvikvm( 264): GC_EXPLICIT freed 88 objects / 4200 bytes in 138ms
D/dalvikvm( 119): GC_EXPLICIT freed 966 objects / 52912 bytes in 188ms
D/SntpClient( 60): request time failed: java.net.SocketException: Address family not supported by protocol
-
It's because you are calling obj.build() in the first line of your method. With this call, you make jPCT-Ae determine the compilation mode and because no animation has been assigned at this stage, it compiles it to static. Try to remove this line.
-
thanks. it works now. :D