Skip to content

Commit

Permalink
ODE4J nodes and sample application (#282)
Browse files Browse the repository at this point in the history
![2024-04-30-01](https://github.com/MarginallyClever/Robot-Overlord-App/assets/1464454/8d3c77f4-4c67-4261-9766-426ed7c4cf75)

![image](https://github.com/MarginallyClever/Robot-Overlord-App/assets/1464454/e43407ba-c464-4bb0-b49c-bae9fe41cf2b)

- Build and run latest.
- Download
[dog3.zip](https://github.com/MarginallyClever/Robot-Overlord-App/files/15173103/dog3.zip)
- Unzip this file to a folder `dog3` and open `dog3/dog3.ro` in latest
app.
- Open `Windows > ODE4J`. (1)
- In `ODE4J` tab (2), click on start icon (3).
  • Loading branch information
i-make-robots authored Jun 4, 2024
2 parents 2ad5ef2 + f1efeb1 commit e701901
Show file tree
Hide file tree
Showing 88 changed files with 3,868 additions and 500 deletions.
2 changes: 1 addition & 1 deletion .github/badges/branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion .github/badges/jacoco.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 16 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.marginallyclever</groupId>
<artifactId>RobotOverlord</artifactId>
<version>2.110.2</version>
<version>2.113.0</version>
<name>Robot Overlord</name>
<description>A friendly 3D user interface for controlling robots.</description>
<url>https://www.marginallyclever.com/</url>
Expand Down Expand Up @@ -81,6 +81,11 @@
<name>jogamp test mirror</name>
<url>https://www.jogamp.org/deployment/maven/</url>
<layout>default</layout>
</repository>
<repository>
<id>maven_central</id>
<name>Maven Central</name>
<url>https://repo.maven.apache.org/maven2/</url>
</repository><!--
<repository>
<id>snapshots-repo</id>
Expand Down Expand Up @@ -476,7 +481,7 @@
<dependency>
<groupId>org.ode4j</groupId>
<artifactId>core</artifactId>
<version>0.4.2</version>
<version>0.5.3</version>
</dependency>

<!-- for making http requests -->
Expand Down Expand Up @@ -525,6 +530,7 @@
<version>0.3.12</version>
</dependency>

<!-- dockable windows -->
<dependency>
<groupId>io.github.andrewauclair</groupId>
<artifactId>modern-docking-api</artifactId>
Expand All @@ -540,6 +546,7 @@
<artifactId>modern-docking-ui</artifactId>
<version>0.11.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.formdev/flatlaf -->
<dependency>
<groupId>com.formdev</groupId>
Expand All @@ -558,6 +565,13 @@
<artifactId>reflections</artifactId>
<version>0.10.2</version>
</dependency>

<!-- for zip file extracting in bulk -->
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>2.11.5</version>
</dependency>
</dependencies>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class FileHelper {
* - The file may be a resource inside a jar file.
* - The file may be on disk.
*
* @param filename The file to open
* @param filename The file to open. May be "filename.ext" or "zipfile.zip:filename.ext"
* @return BufferedInputStream to the file contents
* @throws IOException file open failure
*/
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/com/marginallyclever/ro3/AllPanels.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.marginallyclever.ro3;

import com.formdev.flatlaf.FlatLightLaf;
import com.marginallyclever.ro3.node.nodes.pose.poses.*;
import com.marginallyclever.ro3.apps.ode4j.ODEPhysicsSettingsPanel;
import org.reflections.Reflections;
import org.reflections.util.ClasspathHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -13,6 +14,10 @@
import javax.swing.*;
import java.awt.*;

/**
* This class should be in tests but cannot because {@link Reflections} does not work across the
* production/test boundary.
*/
public class AllPanels {
private static final Logger logger = LoggerFactory.getLogger(AllPanels.class);

Expand Down Expand Up @@ -96,19 +101,19 @@ private Collection<Class<? extends JPanel>> getHandmadeList() {
com.marginallyclever.ro3.node.nodes.LinearJointPanel.class,
com.marginallyclever.ro3.node.nodes.MaterialPanel.class,
com.marginallyclever.ro3.node.nodes.MotorPanel.class,
com.marginallyclever.ro3.node.nodes.RigidBody3DPanel.class,
com.marginallyclever.ro3.node.nodes.behavior.BehaviorTreeRunnerPanel.class,
com.marginallyclever.ro3.node.nodes.behavior.actions.LimbMoveToTargetPanel.class,
com.marginallyclever.ro3.node.nodes.behavior.decorators.RepeatPanel.class,
com.marginallyclever.ro3.node.nodes.limbplanner.LimbPlannerPanel.class,
com.marginallyclever.ro3.node.nodes.limbsolver.LimbSolverPanel.class,
com.marginallyclever.ro3.node.nodes.marlinrobotarm.MarlinRobotArmPanel.class,
ODEPhysicsSettingsPanel.class,
com.marginallyclever.ro3.node.nodes.pose.PosePanel.class,
com.marginallyclever.ro3.node.nodes.pose.poses.AttachmentPointPanel.class,
com.marginallyclever.ro3.node.nodes.pose.poses.CameraPanel.class,
com.marginallyclever.ro3.node.nodes.pose.poses.LimbPanel.class,
com.marginallyclever.ro3.node.nodes.pose.poses.LookAtPanel.class,
com.marginallyclever.ro3.node.nodes.pose.poses.MeshInstancePanel.class,
AttachmentPointPanel.class,
CameraPanel.class,
LimbPanel.class,
LookAtPanel.class,
MeshInstancePanel.class,
com.marginallyclever.ro3.texture.TextureChooserDialog.class
));
}
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/marginallyclever/ro3/RO3.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.marginallyclever.ro3;

import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.FlatLightLaf;
import com.marginallyclever.ro3.apps.RO3Frame;

import javax.swing.*;
Expand All @@ -10,11 +12,31 @@
* You can find the friendly user manual at <a href="mcr.dozuki.com">mcr.dozuki.com</a>.
*/
public class RO3 {
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(RO3.class);

public static void main(String[] args) {
Registry.start();
setLookAndFeel();

if(!GraphicsEnvironment.isHeadless()) {
SwingUtilities.invokeLater(() -> (new RO3Frame()).setVisible(true));
}
}

private static void setLookAndFeel() {
logger.info("Setting look and feel...");
FlatLaf.registerCustomDefaultsSource( "com.marginallyclever.ro3" );
//FlatLaf.registerCustomDefaultsSource("docking");
try {
UIManager.setLookAndFeel(new FlatLightLaf());
// option 2: UIManager.setLookAndFeel(new FlatDarkLaf());
} catch (Exception ignored) {
logger.warn("failed to set flat look and feel. falling back to default native look and feel");
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex) {
logger.warn("failed to set native look and feel.", ex);
}
}
}
}
27 changes: 25 additions & 2 deletions src/main/java/com/marginallyclever/ro3/Registry.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,22 @@
import com.marginallyclever.ro3.node.nodes.limbplanner.LimbPlanner;
import com.marginallyclever.ro3.node.nodes.limbsolver.LimbSolver;
import com.marginallyclever.ro3.node.nodes.marlinrobotarm.MarlinRobotArm;
import com.marginallyclever.ro3.node.nodes.pose.*;
import com.marginallyclever.ro3.node.nodes.odenode.CreatureController;
import com.marginallyclever.ro3.node.nodes.odenode.ODEHinge;
import com.marginallyclever.ro3.node.nodes.odenode.odebody.odebodies.ODEBox;
import com.marginallyclever.ro3.node.nodes.odenode.ODEPlane;
import com.marginallyclever.ro3.node.nodes.odenode.odebody.odebodies.ODECapsule;
import com.marginallyclever.ro3.node.nodes.odenode.odebody.odebodies.ODECylinder;
import com.marginallyclever.ro3.node.nodes.odenode.odebody.odebodies.ODESphere;
import com.marginallyclever.ro3.node.nodes.pose.poses.*;
import com.marginallyclever.ro3.physics.ODEPhysics;
import com.marginallyclever.ro3.node.nodes.pose.*;
import com.marginallyclever.ro3.texture.TextureFactory;

import javax.swing.event.EventListenerList;
import javax.vecmath.Vector3d;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/**
* {@link Registry} is a place to store global variables.
Expand All @@ -35,6 +42,7 @@ public class Registry {
public static final ListWithEvents<Camera> cameras = new ListWithEvents<>();
private static Camera activeCamera = null;
public static final ListWithEvents<Node> selection = new ListWithEvents<>();
private static final ODEPhysics physics = new ODEPhysics();

public static void start() {
nodeFactory.clear();
Expand Down Expand Up @@ -76,6 +84,16 @@ public static void start() {
pose.add("LookAt", LookAt::new);
pose.add("MeshInstance", MeshInstance::new);
}
NodeFactory.Category physics = node.add("Physics", null);
{
physics.add("CreatureController", CreatureController::new);
physics.add("ODEBox", ODEBox::new);
physics.add("ODECapsule", ODECapsule::new);
physics.add("ODECylinder", ODECylinder::new);
physics.add("ODEHinge", ODEHinge::new);
physics.add("ODEPlane", ODEPlane::new);
physics.add("ODESphere", ODESphere::new);
}
}
reset();
}
Expand All @@ -101,6 +119,7 @@ public static void reset() {

textureFactory.reset();
meshFactory.reset();
physics.reset();

scene = new Node("Scene");
}
Expand Down Expand Up @@ -143,4 +162,8 @@ public static Camera getActiveCamera() {
public static void setActiveCamera(Camera camera) {
activeCamera = camera;
}

public static ODEPhysics getPhysics() {
return physics;
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/marginallyclever/ro3/apps/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.awt.*;

/**
* All apps extend from App for Reflection.
* All applications in the environment extend from {@link App} for Reflection.
*/
public abstract class App extends JPanel {
public App() {
Expand Down
Loading

0 comments on commit e701901

Please sign in to comment.