maheshkurmi / OimoPhysics_Java

Java port of Oimophysics 3d Engine
3 stars 3 forks source link

OimoPhysics_Java and libGDX #1

Closed 8Observer8 closed 2 months ago

8Observer8 commented 4 months ago

Hi. I am new in Java and libGDX. How do you think, is it possible to use OimoPhysics_Java with libGDX?

maheshkurmi commented 4 months ago

Yes, there is nothing that should create any problem, although I haven't tested on Android.

On Wed, 22 May, 2024, 5:45 am Ivan, @.***> wrote:

Hi. I am new in Java and libGDX. How do you think, is it possible to use OimoPhysics_Java with libGDX?

— Reply to this email directly, view it on GitHub https://github.com/maheshkurmi/OimoPhysics_Java/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVHVBOVFVWIPLOBENG67GDZDPPTVAVCNFSM6AAAAABICSIMK2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGMYDSMZSGA3TSNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

8Observer8 commented 4 months ago

It is very cool! I have OimoPhysics on the free Glitch Node.js server side. I need it on the client side to for a client prediction. I will finish to study the following tutorial about the gdx-ode4j extension: Tutorial on creating a 3D game with LibGDX - Intro I haven't installed libraries for libGDX before. I will return to OimoPhysics_Java later and I will write about my first steps in this topic.

maheshkurmi commented 4 months ago

Using libgdx has a benefit, you need not write renderer yourself, but the downside is, you can't tweak 3d engine as libgdx uses jni wrapper for bullet engine.

It will be helpful if you write some tutorial (in case you use it) about using oimophysics with android.

On Wed, 22 May, 2024, 2:00 pm Ivan, @.***> wrote:

It is very cool! I have OimoPhysics on the free Glitch https://glitch.com/ Node.js server side. I need it on the client side to for a client prediction. I will finish to study the following tutorial about the gdx-ode4j extension: Tutorial on creating a 3D game with LibGDX

— Reply to this email directly, view it on GitHub https://github.com/maheshkurmi/OimoPhysics_Java/issues/1#issuecomment-2124184772, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVHVBO6NKDKPZGFIEZI53TZDRJSFAVCNFSM6AAAAABICSIMK2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRUGE4DINZXGI . You are receiving this because you commented.Message ID: @.***>

8Observer8 commented 4 months ago

Android and HTML5 are my target platforms. But for a while I don't know how to install third party libraries for Java even on Desktop. I know how to install libs for Desktop, Android and Web using: C++ (Qt WebAssembly) and JavaScript (I use Cordova to build APK, I have tried OimoPhysics for Android). But in Java it is not so simple like with Qt C++ and JavaScript. It will be excellent if OimoPhysics works on Android and HTML5. I feel it will be hard with Java. OimoPhysics is very simple physics engines for beginners. For example, it is much simpler to make collision detection and ray casting than with Ammo.js I want to make tutorials for OimoPhysics for Java and JavaScript in the future for Android and HTML5. I don't know how to install OimoPhysics_Java for Desktop. But I think I should finish to study the tutorial above at first.

For example, in Qt C++ I can just add source code of Box2D and Bullet Physics in Qt Creator and build executables for Android, Desktop and Web. I have made the next demo very quickly in Bullet Physics. It is a simple third person controller in OpenGL ES 2.0. Installing is very trivial: click with right mouse button on the project, select "Add Existing Directory...", select a folder with Bullet Physics

image

image

maheshkurmi commented 4 months ago

Why don't you include oimophysics java as source rather than jar?

On Wed, 22 May, 2024, 3:22 pm Ivan, @.***> wrote:

Android and HTML5 are my target platforms. But for a while I don't know how to install third party libraries for Java even on Desktop. I know how to install libs for Desktop, Android and Web using: C++ (Qt WebAssembly) and JavaScript (I use Cordova to build APK, I have tried OimoPhysics for Android). But in Java it is not so simple like with Qt C++ and JavaScript. It will be excellent if OimoPhysics works on Android and HTML5. I feel it will be hard with Java. OimoPhysics is very simple physics engines for beginners. For example, it is much simpler to make collision detection and ray casting than with Ammo.js I want to make tutorials for OimoPhysics for Java and JavaScript in the future for Android and HTML5. I don't know how to install OimoPhysics_Java for Desktop. But I think I should finish to study the tutorial above at first.

For example, in Qt C++ I can just add source code of Box2D and Bullet Physics in Qt Creator and build executables for Android, Desktop and Web. I have made the next demo very quickly in Bullet Physics. It is a simple third person controller in OpenGL ES 2.0. Installing is very trivial: click with right mouse button on the project, select "Add Existing Directory...", select a folder with Bullet Physics

image.png (view on web) https://github.com/maheshkurmi/OimoPhysics_Java/assets/3908473/6f629d9e-1a12-43eb-95d2-cd01579fd377

image.png (view on web) https://github.com/maheshkurmi/OimoPhysics_Java/assets/3908473/8ba81cf9-2fb3-4048-8214-ea70c706fa55

— Reply to this email directly, view it on GitHub https://github.com/maheshkurmi/OimoPhysics_Java/issues/1#issuecomment-2124357146, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVHVBO4M2B7PWEQ5SAIMO3ZDRTHVAVCNFSM6AAAAABICSIMK2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRUGM2TOMJUGY . You are receiving this because you commented.Message ID: @.***>

maheshkurmi commented 4 months ago

In libgdx core project copy the source of oimophysics in source directory of libgdx core project.

I think it should work.

On Wed, 22 May, 2024, 3:28 pm mahesh kurmi, @.***> wrote:

Why don't you include oimophysics java as source rather than jar?

On Wed, 22 May, 2024, 3:22 pm Ivan, @.***> wrote:

Android and HTML5 are my target platforms. But for a while I don't know how to install third party libraries for Java even on Desktop. I know how to install libs for Desktop, Android and Web using: C++ (Qt WebAssembly) and JavaScript (I use Cordova to build APK, I have tried OimoPhysics for Android). But in Java it is not so simple like with Qt C++ and JavaScript. It will be excellent if OimoPhysics works on Android and HTML5. I feel it will be hard with Java. OimoPhysics is very simple physics engines for beginners. For example, it is much simpler to make collision detection and ray casting than with Ammo.js I want to make tutorials for OimoPhysics for Java and JavaScript in the future for Android and HTML5. I don't know how to install OimoPhysics_Java for Desktop. But I think I should finish to study the tutorial above at first.

For example, in Qt C++ I can just add source code of Box2D and Bullet Physics in Qt Creator and build executables for Android, Desktop and Web. I have made the next demo very quickly in Bullet Physics. It is a simple third person controller in OpenGL ES 2.0. Installing is very trivial: click with right mouse button on the project, select "Add Existing Directory...", select a folder with Bullet Physics

image.png (view on web) https://github.com/maheshkurmi/OimoPhysics_Java/assets/3908473/6f629d9e-1a12-43eb-95d2-cd01579fd377

image.png (view on web) https://github.com/maheshkurmi/OimoPhysics_Java/assets/3908473/8ba81cf9-2fb3-4048-8214-ea70c706fa55

— Reply to this email directly, view it on GitHub https://github.com/maheshkurmi/OimoPhysics_Java/issues/1#issuecomment-2124357146, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVHVBO4M2B7PWEQ5SAIMO3ZDRTHVAVCNFSM6AAAAABICSIMK2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRUGM2TOMJUGY . You are receiving this because you commented.Message ID: @.***>

8Observer8 commented 3 months ago

I have opened the src directory and copied the oimo directory:

image

I have created a libGDX project using gdx-liftoff. I have paste the oimo directory to the project directory:

image

I see the World.java class. I think I should to include it later:

image

But now when I just try to run it (gradlew lwjgl3:run) I see this error:

com\ivan_8observer8\tut3d\oimo\dynamics\World.java:2: error: package oimo.collision does not exist
import oimo.collision.*;

Sorry. I think my questions will be primitive because I am new in Java.

maheshkurmi commented 3 months ago

What is the folder structure of the oimo directory? Does it include a collision folder? What IDE are you using?

On Thu, Jun 20, 2024 at 6:25 PM Ivan @.***> wrote:

I have opened the src directory and copied the oimo directory:

image.png (view on web) https://github.com/maheshkurmi/OimoPhysics_Java/assets/3908473/82c2b258-499f-41de-bd4b-9b6ac15bafac

I have created a libGDX project using gdx-liftoff. I have paste the oimo directory to the project directory:

image.png (view on web) https://github.com/maheshkurmi/OimoPhysics_Java/assets/3908473/22be0dbc-ce9d-43b2-b4f2-b0c690136d0e

I see the World.java class. I think I should to include it:

image.png (view on web) https://github.com/maheshkurmi/OimoPhysics_Java/assets/3908473/97edf7ab-403b-4fd4-a43c-cb6a1b28f6a2

But when I run it (gradlew lwjgl3:run) I see this error:

com\ivan_8observer8\tut3d\oimo\dynamics\World.java:2: error: package oimo.collision does not exist import oimo.collision.*;

Sorry. I think my questions will be primitive because I am new in Java.

— Reply to this email directly, view it on GitHub https://github.com/maheshkurmi/OimoPhysics_Java/issues/1#issuecomment-2180602125, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVHVBN5NQL36DR4RTUJ6E3ZILGLHAVCNFSM6AAAAABICSIMK2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBQGYYDEMJSGU . You are receiving this because you commented.Message ID: @.***>

8Observer8 commented 3 months ago

The problem was solved here: https://discord.com/channels/348229412858101762/1253357520706338837

I have installed OimoPhysics to local Maven repo.

I use Sublime Text 4 and run from CMD.

8Observer8 commented 3 months ago

@maheshkurmi the Maven's solution above works for desktop but I doesn't work for GWT. I want to try to add the oimo directory from your repo to my project. Is it possible? I want to add files as regular java-files:

image

8Observer8 commented 3 months ago

Maybe have I chosen a wrong directory to copy the oimo directory?

8Observer8 commented 3 months ago

I have tried to copy oimo directory to the following directory but the result is the same:

>gradlew lwjgl3:run

> Task :core:compileJava FAILED
E:\_Projects\Physics\OimoPhysics\libgdx-oimophysics\oimophysics-gravity-libgdx\core\src\main\java\oimo\dynamics\World.java:2: error: package oimo.collision does not exist
import oimo.collision.*;
^
E:\_Projects\Physics\OimoPhysics\libgdx-oimophysics\oimophysics-gravity-libgdx\core\src\main\java\oimo\dynamics\rigidbody\Shape.java:2: error: package oimo.collision does not exist
import oimo.collision.*;
^
2 errors

FAILURE: Build failed with an exception.

image

8Observer8 commented 3 months ago

Why package oimo.collision does not exist? It exists here:

image

8Observer8 commented 3 months ago

I have tried to move oimo to java:

image

The same error:

gradlew lwjgl3:run

Task :core:compileJava FAILED E:_Projects\Physics\OimoPhysics\libgdx-oimophysics\oimophysics-gravity-libgdx\core\src\main\java\oimo\dynamics\World.java:2: error: package oimo.collision does not exist import oimo.collision.; ^ E:_Projects\Physics\OimoPhysics\libgdx-oimophysics\oimophysics-gravity-libgdx\core\src\main\java\oimo\dynamics\rigidbody\Shape.java:2: error: package oimo.collision does not exist import oimo.collision.; ^ 2 errors

Geolykt commented 3 months ago

As the person that has been helping @8Observer8 find a solution to this problem over at the libGDX discord:

The cause for above issues are the wildcard imports; Nuking them resolves this very specific problem. As to why this is an issue for one party and not the other, it likely boils down to differences between the eclipse compiler and javac.


As a library author you should take following advice to heart: Use a standardized buildsystem like maven or gradle. And no, your IDE's buildtool does not count. This guarantees that your source code is portable and can be built across a wide configuration of systems and could have avoided parts of this saga. Further, both maven and gradle can publish and consume maven artifacts - making it much easier for people to consume your library and it's dependencies. In the end the differences between gradle (and it's flavours - that is kotlin versus groovy gradle) and maven are superficial and it boils down to whatever you prefer.

8Observer8 commented 3 months ago

The problem was solved for TeaVM and GWT on discord: https://discord.com/channels/348229412858101762/1253357520706338837

I have attacked a source code for an example for GWT/Android/Desktop that prints a gravity: oimophysics-gravity-libgdx.zip For TeaVM just put core/src/main/java/oimo directory from the attached project to core/src/main/java

GWT demo: https://667710d3dd68c8c9dcfc23fc--tut3d-libgdx.netlify.app/

Android's screenshot:

image