I’m having some trouble understanding some various issues when working with 3D. I’m using LibGDX, but I’m not sure if my problems / knowledge gaps are more general to OpenGL or the way LibGDX does things.
Image of the scene: http://i.imgur.com/RHi8CyB.png
Legend:
(1) DirectionalLight
new DirectionalLight().set(0.8f, 0.8f, 0.8f, 2, 1, 2);
(2) PointLight
new PointLight().set(Color.RED, 1f, 0.5f, 1f, 5f);
(3) Cube’s generated inside LibGDX
ModelBuilder modelBuilder = new ModelBuilder();
Model model = modelBuilder.createBox(1f, 1f, 1f,
new Material(ColorAttribute.createDiffuse(Color.GREEN)),
Usage.Position | Usage.Normal);
ModelInstance inst = new ModelInstance(model);
(4) Default cube exported from Blender
assets = new AssetManager();
assets.load("cube.g3db", Model.class);
Model model2 = assets.get("cube.g3db", Model.class);
ModelInstance inst = new ModelInstance(model2);
All these instances are added to an Array and then rendered with as below. Instances are positioned in various places to create the layout shown. The environment contains the 2 lights, as well as some ambient lighting.
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
modelBatch.begin(camera);
modelBatch.render(instances, environment);
modelBatch.end();
Given this, I have a few questions. Even just some pointers about the correct terminology to be reading up on would be great.
a. Why do the imported cubes (4) receive the light from the PointLight(2) but the generated cubes (3) do not? Do I need to adjust the materials that are applied for this to work?
b. Why does the left most cube (4) receive the light from the PointLight(2) when the green cubes (3) are positioned in such a way that it should prevent the light from reaching it? The light passes through the cubes somehow. I don’t want to yet make the cubes cast shadows or anything like that, just block lights with the models. Or is this all the same subject of shadow mapping?
Thanks for the help, and apologies if this should have gone in the OpenGL forum.