Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Gideros 3D — Gideros Forum

Gideros 3D

MoKaLuxMoKaLux Member
edited March 1 in General questions
Let me create this thread to talk about general Gideros 3D stuff.

I will start with the currently supported 3D formats:
- you can import .obj
- you can import .glb/.gltf
- you can import fbx (with or without animations) through fbxconv
- you can import magicavoxel (new)
- unitypackage :o
- .vox

All the above supported formats work on all os: android, windows, html5?, cannot tell for other os but should work fine according to forum feedback :)

There is although a catch with .glb:
- glb files with embedded image textures ONLY work on desktops

I am working on it DONE, see post below :)

Likes: hito9

my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
Tagged:
+1 -1 (+1 / -0 )Share on Facebook

Comments

  • MoKaLuxMoKaLux Member
    edited March 2022
    MoKaLux said:

    There is although a catch with .glb:
    - glb files with no image textures (only vertex color) work on all os
    - glb files with embedded image textures ONLY work on desktops

    I am working on it :)

    Great news, I got it working on my android with the help of hito9 :)

    There is the updated 3d-anim sample https://github.com/mokalux/GIDEROS_LUAU_SAMPLES/tree/main/3D-Anim
    @hito9 could you please check if it is working now for linux :) ?

    PS: I learnt a bit more about Gideros Buffer https://wiki.gideros.rocks/index.php/Buffer + I updated the wiki https://wiki.gideros.rocks/index.php/File_system as I could understand it :p

    Likes: hito9

    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+1 / -0 )Share on Facebook
  • hito9hito9 Member
    Accepted Answer
    MoKaLux said:

    There is the updated 3d-anim sample https://github.com/mokalux/GIDEROS_LUAU_SAMPLES/tree/main/3D-Anim
    @hito9 could you please check if it is working now for linux :) ?

    @MoKaLux, Confirm :), 3D-Anim, 3DDemo1, 3D_Collisions issues has been fixed for Linux too.
    MoKaLux said:

    PS: I learnt a bit more about Gideros Buffer https://wiki.gideros.rocks/index.php/Buffer + I updated the wiki https://wiki.gideros.rocks/index.php/File_system as I could understand it :p

    Me too thanks to you.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • Glad it is working :) pull request to gideros GH sent :)

    I got 3d-Anim working on my old samsung S5 :o

    PS: reactPhysics3D crashes on me on android :'(

    Likes: hito9

    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+1 / -0 )Share on Facebook
  • hito9hito9 Member
    Accepted Answer
    MoKaLux said:

    PS: reactPhysics3D crashes on me on android :'(

    Can you post your backtrace log for @hgy29 . As I remember it was easy to debug with Android studio.
  • MoKaLuxMoKaLux Member
    edited March 2022
    yes I am trying this with android studio but I need to find the as plugin to connect my phone via wifi (too lazy to connect it via usb :D )

    EDIT: FYI here is the debug log for reactphysics3d
    2022-03-23 09:42:43.586 5462-5495/? A/libc: Fatal signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0xc3c8f4ae in tid 5495 (GLThread 3155), pid 5462 (deros.myplayer2)
    2022-03-23 09:42:43.642 5534-5534/? E/crash_dump32: unknown process state: t
    2022-03-23 09:42:43.701 5534-5534/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    ...
    2022-03-23 09:42:43.703 5534-5534/? A/DEBUG: pid: 5462, tid: 5495, name: GLThread 3155 >>> com.gideros.myplayer2 2022-03-23 09:42:43.946 5534-5534/? A/DEBUG: #00 pc 0007f1b8 /data/app/com.gideros.myplayer2-rKjp2Uokf6LbMgpBUHDttQ==/lib/arm/libreactphysics3d.so (reactphysics3d::Set, std::__ndk1::equal_to>::add(reactphysics3d::PhysicsWorld* const&)+376) (BuildId: 27861399df68658ff5a6bef14ee8cf8e4ba316a5)
    2022-03-23 09:42:43.946 5534-5534/? A/DEBUG: #01 pc 0007f010 /data/app/com.gideros.myplayer2-rKjp2Uokf6LbMgpBUHDttQ==/lib/arm/libreactphysics3d.so (reactphysics3d::PhysicsCommon::createPhysicsWorld(reactphysics3d::PhysicsWorld::WorldSettings const&)+84) (BuildId: 27861399df68658ff5a6bef14ee8cf8e4ba316a5)
    2022-03-23 09:42:43.946 5534-5534/? A/DEBUG: #02 pc 0002d000 /data/app/com.gideros.myplayer2-rKjp2Uokf6LbMgpBUHDttQ==/lib/arm/libreactphysics3d.so (BuildId: 27861399df68658ff5a6bef14ee8cf8e4ba316a5)
    2022-03-23 09:42:43.946 5534-5534/? A/DEBUG: #03 pc 0004f608 /data/app/com.gideros.myplayer2-rKjp2Uokf6LbMgpBUHDttQ==/lib/arm/liblua.so (BuildId: 3ee4fcbdd4478ca757e431b177f16d920dfcc349)
    2022-03-23 09:42:43.946 5534-5534/? A/DEBUG: #04 pc 0002c520 /data/app/com.gideros.myplayer2-rKjp2Uokf6LbMgpBUHDttQ==/lib/arm/liblua.so (BuildId: 3ee4fcbdd4478ca757e431b177f16d920dfcc349)
    2022-03-23 09:42:43.946 5534-5534/? A/DEBUG: #05 pc 00023ec4 /data/app/com.gideros.myplayer2-rKjp2Uokf6LbMgpBUHDttQ==/lib/arm/liblua.so (lua_call+36) (BuildId: 3ee4fcbdd4478ca757e431b177f16d920dfcc349)
    2022-03-23 09:42:43.946 5534-5534/? A/DEBUG: #06 pc 001483dd /data/app/com.gideros.myplayer2-rKjp2Uokf6LbMgpBUHDttQ==/lib/arm/libgideros.so (BuildId: db5e5e7af1c5709e2476d1cd2a2a1740c01f3421)

    I will see what I can get out of this.
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • I tried to narrow down the error and found it crashes when creating the r3d world:
    LevelX = Core.class(Sprite)
     
    local r3d = require "reactphysics3d"
     
    function LevelX:init()
    	-- create r3d physics world
    	self.world=r3d.World.new(0, 0, 0) -- CRASH
    --	self.world={} -- NO CRASH
    	-- some lists to store coming objects (deco, bodies, ...)
    	self.world.deco = {}
    I am trying to found out how :)

    FYI: r3d doesn't work on html5 as well
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited March 2022
    I have an issue with r3d and collision detection nothing seems to work :'(
    Before I could write this:
    g_world:setEventListener(function()
    	-- missiles vs enemies collisions
    	for k,v in pairs(g_missiles01) do
    		for k1,v1 in pairs(g_enemies02) do
    			if g_world:testAABBOverlap(v.body, v1.body) then
    				g_score += 10
    				self.scoretf:setText("SCORE :"..g_score)
    				...
    			end
    		end
    	end
    	-- player1 vs enemies collisions
    	for k,v in pairs(g_enemies02) do
    		if g_world:testAABBOverlap(v.body, self.player1.body) then
    			self.lives -= 1
    			self.livestf:setText("LIVES: "..self.lives)
    			...
    		end
    	end
    end)
    But this no longer works.
    When I try various collision detection (testCollision, testAABBOverlap, testOverlap) I have errors like these:
    	-- world listener
    	self.world:setEventListener(function() print("xxx") end) -- BUG!?
    ERROR: scenes/levelX.lua:74: Failed to step world, something is not set up correctlyhttps://github.com/mokalux/GIDEROS_LUAU_SAMPLES/blob/21b0fea1097ccc02aecc16ea9e7416aa4a72d1a5/R3D_TypeTH/assets/scenes/levelX.lua#L39
    function LevelX:player1CollisionCallBack()
    	print("player1 down!")
    	print(self.tiled_level.player1.view) -- BUG!?
    end
    		-- test collisions
    		self.world:testCollision(v, self.tiled_level.player1.body, self.player1CollisionCallBack) -- BUG!?
    ERROR: player1 down!
    scenes/levelX.lua:53: attempt to index nil with 'player1'
    stack traceback:
    scenes/levelX.lua:53: in function player1CollisionCallBack
    scenes/levelX.lua:134: in function onEnterFrame
    https://github.com/mokalux/GIDEROS_LUAU_SAMPLES/blob/21b0fea1097ccc02aecc16ea9e7416aa4a72d1a5/R3D_TypeTH/assets/scenes/levelX.lua#L134
    ...

    I have a sample project on GH if somebody is willing to have a look: https://github.com/mokalux/GIDEROS_LUAU_SAMPLES/tree/main/R3D_TypeTH


    Thank you :)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • I need your insights :)
    How can we use https://wiki.gideros.rocks/index.php/R3d.World:setEventListener ?

    From reactbinder.cpp there is:
    class GidEventListener: public EventListener {
    public:
    	lua_State *L;
    	int cbn;
    	virtual void onContact(
    			const CollisionCallback::CallbackData& ci) {
    		int nbc=ci.getNbContactPairs();
    		for (int k=0;k
    But in lua when I try to add this code to 3D Collisions sample code:
    r3d=require "reactphysics3d"
     
    -- Create physics world
    local world=r3d.World.new(0,-9.8,0)
     
    -- various collision detection
    function collisionsEventListener()
    	print("collision")
    end
    world:setEventListener(collisionsEventListener)
    I have this error:
    Uploading finished.
    main.lua:88: Failed to step world, something is not set up correctly

    Anybody :) ?
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • hgy29hgy29 Maintainer
    It is a bug introduced by the switch to luau. I have fixed it for next release.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • Thank you hgy29 your fix works fine but I am sorry to tell there are some more bugs? regarding r3d collisions and destroy body? or is it me?
    stage:addEventListener(Event.ENTER_FRAME,function(e)
    	-- destroy body before world step?
    	if box02.body.isdirty then
    		box02.body.isdirty = false
    		print("box02 is dirty is true, try to destroy it!")
    --		world:destroyBody(box02.body) -- CRASH!
    	end
    ...
    here is a sample project which crashes gideros player with no information :'(

    PS: I tried figuring it out myself but too little experience with c++ :'(
    zip
    zip
    3D Collisions 2.zip
    167K
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • and a sample project with testAABBOverlap crash :s
    Sorry to bother guys :(
    zip
    zip
    3D Collisions 2_AABB.zip
    167K
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • hgy29hgy29 Maintainer
    @MoKaLux, in your first test it crashes because you keep querying the body (body:getTransform()) after having destroyed it. I will try to add more sanity checks to avoid crashing in these cases.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    @MoKaLux, second test is even easier: testAABBOverlap function isn't implemented

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • Perfect capitain thank you.
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • thanks to hgy29 I managed to put a 3d collision 2. I would like to propose it as an additional demo to gideros build?
    It demonstrates quite a few steps:
    - r3d.Fixture:setMaterial(material)
    - destroybody
    - move body with arrow keys

    It is the same as current 3d collision, so we could also change it with this new demo? What do you think?
    zip
    zip
    3D Collisions 2.zip
    132K
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited February 2023
    there is a memory leak when using Gideros 3dbase files.

    When you switch from menu to level the models data are kept in memory and the memory will add up every time you switch from menu to level.

    The issue seems to be related to D3Anim, D3, G3DFormat not being freed (even when I nil the models before going to the menu scene) :'(

    Do you know how I could prevent the memory leaks, what are the biggest values (tables) that could be nilled?

    I have a test file attached.

    Thank you for any help :)
    zip
    zip
    3D-Anim02.zip
    414K
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited February 2023
    I kinda solved it for my use case, I keep a copy of the models (obj and animated) and reuse them if they exist ;)
    self.model = g_oappmodel or loadObj(finalfolder, self.finalfilewithext)
    g_oappmodel = self.model
    self.model = g_appmodel or buildGdx(self.jsondecoded)
    g_appmodel = self.model
    Viva Gideros!
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited October 2023
    Good morning guys :)
    In 3D is there an OpenGL parameter I can tweak so a texture is not hidden by a transparent texture placed above it?
    Some images to make more sense :D
    Image 3 is the back view of a 3D wall clock with a texture

    Image 2 is the thin glass (semi-transparent) over the wall clock

    Image 1 is the front of the wall clock (with the thin glass above it) which hides the texture below it :'(


    I don't know if it is has something to do with clipping, an OpenGL setting or ... :s

    Any hints would be much appreciated ;) , thank you :)

    PS: this is an .obj 3D object rendered through a render target using the 3dbase libraries

    PS2: I tried setCullMode but the images are not drawn at all when rotating the object (Sprite.CULL_FRONT, Sprite.CULL_BACK)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • hgy29hgy29 Maintainer
    Accepted Answer
    I don't think this has to do with clipping or alpha, but with depth buffer. Are you always rendering your objects from back to front (relative to the camera) ? Are you using different Z values (so that objects aren't within each other but actually layered) ?

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited October 2023
    @hgy29 the clock is one .obj file (I merged all the objects into 1) but they each have their own texture. For example the "cadran" has a wood texture, the back face of the clock has its texture, the glass has a semi-transparent texture, ...

    So I would say the object (the textures) is rendered from back to top(?) and this relative to the camera (the object can rotate though).

    The values for the Z layer (for the object and the textures) should be different, I would say the back of the clock, then the "cadran" then the glass(?).


    PS: this happens only with textures. For an .obj car with vertex color (no textures), the car has some windows and I can see through the window (for example the interior of the car) :)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • PaulHPaulH Member
    Accepted Answer
    I believe hgy29 is exactly right. It's a depth buffer issue. Partially transparent surfaces can be a pain in 3D:

    Within the single 3D model the surfaces don't get rendered in an order you can easily rely on. Any surfaces that include transparent areas might occlude surfaces behind it, since the farther surfaces might get rendered after the near ones, and any surface, even one with a transparent texture, will update the depth buffer. That is, it marks that spot on the image as having been drawn at the distance of that surface, and not to bother drawing any surfaces further away on that part of the screen.

    What I do to deal with this is make two versions of the model: One that includes all the opaque textures, and one for the transparent ones. Then I load both models, opaque one first, and keep them in the same position and orientation at all times. Then the translucent ones get rendered last.

    You could take this further, making it simpler to deal with these kinds of models, by having two children of the 3D scene, added in order: One for all the opaque objects, and one for all the transparent or translucent ones. Then all the the solid objects will be rendered first, and visible through all the translucent ones.

    If objects aren't included in the scene in order so the nearest ones are first (which is computationally expensive to maintain if the objects or the camera are moving a lot) then having all the transparencies in one child like that, you would still see some nearer partially transparent surfaces occlude others behind them.

    Paul

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited October 2023
    thank you guys for the information, really appreciated ;)
    I now have a better understanding of 3D and depth buffer issue :)

    EDIT: I managed to make it work :)

    What I did was in Blender, instead of merging the objects (clock, wood, needles, glass) I parented them to the wood object (maybe I am lucky that the z order is correct?)

    Viva Gideros!
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited March 1
    Continuing on Gideros and 3D, there is this code which can be nice, I post it for information o:) https://github.com/ufbx/ufbx
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
Sign In or Register to comment.