j-rewerts / min3d

Automatically exported from code.google.com/p/min3d
0 stars 0 forks source link

Diffiuse Specular etc not loaded from obj file #22

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If i enable lightning on an obj without textures i dont see the colours. The 
colours are loaded but it doesnt work. I'm trying to make it work now and i 
think it has todo with the following code not being executed.... however it 
deosnt work yet. Maybe you now the solution?

// the approach is just a proof-of concept
// but it doesnt work

            FloatBuffer f = FloatBuffer.allocate(4);
            f.put(1f);
            f.put(0.4f);
            f.put(0.4f);
            f.put(1f);
            f.position(0);
            _gl.glMaterialfv(GL10.GL_FRONT, GL10.GL_DIFFUSE, f);
            f.position(0);
            _gl.glMaterialfv(GL10.GL_FRONT, GL10.GL_AMBIENT, f);
            f.position(0);
            _gl.glMaterialfv(GL10.GL_FRONT, GL10.GL_EMISSION, f);
            f.position(0);
            _gl.glMaterialfv(GL10.GL_FRONT, GL10.GL_SPECULAR, f);

            _gl.glMaterialf(GL10.GL_FRONT, GL10.GL_SHININESS, 15.0f);

Original issue reported on code.google.com by tje...@gmail.com on 15 Nov 2010 at 10:01

GoogleCodeExporter commented 9 years ago
I was wrong this is not it.
However what i did to make it work was:

if ($o.hasVertexColors() && $o.vertexColorsEnabled()) {
            $o.vertices().colors().buffer().position(0);
            _gl.glColorPointer(4, GL10.GL_UNSIGNED_BYTE, 0, $o.vertices().colors().buffer());
            _gl.glMaterialfv(GL10.GL_FRONT, GL10.GL_SPECULAR, $o.vertices().speculars().floatBuffer(null));
            _gl.glEnableClientState(GL10.GL_COLOR_ARRAY); 
        }
        else {
            _gl.glColor4f(
                (float)$o.defaultColor().r / 255f, 
                (float)$o.defaultColor().g / 255f, 
                (float)$o.defaultColor().b / 255f, 
                (float)$o.defaultColor().a / 255f
            );
            _gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
        }

So now the specular is loaded. I also always enable material (not sure if its 
needed)

// Colormaterial
        _gl.glEnable(GL10.GL_COLOR_MATERIAL);
        /*
        _gl.glGetIntegerv(GL10.GL_COLOR_MATERIAL, _scratchIntBuffer);
        _scratchB = (_scratchIntBuffer.get(0) != 0);
        if ($o.colorMaterialEnabled() != _scratchB) {
            if ($o.colorMaterialEnabled())
                _gl.glEnable(GL10.GL_COLOR_MATERIAL);
            else
                _gl.glDisable(GL10.GL_COLOR_MATERIAL);
        }
        */

Original comment by tje...@gmail.com on 17 Nov 2010 at 6:06

GoogleCodeExporter commented 9 years ago
I met same trouble.
So please let me know how to make vertices().speculars().
It is not in trunk.

Thank you.
>           _gl.glMaterialfv(GL10.GL_FRONT, GL10.GL_SPECULAR, 
$o.vertices().speculars().floatBuffer(null));

Original comment by tom...@wh2.fiberbit.net on 13 Apr 2011 at 4:11

GoogleCodeExporter commented 9 years ago
Please let me know how to make vertices().speculars() too...
Thanks.

Original comment by CH.Long...@gmail.com on 1 Aug 2012 at 7:17

GoogleCodeExporter commented 9 years ago
This project is dead since 2011.
You might find libGDX project helpful:

http://libgdx.badlogicgames.com/
http://badlogicgames.com/forum/
http://code.google.com/p/libgdx-users/
http://www.badlogicgames.com/wordpress/?p=2411

Original comment by radiok...@gmx.de on 1 Aug 2012 at 10:37

GoogleCodeExporter commented 9 years ago
Thanks, I will see what can I get in your provide URLs.

Original comment by CH.Long...@gmail.com on 2 Aug 2012 at 2:35