This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 45ea93f10c4857a589c12646cbd3b135c0c07d42 Author: jsorel <[email protected]> AuthorDate: Wed May 6 23:27:01 2026 +0200 feat(Geometry): add physics model api from ISO 12113 --- .../org/apache/sis/geometries/scene/SceneNode.java | 76 +++++ .../main/org/apache/sis/geometries/scene/Skin.java | 1 + .../sis/geometries/scene/physics/Collider.java | 83 +++++ .../geometries/scene/physics/ColliderGeometry.java | 65 ++++ .../geometries/scene/physics/CollisionFilter.java | 85 +++++ .../apache/sis/geometries/scene/physics/Joint.java | 360 +++++++++++++++++++++ .../sis/geometries/scene/physics/Motion.java | 180 +++++++++++ .../geometries/scene/physics/PhysicalMaterial.java | 130 ++++++++ .../sis/geometries/scene/physics/Trigger.java | 87 +++++ 9 files changed, 1067 insertions(+) diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/SceneNode.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/SceneNode.java index d2f16e2ee8..bf4f42ef66 100644 --- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/SceneNode.java +++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/SceneNode.java @@ -31,6 +31,10 @@ import org.opengis.referencing.operation.TransformException; import org.apache.sis.geometries.Geometries; import org.apache.sis.geometries.math.Similarity; import org.apache.sis.geometries.math.Similarity3D; +import org.apache.sis.geometries.scene.physics.Collider; +import org.apache.sis.geometries.scene.physics.Joint; +import org.apache.sis.geometries.scene.physics.Motion; +import org.apache.sis.geometries.scene.physics.Trigger; import org.apache.sis.geometry.Envelopes; import org.apache.sis.geometry.GeneralEnvelope; import org.apache.sis.measure.NumberRange; @@ -104,6 +108,10 @@ public class SceneNode { private String name; private Feature feature; private Skin skin; + private Motion motion; + private Collider collider; + private Trigger trigger; + private Joint joint; private final List<Animation> animations = new ArrayList<>(); //user properties private Map<String,Object> properties; @@ -258,6 +266,62 @@ public class SceneNode { this.skin = skin; } + /** + * @return node motion, can be null + */ + public Motion getMotion() { + return motion; + } + + /** + * @param motion set motion + */ + public void setMotion(Motion motion) { + this.motion = motion; + } + + /** + * @return node collider, can be null + */ + public Collider getCollider() { + return collider; + } + + /** + * @param collider set collider + */ + public void setCollider(Collider collider) { + this.collider = collider; + } + + /** + * @return node trigger, can be null + */ + public Trigger getTrigger() { + return trigger; + } + + /** + * @param trigger set trigger + */ + public void setTrigger(Trigger trigger) { + this.trigger = trigger; + } + + /** + * @return node joint, can be null + */ + public Joint getJoint() { + return joint; + } + + /** + * @param joint set joint + */ + public void setJoint(Joint joint) { + this.joint = joint; + } + /** * @return animations attached to this node */ @@ -397,6 +461,18 @@ public class SceneNode { if (!Objects.equals(this.skin, other.skin)) { return false; } + if (!Objects.equals(this.motion, other.motion)) { + return false; + } + if (!Objects.equals(this.collider, other.collider)) { + return false; + } + if (!Objects.equals(this.trigger, other.trigger)) { + return false; + } + if (!Objects.equals(this.joint, other.joint)) { + return false; + } if (!Objects.equals(this.animations, other.animations)) { return false; } diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/Skin.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/Skin.java index bf6da97ead..a2f80322bd 100644 --- a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/Skin.java +++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/Skin.java @@ -22,6 +22,7 @@ import org.apache.sis.geometries.math.Matrix4D; /** + * Synonym : Skeleton mapping * * @author Johann Sorel (Geomatys) */ diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/Collider.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/Collider.java new file mode 100644 index 0000000000..a00d50401c --- /dev/null +++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/Collider.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.geometries.scene.physics; + +/** + * Describes the physical representation of a node's shape for collision detection. + * + * @author Johann Sorel + * @spec ISO_12113 KHR_physics_rigid_bodies extension Collider + * @see https://github.com/eoineoineoin/glTF_Physics/tree/master/extensions/2.0/Khronos/KHR_physics_rigid_bodies#colliders + */ +public final class Collider { + + private ColliderGeometry geometry; + private PhysicalMaterial material; + private CollisionFilter collisionFilter; + + /** + * An object describing the geometrical representation of this collider. + * + * @return the geometry + */ + public ColliderGeometry getGeometry() { + return geometry; + } + + /** + * @param geometry the geometry to set + * @see #getGeometry() + */ + public void setGeometry(ColliderGeometry geometry) { + this.geometry = geometry; + } + + /** + * Describes how the collider should respond to collisions. + * + * @return the material + */ + public PhysicalMaterial getMaterial() { + return material; + } + + /** + * @param material the material to set + * @see #getMaterial() + */ + public void setMaterial(PhysicalMaterial material) { + this.material = material; + } + + /** + * Describes a filter which determines if this collider should perform collision detection + * against another collider. + * + * @return the collisionfilter + */ + public CollisionFilter getCollisionFilter() { + return collisionFilter; + } + + /** + * @param collisionfilter the collisionfilter to set + * @see #getCollisionFilter() + */ + public void setCollisionFilter(CollisionFilter collisionfilter) { + this.collisionFilter = collisionfilter; + } +} diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/ColliderGeometry.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/ColliderGeometry.java new file mode 100644 index 0000000000..dfe04b1e33 --- /dev/null +++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/ColliderGeometry.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.geometries.scene.physics; + +import org.apache.sis.geometries.Geometry; + +/** + * + * @author Johann Sorel + * @spec ISO_12113 KHR_physics_rigid_bodies extension Geometry + * @see https://github.com/eoineoineoin/glTF_Physics/tree/master/extensions/2.0/Khronos/KHR_physics_rigid_bodies#geometry + */ +public final class ColliderGeometry { + + private Geometry shape; + private boolean convexHull; + + /** + * Providing an implicit representation of the geometry. + * + * @return the shape + */ + public Geometry getShape() { + return shape; + } + + /** + * @param shape the shape to set + */ + public void setShape(Geometry shape) { + this.shape = shape; + } + + /** + * Flag to indicate that the geometry should be a convex hull. + * + * @return the convexHull + */ + public boolean isConvexHull() { + return convexHull; + } + + /** + * @param convexHull the convexHull to set + */ + public void setConvexHull(boolean convexHull) { + this.convexHull = convexHull; + } + + +} diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/CollisionFilter.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/CollisionFilter.java new file mode 100644 index 0000000000..95c0815d93 --- /dev/null +++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/CollisionFilter.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.geometries.scene.physics; + +import java.util.Set; + +/** + * Describes a filter which determines if this collider should perform collision detection + * against another collider. + * + * @author Johann Sorel + * @spec ISO_12113 KHR_physics_rigid_bodies extension, Collision Filtering + * @see https://github.com/eoineoineoin/glTF_Physics/tree/master/extensions/2.0/Khronos/KHR_physics_rigid_bodies#collision-filtering + */ +public final class CollisionFilter { + + private Set<String> collisionSystems; + private Set<String> notCollideWithSystems; + private Set<String> collideWithSystems; + + /** + * An array of arbitrary strings indicating the "system" a node is a member of. + * + * @return the collisionSystems + */ + public Set<String> getCollisionSystems() { + return collisionSystems; + } + + /** + * @param collisionSystems the collisionSystems to set + * @see #getCollisionSystems() + */ + public void setCollisionSystems(Set<String> collisionSystems) { + this.collisionSystems = collisionSystems; + } + + /** + * An array of strings representing the systems which this node can not collide with + * + * @return the notCollideWithSystems + */ + public Set<String> getNotCollideWithSystems() { + return notCollideWithSystems; + } + + /** + * @param notCollideWithSystems the notCollideWithSystems to set + * @see #getNotCollideWithSystems() + */ + public void setNotCollideWithSystems(Set<String> notCollideWithSystems) { + this.notCollideWithSystems = notCollideWithSystems; + } + + /** + * An array of strings representing the systems which this node can collide with + * + * @return the collideWithSystems + */ + public Set<String> getCollideWithSystems() { + return collideWithSystems; + } + + /** + * @param collideWithSystems the collideWithSystems to set + * @see #getCollideWithSystems() + */ + public void setCollideWithSystems(Set<String> collideWithSystems) { + this.collideWithSystems = collideWithSystems; + } +} diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/Joint.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/Joint.java new file mode 100644 index 0000000000..aa6ceb6ac3 --- /dev/null +++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/Joint.java @@ -0,0 +1,360 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.geometries.scene.physics; + +import java.util.List; +import org.apache.sis.geometries.scene.SceneNode; + +/** + * Constrains the motion of this node relative to another. + * + * @author Johann Sorel + * @spec ISO_12113 KHR_physics_rigid_bodies extension, Joint + * @see https://github.com/eoineoineoin/glTF_Physics/tree/master/extensions/2.0/Khronos/KHR_physics_rigid_bodies#joints + */ +public final class Joint { + + private SceneNode connectedNode; + private List<Limit> limits; + private List<Drive> drives; + private boolean enableCollision; + + /** + * Node to use for one attachment frame. + * + * @return the connectedNode + */ + public SceneNode getConnectedNode() { + return connectedNode; + } + + /** + * @param connectedNode the connectedNode to set + */ + public void setConnectedNode(SceneNode connectedNode) { + this.connectedNode = connectedNode; + } + + /** + * @return the limits + */ + public List<Limit> getLimits() { + return limits; + } + + /** + * @param limits the limits to set + */ + public void setLimits(List<Limit> limits) { + this.limits = limits; + } + + /** + * @return the drives + */ + public List<Drive> getDrives() { + return drives; + } + + /** + * @param drives the drives to set + */ + public void setDrives(List<Drive> drives) { + this.drives = drives; + } + + /** + * Flag which controls collision detection between the constrained objects + * + * @return the enableCollision + */ + public boolean isEnableCollision() { + return enableCollision; + } + + /** + * @param enableCollision the enableCollision to set + * @see #isEnableCollision() + */ + public void setEnableCollision(boolean enableCollision) { + this.enableCollision = enableCollision; + } + + public static final class Limit { + private int[] linearAxes; + private int[] angularAxes; + private double min; + private double max; + private double stiffness; + private double damping; + + /** + * The linear axes to constrain (0=X, 1=Y, 2=Z). + * + * @return the linearAxes + */ + public int[] getLinearAxes() { + return linearAxes; + } + + /** + * @param linearAxes the linearAxes to set + */ + public void setLinearAxes(int[] linearAxes) { + this.linearAxes = linearAxes; + } + + /** + * The angular axes to constrain (0=X, 1=Y, 2=Z). + * + * @return the angularAxes + */ + public int[] getAngularAxes() { + return angularAxes; + } + + /** + * @param angularAxes the angularAxes to set + */ + public void setAngularAxes(int[] angularAxes) { + this.angularAxes = angularAxes; + } + + /** + * The minimum allowed relative distance/angle. + * + * @return the min + */ + public double getMin() { + return min; + } + + /** + * @param min the min to set + */ + public void setMin(double min) { + this.min = min; + } + + /** + * The maximum allowed relative distance/angle. + * + * @return the max + */ + public double getMax() { + return max; + } + + /** + * @param max the max to set + */ + public void setMax(double max) { + this.max = max; + } + + /** + * Optional softness of the limits when beyond the limits. + * In Newton per meter (N·m-1) for linear limits . + * In Newton meter per radian (N·m·rad-1) for angular limits. + * + * @return the stiffness + */ + public double getStiffness() { + return stiffness; + } + + /** + * @param stiffness the stiffness to set + */ + public void setStiffness(double stiffness) { + this.stiffness = stiffness; + } + + /** + * Optional spring damping applied when beyond the limits. + * In Newton second per meter (N·s·m-1) for linear limits. + * In Newton second meter per radian (N·s·m·rad-1) for angular limits. + * + * @return the damping + */ + public double getDamping() { + return damping; + } + + /** + * @param damping the damping to set + */ + public void setDamping(double damping) { + this.damping = damping; + } + + } + + public static final class Drive { + public static enum Type { + LINEAR, + ANGULAR + } + + public static enum Mode { + FORCE, + ACCELERATION + } + + private Type type; + private Mode mode; + private int axis; + private double maxForce; + private double positionTarget; + private double velocityTarget; + private double stiffness; + private double damping; + + /** + * Determines if the drive affects is a linear or angular drive + * + * @return the type + */ + public Type getType() { + return type; + } + + /** + * @param type the type to set + */ + public void setType(Type type) { + this.type = type; + } + + /** + * Determines if the drive is operating in force or acceleration mode + * + * @return the mode + */ + public Mode getMode() { + return mode; + } + + /** + * @param mode the mode to set + */ + public void setMode(Mode mode) { + this.mode = mode; + } + + /** + * The index of the axis which this drive affects + * + * @return the axis + */ + public int getAxis() { + return axis; + } + + /** + * @param axis the axis to set + */ + public void setAxis(int axis) { + this.axis = axis; + } + + /** + * The maximum force that the drive can apply + * + * @return the maxForce + */ + public double getMaxForce() { + return maxForce; + } + + /** + * @param maxForce the maxForce to set + */ + public void setMaxForce(double maxForce) { + this.maxForce = maxForce; + } + + /** + * The desired relative target between the pivot axes + * + * @return the positionTarget + */ + public double getPositionTarget() { + return positionTarget; + } + + /** + * @param positionTarget the positionTarget to set + */ + public void setPositionTarget(double positionTarget) { + this.positionTarget = positionTarget; + } + + /** + * The desired relative velocity of the pivot axes + * + * @return the velocityTarget + */ + public double getVelocityTarget() { + return velocityTarget; + } + + /** + * @param velocityTarget the velocityTarget to set + */ + public void setVelocityTarget(double velocityTarget) { + this.velocityTarget = velocityTarget; + } + + /** + * The drive's stiffness, used to achieve the position target + * In Newton per meter (N·m-1) for linear limits . + * In Newton meter per radian (N·m·rad-1) for angular limits. + * + * @return the stiffness + */ + public double getStiffness() { + return stiffness; + } + + /** + * @param stiffness the stiffness to set + */ + public void setStiffness(double stiffness) { + this.stiffness = stiffness; + } + + /** + * The damping factor applied to reach the velocity target + * In Newton second per meter (N·s·m-1) for linear limits. + * In Newton second meter per radian (N·s·m·rad-1) for angular limits. + * + * @return the damping + */ + public double getDamping() { + return damping; + } + + /** + * @param damping the damping to set + */ + public void setDamping(double damping) { + this.damping = damping; + } + + } +} diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/Motion.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/Motion.java new file mode 100644 index 0000000000..b9321af596 --- /dev/null +++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/Motion.java @@ -0,0 +1,180 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.geometries.scene.physics; + +import org.apache.sis.geometries.math.Quaternion; +import org.apache.sis.geometries.math.Vector3D; + +/** + * Allows the simulation to move this node, describing parameters for that motion. + * + * @author Johann Sorel + * @spec ISO_12113 KHR_physics_rigid_bodies extension Motion + * @see https://github.com/eoineoineoin/glTF_Physics/tree/master/extensions/2.0/Khronos/KHR_physics_rigid_bodies#motions + */ +public final class Motion { + + private boolean isKinematic = false; + private double mass = 1.0; + private Vector3D.Double centerOfMass = new Vector3D.Double(); + private Vector3D.Double inertialDiagonal = new Vector3D.Double(); + private Quaternion inertiaOrientation = new Quaternion(); + private Vector3D.Double linearVelocity = new Vector3D.Double(); + private Vector3D.Double angularVelocity = new Vector3D.Double(); + private double gravityFactor = 1.0; + + /** + * When true, treat the rigid body as having infinite mass. + * Its velocity will be constant during simulation. + * + * @return the isKinematic + */ + public boolean isIsKinematic() { + return isKinematic; + } + + /** + * @param isKinematic the isKinematic to set + * @see #isKinematic() + */ + public void setIsKinematic(boolean isKinematic) { + this.isKinematic = isKinematic; + } + + /** + * The mass of the rigid body. Larger values imply the rigid body is harder to move. + * In Kilograms (kg). + * + * @return the mass + */ + public double getMass() { + return mass; + } + + /** + * @param mass the mass to set + * @see #getMass() + */ + public void setMass(double mass) { + this.mass = mass; + } + + /** + * Center of mass of the rigid body in node space. + * + * @return the centerOfMass + */ + public Vector3D.Double getCenterOfMass() { + return centerOfMass; + } + + /** + * @param centerOfMass the centerOfMass to set + * @see #getCenterOfMass() + */ + public void setCenterOfMass(Vector3D.Double centerOfMass) { + this.centerOfMass = centerOfMass; + } + + /** + * The principal moments of inertia. Larger values imply the rigid body is harder to rotate. + * In Kilogram meter squared (kg·m2). + * + * @return the inertialDiagonal + */ + public Vector3D.Double getInertialDiagonal() { + return inertialDiagonal; + } + + /** + * @param inertialDiagonal the inertialDiagonal to set + * @see #getInertialDiagonal() + */ + public void setInertialDiagonal(Vector3D.Double inertialDiagonal) { + this.inertialDiagonal = inertialDiagonal; + } + + /** + * The quaternion rotating from inertia major axis space to node space. + * + * @return the inertiaOrientation + */ + public Quaternion getInertiaOrientation() { + return inertiaOrientation; + } + + /** + * @param inertiaOrientation the inertiaOrientation to set + * @see #getInertiaOrientation() + */ + public void setInertiaOrientation(Quaternion inertiaOrientation) { + this.inertiaOrientation = inertiaOrientation; + } + + /** + * Initial linear velocity of the rigid body in node space. + * In Meter per second (m·s-1). + * + * @return the linearVelocity + */ + public Vector3D.Double getLinearVelocity() { + return linearVelocity; + } + + /** + * @param linearVelocity the linearVelocity to set + * @see #getLinearVelocity() + */ + public void setLinearVelocity(Vector3D.Double linearVelocity) { + this.linearVelocity = linearVelocity; + } + + /** + * Initial angular velocity of the rigid body in node space. + * In Radian per second (rad·s-1). + * + * @return the angularVelocity + */ + public Vector3D.Double getAngularVelocity() { + return angularVelocity; + } + + /** + * @param angularVelocity the angularVelocity to set + * @see #getAngularVelocity() + */ + public void setAngularVelocity(Vector3D.Double angularVelocity) { + this.angularVelocity = angularVelocity; + } + + /** + * Scalar value used to modify the effect of gravity on this motion + * + * @return the gravityFactor + */ + public double getGravityFactor() { + return gravityFactor; + } + + /** + * @param gravityFactor the gravityFactor to set + * @see #getGravityFactor() + */ + public void setGravityFactor(double gravityFactor) { + this.gravityFactor = gravityFactor; + } +} diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/PhysicalMaterial.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/PhysicalMaterial.java new file mode 100644 index 0000000000..99701cbe72 --- /dev/null +++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/PhysicalMaterial.java @@ -0,0 +1,130 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.geometries.scene.physics; + +/** + * Describes how the collider should respond to collisions. + * + * @author Johann Sorel + * @spec ISO_12113 KHR_physics_rigid_bodies extension, Physics Materials + * @see https://github.com/eoineoineoin/glTF_Physics/tree/master/extensions/2.0/Khronos/KHR_physics_rigid_bodies#physics-materials + */ +public final class PhysicalMaterial { + + public static enum Combine { + AVERAGE, + MINIMUM, + MAXIMUM, + MULTIPLY + } + + private double staticFriction; + private double dynamicFriction; + private double restitution; + private Combine frictionCombine; + private Combine restitutionCombine; + + /** + * The friction used when an object is laying still on a surface. + * Typical range from 0 to 1. + * + * @return the staticFriction + */ + public double getStaticFriction() { + return staticFriction; + } + + /** + * @param staticFriction the staticFriction to set + * @see #getStaticFriction() + */ + public void setStaticFriction(double staticFriction) { + this.staticFriction = staticFriction; + } + + /** + * The friction used when already moving. + * Typical range from 0 to 1. + * + * @return the dynamicFriction + */ + public double getDynamicFriction() { + return dynamicFriction; + } + + /** + * @param dynamicFriction the dynamicFriction to set + * @see #getDynamicFriction() + */ + public void setDynamicFriction(double dynamicFriction) { + this.dynamicFriction = dynamicFriction; + } + + /** + * Coefficient of restitution. + * Typical range from 0 to 1. + * + * @return the restitution + */ + public double getRestitution() { + return restitution; + } + + /** + * @param restitution the restitution to set + * @see #getRestitution() + */ + public void setRestitution(double restitution) { + this.restitution = restitution; + } + + /** + * How to combine two friction values. + * + * @return the frictionCombine + */ + public Combine getFrictionCombine() { + return frictionCombine; + } + + /** + * @param frictionCombine the frictionCombine to set + * @see #getFrictionCombine() + */ + public void setFrictionCombine(Combine frictionCombine) { + this.frictionCombine = frictionCombine; + } + + /** + * How to combine two restitution values. + * + * @return the restitutionCombine + */ + public Combine getRestitutionCombine() { + return restitutionCombine; + } + + /** + * @param restitutionCombine the restitutionCombine to set + * @see #getRestitutionCombine() + */ + public void setRestitutionCombine(Combine restitutionCombine) { + this.restitutionCombine = restitutionCombine; + } + + +} diff --git a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/Trigger.java b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/Trigger.java new file mode 100644 index 0000000000..f9d8cbeb84 --- /dev/null +++ b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/scene/physics/Trigger.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.geometries.scene.physics; + +import java.util.List; +import org.apache.sis.geometries.scene.SceneNode; + +/** + * Describes a volume which can detect collisions, but does not generate a physical response. + * + * @author Johann Sorel + * @spec ISO_12113 KHR_physics_rigid_bodies extension, Trigger + * @see https://github.com/eoineoineoin/glTF_Physics/tree/master/extensions/2.0/Khronos/KHR_physics_rigid_bodies#triggers + */ +public final class Trigger { + + private ColliderGeometry geometry; + private List<SceneNode> nodes; + private CollisionFilter collisionFilter; + + /** + * An object describing the geometrical representation of this trigger. + * + * @return the geometry + */ + public ColliderGeometry getGeometry() { + return geometry; + } + + /** + * @param geometry the geometry to set + * @see #getGeometry() + */ + public void setGeometry(ColliderGeometry geometry) { + this.geometry = geometry; + } + + /** + * For compound triggers, the set of descendant glTF nodes with a trigger + * property that make up this compound trigger. + * + * @return the nodes + */ + public List<SceneNode> getNodes() { + return nodes; + } + + /** + * @param nodes the nodes to set + * @see #getNodes() + */ + public void setNodes(List<SceneNode> nodes) { + this.nodes = nodes; + } + + /** + * describes a filter which determines if this collider should perform collision + * detection against another collider. + * + * @return the collisionfilter + */ + public CollisionFilter getCollisionFilter() { + return collisionFilter; + } + + /** + * @param collisionfilter the collisionfilter to set + * @see #getCollisionFilter() + */ + public void setCollisionFilter(CollisionFilter collisionfilter) { + this.collisionFilter = collisionfilter; + } +}
