[x3d-public] Joe, please look over this scaled Jin.
John Carlson
yottzumm at gmail.com
Sun Mar 24 19:15:18 PDT 2024
JSHumanoids/data/JinLOA4.scaled1.x3d at main · coderextreme/JSHumanoids
(github.com)
<https://github.com/coderextreme/JSHumanoids/blob/main/data/JinLOA4.scaled1.x3d>
For specific purpose, I am providing specific code to rescale JinLOA4.x3d
from the archive as this link:
JSHumanoids/graaljs/net/coderextreme/rescale.js at main ·
coderextreme/JSHumanoids (github.com)
<https://github.com/coderextreme/JSHumanoids/blob/main/graaljs/net/coderextreme/rescale.js>
Be careful using this as it does not scale all geometry (for example,
Sphere radius or Box size). If someone desires a more complex scene
handling, let me know, and I will add it. Indeed, it doesn't handle scale
in Transforms, just scales the translation.
These nodes are mostly handled (under HAnimHumanoid)
HAnimHumanoid
HAnimJoint
HAnimSite
HAnimSegment
Group
Transform
Shape
IndexedFaceSet
Appearance
Coordinate
These are the fields retrieved:
getAppearance();
getCenter();
getChildren();
getChildrenList();
getCoord();
getCoordIndex();
getDEF();
getDisplacersList();
getGeometry();
getName();
getPoint();
getScale();
getSkeleton();
getTexCoordIndex();
getTranslation();
Here are the fields set:
humanoid.setScale(Java.to([ 1, 1, 1 ], Java.type("double[]")));
joint.setCenter(center);
joint.setTranslation(Java.to([0, 0, 0], Java.type("double[]")));
site.setCenter(center);
site.setTranslation(Java.to([0, 0, 0], Java.type("double[]")));
transform.setTranslation(Java.to([0, 0, 0], Java.type("double[]")));
parentNode.setChildren(parentArray);
coordinate.setPoint(point);
So, no, I don't handle scaling or rotation in HAnim (except for
HAnimHumanoid scale, which it defaults) or Transform nodes yet.
Translation in HAnim nodes is TBD.
If you use my code,* remember to catch Exceptions from Java* and print the
exception, otherwise, GraalJS will hide it!
I don't have experience running GraalJS inside NetBeans, maybe someone can
try!
After a lot of heartache, this is the GraalJS code I got to work in
Transforms. Note that I got rid of all previous data in the parent of
transform, this was because *I couldn't find a way to remove one child from
an HAnimSegment in X3DJSAIL*, so I had to blow away everything. I didn't
bother to look up the index of the Transform. Library support would be
welcome, but probably difficult to generalize. Probably programming in
Java would be simpler, if we could compile HAnim well in Java.
try {
if (transform.getDEF() || transform.getName()) {
// add more defaults, so we won't delete the node, if there's more than
children data
transform.setTranslation(Java.to([0, 0, 0],
Java.type("double[]"))); // Transform should be abandoned, but result
leads to NO-OP
children = transform.getChildrenList();
} else {
print("Deleting ALL nodes below ",
parentNode, parentNode.getDEF(), parentNode.getName(), ", not just the
singleton Transform");
let transformArray =
transform.getChildren();
let parentArray = transformArray.clone();
// TODO delete the ONE transform, not the
whole parentNode array
parentNode.setChildren(parentArray);
children = parentNode.getChildrenList();
}
} catch (e) {
print("error ", e);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20240324/5452205b/attachment.html>
More information about the x3d-public
mailing list