mirror of https://github.com/axmolengine/axmol.git
animation bug
This commit is contained in:
parent
a991940268
commit
6d09b50699
|
@ -116,6 +116,7 @@ void Animate3D::update(float t)
|
||||||
if (curve->rotCurve)
|
if (curve->rotCurve)
|
||||||
{
|
{
|
||||||
curve->rotCurve->evaluate(t, dst, QuatSlerp);
|
curve->rotCurve->evaluate(t, dst, QuatSlerp);
|
||||||
|
CCLOG("%f,%f,%f,%f", dst[0], dst[1], dst[2], dst[3]);
|
||||||
bone->setAnimationValueRotation(dst);
|
bone->setAnimationValueRotation(dst);
|
||||||
}
|
}
|
||||||
if (curve->scaleCurve)
|
if (curve->scaleCurve)
|
||||||
|
|
|
@ -21,7 +21,7 @@ void AnimationCurve<componentSize>::evaluate(float time, float* dst, EvaluateTyp
|
||||||
float scale = (_keytime[index + 1] - _keytime[index]);
|
float scale = (_keytime[index + 1] - _keytime[index]);
|
||||||
float t = (time - _keytime[index]) / scale;
|
float t = (time - _keytime[index]) / scale;
|
||||||
|
|
||||||
float* fromValue = &_value[index * _componentSizeByte];
|
float* fromValue = &_value[index * componentSize];
|
||||||
float* toValue = fromValue + componentSize;
|
float* toValue = fromValue + componentSize;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
|
@ -85,17 +85,19 @@ bool Bundle3D::loadMeshData(const std::string& id, MeshData* meshdata)
|
||||||
meshdata->resetData();
|
meshdata->resetData();
|
||||||
meshdata->vertexSizeInFloat = 13 * 4;
|
meshdata->vertexSizeInFloat = 13 * 4;
|
||||||
meshdata->vertex = new float[meshdata->vertexSizeInFloat];
|
meshdata->vertex = new float[meshdata->vertexSizeInFloat];
|
||||||
float vert[] = {0.f,50.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,1.f,0.f,0.f,0.f,
|
float vert[] = {0.f,50.f,0.f, 0.f,0.f, 0.f,0.f,0.f,0.f, 1.f,0.f,0.f,0.f,
|
||||||
0.f,0.f,50.f,1.f,1.f,0.f,0.f,0.f,0.f,1.f,0.f,0.f,0.f,
|
0.f,0.f,50.f, 1.f,1.f, 0.f,0.f,0.f,0.f, 1.f,0.f,0.f,0.f,
|
||||||
50.f,0.f,0.f,1.f,1.f,0.f,0.f,0.f,0.f,1.f,0.f,0.f,0.f,
|
50.f,0.f,0.f, 1.f,1.f, 0.f,0.f,0.f,0.f, 1.f,0.f,0.f,0.f,
|
||||||
-50.f,0.f,0.f,1.f,1.f,0.f,0.f,0.f,0.f,1.f,0.f,0.f,0.f};
|
-50.f,0.f,0.f, 1.f,1.f, 0.f,0.f,0.f,0.f, 1.f,0.f,0.f,0.f};
|
||||||
//float vert[] = {0.f,50.f,0.f, 0.f,0.f,50.f, 50.f,0.f,0.f, -50.f,0.f,0.f};
|
//float vert[] = {0.f,50.f,0.f, 0.f,0.f,50.f, 50.f,0.f,0.f, -50.f,0.f,0.f};
|
||||||
memcpy(meshdata->vertex, vert, meshdata->vertexSizeInFloat * sizeof(float));
|
memcpy(meshdata->vertex, vert, meshdata->vertexSizeInFloat * sizeof(float));
|
||||||
|
|
||||||
meshdata->numIndex = 4 * 3;
|
//meshdata->numIndex = 4 * 3;
|
||||||
//meshdata->numIndex = 3;
|
meshdata->numIndex = 3;
|
||||||
meshdata->indices = new unsigned short[meshdata->numIndex];
|
meshdata->indices = new unsigned short[meshdata->numIndex];
|
||||||
unsigned short index[] = {0,1,2, 0,3,1, 0,2,3, 3,2,1};
|
//unsigned short index[] = {0,1,2, 0,3,1, 0,2,3, 3,2,1};
|
||||||
|
unsigned short index[] = {0,3,2};
|
||||||
|
//unsigned short index[] = {0,1,2};
|
||||||
memcpy(meshdata->indices, index, meshdata->numIndex * sizeof(unsigned short));
|
memcpy(meshdata->indices, index, meshdata->numIndex * sizeof(unsigned short));
|
||||||
|
|
||||||
meshdata->attribCount = 4;
|
meshdata->attribCount = 4;
|
||||||
|
@ -167,16 +169,16 @@ bool Bundle3D::loadAnimationData(const std::string& id, Animation3DData* animati
|
||||||
//curve->translateCurve = Animation3D::Curve::AnimationCurveVec3::create(keytime, pos, 2);
|
//curve->translateCurve = Animation3D::Curve::AnimationCurveVec3::create(keytime, pos, 2);
|
||||||
//curve->translateCurve->retain();
|
//curve->translateCurve->retain();
|
||||||
|
|
||||||
float keytime1[] = {0.f, 0.25f, 0.5f, 1.f};
|
float keytime1[] = {0.f, 0.333f, 0.667f, 1.f};
|
||||||
float rot[4 * 4];
|
float rot[4 * 4];
|
||||||
Quaternion quat;
|
Quaternion quat;
|
||||||
Quaternion::createFromAxisAngle(Vec3(0.f, 1.f, 0.f), 0, &quat);
|
Quaternion::createFromAxisAngle(Vec3(1.f, 0.f, 0.f), 0, &quat);
|
||||||
rot[0] = quat.x, rot[1] = quat.y, rot[2] = quat.z, rot[3] = quat.w;
|
rot[0] = quat.x, rot[1] = quat.y, rot[2] = quat.z, rot[3] = quat.w;
|
||||||
Quaternion::createFromAxisAngle(Vec3(0.f, 1.f, 0.f), MATH_DEG_TO_RAD(90), &quat);
|
Quaternion::createFromAxisAngle(Vec3(1.f, 0.f, 0.f), MATH_DEG_TO_RAD(0), &quat);
|
||||||
rot[4] = quat.x, rot[5] = quat.y, rot[6] = quat.z, rot[7] = quat.w;
|
rot[4] = quat.x, rot[5] = quat.y, rot[6] = quat.z, rot[7] = quat.w;
|
||||||
Quaternion::createFromAxisAngle(Vec3(0.f, 1.f, 0.f), MATH_DEG_TO_RAD(180), &quat);
|
Quaternion::createFromAxisAngle(Vec3(1.f, 0.f, 0.f), MATH_DEG_TO_RAD(0), &quat);
|
||||||
rot[8] = quat.x, rot[9] = quat.y, rot[10] = quat.z, rot[11] = quat.w;
|
rot[8] = quat.x, rot[9] = quat.y, rot[10] = quat.z, rot[11] = quat.w;
|
||||||
Quaternion::createFromAxisAngle(Vec3(0.f, 1.f, 0.f), MATH_DEG_TO_RAD(270), &quat);
|
Quaternion::createFromAxisAngle(Vec3(1.f, 0.f, 0.f), MATH_DEG_TO_RAD(0), &quat);
|
||||||
rot[12] = quat.x, rot[13] = quat.y, rot[14] = quat.z, rot[15] = quat.w;
|
rot[12] = quat.x, rot[13] = quat.y, rot[14] = quat.z, rot[15] = quat.w;
|
||||||
curve->rotCurve = Animation3D::Curve::AnimationCurveQuat::create(keytime1, rot, 4);
|
curve->rotCurve = Animation3D::Curve::AnimationCurveQuat::create(keytime1, rot, 4);
|
||||||
curve->rotCurve->retain();
|
curve->rotCurve->retain();
|
||||||
|
|
|
@ -353,6 +353,12 @@ void GLProgram::parseUniforms()
|
||||||
}
|
}
|
||||||
uniform.name = std::string(uniformName);
|
uniform.name = std::string(uniformName);
|
||||||
uniform.location = glGetUniformLocation(_program, uniformName);
|
uniform.location = glGetUniformLocation(_program, uniformName);
|
||||||
|
GLenum __gl_error_code = glGetError();
|
||||||
|
if (__gl_error_code != GL_NO_ERROR)
|
||||||
|
{
|
||||||
|
CCLOG("error: 0x%x", (int)__gl_error_code);
|
||||||
|
}
|
||||||
|
assert(__gl_error_code == GL_NO_ERROR);
|
||||||
|
|
||||||
_userUniforms[uniform.name] = uniform;
|
_userUniforms[uniform.name] = uniform;
|
||||||
}
|
}
|
||||||
|
|
|
@ -534,8 +534,10 @@ void Sprite3DWithSkinTest::addNewSpriteWithCoords(Vec2 p)
|
||||||
sprite->setPosition( Vec2( p.x, p.y) );
|
sprite->setPosition( Vec2( p.x, p.y) );
|
||||||
auto animation = Animation3D::getOrCreate("Sprite3DTest/XXX.c3t");
|
auto animation = Animation3D::getOrCreate("Sprite3DTest/XXX.c3t");
|
||||||
|
|
||||||
|
|
||||||
auto animate = Animate3D::create(animation);
|
auto animate = Animate3D::create(animation);
|
||||||
sprite->runAction(animate);
|
|
||||||
|
sprite->runAction(RepeatForever::create(animate));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite3DWithSkinTest::onTouchesEnded(const std::vector<Touch*>& touches, Event* event)
|
void Sprite3DWithSkinTest::onTouchesEnded(const std::vector<Touch*>& touches, Event* event)
|
||||||
|
|
Loading…
Reference in New Issue