[x3d-public] Isolating problems with HAnimHumanoid.java and X3DUOM, etc.
John Carlson
yottzumm at gmail.com
Mon Jun 24 03:21:27 PDT 2024
I will try again.
Problem: setting containerField on HAnimHumanoid children nodes to
something besides "children" or default.
Constraint: do not set containerField in application code, instead use
addSegments, addJoints.
Target client code:
Humanoid1.addJoints(HAnimJoint1)
Implementation:
==================================================================
HAnimHumanoid.java:
Map<HAnimHumanoidHAnimJointContainerFieldEnum,X3DGroupingNode>
enumToContainerField = new
Map<HAnimHumanoidHAnimJointContainerFieldEnum,X3DGroupingNode>();
{{
enumToContainerField .put(HAnimHumanoidHAnimJointContainerFieldEnum.joints,
joints);
enumToContainerField
.put(HAnimHumanoidHAnimJointContainerFieldEnum.skeleton, skeleton);
}}
public Humanoid1 addJoints(HAnimJoint joint) throw new
ContainerFieldException {
try {
joint.setTypeSafeContainerField(this.getClass(),
HAnimHumanoidHAnimJointContainerFieldEnum.joints);
joints.add(joint);
} catch (Exception e) {
throw new ContainerFieldException();
}
return this;
}
===================================================================
HAnimJoint.java:
Map<Class,Set<HAnimHumanoidHAnimJointContainerFieldEnum>> containerFieldMap
= new HashMap<Class,Set<HAnimHumanoidHAnimJointContainerFieldEnum>>();
public enum HAnimHumanoidHAnimJointContainerFieldEnum {
joints,
skeleton
}
Set<HAnimHumanoidHAnimJointContainerFieldEnum> cfEnumSet =
HashSet<HAnimHumanoidHAnimJointContainerFieldEnum>()
cfEnumSet.add(HAnimHumanoidHAnimJointContainerFieldEnum.joints);
cfEnumSet.add(HAnimHumanoidHAnimJointContainerFieldEnum.skeleton);
containerFieldMap.put(HAnimHumanoid.class,cfEnumSet);
public boolean setTypeSafeContainerField(Class c,
HAnimHumanoidHAnimJointContainerFieldEnum cf) {
return containerFieldMap.get(c).get(cf);
}
I can provide more detail if asked questions.
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20240624/59958639/attachment.html>
More information about the x3d-public
mailing list