Loading obj model

Hi,
I’ve made a little game (https://github.com/jonli/spacestarprocessing) and now want to convert it to 3D.
I’ve done some things with spheres in P3D before, so I’m not completely new to this.
But now I’ve encountered a weird problem:
If I load the obj File for the Star in the Constructor (which is a bad Idea), it works fine (but runs extremely slow, even lags on my i5-12600k), but if I load it in setup(), it doesn’t work.
With the Debugger I saw that the loaded PShape doesn’t have any vertices, but why?
Also, weirdly only when using the debugger I get these lines in the output:

RunnableTask.run(): A caught exception occured on thread main-Display-.x11_:0-1-EDT-1: RunnableTask[enqueued true[executed false, flushed false, thread[0x33a9822b, main-Display-.x11_:0-1-EDT-1]], tTotal 0 ms, tExec 0 ms, tQueue 0 ms, attachment null, throwable java.lang.RuntimeException: Waited 5000ms for: <364c201e, 7d976186>[count 2, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.x11_:0-1-EDT-1>]
java.lang.RuntimeException: Waited 5000ms for: <364c201e, 7d976186>[count 2, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.x11_:0-1-EDT-1>
	at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198)
	at jogamp.newt.WindowImpl$ResizableAction.run(WindowImpl.java:2159)
	at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:447)
	at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:2859)
	at jogamp.newt.WindowImpl.setResizable(WindowImpl.java:2195)
	at com.jogamp.newt.opengl.GLWindow.setResizable(GLWindow.java:371)
	at processing.opengl.PSurfaceJOGL.lambda$setResizable$5(PSurfaceJOGL.java:436)
	at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:125)
	at jogamp.newt.DefaultEDTUtil$NEDT.run(DefaultEDTUtil.java:375)
DefaultEDT.run(): Caught exception occured on thread main-Display-.x11_:0-1-EDT-1: RunnableTask[enqueued false[executed true, flushed false, thread[0x33a9822b, main-Display-.x11_:0-1-EDT-1]], tTotal 5001 ms, tExec 5001 ms, tQueue 0 ms, attachment null, throwable java.lang.RuntimeException: Waited 5000ms for: <364c201e, 7d976186>[count 2, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.x11_:0-1-EDT-1>]
java.lang.RuntimeException: Waited 5000ms for: <364c201e, 7d976186>[count 2, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.x11_:0-1-EDT-1>
	at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198)
	at jogamp.newt.WindowImpl$ResizableAction.run(WindowImpl.java:2159)
	at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:447)
	at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:2859)
	at jogamp.newt.WindowImpl.setResizable(WindowImpl.java:2195)
	at com.jogamp.newt.opengl.GLWindow.setResizable(GLWindow.java:371)
	at processing.opengl.PSurfaceJOGL.lambda$setResizable$5(PSurfaceJOGL.java:436)
	at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:125)
	at jogamp.newt.DefaultEDTUtil$NEDT.run(DefaultEDTUtil.java:375)

This happens both on my PC and Laptop with Processing 4.0b7 and 4.0b8

I’ll make a new repo for the 3D version, and give links to the models, so you can replicate it.
Edit: Here’s the link: GitHub - JonLit/SpaceStarProcessing3D: SpaceStar game, written in Processing, with 3D Graphics
I included the Cirno model and texture with it’s license, but I’m not sure about the rock model and textures, so you’ll have to get them yourselves, links are provided though

Hi @JoLi ,

Have you tried using Saito OBJLoader instead of PShape?

I have worked with it in the past and it renders 3D objects quite well

I have not tried your code but it might be worth giving a shot to the library mentioned :slight_smile:

When trying to run your code I am having errors. The directories are not the same as your hard coded for textures and obj (mainly from cirno).
Also, the texture files might be missing (at least it complains from the .mtl files for the textures

1 Like