GLBasic forum

Main forum => Bug Reports => Topic started by: mentalthink on 2011-Oct-18

Title: Problem 3d on Android
Post by: mentalthink on 2011-Oct-18
Hi in Android I have a very strange effect in 3D.

I explain but it´s a little confuse, when you draw somethings geomtries, in example making a for, and repeat sometimes a geometry, you have an extrange effect like if any geometry is over the previous geometry, in some cases parts of the geometries turns transparents when rotating the objects.

NOT it´s a trouble of X_Cullmode I try all modes -1,0 and 1 and the effects occurs, but drawing the normal what you select whit X_Cullmode.

PS: If it´s too much confuse I try to make a capture in Android and Palm Pre...
Title: Re: Problem 3d on Android
Post by: Kitty Hello on 2011-Oct-18
We noticed that too. It's terrible. As if the z-buffer was inverse.
Title: Re: Problem 3d on Android
Post by: mentalthink on 2011-Oct-18
Ok Gernnot don´t care, my game don´t go to the market in a long time... only was for advice.
Thanks
Title: Re: Problem 3d on Android
Post by: MrTAToad on 2011-Oct-19
It is weird - the only thing I can suggest is change your rendering order...
Title: Re: Problem 3d on Android
Post by: Kitty Hello on 2011-Oct-19
maybe there's no Z-buffer in use AT ALL!?

Can someone quickly test a plane and an intersecting triangle?
Title: Re: Problem 3d on Android
Post by: Minion on 2011-Nov-27
Sorry to highjack this thread, but I too have a problem with Android and 3D and it seemed a bit silly starting up a new thread when this one will sufice. Basically, everything runs fine on the PC (Colour wise), but on my phone the image is coming back all blue ;(

The first pic is how it should look, the 2nd is how it looks on my phone (ive manually edited it to look like that, cant get a decent snap shot of the actual phone screen, sorry). It looks like there is no red or green component.

[attachment deleted by admin]
Title: Re: Problem 3d on Android
Post by: MrTAToad on 2011-Nov-27
Are you using ambient lighting or a spot light ?
Title: Re: Problem 3d on Android
Post by: Minion on 2011-Nov-27
Thankyou MrTAToad. Its my first venture into 3D (In GLB) and had assumed that some form of lighting was required, so had an ambient light of 0xffffff. Had I tried without that it works fine. Thank you. Now... this ambient light problem with Android ..... ;)
Title: Re: Problem 3d on Android
Post by: MrTAToad on 2011-Nov-27
That ambient light value should be fine (and should be white) - I presume you use RGB(255,255,255)
Title: Re: Problem 3d on Android
Post by: matchy on 2014-May-30
This seems to be still a an issue as X_ENABLE_Z has no effect in Android. When setting X_ENABLE_Z as false in WIN32 is what it looks like on the Android. For just one object only and it is fine with the camera internally, but external display the X_OBJADDVERTEX group order.

Can this be set? Otherwise I'll break down objects and z-ordering so without having the camera on the inside/backside. For example, a wall with four sides as one object should be four object walls pushmatrixed as a room.

Title: Re: Problem 3d on Android
Post by: mentalthink on 2014-May-30
My recomendation Minion(Wellcome) it's use the Kanonet Library of OpenGL or mine... Kanonet it's better done but mine have a bit more of contorl over the lights...
GLbasic by default it' a bit poor in 3D... but you can do cool things using AO, and global ilumination from a 3D suite.
Title: Re: Problem 3d on Android
Post by: erico on 2014-May-30
Hi Mental, the thread is old, it is more about Matchy´s latest question, which unfortunantly I have no clue about.

Would your or kanonet´s lib work on android?
Title: Re: Problem 3d on Android
Post by: mentalthink on 2014-May-30
JAJAJ!!!  =D =D I read the question of Minion and I thinked was this...

About the Libraries, I think the Kanonet have to work... mine yes works in anyplace... I only take the OpenGlES 1.1 and make more commands... I test in devices like PalmPre and runs fine... I'm not sure 100% all commands runs fine , but you can do more interesting things than using the default with GLBasic.
Title: Re: Problem 3d on Android
Post by: matchy on 2014-May-31
Could it be simply a inline opengl command for enabling the (object face) zorder?
I have used Kanonet's libESL but the OpenGL commands relate to light. mentalthink, where is your library?
:whistle:
Experimentally, from the camera origin I radially draw objects in zorder fine. So now I would have to reallocate how an object would be drawn with software face culling. Let's say, a cube is created with the front, back, left, right, top and then bottom. To view this from another angle, either a fixed or runtime object would be used.
Title: Re: Problem 3d on Android
Post by: kanonet on 2014-May-31
I dont really understand what you want to do/is not working.

I think mental was talking about my light fixes (http://www.kanonet.de/downloads/lightsfixes), even though its no lib, more a demonstration how to do it.
Title: Re: Problem 3d on Android
Post by: erico on 2014-May-31
I think Mental wrapped an opengl lib compatible to opengls 1.0 couple years ago, I think he relates to that.
I did a few searched but did not find the topic, better wait for Mental to check it.

MAtchy, you may also take a look at this:
http://www.glbasic.com/forum/index.php?topic=6982.0

Title: Re: Problem 3d on Android
Post by: matchy on 2014-May-31
Quote from: Kitty Hello on 2011-Oct-19
maybe there's no Z-buffer in use AT ALL!?

Can someone quickly test a plane and an intersecting triangle?

Quote from: kanonet on 2014-May-31
I dont really understand what you want to do/is not working.

Z_ENABLE TRUE is not working on Android.

Title: Re: Problem 3d on Android
Post by: erico on 2014-May-31
you doing that with incode objects?
Title: Re: Problem 3d on Android
Post by: matchy on 2014-May-31
Yes. It's simple a tiled room with a face for each four directions. It happens for either one whole or many objects.
Title: Re: Problem 3d on Android
Post by: erico on 2014-May-31
I was wondering, because you are using flat polygons.
Would the same happen if the tile was actually a cube? I mean the wall has a thickness?

I ask that because in software packages there are a bunch of troubles in open gl and render whe you have a flat object, usually adding a thickness to it resolves the visuals.

EDIT: I meant about those faces for each direction, that it has a thickness but as a connected 3d object. not loose polygons.
Title: Re: Problem 3d on Android
Post by: matchy on 2014-May-31
There's no difference with a cube.  :'(
Title: Re: Problem 3d on Android
Post by: erico on 2014-May-31
I mean if each wall and floor and ceiling is made of an object like this.
So if you want a room, you have 6 of this object forming a cube.

edit: maybe stretched as you have in the img, vertical tiles, but see if this helps. :)
edit2:post a picture of the results so I get an idea of what is happening.
Title: Re: Problem 3d on Android
Post by: matchy on 2014-May-31
The rooms are tiled cubed spaces and it matter which way the polys are plotted.

When I trick block.ddd only one wall shows up on my map at 0, 0. Have you got a block cube of size 1.0³?
Title: Re: Problem 3d on Android
Post by: erico on 2014-May-31
That size is hard to guess here Matchy.
The object I sent you is reported to be a 1meter by 1 meter in size, 20milimiters in thickness center object´s pivot by my 3d app.
I then translated it to DDD by GLBasic´s tool.

According to that, what would be the size you need?

edit:ops, I sent only ony side, like the appended image.
Title: Re: Problem 3d on Android
Post by: matchy on 2014-May-31
It seems to be 1.0 in height but one face back and front is all that I see.
Title: Re: Problem 3d on Android
Post by: erico on 2014-May-31
maybe I should add a uvmap to it to easy up visualizing?
Title: Re: Problem 3d on Android
Post by: matchy on 2014-May-31
No need as the uvmap relates to to the texture. Are you able to test it in GLBasic?
Title: Re: Problem 3d on Android
Post by: erico on 2014-May-31
I can test code done now, I can´t code, my brother is home for a two days finally hehe
Title: Re: Problem 3d on Android
Post by: erico on 2014-May-31
Send it over matchy, I give a go, you have my email ;)
Title: Re: Problem 3d on Android
Post by: matchy on 2014-May-31
Oh, can you just put some simple 3d code?
Title: Re: Problem 3d on Android
Post by: erico on 2014-May-31
here it goes, you might want a cube with flipped surface, but here is a normal one.
Title: Re: Problem 3d on Android
Post by: matchy on 2014-May-31
Still the same erico.  :(

Here's test code!  :P

Code (glbasic) Select

// --------------------------------- //
// Project: z_denabled
// Start: Sunday, June 01, 2014
// IDE Version: 11.414

TYPE _obj
id
index
texture_id
screen_id
x
y
z
px
py
pz
width
height
depth
color_value
ENDTYPE

GLOBAL sprite AS _obj
GLOBAL block AS _obj

loop()

FUNCTION paint_test_pattern:
LOCAL obj AS _obj, i
obj.x = 0
obj.y = 0
obj.width = sprite.width / 2
obj.height = sprite.height / 2
FOR obj.py = 0 TO 1
FOR obj.px = 0 TO 1
obj.x = obj.px * obj.width
obj.y = obj.py * obj.height
SELECT i
CASE 0
obj.color_value = 0x0000ff
CASE 1
obj.color_value = 0x00ff00
CASE 2
obj.color_value = 0xff0000
CASE 3
obj.color_value = 0xff00ff
ENDSELECT
INC i
DRAWRECT obj.x, obj.y, obj.width, obj.height, obj.color_value
NEXT
NEXT
ENDFUNCTION

FUNCTION load_block:
block.id = GENX_OBJ()
X_LOADOBJ "Media/block.ddd", block.id
ENDFUNCTION

FUNCTION create_block:
block.id = GENX_OBJ()
X_OBJSTART block.id
X_OBJADDVERTEX -0.5, +1.0, -0.5,  0.0, 0.0,  0xffffff
X_OBJADDVERTEX -0.5, +1.0, +0.5,  0.5, 0.0,  0xffffff
X_OBJADDVERTEX -0.5, +0.0, -0.5,  0.0, 1.0,  0xffffff
X_OBJADDVERTEX -0.5, +0.0, +0.5,  0.5, 1.0,  0xffffff
X_OBJNEWGROUP // LEFT
X_OBJADDVERTEX +0.5, +1.0, +0.5,  1.0, 0.0,  0xffffff
X_OBJADDVERTEX +0.5, +1.0, -0.5,  0.5, 0.0,  0xffffff
X_OBJADDVERTEX +0.5, +0.0, +0.5,  1.0, 1.0,  0xffffff
X_OBJADDVERTEX +0.5, +0.0, -0.5,  0.5, 1.0,  0xffffff
X_OBJNEWGROUP // RIGHT
X_OBJADDVERTEX -0.5, +1.0, -0.5,  0.0, 0.0,  0xffffff
X_OBJADDVERTEX +0.5, +1.0, -0.5,  0.5, 0.0,  0xffffff
X_OBJADDVERTEX -0.5, -0.0, -0.5,  0.0, 1.0,  0xffffff
X_OBJADDVERTEX +0.5, -0.0, -0.5,  0.5, 1.0,  0xffffff
X_OBJNEWGROUP // FRONT
X_OBJADDVERTEX +0.5, +1.0, +0.5,  1.0, 0.0,  0xffffff
X_OBJADDVERTEX -0.5, +1.0, +0.5,  0.5, 0.0,  0xffffff
X_OBJADDVERTEX +0.5, -0.0, +0.5,  1.0, 1.0,  0xffffff
X_OBJADDVERTEX -0.5, -0.0, +0.5,  0.5, 1.0,  0xffffff
X_OBJNEWGROUP // BACK
X_OBJEND
ENDFUNCTION

FUNCTION draw_obj: ob AS _obj
X_SETTEXTURE sprite.id, -1
X_MOVEMENT ob.x, ob.y, ob.z
X_DRAWOBJ block.id, -1
ENDFUNCTION

FUNCTION loop_draw:
LOCAL obj AS _obj
FOR obj.z = 2 TO 5
FOR obj.x = 2 TO 5
draw_obj(obj)
NEXT
NEXT
ENDFUNCTION

FUNCTION create_sprite:
sprite.screen_id = 1
sprite.id = GENSPRITE()
sprite.width = 256
sprite.height = 256
CREATESCREEN sprite.screen_id, sprite.id, sprite.width, sprite.height
USESCREEN sprite.screen_id
paint_test_pattern()
USESCREEN -1
ENDFUNCTION

FUNCTION setup:
create_sprite()
create_block()
// load_block()
ENDFUNCTION

FUNCTION loop:
setup()
WHILE TRUE
X_MAKE3D 0.0001, 100, 45
X_ENABLE_Z FALSE ////////////////////
X_CAMERA 0, 0.5, 0, 1.1, 0.5, 1.2
loop_draw()
SHOWSCREEN
WEND
ENDFUNCTION
Title: Re: Problem 3d on Android
Post by: erico on 2014-May-31
Strange I change the cube obj to a sphere obj and get the same image.
I guess I have to read the code closer.
Title: Re: Problem 3d on Android
Post by: matchy on 2014-Jun-07
So I was able to reconstruct the process of display room walls by only drawing the faces of those closest to the camera. So with Z_ENABLED FALSE, this works well on the Android for now to continue on that platform.
Title: Re: Problem 3d on Android
Post by: erico on 2014-Jun-07
Great! :good:
Title: Re: Problem 3d on Android
Post by: matchy on 2015-Nov-29
Has anyone released an Android 3D app because this bug is a big obstacle?  :rant:
Title: Re: Problem 3d on Android
Post by: Kitty Hello on 2015-Nov-29
The z buffer does not work? So the puxelformat is bad... Spacefractal?
Title: Re: Problem 3d on Android
Post by: matchy on 2015-Nov-29
Can maybe inline glBegin commands correct it?  :blink: