Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
More experiments with 3D - Page 2 — Gideros Forum

More experiments with 3D

2»

Comments

  • wouaw, that looks so much better now, thank you for the explanations <3
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited December 2020
    monsieur hgy29 :) I can see in both your videos that you have shadows for all your objects in the world at once. Why doesn't it work for me? Is it due to the size of the world? My world is 512*512 pixels.

    Everytime I pass a certain limit the shadow disappears.

    I would like to position the light somewhere up in the sky (a sun) and see all the shadows of my objects :'( What am I missing?

    I have updated my GH https://github.com/mokalux/gideros-3D-FP
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • hgy29hgy29 Maintainer
    Actually I don’t, my shadows are only visible on a certain area. In the first version the area was big, but the shadows not very smooth. In the latest versions, I move the shadow area with the player, so that shadows are visible for objects nearby the player

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • thank you I will try to increase the area around the player :)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • hgy29hgy29 Maintainer
    Todays progress:
    - First world (I'd like to propose at least three worlds) elements are done. Still perfectible in many ways but already something.
    - Made a short world entry scene, basically a camera flight and a mission explanation dialogue (shortened in the video).
    - Tractor beam and item lifting/releasing works (not shown on the video)
    - I am progressing really slowly currently, having hard time building the scenery. The game story is taking form though, and the hardest part is yet to come.

    +1 -1 (+2 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited December 2020
    I have a question please :)
    Is it possible to render the animation in a render target? I don't know what the source should be the camera? the scene? or the mesh?
    I tried playing with scaling and everything but could not get a proper render, it looks like the mesh is rotated somehow.
    Could you help me please? I have a big IDEA in mind but I am stuck :)
    SOLVED: if you want to capture your model you can do:
    local camera = D3.View.new(width, height, 45, 0.1, 32)
    local rt = RenderTarget.new(256, 256)
    local bmprt = Bitmap.new(rt)
    self:addChild(bmprt)
    rt:draw(camera.view)
    <3

    Likes: MoKaLux

    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited December 2020
    I have a question please :)
    I can get the width and the height of a 3d mesh
    -- the model
    local xfile = "3d_anims/walking.json"
    local model = buildGdx(xfile, {} )
    print("MODEL SIZE", model:getWidth(), model:getHeight())
    How do I get its length (on the z axis, I don't know what it's called)? From G3DFormat.lua I can see:
    function G3DFormat.computeG3DSizes(g3d)
    ...
    elseif g3d.type=="mesh" then
    	local minx,miny,minz=100000,100000,100000
    	local maxx,maxy,maxz=-100000,-100000,-100000
    	for id=1,#g3d.indices do
    		local i=g3d.indices[id]*3-2
    		local x,y,z=g3d.vertices[i],g3d.vertices[i+1],g3d.vertices[i+2]
    		minx=math.min(minx,x)
    		miny=math.min(miny,y)
    		minz=math.min(minz,z)
    		maxx=math.max(maxx,x)
    		maxy=math.max(maxy,y)
    		maxz=math.max(maxz,z)
    	end
    ...
    if m then
    	g3d.min[1],g3d.min[2],g3d.min[3] = m:transformPoint(g3d.min[1],g3d.min[2],g3d.min[3])
    	g3d.max[1],g3d.max[2],g3d.max[3] = m:transformPoint(g3d.max[1],g3d.max[2],g3d.max[3])
    end
    end
    Thank you ;)
    I don't want to "pollute" this topic so I add my thank you here for the below answer by hgy29.
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • hgy29hgy29 Maintainer
    To get the depth, you can do model.max[3]-model.min[3]

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited December 2020
    one more question please :o
    Is it possible to set an ortographic projection? I don't know what to pass as arguments :/
    D3View=Core.class(Sprite)
    function D3View:init(sw,sh,fov,near,far)
    	self.view=Viewport.new()
    	self.projection=Matrix.new()
    	self.fov=fov or 45
    	self.near=near or 0.1
    	self.far=far or 1000
    	self:setSize(sw or 1, sh or 1)
    	self.scene=Sprite.new()
    	self.view:setContent(self.scene)
    	self:addChild(self.view)	
    end
     
    function D3View:setSize(w,h)
    	self.sw=w
    	self.sh=h
    --	self.projection:perspectiveProjection(self.fov,self.sw/self.sh,self.near,self.far)
    --	self.projection:orthographicProjection(-self.sw/2, self.sw/2, -self.sh/2, self.sh/2, self.near, self.far)
    	self.projection:orthographicProjection(0, self.sw, 0, self.sh, self.near, self.far)
    	self.view:setProjection(self.projection)
    	self.view:setPosition(self.sw/2,self.sh/2)
    	self.view:setScale(-self.sw/2,-self.sh/2,1)
    end
    Sorry for all the questions.

    EDIT: this works :)
    function D3View:setSize(w,h)
    	self.sw=w
    	self.sh=h
    --	self.projection:perspectiveProjection(self.fov,self.sw/self.sh,self.near,self.far)
    	local xx = 2.5
    	self.projection:orthographicProjection(-xx,xx,-xx,xx,self.near,self.far)
    	self.view:setProjection(self.projection)
    	self.view:setPosition(self.sw/2,self.sh/2)
    	self.view:setScale(-self.sw/2,-self.sh/2,1)
    end
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited April 2021
    "Texture coordinates range from 0 to 1 in the x and y axis. Texture coordinates start at (0,0) for the lower left corner of a texture image to (1,1) for the upper right corner of a texture image."

    Is this true for gideros too? I thought 0,0 was the top left corner!?
    "Texture coordinates start at (0,0) for the lower left corner of a texture image to (1,1) for the upper right corner of a texture image."

    Thank you :)
    float texCoords[] = {
    0.0f, 0.0f, // lower-left corner
    1.0f, 0.0f, // lower-right corner
    0.5f, 1.0f // top-center corner
    };
    Trying to learn openGL o:)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • hgy29hgy29 Maintainer
    edited April 2021
    This is true from OpenGL docs point of view, but false from Gideros point of view, and this without Gideros even swapping or messing with the coordinates.

    In OpenGL, everything is 'bottom up', in Gideros everything is 'top down'. From the texture point of view, this doesn't make a difference since OpenGL API also suppose you supply texture data starting from the bottom line. Gideros always supply texture data from the top line. So y axis is reversed in OpenGL, but input image is flipped too, so in the end this double inversion cancels the coordinate system difference.

    PS: I had to search for maybe 20 minutes to figure out why textures weren't flipped :smiley:

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited April 2021
    thank you, yes that is strange that opengl draws from bottom up and then flips the image :* I will do more tests in gideros before wasting any more of your time hgy29, sorry :(
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
Sign In or Register to comment.