physics initialization code for seeking is fixed.
@@ -4,9 +4,10 @@ | ||
4 | 4 | #include <btBulletDynamicsCommon.h> |
5 | 5 | #include <btBulletCollisionCommon.h> |
6 | 6 | |
7 | -btDiscreteDynamicsWorld *mDynamicsWorld; | |
8 | -btRigidBody *rb[4096]; | |
9 | -btDefaultMotionState *ms[4096]; | |
7 | +btDiscreteDynamicsWorld *g_DynamicsWorld; | |
8 | +btRigidBody *g_rb[4096]; | |
9 | +btDefaultMotionState *g_ms[4096]; | |
10 | +btTransform *g_pos[4096]; | |
10 | 11 | int g_ptr; |
11 | 12 | |
12 | 13 | btGeneric6DofSpringConstraint *g_cst[4096]; |
@@ -50,10 +51,10 @@ | ||
50 | 51 | btCollisionDispatcher *dispatcher = new btCollisionDispatcher(collisionConfiguration); |
51 | 52 | btDbvtBroadphase *broadphase = new btDbvtBroadphase(); |
52 | 53 | btSequentialImpulseConstraintSolver *solver = new btSequentialImpulseConstraintSolver(); |
53 | - mDynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration); | |
54 | + g_DynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration); | |
54 | 55 | |
55 | - btVector3 *g = new btVector3(0, -9.8, 0); | |
56 | - mDynamicsWorld->setGravity(*g); | |
56 | + btVector3 *g = new btVector3(0, -9.8 * 2.5, 0); | |
57 | + g_DynamicsWorld->setGravity(*g); | |
57 | 58 | |
58 | 59 | g_ptr = 0; |
59 | 60 | g_cptr = 0; |
@@ -95,7 +96,7 @@ | ||
95 | 96 | extern "C" jint Java_jp_gauzau_MikuMikuDroid_Miku_btAddRigidBody(JNIEnv* env, jobject thiz, |
96 | 97 | jint type, jint shape, |
97 | 98 | jfloat w, jfloat h, jfloat d, |
98 | - jfloatArray pos, jfloatArray rot, | |
99 | + jfloatArray pos, jfloatArray rot, jfloatArray head_pos, jfloatArray bone, | |
99 | 100 | jfloat mass, jfloat v_dim, jfloat r_dim, jfloat recoil, jfloat friction, |
100 | 101 | jbyte group_index, jshort group_target) |
101 | 102 | { |
@@ -118,6 +119,15 @@ | ||
118 | 119 | |
119 | 120 | // position and rotation |
120 | 121 | btTransform transf = createBtTransform(env, pos, rot); |
122 | + btMatrix3x3 norot; | |
123 | + norot.setIdentity(); | |
124 | + g_pos[g_ptr] = new btTransform(btTransform(norot, createBtVector3(env, head_pos)) * transf); | |
125 | + | |
126 | + float* bone_native = env->GetFloatArrayElements(bone, 0); | |
127 | + btTransform tr; | |
128 | + tr.setFromOpenGLMatrix(bone_native); | |
129 | + env->ReleaseFloatArrayElements(bone, bone_native, 0); | |
130 | + transf = tr * transf; | |
121 | 131 | |
122 | 132 | // inertia |
123 | 133 | btVector3 inertia(0, 0, 0); |
@@ -124,21 +134,21 @@ | ||
124 | 134 | cs->calculateLocalInertia(type == 0 ? 0 : mass, inertia); |
125 | 135 | |
126 | 136 | // create rigid body with default motion state |
127 | - ms[g_ptr] = new btDefaultMotionState(transf); | |
137 | + g_ms[g_ptr] = new btDefaultMotionState(transf); | |
128 | 138 | |
129 | - btRigidBody :: btRigidBodyConstructionInfo* rbi = new btRigidBody :: btRigidBodyConstructionInfo(type == 0 ? 0 : mass, ms[g_ptr], cs, inertia); | |
139 | + btRigidBody :: btRigidBodyConstructionInfo* rbi = new btRigidBody :: btRigidBodyConstructionInfo(type == 0 ? 0 : mass, g_ms[g_ptr], cs, inertia); | |
130 | 140 | rbi->m_linearDamping = v_dim; |
131 | 141 | rbi->m_angularDamping = r_dim; |
132 | 142 | rbi->m_restitution = recoil; |
133 | 143 | rbi->m_friction = friction; |
134 | - rb[g_ptr] = new btRigidBody(*rbi); | |
144 | + g_rb[g_ptr] = new btRigidBody(*rbi); | |
135 | 145 | |
136 | 146 | if(type == 0) { |
137 | - rb[g_ptr]->setActivationState(DISABLE_DEACTIVATION); | |
138 | - rb[g_ptr]->setCollisionFlags(rb[g_ptr]->getCollisionFlags() | btCollisionObject :: CF_KINEMATIC_OBJECT); | |
147 | + g_rb[g_ptr]->setActivationState(DISABLE_DEACTIVATION); | |
148 | + g_rb[g_ptr]->setCollisionFlags(g_rb[g_ptr]->getCollisionFlags() | btCollisionObject :: CF_KINEMATIC_OBJECT); | |
139 | 149 | } |
140 | 150 | |
141 | - mDynamicsWorld->addRigidBody(rb[g_ptr], (1 << group_index), group_target); | |
151 | + g_DynamicsWorld->addRigidBody(g_rb[g_ptr], (1 << group_index), group_target); | |
142 | 152 | |
143 | 153 | return g_ptr++; |
144 | 154 | } |
@@ -148,9 +158,11 @@ | ||
148 | 158 | { |
149 | 159 | btTransform jt = createBtTransform(env, pos, rot); |
150 | 160 | |
151 | - btTransform tr1 = rb[rb1]->getCenterOfMassTransform().inverse() * jt; | |
152 | - btTransform tr2 = rb[rb2]->getCenterOfMassTransform().inverse() * jt; | |
153 | - btGeneric6DofSpringConstraint* dof = new btGeneric6DofSpringConstraint(*rb[rb1], *rb[rb2], tr1, tr2, true); | |
161 | +// btTransform tr1 = g_rb[rb1]->getCenterOfMassTransform().inverse() * jt; | |
162 | +// btTransform tr2 = g_rb[rb2]->getCenterOfMassTransform().inverse() * jt; | |
163 | + btTransform tr1 = g_pos[rb1]->inverse() * jt; | |
164 | + btTransform tr2 = g_pos[rb2]->inverse() * jt; | |
165 | + btGeneric6DofSpringConstraint* dof = new btGeneric6DofSpringConstraint(*g_rb[rb1], *g_rb[rb2], tr1, tr2, true); | |
154 | 166 | |
155 | 167 | dof->setLinearLowerLimit(createBtVector3(env, p1)); |
156 | 168 | dof->setLinearUpperLimit(createBtVector3(env, p2)); |
@@ -169,7 +181,7 @@ | ||
169 | 181 | env->ReleaseFloatArrayElements(sp, sp_n, 0); |
170 | 182 | env->ReleaseFloatArrayElements(sr, sr_n, 0); |
171 | 183 | |
172 | - mDynamicsWorld->addConstraint(dof, true); // disableCollisionsBetweenLinkedBodies | |
184 | + g_DynamicsWorld->addConstraint(dof, true); // disableCollisionsBetweenLinkedBodies | |
173 | 185 | g_cst[g_cptr] = dof; |
174 | 186 | |
175 | 187 | return g_cptr++; |
@@ -178,17 +190,19 @@ | ||
178 | 190 | extern "C" void Java_jp_gauzau_MikuMikuDroid_CoreLogic_btClearAllData(JNIEnv* env, jobject thiz) |
179 | 191 | { |
180 | 192 | for(int i = 0; i < g_cptr; i++) { |
181 | - mDynamicsWorld->removeConstraint(g_cst[i]); | |
193 | + g_DynamicsWorld->removeConstraint(g_cst[i]); | |
182 | 194 | delete g_cst[i]; |
183 | 195 | g_cst[i] = 0; |
184 | 196 | } |
185 | 197 | |
186 | 198 | for(int i = 0; i < g_ptr; i++) { |
187 | - mDynamicsWorld->removeRigidBody(rb[i]); | |
188 | - delete rb[i]; | |
189 | - delete ms[i]; | |
190 | - rb[i] = 0; | |
191 | - ms[i] = 0; | |
199 | + g_DynamicsWorld->removeRigidBody(g_rb[i]); | |
200 | + delete g_rb[i]; | |
201 | + delete g_ms[i]; | |
202 | + delete g_pos[i]; | |
203 | + g_rb[i] = 0; | |
204 | + g_ms[i] = 0; | |
205 | + g_pos[i] = 0; | |
192 | 206 | } |
193 | 207 | |
194 | 208 | g_ptr = 0; |
@@ -195,10 +209,9 @@ | ||
195 | 209 | g_cptr = 0; |
196 | 210 | } |
197 | 211 | |
198 | -extern "C" void Java_jp_gauzau_MikuMikuDroid_CoreLogic_btStepSimulation(JNIEnv* env, jobject thiz, jfloat step) | |
212 | +extern "C" void Java_jp_gauzau_MikuMikuDroid_CoreLogic_btStepSimulation(JNIEnv* env, jobject thiz, jfloat step, jint max) | |
199 | 213 | { |
200 | - mDynamicsWorld->stepSimulation(step, 4); | |
201 | -// mDynamicsWorld->stepSimulation(step, 0); | |
214 | + g_DynamicsWorld->stepSimulation(step, max); | |
202 | 215 | } |
203 | 216 | |
204 | 217 | extern "C" void Java_jp_gauzau_MikuMikuDroid_Miku_btGetOpenGLMatrix(JNIEnv* env, jobject thiz, jint rb, jfloatArray matrix, jfloatArray pos, jfloatArray rot) |
@@ -208,7 +221,7 @@ | ||
208 | 221 | |
209 | 222 | // rigid body in dynamics world |
210 | 223 | btTransform tr; |
211 | - ms[rb]->getWorldTransform(tr); | |
224 | + g_ms[rb]->getWorldTransform(tr); | |
212 | 225 | |
213 | 226 | tr = tr * rbt.inverse(); |
214 | 227 |
@@ -231,26 +244,7 @@ | ||
231 | 244 | |
232 | 245 | tr = tr * rbt; |
233 | 246 | |
234 | - ms[rb]->setWorldTransform(tr); | |
247 | + g_ms[rb]->setWorldTransform(tr); | |
235 | 248 | } |
236 | 249 | } |
237 | 250 | |
238 | -extern "C" void Java_jp_gauzau_MikuMikuDroid_Miku_btForceOpenGLMatrix(JNIEnv* env, jobject thiz, jint rbi, jfloatArray matrix, jfloatArray pos, jfloatArray rot) | |
239 | -{ | |
240 | - // rigid body initial position & rotation | |
241 | - btTransform rbt = createBtTransform(env, pos, rot); | |
242 | - | |
243 | - // rigid body in VMD world | |
244 | - float* matrix_native = env->GetFloatArrayElements(matrix, 0); | |
245 | - btTransform tr; | |
246 | - tr.setFromOpenGLMatrix(matrix_native); | |
247 | - env->ReleaseFloatArrayElements(matrix, matrix_native, 0); | |
248 | - | |
249 | - tr = tr * rbt; | |
250 | - | |
251 | - btVector3 zero(0, 0, 0); | |
252 | - ms[rbi]->setWorldTransform(tr); | |
253 | - rb[rbi]->setLinearVelocity(zero); | |
254 | - rb[rbi]->setAngularVelocity(zero); | |
255 | - rb[rbi]->setCenterOfMassTransform(tr); | |
256 | -} |
@@ -52,6 +52,7 @@ | ||
52 | 52 | mCoreLogic = new CoreLogic(this) { |
53 | 53 | @Override |
54 | 54 | public void onInitialize() { |
55 | + /* | |
55 | 56 | try { |
56 | 57 | mCoreLogic.restoreState(); |
57 | 58 | final int max = mCoreLogic.getDulation(); |
@@ -69,7 +70,7 @@ | ||
69 | 70 | } |
70 | 71 | }); |
71 | 72 | } |
72 | - /* | |
73 | + */ | |
73 | 74 | MikuMikuDroid.this.runOnUiThread(new Runnable() { |
74 | 75 | @Override |
75 | 76 | public void run() { |
@@ -105,7 +106,6 @@ | ||
105 | 106 | ae.execute(mCoreLogic); |
106 | 107 | } |
107 | 108 | }); |
108 | - */ | |
109 | 109 | } |
110 | 110 | |
111 | 111 | @Override |
@@ -48,11 +48,20 @@ | ||
48 | 48 | private FacePair mFacePair = new FacePair(); |
49 | 49 | private FaceIndex mFaceIndex = new FaceIndex(); |
50 | 50 | |
51 | + private Bone mZeroBone; | |
52 | + | |
51 | 53 | public Miku(MikuModel model) { |
52 | 54 | mModel = model; |
53 | 55 | mMwork.location = new float[3]; |
54 | 56 | mMwork.rotation = new float[4]; |
55 | 57 | mIsArm = CoreLogic.isArm(); |
58 | + | |
59 | + // for physics simulation | |
60 | + mZeroBone = new Bone(); | |
61 | + mZeroBone.matrix = new float[16]; | |
62 | + mZeroBone.head_pos = new float[3]; | |
63 | + Matrix.setIdentityM(mZeroBone.matrix, 0); | |
64 | + mZeroBone.head_pos[0] = 0; mZeroBone.head_pos[1] = 0; mZeroBone.head_pos[2] = 0; | |
56 | 65 | } |
57 | 66 | |
58 | 67 | public void attachMotion(MikuMotion mm) { |
@@ -92,7 +101,7 @@ | ||
92 | 101 | if(initPhysics) { |
93 | 102 | initializePhysics(); |
94 | 103 | } |
95 | - solvePhysicsPre(step, initPhysics); | |
104 | + solvePhysicsPre(); | |
96 | 105 | } |
97 | 106 | } |
98 | 107 | } |
@@ -178,12 +187,7 @@ | ||
178 | 187 | |
179 | 188 | native private void setFaceNative(FloatBuffer vertex, IntBuffer pointer, int count, IntBuffer index, FloatBuffer offset, float weight); |
180 | 189 | |
181 | - native private int btAddRigidBody( | |
182 | - int type, int shape, | |
183 | - float w, float h, float d, | |
184 | - float[] pos, float[] rot, | |
185 | - float mass, float v_dim, float r_dim, float recoil, float friction, | |
186 | - byte group_index, short group_target); | |
190 | + native private int btAddRigidBody(int type, int shape, float w, float h, float d, float[] pos, float[] rot, float[] head_pos, float[] bone, float mass, float v_dim, float r_dim, float recoil, float friction, byte group_index, short group_target); | |
187 | 191 | |
188 | 192 | native private int btAddJoint(int rb1, int rb2, float[] pos, float[] rot, float[] p1, float[] p2, float[] r1, float[] r2, float[] sp, float[] sr); |
189 | 193 |
@@ -191,8 +195,6 @@ | ||
191 | 195 | |
192 | 196 | native private float btSetOpenGLMatrix(int rb, float[] matrix, float[] pos, float[] rot); |
193 | 197 | |
194 | - native private float btForceOpenGLMatrix(int rb, float[] matrix, float[] pos, float[] rot); | |
195 | - | |
196 | 198 | private void initializePhysics() { |
197 | 199 | /////////////////////////////////////////// |
198 | 200 | // MAKE RIGID BODIES |
@@ -200,18 +202,10 @@ | ||
200 | 202 | if(rba != null) { |
201 | 203 | for(int i = 0; i < rba.size(); i++) { |
202 | 204 | RigidBody rb = rba.get(i); |
203 | - if(rb.bone_index == -1) { | |
204 | - tmpVecs[0] = rb.location[0]; | |
205 | - tmpVecs[1] = rb.location[1]; | |
206 | - tmpVecs[2] = rb.location[2]; | |
207 | - } else { | |
208 | - Bone b = mModel.mBone.get(rb.bone_index); | |
209 | - Vector.add(tmpVecs, rb.location, b.head_pos); | |
210 | - } | |
211 | - | |
205 | + Bone b = rb.bone_index == -1 ? mZeroBone : mModel.mBone.get(rb.bone_index); | |
212 | 206 | rb.btrb = btAddRigidBody(rb.type, rb.shape, |
213 | 207 | rb.size[0], rb.size[1], rb.size[2], |
214 | - tmpVecs, rb.rotation, | |
208 | + rb.location, rb.rotation, b.head_pos, b.matrix, | |
215 | 209 | rb.weight, rb.v_dim, rb.r_dim, rb.recoil, rb.friction, |
216 | 210 | rb.group_index, rb.group_target); |
217 | 211 | } |
@@ -233,17 +227,13 @@ | ||
233 | 227 | } |
234 | 228 | } |
235 | 229 | |
236 | - private void solvePhysicsPre(float step, boolean initializePhysics) { | |
230 | + private void solvePhysicsPre() { | |
237 | 231 | if(mModel.mRigidBody != null) { |
238 | 232 | for(int i = 0; i < mModel.mRigidBody.size(); i++) { |
239 | 233 | RigidBody rb = mModel.mRigidBody.get(i); |
240 | - if(rb.bone_index >= 0) { | |
234 | + if(rb.bone_index >= 0 && rb.type == 0) { | |
241 | 235 | Bone b = mModel.mBone.get(rb.bone_index); |
242 | - if(rb.type == 0) { | |
243 | - btSetOpenGLMatrix(rb.btrb, b.matrix, rb.location, rb.rotation); | |
244 | - } else if(initializePhysics) { | |
245 | - btForceOpenGLMatrix(rb.btrb, b.matrix, rb.location, rb.rotation); | |
246 | - } | |
236 | + btSetOpenGLMatrix(rb.btrb, b.matrix, rb.location, rb.rotation); | |
247 | 237 | } |
248 | 238 | } |
249 | 239 | } |
@@ -263,6 +253,7 @@ | ||
263 | 253 | b.matrix[j] = b.matrix_current[j]; |
264 | 254 | } |
265 | 255 | } |
256 | + b.updated = true; | |
266 | 257 | } |
267 | 258 | } |
268 | 259 | } |
@@ -30,6 +30,7 @@ | ||
30 | 30 | private MediaPlayer mMedia; |
31 | 31 | private FakeMedia mFakeMedia; |
32 | 32 | private String mMediaName; |
33 | + private long mCurTime; | |
33 | 34 | private long mPrevTime; |
34 | 35 | private long mStartTime; |
35 | 36 | private double mFPS; |
@@ -46,8 +47,6 @@ | ||
46 | 47 | private int mHeight; |
47 | 48 | private int mAngle; |
48 | 49 | |
49 | - private boolean mIsSought = true; | |
50 | - | |
51 | 50 | // temporary data |
52 | 51 | private CameraIndex mCameraIndex = new CameraIndex(); |
53 | 52 | private CameraPair mCameraPair = new CameraPair(); |
@@ -216,9 +215,9 @@ | ||
216 | 215 | if(mMiku != null) { |
217 | 216 | Miku miku = mMiku.get(mMiku.size() - 1); |
218 | 217 | miku.attachMotion(motion); |
219 | -// miku.setBonePosByVMDFramePre(0, 0, true); | |
220 | -// miku.setBonePosByVMDFramePost(); | |
221 | -// miku.setFaceByVMDFrame(0); | |
218 | + miku.setBonePosByVMDFramePre(0, 0, true); | |
219 | + miku.setBonePosByVMDFramePost(); | |
220 | + miku.setFaceByVMDFrame(0); | |
222 | 221 | |
223 | 222 | // store IK chache |
224 | 223 | File f = new File(vmc); |
@@ -270,9 +269,9 @@ | ||
270 | 269 | // Create Miku |
271 | 270 | Miku miku = new Miku(model); |
272 | 271 | miku.attachMotion(motion); |
273 | -// miku.setBonePosByVMDFramePre(0, 0, true); | |
274 | -// miku.setBonePosByVMDFramePost(); | |
275 | -// miku.setFaceByVMDFrame(0); | |
272 | + miku.setBonePosByVMDFramePre(0, 0, true); | |
273 | + miku.setBonePosByVMDFramePost(); | |
274 | + miku.setFaceByVMDFrame(0); | |
276 | 275 | miku.addRenderSenario("builtin:default", "screen"); |
277 | 276 | miku.addRenderSenario("builtin:default_alpha", "screen"); |
278 | 277 |
@@ -365,7 +364,6 @@ | ||
365 | 364 | mMedia.setWakeMode(mCtx, PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE); |
366 | 365 | mMedia.setLooping(true); |
367 | 366 | } |
368 | - mIsSought = true; | |
369 | 367 | } |
370 | 368 | |
371 | 369 | public synchronized void loadCamera(String camera) throws IOException { |
@@ -419,20 +417,19 @@ | ||
419 | 417 | } |
420 | 418 | } |
421 | 419 | |
422 | - native private void btStepSimulation(float step); | |
420 | + native private void btStepSimulation(float step, int max); | |
423 | 421 | |
424 | 422 | public synchronized int applyCurrentMotion() { |
425 | 423 | boolean initializePhysics = false; |
426 | - if(mIsSought) { // NO ATOMIC!!! must be fixed | |
424 | + | |
425 | + calcCurrentTime(); | |
426 | + double frame = getCurrentFrames(32767); | |
427 | + float step = (float) (getDeltaTimeMills() / 1000.0); | |
428 | + if(step >= 0.2 || step < 0) { | |
429 | + step = 0; | |
427 | 430 | initializePhysics = true; |
428 | - mIsSought = false; | |
429 | - btClearAllData(); | |
431 | + btClearAllData(); | |
430 | 432 | } |
431 | - double frame; | |
432 | - double prev; | |
433 | - prev = mPrevTime; | |
434 | - frame = nowFrames(32767); | |
435 | - float step = (float) (mPrevTime - prev) / 1000; | |
436 | 433 | |
437 | 434 | if (mMiku != null) { |
438 | 435 | for (Miku miku : mMiku) { |
@@ -445,7 +442,7 @@ | ||
445 | 442 | |
446 | 443 | // exec physics simulation |
447 | 444 | if(isArm() && (step != 0 || !initializePhysics)) { |
448 | - btStepSimulation(step); | |
445 | + btStepSimulation(step, 5); | |
449 | 446 | } |
450 | 447 | |
451 | 448 | if (mMiku != null) { |
@@ -454,7 +451,7 @@ | ||
454 | 451 | miku.setBonePosByVMDFramePost(); |
455 | 452 | } |
456 | 453 | } |
457 | - } | |
454 | + } | |
458 | 455 | |
459 | 456 | setCameraByVMDFrame(frame); |
460 | 457 |
@@ -502,7 +499,6 @@ | ||
502 | 499 | } else { |
503 | 500 | mFakeMedia.seekTo(pos); |
504 | 501 | } |
505 | - mIsSought = true; | |
506 | 502 | } |
507 | 503 | |
508 | 504 | public int getDulation() { |
@@ -798,32 +794,40 @@ | ||
798 | 794 | } |
799 | 795 | } |
800 | 796 | |
801 | - protected double nowFrames(int max_frame) { | |
802 | - double frame; | |
803 | - long timeMedia; | |
797 | + private void calcCurrentTime() { | |
798 | + // update previous time | |
799 | + mPrevTime = mCurTime; | |
800 | + | |
801 | + // calculate current time | |
804 | 802 | if (mMedia != null) { |
805 | - timeMedia = mMedia.getCurrentPosition(); | |
803 | + mCurTime = mMedia.getCurrentPosition(); | |
806 | 804 | if(mMedia.isPlaying()) { |
807 | 805 | long timeLocal = System.currentTimeMillis(); |
808 | - if (Math.abs(timeLocal - mStartTime - timeMedia) > 500 || mMedia.isPlaying() == false) { | |
809 | - mStartTime = timeLocal - timeMedia; | |
806 | + if (Math.abs(timeLocal - mStartTime - mCurTime) > 500 || mMedia.isPlaying() == false) { | |
807 | + mStartTime = timeLocal - mCurTime; | |
810 | 808 | } else { |
811 | - timeMedia = timeLocal - mStartTime; | |
809 | + mCurTime = timeLocal - mStartTime; | |
812 | 810 | } |
813 | 811 | } |
814 | 812 | } else { |
815 | - timeMedia = mFakeMedia.getCurrentPosition(); | |
813 | + mCurTime = mFakeMedia.getCurrentPosition(); | |
816 | 814 | } |
817 | - | |
818 | - frame = ((float) timeMedia * 30.0 / 1000.0); | |
815 | + } | |
816 | + | |
817 | + protected double getCurrentFrames(int max_frame) { | |
818 | + double frame; | |
819 | + frame = ((float) mCurTime * 30.0 / 1000.0); | |
819 | 820 | if (frame > max_frame) { |
820 | 821 | frame = max_frame; |
821 | 822 | } |
822 | - mFPS = 1000.0 / (timeMedia - mPrevTime); | |
823 | - mPrevTime = timeMedia; | |
823 | + mFPS = 1000.0 / (mCurTime - mPrevTime); | |
824 | 824 | |
825 | 825 | return frame; |
826 | 826 | } |
827 | + | |
828 | + private long getDeltaTimeMills() { | |
829 | + return mCurTime - mPrevTime; | |
830 | + } | |
827 | 831 | |
828 | 832 | protected void setCameraByVMDFrame(double frame) { |
829 | 833 | if (mCamera != null) { |