Skip to content

Commit

Permalink
功能预览版本
Browse files Browse the repository at this point in the history
  • Loading branch information
noterpopo committed Dec 19, 2018
1 parent 6063f95 commit ef967d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/src/main/assets/shaders/object.frag
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void main() {
vec3 viewNormal = normalize(v_ViewNormal);

// Flip the y-texture coordinate to address the texture from top-left.
vec4 objectColor = texture2D(u_Texture, vec2(v_TexCoord.x, 1.0 - v_TexCoord.y));
vec4 objectColor = texture2D(u_Texture, vec2(v_TexCoord.x, v_TexCoord.y));
//vec4 objectColor = vec4(v_we.xyz,1.0);

// Apply color to grayscale image only if the alpha of u_ObjColor is
Expand Down
15 changes: 8 additions & 7 deletions app/src/main/cpp/native-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ map<string, unsigned int> m_bone_mapping; // maps a bone name and their index

unsigned int m_num_bones=0;

vector<BoneMatrix> m_bone_matrices;
static vector<BoneMatrix> m_bone_matrices;

float ticks_per_second = 0.0f;

Expand Down Expand Up @@ -140,7 +140,7 @@ Java_com_popo_assimptest_AssimpImporter_modelimporter(JNIEnv* env,jobject obj,jo

char *buf=reinterpret_cast<char*>(buffer.data());

importer.ReadFileFromMemory(buf,count,aiProcessPreset_TargetRealtime_Fast);
importer.ReadFileFromMemory(buf,count,aiProcess_Triangulate | aiProcess_FlipUVs);
scene=importer.GetOrphanedScene();
// const aiScene* scene=importer.ReadFile("/sdcard/temp.txt", aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_CalcTangentSpace);
if(!scene){return JNI_FALSE;}
Expand Down Expand Up @@ -175,13 +175,15 @@ Java_com_popo_assimptest_AssimpImporter_modelimporter(JNIEnv* env,jobject obj,jo
textureCoordArray=new float[textureCoordArraySize];
indexArray=new jshort[indexArraySize];
boneIds=new jfloat[boneIdsAndWeightsSize];
memset(boneIds,0,boneIdsAndWeightsSize);
weights=new jfloat[boneIdsAndWeightsSize];
memset(weights,0,boneIdsAndWeightsSize);

// init all values in array = 0
memset(boneIds, 0, sizeof(boneIds));
memset(weights, 0, sizeof(weights));
memset(vertexArray, 0, sizeof(jfloat)*vertexArraySize);
memset(normalArray, 0, sizeof(jfloat)*normalArraySize);
memset(textureCoordArray, 0, sizeof(jfloat)*textureCoordArraySize);
memset(indexArray, 0, sizeof(jshort)*indexArraySize);
memset(boneIds, 0, sizeof(jfloat)*boneIdsAndWeightsSize);
memset(weights, 0, sizeof(jfloat)*boneIdsAndWeightsSize);



Expand Down Expand Up @@ -402,7 +404,6 @@ Java_com_popo_assimptest_AssimpImporter_getBoneTransform(JNIEnv* env,jobject obj

void readNodeHierarchy(aiScene* gscene,float p_animation_time, const aiNode* p_node, const aiMatrix4x4 parent_transform)
{
p_node->mName.data;
string node_name(p_node->mName.data);

const aiAnimation* animation = gscene->mAnimations[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public void draw(
AniMartData aniMartData=importer.getAniData((System.currentTimeMillis()-start)/1000.0f);
for (int i = 0; i < aniMartData.getAniMatrixArray().size(); i++) // move all matrices for actual model position to shader
{
GLES20.glUniformMatrix4fv(boneLocation[i], 1, false, aniMartData.getAniMatrixArray().get(i), 0);
GLES20.glUniformMatrix4fv(boneLocation[i], 1, true, aniMartData.getAniMatrixArray().get(i), 0);
}
}
ShaderUtil.checkGLError(TAG, "after ani");
Expand Down

0 comments on commit ef967d5

Please sign in to comment.