Hi all,
today I want to show how to create full 3D games using B4X and my WebGL library.
This B4J demo even show how to completely change the full scene game by just load a different scene model.
After the model is loaded, it is passed to the physic engine that automatically calculate it for collisions with other bodies added by code at run time, in this case the balls.
This happen without user intervention at all.
With that template you can develop offline, or online multiplayer games with help of SocketIO.
Here the Youtube video for this project, ensure to play it at 1080p and see what the WebGL library can do for you. This is just a tiny fraction of what it can do.
Note that at minute 10:40 I switch the scene by just commenting one line and uncomment the default. This will load a different scene.
Any scene can be a model you download or you made, it can be created/edited including textures, animations etc... on CAD programs like Blender to suit your needs.
If you like my works please subscribe to my Youtube channel.
The project requires some resources, they are not big, less than 5MB, but because I cannot post here, you can find the zip file
to my Google Drive, Resources.zip, download it and place in your assets folder, after a resource refresh you are able to compile.
Note that you need WebGL library for B4J and follow (one time) instructions to setup it.
Please see the main project. The library download is on the bottom of my post, ensure to carefully read the full post: https://www.b4x.com/android/forum/threads/b4j-webgl-library.164553/
For peoples who don't know how this is.... I developed the WebGL library for B4X, that is based on a really powerful threejs library.
I managed to get a working library for desktop (Win, Linux, Mac) and Android.
For peoples who think that develop a 3D game is something almost impossible..... No, I'm not pratical to develop games, I just started from one of 100+ threejs code examples, then changed it significatly to suit my needs. I know this is not a super game, it is just a test some library functionalities. It even depends on models loaded, here only I used low-poly, the models for all 2 scenes are very small, 2 files about 5MB, I managed some scenes where I load more models 50-100MB each.
Here is the original game example project: https://threejs.org/examples/?q=fp#games_fps
I modified the code, even I edited the scene model (.glb format, that is binary GLTF) in Blender to suit my needs, so reused the model scene, changed some textures and added some other objects. After that I resaved the file and imported it with WebGL library. Yes I changed some javascript code.
Here we control the game with mouse and keyboard, but I managed to get a class that support up 4 gamepads, that already work with my Playstation gamepad with USB adapter, but because this is not recognized as standard controller, may this have to be adapted to work with other gamepads, probably only the order of controls have to be changed. It even works with bluetooth game controllers. This for desktop, on Android both USB and BT I receive some commands but others are significatly unmapped, this depends on a WebView implementation, I just used the Gamepad web API it should work on any platform. I will do some research...
Threejs can do anything with 3D, from games, to super realistic scenes, to 3D cartoons, to realistic simulations, to virtual reality, a lots of things, even manage normal and spatial audio.
You can do anything you imagine if your hardware permits it. Because it works on the web, your creations will be available on every device exposed over http, so you just need a device with web browser that have WebGL capability.
Because big differences between desktop and mobile devices I had to do a very big work to adapt the library to handle all differences between desktop and mobile devices, and finally adapted it in a way that it is fully transparent to the end user that use the library. After a lot of work it is now fully code compatible between platforms, so, any B4J code to work on desktop device will work on Android device (using B4A) and viceversa, only need one different line that is the initializer of the library, with all other code we can copy/paste between IDEs and it will works.
Enjoy
today I want to show how to create full 3D games using B4X and my WebGL library.
This B4J demo even show how to completely change the full scene game by just load a different scene model.
After the model is loaded, it is passed to the physic engine that automatically calculate it for collisions with other bodies added by code at run time, in this case the balls.
This happen without user intervention at all.
With that template you can develop offline, or online multiplayer games with help of SocketIO.
Here the Youtube video for this project, ensure to play it at 1080p and see what the WebGL library can do for you. This is just a tiny fraction of what it can do.
Note that at minute 10:40 I switch the scene by just commenting one line and uncomment the default. This will load a different scene.
Any scene can be a model you download or you made, it can be created/edited including textures, animations etc... on CAD programs like Blender to suit your needs.
If you like my works please subscribe to my Youtube channel.
The project requires some resources, they are not big, less than 5MB, but because I cannot post here, you can find the zip file
to my Google Drive, Resources.zip, download it and place in your assets folder, after a resource refresh you are able to compile.
Note that you need WebGL library for B4J and follow (one time) instructions to setup it.
Please see the main project. The library download is on the bottom of my post, ensure to carefully read the full post: https://www.b4x.com/android/forum/threads/b4j-webgl-library.164553/
For peoples who don't know how this is.... I developed the WebGL library for B4X, that is based on a really powerful threejs library.
I managed to get a working library for desktop (Win, Linux, Mac) and Android.
For peoples who think that develop a 3D game is something almost impossible..... No, I'm not pratical to develop games, I just started from one of 100+ threejs code examples, then changed it significatly to suit my needs. I know this is not a super game, it is just a test some library functionalities. It even depends on models loaded, here only I used low-poly, the models for all 2 scenes are very small, 2 files about 5MB, I managed some scenes where I load more models 50-100MB each.
Here is the original game example project: https://threejs.org/examples/?q=fp#games_fps
I modified the code, even I edited the scene model (.glb format, that is binary GLTF) in Blender to suit my needs, so reused the model scene, changed some textures and added some other objects. After that I resaved the file and imported it with WebGL library. Yes I changed some javascript code.
Here we control the game with mouse and keyboard, but I managed to get a class that support up 4 gamepads, that already work with my Playstation gamepad with USB adapter, but because this is not recognized as standard controller, may this have to be adapted to work with other gamepads, probably only the order of controls have to be changed. It even works with bluetooth game controllers. This for desktop, on Android both USB and BT I receive some commands but others are significatly unmapped, this depends on a WebView implementation, I just used the Gamepad web API it should work on any platform. I will do some research...
Threejs can do anything with 3D, from games, to super realistic scenes, to 3D cartoons, to realistic simulations, to virtual reality, a lots of things, even manage normal and spatial audio.
You can do anything you imagine if your hardware permits it. Because it works on the web, your creations will be available on every device exposed over http, so you just need a device with web browser that have WebGL capability.
Because big differences between desktop and mobile devices I had to do a very big work to adapt the library to handle all differences between desktop and mobile devices, and finally adapted it in a way that it is fully transparent to the end user that use the library. After a lot of work it is now fully code compatible between platforms, so, any B4J code to work on desktop device will work on Android device (using B4A) and viceversa, only need one different line that is the initializer of the library, with all other code we can copy/paste between IDEs and it will works.
Enjoy
Attachments
Last edited: