-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add the ConstWheelSettings interface
- Loading branch information
1 parent
a3008d9
commit 18f5a03
Showing
2 changed files
with
105 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ of this software and associated documentation files (the "Software"), to deal | |
*/ | ||
package com.github.stephengold.joltjni; | ||
|
||
import com.github.stephengold.joltjni.readonly.ConstWheelSettings; | ||
import com.github.stephengold.joltjni.readonly.Vec3Arg; | ||
import com.github.stephengold.joltjni.template.Ref; | ||
|
||
|
@@ -29,7 +30,9 @@ of this software and associated documentation files (the "Software"), to deal | |
* | ||
* @author Stephen Gold [email protected] | ||
*/ | ||
abstract public class WheelSettings extends SerializableObject { | ||
abstract public class WheelSettings | ||
extends SerializableObject | ||
implements ConstWheelSettings { | ||
// ************************************************************************* | ||
// constructors | ||
|
||
|
@@ -43,12 +46,56 @@ abstract public class WheelSettings extends SerializableObject { | |
// ************************************************************************* | ||
// new methods exposed | ||
|
||
/** | ||
* Alter the location of the attachment point. (native attribute: mPosition) | ||
* | ||
* @param position the location of the attachment point (in the body's local | ||
* system, not null, unaffected, default=(0,0,0)) | ||
*/ | ||
public void setPosition(Vec3Arg position) { | ||
long settingsVa = va(); | ||
float x = position.getX(); | ||
float y = position.getY(); | ||
float z = position.getZ(); | ||
setPosition(settingsVa, x, y, z); | ||
} | ||
|
||
/** | ||
* Alter the radius of the wheel. (native attribute: mRadius) | ||
* | ||
* @param radius the desired radius (in meters, default=0.3) | ||
*/ | ||
public void setRadius(float radius) { | ||
long settingsVa = va(); | ||
setRadius(settingsVa, radius); | ||
} | ||
|
||
/** | ||
* Alter the width of the wheel. (native attribute: mWidth) | ||
* | ||
* @param width the desired width (in meters, default=0.1) | ||
*/ | ||
public void setWidth(float width) { | ||
long settingsVa = va(); | ||
setWidth(settingsVa, width); | ||
} | ||
|
||
/** | ||
* Create a counted reference to the native {@code WheelSettings}. | ||
* | ||
* @return a new JVM object with a new native object assigned | ||
*/ | ||
abstract public Ref toRef(); | ||
// ************************************************************************* | ||
// ConstWheelSettings methods | ||
|
||
/** | ||
* Copy the location of the attachment point. The settings are unaffected. | ||
* (native attribute: mPosition) | ||
* | ||
* @return a new location vector (in the body's local system) | ||
*/ | ||
@Override | ||
public Vec3 getPosition() { | ||
long settingsVa = va(); | ||
float x = getPositionX(settingsVa); | ||
|
@@ -65,6 +112,7 @@ public Vec3 getPosition() { | |
* | ||
* @return the radius (in maters) | ||
*/ | ||
@Override | ||
public float getRadius() { | ||
long settingsVa = va(); | ||
float result = getRadius(settingsVa); | ||
|
@@ -78,53 +126,13 @@ public float getRadius() { | |
* | ||
* @return the width (in maters) | ||
*/ | ||
@Override | ||
public float getWidth() { | ||
long settingsVa = va(); | ||
float result = getWidth(settingsVa); | ||
|
||
return result; | ||
} | ||
|
||
/** | ||
* Alter the location of the attachment point. (native attribute: mPosition) | ||
* | ||
* @param position the location of the attachment point (in the body's local | ||
* system, not null, unaffected, default=(0,0,0)) | ||
*/ | ||
public void setPosition(Vec3Arg position) { | ||
long settingsVa = va(); | ||
float x = position.getX(); | ||
float y = position.getY(); | ||
float z = position.getZ(); | ||
setPosition(settingsVa, x, y, z); | ||
} | ||
|
||
/** | ||
* Alter the radius of the wheel. (native attribute: mRadius) | ||
* | ||
* @param radius the desired radius (in meters, default=0.3) | ||
*/ | ||
public void setRadius(float radius) { | ||
long settingsVa = va(); | ||
setRadius(settingsVa, radius); | ||
} | ||
|
||
/** | ||
* Alter the width of the wheel. (native attribute: mWidth) | ||
* | ||
* @param width the desired width (in meters, default=0.1) | ||
*/ | ||
public void setWidth(float width) { | ||
long settingsVa = va(); | ||
setWidth(settingsVa, width); | ||
} | ||
|
||
/** | ||
* Create a counted reference to the native {@code WheelSettings}. | ||
* | ||
* @return a new JVM object with a new native object assigned | ||
*/ | ||
abstract public Ref toRef(); | ||
// ************************************************************************* | ||
// native private methods | ||
|
||
|
55 changes: 55 additions & 0 deletions
55
src/main/java/com/github/stephengold/joltjni/readonly/ConstWheelSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
Copyright (c) 2024 Stephen Gold | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
package com.github.stephengold.joltjni.readonly; | ||
|
||
import com.github.stephengold.joltjni.Vec3; | ||
|
||
/** | ||
* Read-only access to {@code WheelSettings}. (native type: const WheelSettings) | ||
* | ||
* @author Stephen Gold [email protected] | ||
*/ | ||
public interface ConstWheelSettings extends ConstJoltPhysicsObject { | ||
// ************************************************************************* | ||
// new methods exposed | ||
|
||
/** | ||
* Copy the location of the attachment point. The settings are unaffected. | ||
* | ||
* @return a new location vector (in the body's local system) | ||
*/ | ||
Vec3 getPosition(); | ||
|
||
/** | ||
* Return the radius of the wheel. The settings are unaffected. | ||
* | ||
* @return the radius (in maters) | ||
*/ | ||
float getRadius(); | ||
|
||
/** | ||
* Return the width of the wheel. The settings are unaffected. | ||
* | ||
* @return the width (in maters) | ||
*/ | ||
float getWidth(); | ||
} |