diff --git a/Output/Animation_Skin/Animation_Skin_12.bin b/Output/Animation_Skin/Animation_Skin_12.bin deleted file mode 100644 index e18fae14..00000000 Binary files a/Output/Animation_Skin/Animation_Skin_12.bin and /dev/null differ diff --git a/Output/Animation_Skin/Animation_Skin_12.gltf b/Output/Animation_Skin/Animation_Skin_12.gltf deleted file mode 100644 index a9dde53e..00000000 --- a/Output/Animation_Skin/Animation_Skin_12.gltf +++ /dev/null @@ -1,311 +0,0 @@ -{ - "accessors": [ - { - "bufferView": 0, - "componentType": 5126, - "count": 18, - "type": "VEC3", - "max": [ - 0.25, - 0.0, - 0.399999976 - ], - "min": [ - -0.25, - 0.0, - -0.4 - ], - "name": "Positions Accessor" - }, - { - "bufferView": 1, - "componentType": 5125, - "count": 48, - "type": "SCALAR", - "name": "Indices Accessor" - }, - { - "bufferView": 2, - "componentType": 5126, - "count": 18, - "type": "VEC4", - "name": "weights accessor" - }, - { - "bufferView": 3, - "componentType": 5123, - "count": 18, - "type": "VEC4", - "name": "joint indices accessor" - }, - { - "bufferView": 4, - "componentType": 5126, - "count": 18, - "type": "VEC4", - "name": "weights accessor" - }, - { - "bufferView": 5, - "componentType": 5123, - "count": 18, - "type": "VEC4", - "name": "joint indices accessor" - }, - { - "bufferView": 6, - "componentType": 5126, - "count": 8, - "type": "MAT4", - "name": "IBM" - } - ], - "asset": { - "generator": "glTF Asset Generator", - "version": "2.0" - }, - "buffers": [ - { - "uri": "Animation_Skin_12.bin", - "byteLength": 1784 - } - ], - "bufferViews": [ - { - "buffer": 0, - "byteLength": 216, - "name": "Positions" - }, - { - "buffer": 0, - "byteOffset": 216, - "byteLength": 192, - "name": "Indices" - }, - { - "buffer": 0, - "byteOffset": 408, - "byteLength": 288, - "name": "weights buffer view" - }, - { - "buffer": 0, - "byteOffset": 696, - "byteLength": 144, - "name": "joint indices buffer view" - }, - { - "buffer": 0, - "byteOffset": 840, - "byteLength": 288, - "name": "weights buffer view" - }, - { - "buffer": 0, - "byteOffset": 1128, - "byteLength": 144, - "name": "joint indices buffer view" - }, - { - "buffer": 0, - "byteOffset": 1272, - "byteLength": 512, - "name": "Inverse Bind Matrix" - } - ], - "materials": [ - { - "pbrMetallicRoughness": { - "baseColorFactor": [ - 0.8, - 0.8, - 0.8, - 1.0 - ] - }, - "doubleSided": true - } - ], - "meshes": [ - { - "primitives": [ - { - "attributes": { - "POSITION": 0, - "WEIGHTS_0": 2, - "JOINTS_0": 3, - "WEIGHTS_1": 4, - "JOINTS_1": 5 - }, - "indices": 1, - "material": 0 - } - ] - } - ], - "nodes": [ - { - "skin": 0, - "mesh": 0, - "name": "plane" - }, - { - "children": [ - 2 - ], - "rotation": [ - -0.7071067, - 0.0, - 0.0, - 0.707106769 - ], - "translation": [ - 0.0, - -0.4, - 0.0 - ], - "name": "joint0" - }, - { - "children": [ - 3 - ], - "rotation": [ - -0.0871557444, - 0.0, - 0.0, - 0.9961947 - ], - "translation": [ - 0.0, - 0.0, - 0.1 - ], - "name": "joint1" - }, - { - "children": [ - 4 - ], - "rotation": [ - -0.0871557444, - 0.0, - 0.0, - 0.9961947 - ], - "translation": [ - 0.0, - 0.0, - 0.1 - ], - "name": "joint2" - }, - { - "children": [ - 5 - ], - "rotation": [ - -0.0871557444, - 0.0, - 0.0, - 0.9961947 - ], - "translation": [ - 0.0, - 0.0, - 0.1 - ], - "name": "joint3" - }, - { - "children": [ - 6 - ], - "rotation": [ - -0.0871557444, - 0.0, - 0.0, - 0.9961947 - ], - "translation": [ - 0.0, - 0.0, - 0.1 - ], - "name": "joint4" - }, - { - "children": [ - 7 - ], - "rotation": [ - -0.0871557444, - 0.0, - 0.0, - 0.9961947 - ], - "translation": [ - 0.0, - 0.0, - 0.1 - ], - "name": "joint5" - }, - { - "children": [ - 8 - ], - "rotation": [ - -0.0871557444, - 0.0, - 0.0, - 0.9961947 - ], - "translation": [ - 0.0, - 0.0, - 0.1 - ], - "name": "joint6" - }, - { - "rotation": [ - -0.0871557444, - 0.0, - 0.0, - 0.9961947 - ], - "translation": [ - 0.0, - 0.0, - 0.1 - ], - "name": "joint7" - } - ], - "scene": 0, - "scenes": [ - { - "nodes": [ - 0, - 1 - ] - } - ], - "skins": [ - { - "inverseBindMatrices": 6, - "joints": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8 - ], - "name": "skinF" - } - ] -} \ No newline at end of file diff --git a/Output/Animation_Skin/Figures/SampleImages/Animation_Skin_12.png b/Output/Animation_Skin/Figures/SampleImages/Animation_Skin_12.png deleted file mode 100644 index de4aa208..00000000 Binary files a/Output/Animation_Skin/Figures/SampleImages/Animation_Skin_12.png and /dev/null differ diff --git a/Output/Animation_Skin/Figures/Thumbnails/Animation_Skin_12.png b/Output/Animation_Skin/Figures/Thumbnails/Animation_Skin_12.png deleted file mode 100644 index de4aa208..00000000 Binary files a/Output/Animation_Skin/Figures/Thumbnails/Animation_Skin_12.png and /dev/null differ diff --git a/Output/Animation_Skin/Manifest.json b/Output/Animation_Skin/Manifest.json index 8c290fbc..a82f4a08 100644 --- a/Output/Animation_Skin/Manifest.json +++ b/Output/Animation_Skin/Manifest.json @@ -132,17 +132,6 @@ 1.0 ] } - }, - { - "fileName": "Animation_Skin_12.gltf", - "sampleImageName": "Figures/SampleImages/Animation_Skin_12.png", - "camera": { - "translation": [ - 1.5, - 0.0, - 1.0 - ] - } } ] } \ No newline at end of file diff --git a/Output/Animation_Skin/README.md b/Output/Animation_Skin/README.md index 4fcf400a..0893d840 100644 --- a/Output/Animation_Skin/README.md +++ b/Output/Animation_Skin/README.md @@ -6,9 +6,13 @@ skinA | skinB | skinC :---: | :---: | :---: | | -skinD | skinE | skinF -:---: | :---: | :---: - | | +skinD | skinE +:---: | :---: + | + + + + The following table shows the properties that are set for a given model. @@ -26,5 +30,4 @@ The following table shows the properties that are set for a given model. | [09](Animation_Skin_09.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=2&model=9) | [](Figures/SampleImages/Animation_Skin_09.png) | `skinC` where all of the joints have a local rotation of -10 degrees, except the root which is rotated -90 degrees. | | [10](Animation_Skin_10.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=2&model=10) | [](Figures/SampleImages/Animation_Skin_10.png) | `skinD` where each joint is animating with a rotation. There is a transform node in the joint hierarchy that is not a joint. That node has a mesh attached to it in order to show its location. | | [11](Animation_Skin_11.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=2&model=11) | [](Figures/SampleImages/Animation_Skin_11.png) | `skinE`. | -| [12](Animation_Skin_12.gltf)
[View](https://bghgary.github.io/glTF-Assets-Viewer/?folder=2&model=12) | [](Figures/SampleImages/Animation_Skin_12.png) | `skinF`. | diff --git a/Output/Manifest.json b/Output/Manifest.json index 7e979f21..6eff3852 100644 --- a/Output/Manifest.json +++ b/Output/Manifest.json @@ -297,17 +297,6 @@ 1.0 ] } - }, - { - "fileName": "Animation_Skin_12.gltf", - "sampleImageName": "Figures/SampleImages/Animation_Skin_12.png", - "camera": { - "translation": [ - 1.5, - 0.0, - 1.0 - ] - } } ] }, diff --git a/Source/ModelGroups/Animation_Skin.cs b/Source/ModelGroups/Animation_Skin.cs index e064fd63..190d4a12 100644 --- a/Source/ModelGroups/Animation_Skin.cs +++ b/Source/ModelGroups/Animation_Skin.cs @@ -352,63 +352,64 @@ Runtime.Animation CreateFoldingAnimation(Runtime.Node jointRootNode, List { model.Camera = distantCamera; }), - CreateModel((properties, animations, nodes) => { - foreach (Runtime.Node node in Nodes.CreateFoldingPlaneSkin("skinF", 8, 9, vertexVerticalSpacingMultiplier: 0.5f)) - { - nodes.Add(node); - } - - // Rotate each joint node, except the root which already has the desired rotation - Runtime.Node nodeCheck = nodes[1].Children.First(); - float rotationRadian = FloatMath.ConvertDegreesToRadians(-10.0f); - Quaternion rotationQuaternion = Quaternion.CreateFromYawPitchRoll(0.0f, rotationRadian, 0.0f); - nodeCheck.Rotation = rotationQuaternion; - while (nodeCheck.Children != null) - { - foreach (Runtime.Node node in nodeCheck.Children) - { - node.Rotation = rotationQuaternion; - } - nodeCheck = nodeCheck.Children.First(); - } - - // Rebuild the inverseBindMatrix for each joint (except the root) to work with the new rotation - var skinJointList = (List)nodes[0].Skin.SkinJoints; - for (int skinJointIndex = 1; skinJointIndex < skinJointList.Count(); skinJointIndex++) - { - Matrix4x4 translationInverseBindMatrix = skinJointList.ElementAt(skinJointIndex).InverseBindMatrix; - Matrix4x4.Invert(Matrix4x4.CreateRotationX(rotationRadian * (skinJointIndex + 1)) , out Matrix4x4 invertedRotation); - skinJointList.ElementAt(skinJointIndex).InverseBindMatrix = Matrix4x4.Multiply(translationInverseBindMatrix, invertedRotation); - } - - // Rebuild weights to include every joint instead of just the ones with a weight > 0 - var weightList = (List>)nodes[0].Mesh.MeshPrimitives.First().VertexJointWeights; - for (int weightIndex = 0; weightIndex < weightList.Count(); weightIndex++) - { - var jointWeight = new List(); - - for (int skinJointIndex = 0; skinJointIndex < skinJointList.Count; skinJointIndex++) - { - int weightToUse = 0; - // Set the weight to 1 if the skinJoint is at the same level as the vertex. - // Or Set the weight to 1 if the vertex is further out than the last skinjoint and the last skinjoint is being set. - if (skinJointIndex == (weightIndex / 2) || (((weightIndex / 2) > skinJointList.Count - 1) && (skinJointIndex == skinJointList.Count - 1)) ) - { - weightToUse = 1; - } - - jointWeight.Add(new Runtime.JointWeight - { - Joint = skinJointList[skinJointIndex], - Weight = weightToUse, - }); - } - - weightList[weightIndex] = jointWeight; - } - - properties.Add(new Property(PropertyName.Description, "`skinF`.")); - }, (model) => { model.Camera = distantCamera; }), + // Removing this model for now, since no viewer currently supports models that have >4 jointweights per vertex. + //CreateModel((properties, animations, nodes) => { + // foreach (Runtime.Node node in Nodes.CreateFoldingPlaneSkin("skinF", 8, 9, vertexVerticalSpacingMultiplier: 0.5f)) + // { + // nodes.Add(node); + // } + + // // Rotate each joint node, except the root which already has the desired rotation + // Runtime.Node nodeCheck = nodes[1].Children.First(); + // float rotationRadian = FloatMath.ConvertDegreesToRadians(-10.0f); + // Quaternion rotationQuaternion = Quaternion.CreateFromYawPitchRoll(0.0f, rotationRadian, 0.0f); + // nodeCheck.Rotation = rotationQuaternion; + // while (nodeCheck.Children != null) + // { + // foreach (Runtime.Node node in nodeCheck.Children) + // { + // node.Rotation = rotationQuaternion; + // } + // nodeCheck = nodeCheck.Children.First(); + // } + + // // Rebuild the inverseBindMatrix for each joint (except the root) to work with the new rotation + // var skinJointList = (List)nodes[0].Skin.SkinJoints; + // for (int skinJointIndex = 1; skinJointIndex < skinJointList.Count(); skinJointIndex++) + // { + // Matrix4x4 translationInverseBindMatrix = skinJointList.ElementAt(skinJointIndex).InverseBindMatrix; + // Matrix4x4.Invert(Matrix4x4.CreateRotationX(rotationRadian * (skinJointIndex + 1)) , out Matrix4x4 invertedRotation); + // skinJointList.ElementAt(skinJointIndex).InverseBindMatrix = Matrix4x4.Multiply(translationInverseBindMatrix, invertedRotation); + // } + + // // Rebuild weights to include every joint instead of just the ones with a weight > 0 + // var weightList = (List>)nodes[0].Mesh.MeshPrimitives.First().VertexJointWeights; + // for (int weightIndex = 0; weightIndex < weightList.Count(); weightIndex++) + // { + // var jointWeight = new List(); + + // for (int skinJointIndex = 0; skinJointIndex < skinJointList.Count; skinJointIndex++) + // { + // int weightToUse = 0; + // // Set the weight to 1 if the skinJoint is at the same level as the vertex. + // // Or Set the weight to 1 if the vertex is further out than the last skinjoint and the last skinjoint is being set. + // if (skinJointIndex == (weightIndex / 2) || (((weightIndex / 2) > skinJointList.Count - 1) && (skinJointIndex == skinJointList.Count - 1)) ) + // { + // weightToUse = 1; + // } + + // jointWeight.Add(new Runtime.JointWeight + // { + // Joint = skinJointList[skinJointIndex], + // Weight = weightToUse, + // }); + // } + + // weightList[weightIndex] = jointWeight; + // } + + // properties.Add(new Property(PropertyName.Description, "`skinF`. Each vertex has weights for more than four joints.")); + //}, (model) => { model.Camera = distantCamera; }), }; GenerateUsedPropertiesList(); diff --git a/Source/ReadmeTemplates/Animation_Skin.md b/Source/ReadmeTemplates/Animation_Skin.md index b7f25a55..9d2f6d10 100644 --- a/Source/ReadmeTemplates/Animation_Skin.md +++ b/Source/ReadmeTemplates/Animation_Skin.md @@ -6,9 +6,13 @@ skinA | skinB | skinC :---: | :---: | :---: | | -skinD | skinE | skinF -:---: | :---: | :---: - | | +skinD | skinE +:---: | :---: + | + + + + The following table shows the properties that are set for a given model.