jPCT-AE 3D engine Wrapper

alhowiriny

Member
Licensed User
Longtime User



This's full wrapper of the engine, plus addon classes which are not part of the engine, such as glsurfaceview wrapper with rendring implementation, multitouch/gestures/scale implementation, 5 Interfaces implementation ..etc.

The wrapper contains about 47 classes, the javadoc of the 3d engine is embedded inside the wrapper, so it will show as tool-tip when you type in basic4android.

Using this 3D library requires you have basic understanding of 3D. I have created 6 examples to help understand the engine (the above image is taken from these examples), you should take a look at 'HelloWorld' example which's a convert of the Java 'helloworld', it also has enough comments to get you started, all the other examples assume you've understood the 'hello world' example. The examples run on OpenGL 1, The engine is capable of running on OpenGL 2 provided you know how write Shaders.

The examples don't show the perfect way of using this engine, nor show a good programming practice in b4a, rather they show my own understanding and practice.

Since i don't have time/energy to maintain this project, the full source code of the wrapper is available as an (eclipse project). If there's bugs, errors .. you have the source, so you get to fix it. note, that i didn't test all the engine's features.

How to use:
- Extract "JPCT-AE (Lib+Wrapper).zip".
- Copy the 3 files into your basic4android library's folder.
- Open 'HelloWorld' example.
- Make sure the engine is loaded from within Libs tab, the name of the engine will be "JPCT-AE (alhowiriny)" before loading, and "JPCT-AE (version 1.0)" after loading.

I've tested the engine/examples with basic4android version 2.52, on 2 devices, both have mali400GPU. works fine for me.

JPCT-AE B4a Wrapper
JPCT-AE (Lib+Wrapper).zip

JPCT-AE Examples
jPCT-AE Examples.zip

JPCT-AE Wrapper Source (Eclipse Project)
jPCT-AE Wrapper(Eclipse Project).zip
 

Attachments

  • jpct.jpg
    81.3 KB · Views: 2,025

Stulish

Active Member
Licensed User
Longtime User
Wow

WoW they look amazing, the only problem i had was getting the hello world B4A project to work, i get:


There is defiantly a sub there:

B4X:
Sub RendrerFPS(Data As Object)
   fps.Text = Data&" FPS" '<- Data = fpsCounter
End Sub

so not sure what is going on, all the other projects run fine

Stu
 

alhowiriny

Member
Licensed User
Longtime User
Waw! I haven't been able to take a deeper look into it but at first glance this looks amazing alhowiriny. I had seen the original lib before but never had the time to convert it for b4a. Truly a great job and thank you!

Thank you.


Probably you're using older version of Basic4Android.

in "HelloWorld" example, under Jpct_SurfaceDraw, comment
the line where it says:

Jpct.SendDataTo("RendrerFPS", fpsCounter)

Or replace it with this, if you want fpsCounter logged
Log(fpsCounter)

Jpct.SendDataTo..., uses (BA.raiseEventFromDifferentThread), its the only method that uses it, which sends fpsCounter's value from the rendreing thread to the main (B4A) thread, to show the value inside a label.

The rest of the examples don't use SendDataTo, so they worked.
 

Stulish

Active Member
Licensed User
Longtime User
The Saga Continues

I commented out the 'Jpct.SendDataTo("RendrerFPS", fpsCounter)' and it worked fine.

I then added Log(fpsCounter) and the phone reset with the following logged error:

B4X:
@@@ ABORTING: INVALID HEAP ADDRESS IN dlfree addr=0x671e1000
Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 2356 (er.ServerThread)

After the reset the app runs fine and diaplays the FPS in the log

So not sure what happened.

Oh yeah i am using B4A 2.7
 

alhowiriny

Member
Licensed User
Longtime User
I dont know what that msg means, but i'm guessing its threading issue.

Don't use B4A native Log, Use JPCT Log instead. somthing like:

B4X:
Dim Logger As JpctLogger '<- put this under Process_Globals

Logger.Initialize '<- put this under Activity_Create

Logger.Log(fpsCounter) '<- put this under Jpct_SurfaceDraw, replace it with Log(fpsCounter)


now before compiling make sure you untick 'Filter' under Logs tab, and when you run the example, wait untill all the garbage in the Log tab go away, and you should see something like this:



Now, this's not what i'm intrested in. what i want to understand is why the sub rendrerfps isn't found when using SendDataTo. i've tested it with B4A 2.7 on 2 devices 4.0.3 and it works fine.

Would you please rename Sub RendrerFPS... to lowercase somthing like : Sub rendrerfps(Data As Object) and dont forget to uncomment Jpct.SendDataTo ..

does it find it?
 

Attachments

  • fps.jpg
    79.8 KB · Views: 1,693

Stulish

Active Member
Licensed User
Longtime User
I done everything you listed and the FPS did show in the Log (amongst everything else)

I changed to lowercase with the same result and then put your new library in the Additional Libs folder and now it wont compile:


Just so you know this is running on Samsung G3 with JB version 4.1.2
 

alhowiriny

Member
Licensed User
Longtime User
I see you're using jdk 1.7.0_21, while i'm using 1.6.0_31. maybe this's why it won't compile.

attached an apk i just compiled.


This's the method SendDataTo:
If someone can see anything wrong, please inform me.
B4X:
    /**
      * Send Data (Single Object) To UI thread
      * SubName: Name of the Sub to send to, ie. "MySub"
      * Data: The Data Object you need to send
      */
     public void SendDataTo(String SubName, Object Data) { 
        ba.raiseEventFromDifferentThread(getObject(),
                   null, 0, (SubName).toLowerCase(BA.cul), true, new Object[] {Data});
     }
 

Attachments

  • helloworld.apk
    364.4 KB · Views: 356

Stulish

Active Member
Licensed User
Longtime User
The APK installed and Ran fine, with the FPS displayed at the top

Not sure what my problem is, like you said maybe jdk?

Thanks

stu
 

alhowiriny

Member
Licensed User
Longtime User
The last log you posted shows you're using jdk 1.7.0_21, probably its bugged or there's issue with it & b4a libs. if you install jdk6 then from b4a IDE you can change to it.

I have deleted my previous post with the new lib, you should delete it too, and stick with the old one.
 

moster67

Expert
Licensed User
Longtime User
Thank you!

It is a bit out of my league and not something I will use in my current projects but nevertheless many thanks to you for sharing this with the B4A-community. I am sure it can be useful for many other users.
 

Informatix

Expert
Licensed User
Longtime User

The problem is not the JDK version (it only matters when you compile under Eclipse), it's because the sub has a name not compatible with the obfuscation mode. If you rename it Rendrer_FPS, that's OK.
 
Reactions: eps

PhilN

Member
Licensed User
Longtime User
Thanks dude! I'm gonna try it out... will let you know if I have any success! :sign0060:
 

ldb68

Member
Licensed User
Longtime User
Some questions.
How can I set an image backgroud?
What's the maximum size that can used for models? A 8 Mb 3ds model is not loaded.
Has anyone tried the demo on Andrdoid 4.3. On my nexus 7 pinch to zoom does not work.

thanks
 

peacemaker

Expert
Licensed User
Longtime User
And how (what software) to prepare 3D-models for using with this framework in b4a?
 

John.E

Member
Licensed User
Longtime User
And how (what software) to prepare 3D-models for using with this framework in b4a?

SketchUp (pain now it is PayWare) or you could try Blender (freebie and a full fledge design package that will allow you to do loads, just don't ask me for help, I am still learning to use it)

Oh, and while I remember ... Thanks for the wrapper alhowiriny
 
Last edited:

cbass

New Member
Licensed User
Longtime User
Does this Lib work with the Rapid debugger?

I've been playing with the tutorials successfully with the legacy debugger, but when switching to the rapid debugger, the project compiles, installs, and the activity starts, but then it throws this exception and never fully starts.

Ignoring event: jpct_surfacedraw. Raised from the wrong thread.

Nexus 7, and I tried the Tools - clean project command with no success.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…