Game Development Reference
In-Depth Information
If the object is not of the RiggedMesh type, we disable the attributes
( gl.disableVertexAttribArray(shaderProgram.skinIndex) ).
function drawScene() {
...
if(stage.stageObjects[i] instanceof RiggedMesh) {
gl.uniform1i(shaderProgram.useSkinning,1);
gl.enableVertexAttribArray(shaderProgram.skinIndex);
gl.enableVertexAttribArray(shaderProgram.skinWeight);
gl.uniformMatrix4fv( shaderProgram.boneGlobalMatrices,
false, stage.stageObjects[i].boneMatrices );
gl.bindBuffer(gl.ARRAY_BUFFER,
stage.stageObjects[i].skinIndexBuffer);
gl.vertexAttribPointer(shaderProgram.skinIndex, 4,
gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER,
stage.stageObjects[i].skinWeightBuffer);
gl.vertexAttribPointer(shaderProgram.skinWeight, 4,
gl.FLOAT, false, 0, 0);
} else {
gl.disableVertexAttribArray(shaderProgram.skinIndex);
gl.disableVertexAttribArray(shaderProgram.skinWeight);
gl.uniform1i(shaderProgram.useSkinning,0);
}
...
}
Animating a rigged JSON model
Well, we did not take much effort to load a static model, rather we took more effort
to animate the model. Hence, let's first understand how animation data is encoded
in a JSON file.
 
Search WWH ::




Custom Search