BangTao Posted February 13, 2017 Share Posted February 13, 2017 Hi all. There's a question about animation(exported from 3dsMax,and i only know 3dsMax a little ) which is : Q1:How skeleton's bones influence mesh's vertex data? Q2: the PG. and how can i get every mesh's vertex data from the .babylon file? Q3:these is meshes Attr from Dude.babylon's , and i don't know why there isn't positions Attr/ Q4:And there pic ,i don't know why the first bones's parentBoneIndex is "-1".... Thx for u time. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 16, 2017 Share Posted February 16, 2017 Hi BT! Sorry for slow replies. I am not expert, but I try to help. Please DL/view https://github.com/Wingnutt/misc/blob/master/stripped_dude.zip It is "stripped" (and white-spaced) dude.babylon. In "meshes" section, I have removed almost all values in big arrays... such as "positions", "indices", "matricesIndices", and "matricesWeights". Now they are only for looking-at. This .babylon file will not load properly. I broke it. Please take notice of matricesIndices and matricesWeights. Those affect animation. See all 58 matrix animations in stripped_dude.babylon? All are dataType 3. Go to some playground and enter line console.log(BABYLON.Animation.ANIMATIONTYPE_MATRIX); Returns: 3. All 58 animations... are matrix animations! They are being done to "bones" which are not mesh, but really matrix transformations, that happen to mesh... which have properties matricesIndices and matricesWeights. Starting to see answer to Q1? When you do see it, TEACH ME ALSO, PLEASE. heh. Q2: http://www.babylonjs-playground.com/#1BZJVJ#69 Here I was playing. I do funny rotations in line 25-26. In line 27, I get positionsKind data for meshes[1]. Then lines 28-30... I try to move (transform) one .position/vertex. Then line 34, I try to "write" positionsKind data back to object, with parameter updateExtends = true. (updateExtends adjusts boundingBox size if needed). As you can see, bounding box size IS growing, but I cannot make a vertex on dude's head... move/display movement. Maybe he is set updatable = false. hmm. Just playing with the mesh... having fun learning. Q3: and Q4: I have no answers. Possibly, JSON parsing/de-serialization performance is optimized by using these methods. Not sure. Perhaps @Deltakosh or other 3DMax exporter contributors will respond soon. Fellow forum helpers... please help, and please correct me if I have said wrong things. I am no expert in bones, skeletons, and their animations. (actually, I'm no expert in ANYTHING, except perhaps aimless talking.) heh. Darn. Matrix transformation animations! Coooool. Bad to the "bone". Sorry I wasn't more helpful. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 16, 2017 Share Posted February 16, 2017 Hello! Q1: Bones influence a mesh through mesh's vertices data. There are two sets of vertex data that you want to check: matrices indices and matrices weight (as wingnut mentioned). Inside the vertex shader, every vertex will be transformed by a matrix build from bones (which are actually only matrices :)) . The active bones are referenced by matrices indices (every index points to a bone) and the weight of each bone is deduced from matrices weights (value from 0 to 1). Q2: Wingnut is right (again): just use getVertexData with one of the kind you are interested by: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.vertexBuffer.ts#L155 Q3: Bones are matrices. And matrices contain rotation, scaling and position Q4: The first bone has no parent. It is the top most bone (hence no parent, so parentIndex set to an impossible value (-1)) Wingnut 1 Quote Link to comment Share on other sites More sharing options...
BangTao Posted February 22, 2017 Author Share Posted February 22, 2017 @Wingnut @Deltakosh oh,haha,sorry for late reply too,thank u for your time,so,here is what I understand: As for bones animation,mesh's vertices data is according to bones(matrices),matrices change,then vertices change.so,if i wanna get the vertices data ,i can get the bone's Initial state matrix first(i don't know if the first pic shows right/,hope it's right), and Calculate the matrices indices and matrices weight ,each vertex matrix is computed as follows(not sure if it's right): finalMatrix = worldMatrix * (bonesMatrices[index0] * weight0 + bonesMatrices[index1] * weight1 + bonesMatrices[index2] * weight2 + bonesMatrices[index3] * weight3) but why the matricesWeights.length is larger than matricesWeights.length,Shouldn't they be the same length? and what's the worldMatrix here? i didn't find this Attr. oh.one last thing.Use "getVerticesData(BABYLON.VertexBuffer.PositionKind)" only get the mesh's initial position,i'm trying to get the position data every time the bones changed,that's what i'm i doing now ; http://www.babylonjs-playground.com/#1BZJVJ#70 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 22, 2017 Share Posted February 22, 2017 So: - your formula is correct - MatricesIndices are int values. Every int is actually made of 4 bytes (one per matrix) - WorldMatrix comes from the mesh and is comptued by babylonjs based on mesh position, etc. -You cannot get the updated position as they are not stored by computed live by shaders But if you really want to get these values, you can turn off shader computation for bones with mesh.computeBonesUsingShaders = false. In this case this code uses the CPU to compute bones:https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.mesh.ts#L2617 Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.