Skip to content

Commit c75f168

Browse files
committed
shadow #61 disabled
1 parent 6ff3c8a commit c75f168

File tree

5 files changed

+17
-37
lines changed

5 files changed

+17
-37
lines changed

engine/src/main/java/org/andresoviedo/android_3d_model_engine/gui/Rotator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private Rotator(Widget widget) {
2222
final FloatBuffer vertexBuffer = IOUtils.createFloatBuffer(10 * 3);
2323
final FloatBuffer colorBuffer = IOUtils.createFloatBuffer(10 * 4);
2424
// build
25-
build(vertexBuffer, colorBuffer, getMaterial().getColor(), widget_dimensions);
25+
build(vertexBuffer, colorBuffer, getColor(), widget_dimensions);
2626
// setup
2727
setVertexBuffer(vertexBuffer);
2828
setColorsBuffer(colorBuffer);

engine/src/main/java/org/andresoviedo/android_3d_model_engine/model/Object3DData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ protected static class ChangeEvent extends EventObject {
144144
// defines whether this object matrix can be changed
145145
private boolean readOnly;
146146

147-
// fixed size - not dynamic
147+
// fixed place
148148
private boolean pinned;
149149

150150
// defines whether the transformations are relative to it's mass center

engine/src/main/java/org/andresoviedo/android_3d_model_engine/view/ModelRenderer.java

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public class ModelRenderer implements GLSurfaceView.Renderer {
176176
private boolean fatalException = false;
177177

178178
// shadowing
179-
private boolean doShadowing = true;
179+
private boolean doShadowing = false;
180180
private ShadowsRenderer shadowsRenderer;
181181
final Object3DData plane2 = Plane2.build();
182182
final Object3DData plane3 = Plane2.build();
@@ -381,17 +381,15 @@ public void onDrawFrame(GL10 unused) {
381381
return;
382382
}
383383

384-
// FIXME: ground plane
385-
386-
if (scene.getObjects().size() > 0 && !scene.getObjects().contains(plane2)) {
384+
// shadows
385+
if (doShadowing && scene.getObjects().size() > 0 && !scene.getObjects().contains(plane2)) {
387386
scene.getLightBulb().setLocation(new float[]{25f, 200f, 0f});
388387
plane2.setColor(Constants.COLOR_GRAY);
389388
plane2.setLocation(new float[]{0f, -50f, 0f});
390389
plane2.setPinned(true);
391390
scene.addObject(plane2);
392391
}
393392

394-
395393
float[] colorMask = BLENDING_MASK_DEFAULT;
396394
if (scene.isBlendingEnabled()) {
397395
// Enable blending for combining colors when there is transparency
@@ -456,47 +454,36 @@ public void onDrawFrame(GL10 unused) {
456454
lightPosInWorldSpace[2] = tempVector4[2];
457455

458456
// Calculate position of the light in world space to support lighting
459-
doShadowing = false;
460-
if (scene.isRotatingLight()) {
461-
doShadowing = true;
462-
} else {
457+
if (!scene.isRotatingLight()) {
463458
lightPosInWorldSpace[0] = cameraPosInWorldSpace[0];
464459
lightPosInWorldSpace[1] = cameraPosInWorldSpace[1];
465460
lightPosInWorldSpace[2] = cameraPosInWorldSpace[2];
466-
doShadowing = true;
467461
}
468462

469463
// render shadow
470464
if (doShadowing){
471465
shadowsRenderer.onPrepareFrame(unused, projectionMatrix, viewMatrix, lightPosInWorldSpace, scene);
472466
}
473467

474-
475468
drawSkyBox(viewMatrix, projectionMatrix, cameraPosInWorldSpace, colorMask);
476469

470+
477471
if (scene.isDrawLighting()) {
478472
if (scene.isRotatingLight()) {
479473
// Draw a point that represents the light bulb
480474
basicShader.draw(scene.getLightBulb(), projectionMatrix, viewMatrix, -1, lightPosInWorldSpace, colorMask, cameraPosInWorldSpace, scene.getLightBulb().getDrawMode(), scene.getLightBulb().getDrawSize());
481475
//basicShader.draw(Point.build(lightPosInWorldSpace), projectionMatrix, viewMatrix, -1, lightPosInWorldSpace, colorMask, cameraPosInWorldSpace);
482476
}
483-
484-
485-
Object3DData data = Line.build(new float[]{lightPosInWorldSpace[0],
486-
lightPosInWorldSpace[1], lightPosInWorldSpace[2], 0, 0, 0}).setId("light_line");
487-
basicShader.draw(data, projectionMatrix,
488-
viewMatrix, -1,
489-
lightPosInWorldSpace,
490-
colorMask, cameraPosInWorldSpace, data.getDrawMode(), data.getDrawSize());
491477
}
492478

493-
// FIXME: integrate this
479+
// render with shadows
494480
if (doShadowing && scene.getObjects().size() > 0) {
495481
// shadowsRenderer.onPrepareFrame(unused, projectionMatrix, viewMatrix, lightPosInWorldSpace, scene);
496482
shadowsRenderer.onDrawFrame(unused, projectionMatrix, viewMatrix, lightPosInWorldSpace, scene);
497483
return;
498484
}
499485

486+
// render
500487
if (!scene.isStereoscopic()) {
501488
this.onDrawFrame(viewMatrix, projectionMatrix, colorMask);
502489
if(camera.hasChanged()) camera.setChanged(false);

engine/src/main/res/raw/shader_animated_frag.glsl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ precision highp float;
22

33
// data
44
uniform mat4 u_MMatrix;
5-
varying vec3 v_Position;
65
uniform vec3 u_cameraPos;
7-
uniform bool u_Debug;
6+
varying vec3 v_Position;
87

98
// color
109
uniform vec4 vColor;
@@ -19,7 +18,7 @@ uniform bool u_Textured;
1918
uniform sampler2D u_Texture;
2019
varying vec2 v_TexCoordinate;
2120

22-
// lights
21+
// light
2322
uniform bool u_Lighted;
2423
uniform vec3 u_LightPos;
2524
varying vec3 v_Normal;
@@ -104,11 +103,6 @@ void main(){
104103
}
105104

106105
// calculate final color
107-
gl_FragColor = color * tex * light * vColorMask;
106+
gl_FragColor = color * tex * vColorMask * light;
108107
gl_FragColor[3] = color[3] * vColorMask[3];
109-
110-
// debug
111-
if (u_Debug){
112-
gl_FragColor = vec4(nmap,1.0);
113-
}
114-
}
108+
}

engine/src/main/res/raw/shader_animated_vert.glsl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,21 @@ uniform bool u_Coloured;
1717
attribute vec4 a_Color;
1818
varying vec4 v_Color;
1919

20-
// textures
20+
// texture
2121
uniform bool u_Textured;
2222
attribute vec2 a_TexCoordinate;
2323
varying vec2 v_TexCoordinate;
2424

25-
// normals
25+
// light
2626
uniform bool u_Lighted;
27-
//uniform mat3 u_MMatrix_Normal;
2827
attribute vec3 a_Normal;
2928
varying vec3 v_Normal;
3029

31-
// normal Map
30+
// normalMap
3231
uniform bool u_NormalTextured;
3332
uniform sampler2D u_NormalTexture;
3433

35-
// emissive Map
34+
// emissiveMap
3635
uniform bool u_EmissiveTextured;
3736
uniform sampler2D u_EmissiveTexture;
3837

0 commit comments

Comments
 (0)