You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fun playTransformer(angle: Float): Boolean {
if (asset == null) {
return true
}
val currentTransformMatrix = FloatArray(16)
val rotationMatrixY = FloatArray(16)
val rotationMatrixZ = FloatArray(16)
val tcm = engine.transformManager
val boundingBox = asset!!.boundingBox
val centerX = boundingBox.center[0]
val centerY = boundingBox.center[1]
val centerZ = -boundingBox.center[2]
val entity = tcm.getInstance(asset!!.root)
tcm.getTransform(entity, currentTransformMatrix)
Matrix.translateM(currentTransformMatrix, 0, -centerX, -centerY, -centerZ)
Matrix.setRotateM(rotationMatrixY, 0, angle, 0.0f, 1f, 0.0f)
Matrix.multiplyMM(
currentTransformMatrix, 0, currentTransformMatrix, 0, rotationMatrixY, 0
)
if (isFirst) {
Matrix.setRotateM(rotationMatrixZ, 0, 5f, 0.0f, 0.0f, 1f)
Matrix.multiplyMM(
currentTransformMatrix, 0, currentTransformMatrix, 0, rotationMatrixZ, 0
)
isFirst = false
}
Matrix.translateM(currentTransformMatrix, 0, centerX, centerY, centerZ)
tcm.setTransform(entity, currentTransformMatrix)
Log.i(TAG, "playTransformer currentAngle:${getModelXRotationAngle()}")
return false
}
At present, the model will not tilt if it is rotated only around the Y axis, but if it is rotated around the Y and Z axes at the same time, the model will tilt,The playTransformer method is called multiple times, is there any good solution
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
At present, the model will not tilt if it is rotated only around the Y axis, but if it is rotated around the Y and Z axes at the same time, the model will tilt,The playTransformer method is called multiple times, is there any good solution
Beta Was this translation helpful? Give feedback.
All reactions