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

React Physics 3D

MoKaLuxMoKaLux Member
edited December 2020 in Game & application design
Let me create this post to share my progress with gideros and react physics 3d and animations.
What I have done:
-imported a 3d model from mixamo to blender to gideros
-animated it in gideros
-built a level with Tiled (from a top down view perspective)
-you control the player with arrow keys

What is left:
-"writing" a class for each type of shape I would like (plane, cube, circle, ...)
-"writing" a class to import obj or fbx
-adding other characters (why always enemies)
-I don't want to make it an FPS (I am a peaceman)
-but he needs to throw something (pebbles?)
-...
-always having fun :)

I try to keep GH up to date: https://github.com/mokalux/gideros-3D-FP

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

Comments

  • hgy29hgy29 Maintainer
    Great to see 3D projects progressing with Gideros. I am progressing on my own lander game too, I'll post another video soon. While looking for tools to create terrains for 3D games, I discovered a great free tool: TerreSculptor. http://www.demenzunmedia.com/home/terresculptor/
    It is usable with any engine, even Gideros of course.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • great I am downloading it see what I can do to help building my world :) Thank you hgy29 <3
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited December 2020
    I can't seem to use materials anymore in gideros r3d. According to the r3d 0.8 official doc this should still work:
    Now we need to call get and set material on the fixture:
    -- materials
    --local mat = view.body:getMaterial() -- default: bounciness = 0.5, frictionCoefficient = 0.3, rollingResistance = 0
    local mat = fixture:getMaterial() -- default: bounciness = 0.5, frictionCoefficient = 0.3, rollingResistance = 0
    mat.bounciness = 0.1
    mat.frictionCoefficient = 0.5
    mat.rollingResistance = 0.1 -- 0 = no resistance, 1 = max resistance
    fixture:setMaterial(mat)
    Will try to update wiki asapDONE.
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+2 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited December 2020
    I have a problemSOLVED :) How can I apply 2 matrices to 1 object? 1 matrix to apply position/rotation and the other matrix to apply scale?
    function LevelX:onEnterFrame(e)
    	local matrix2
    	for k, v in pairs(self.world.dynamicbodies) do
    		matrix2 = v.body:getTransform()
    		k:setMatrix(matrix2)
    --		k:setPosition(v.matrix:getPosition())
    --		k:setRotation(v.matrix:getRotation())
    		k:setScale(v.matrix:getScale()) -- PROBLEM
    	end
    end
    The code above almost works but:
    -when I comment the line PROBLEM the ball rolls but has wrong scale
    -when I uncomment the line PROBLEM the ball doesn't roll but has correct scale

    How would you go about it please?

    One solution would be to implement R3d.Body:getTransform() to return the scale of the body along the position and rotation values. That would be cool! https://wiki.gideros.rocks/index.php/R3d.Body:getTransform

    Another solution was to modify the sphere class to add a radius to it:
    local Sphere3Db=Core.class(Mesh3Db)
     
    function Sphere3Db:init(radius, steps)
    	local va,ia={},{}
    	local rs=(2*3.141592654)/steps
    	local i,ni=4,1
    	--Vertices
    	va[1]=0 va[2]=1 va[3]=0
    	for iy=1,(steps//2)-1 do
    		local y=math.cos(iy*rs) * radius
    		local r=math.sin(iy*rs) * radius
    		for ix=0,steps do
    			local x=r*math.cos(ix*rs)
    			local z=r*math.sin(ix*rs)
    			va[i]=x i+=1
    			va[i]=y i+=1
    			va[i]=z i+=1
    		end
    	end
    	va[i]=0	va[i+1]=-1 va[i+2]=0
    	local lvi=i//3+1
    	--Indices
    	--a) top and bottom fans
    	for i=1,steps do
    		ia[ni]=1 ni+=1 ia[ni]=i+1 ni+=1 ia[ni]=i+2 ni+=1
    		ia[ni]=lvi ni+=1 ia[ni]=lvi-i ni+=1 ia[ni]=lvi-i-1 ni+=1
    	end
    	--b) quads
    	for iy=1,(steps//2)-2 do
    		local b=1+(steps+1)*(iy-1)
    		for ix=1,steps do
    			ia[ni]=b+ix ni+=1 ia[ni]=b+ix+1 ni+=1 ia[ni]=b+ix+steps+1 ni+=1
    			ia[ni]=b+ix+steps+1 ni+=1 ia[ni]=b+ix+1 ni+=1 ia[ni]=b+ix+steps+2 ni+=1
    		end
    	end
    	self:setGenericArray(3,Shader.DFLOAT,3,lvi,va)
    	self:setVertexArray(va)
    	self:setIndexArray(ia)
    	self._steps=steps
    	self._va=va self._ia=ia
    end
    There is a little "hole" at the bottom of my spheres but that's ok, now my spheres roll like gideros rocks.
    image.png
    601 x 411 - 429K
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited December 2020
    I have a problem ;) I have some fbx files with apparently more than one textures embeded. They produce:
    "attributes": [
    "POSITION", "NORMAL", "COLOR", "TEXCOORD0", "TEXCOORD1", "TEXCOORD2", "TEXCOORD3", "TEXCOORD4",
    "TEXCOORD5", "TEXCOORD6", "TEXCOORD7"
    , "BLENDWEIGHT0", "BLENDWEIGHT1", "BLENDWEIGHT2", "BLENDWEIGHT3"
    ],

    only TEXCOORD0 is recognised by gideros 3DGdxLoader. I tried to add the other TEXCOORD but that doesn't seem to work (I don't see my fbx in the scene).
    	for _,a in ipairs(gm.attributes) do		
    		if a=="POSITION" then as=3 an="v"
    		elseif a=="NORMAL" then as=3 an="n"
    		elseif a=="COLOR" then as=4 an="c"
    		elseif a=="TEXCOORD0" then as=2 an="t"
    -- fix?
    		elseif a=="TEXCOORD1" then as=2 an="t"
    		elseif a=="TEXCOORD2" then as=2 an="t"
    		elseif a=="TEXCOORD3" then as=2 an="t"
    		elseif a=="TEXCOORD4" then as=2 an="t"
    		elseif a=="TEXCOORD5" then as=2 an="t"
    		elseif a=="TEXCOORD6" then as=2 an="t"
    		elseif a=="TEXCOORD7" then as=2 an="t"
    -- fix?
    		elseif a:sub(1,11)=="BLENDWEIGHT" then as=2 an="bw"..a:sub(12,12)
    		else assert(false, "Attribute not handled:"..a) end
    		attrs[an]={ ab=ds, al=as, d={} }
    		ds+=as
    	end
    Do you know if the above code is valid?
    EDIT: that seems to work :) I have lost my texture though will try to find where the texture is (ps: it is animated too).

    GH updated
    r3d03.png
    601 x 411 - 360K
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited December 2020
    ok that was all fun and stuff but I am stuck building my levels :o
    I tried to look at some programs to build them but found Tiled to be the best so far. I build my level from a top down view but that's not a problem at all.

    The biggest issue I have is attaching collision shapes to my meshes. For example I have some houses scattered around the level and I would like the player to be able to enter those.

    My process was placing the mesh houses with no collision in a Tiled layer then on another level layer I was adding the collision for the walls, that works but it takes tooooo long to do.

    Another solution would be to build the houses from parts (walls, roof, doors, ...) and build them by hand but that seems complicated too :p

    I need to give it some time and get back to it later. In the meantime I had the idea to make a 3d platformer B) That seems feasible, it should be a mario like 2d platformer but in 3d :)

    I think I have everything I need: gideros - Tiled - reactphysics3d - animation

    Wish me luck and a nice YT serie should I succeed.

    Viva gideros!
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+3 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited April 2021
    Where do I find reactphysics3d files in gideros GH?
    I am looking for this r3d file: ContactSolverSystem.cpp
    more precisely this line: if (mContactPoints[contactPointIndex].penetrationDepth > SLOP) biasPenetrationDepth = -(beta/mTimeStep) *
    or even this file? reactphysics3d/reactphysics3d.h

    They are hidden somewhere :/
    Thank you :)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • hgy29hgy29 Maintainer

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited February 2022
    I updated my r3d gideros project to latest gideros 2022.1.3b and I am happy to share it on github https://github.com/mokalux/GIDEROS_LUAU_SAMPLES

    Feel free to ask any questions, I will try to answer :p


    You control the character (the female from the gideros 3d sample) with IJKL + W to jump. The level is built using Tiled (available in the repo). I am looking forward to enhance it :)

    Viva Gideros Luau!

    PS: at hgy29 I would like to make it an official demo in a future Gideros release with your permission of course ;)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+2 / -0 )Share on Facebook
  • hito9hito9 Member
    edited February 2022
    I got this error with a newly Build.Linux but there may be a incomplete job when compiling on my side
    DELETED
  • MoKaLuxMoKaLux Member
    edited February 2022
    @hito9 I think you got the wrong github repo. I believe the one you posted screenshot of was r3d project using previous Gideros (2021.11). For the latest r3d demo using Gideros 2022.1.3b are you using this repo: https://github.com/mokalux/GIDEROS_LUAU_SAMPLES ? Lua shaders were rewritten for luau.

    PS: I barely know any shaders programming so cannot help on this side, sorry :s

    Likes: hito9

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

    the latest r3d demo using Gideros 2022.1.3b are you using this repo: https://github.com/mokalux/GIDEROS_LUAU_SAMPLES ? Lua shaders were rewritten for luau.

    Yes, your are right. The Luau version of your project worked fine :) Keep up doing good work.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    MoKaLux said:

    at hgy29 I would like to make it an official demo in a future Gideros release with your permission of course ;)

    With great pleasure of course. Tell me when it is ready to turn into an example, I'll grab a copy and integrate it into Gideros

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.