Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Unexpected gaps between cubes

Author
Message
Circumdederunt
6
Years of Service
User Offline
Joined: 9th Apr 2017
Location:
Posted: 6th Jun 2017 13:33
Hello. This code:

Gives this result: https://media.giphy.com/media/3ohzdQMkTCZlU57obu/giphy.gif
As you can see, black gaps appear between cubes as they move left. Is there a way to fix this issue?
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 6th Jun 2017 22:48
Hi.

I had a similar problem recently here - https://forum.thegamecreators.com/thread/219159

I decided I would make the array of cubes at the point I needed them, as it seemed a lot of bother to try (might not even work) to fix this.
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 6th Jun 2017 23:51 Edited at: 6th Jun 2017 23:56
I'm having this problem, as well.

Really bummed to see there is no solution. I had planned to add a texture to the blocks.

Nz0, do you think if I made boxes in blender and textured them there I would still get the "lines"? Its pretty essential that I have them as blocks and not joined as an object, so I can randomly create decor.

Below is code to my mini-not-so-random dungeon generator(its not complete I have yet to add decor or textures). You can see the lines are pretty horrific, and zooming in does not work.


Circumdederunt
6
Years of Service
User Offline
Joined: 9th Apr 2017
Location:
Posted: 7th Jun 2017 12:06
Quote: "make the array of cubes at the point I needed them"

nz0, what do you mean? I tried to recreate cubes every step (decreasing their X) instead of moving the camera right, but gaps still appear.
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 8th Jun 2017 20:15
Well, I'm not sure there's no solution. It probably involves messing with vertexes and/or edge shading. I noted that other 3D tools don't exhibit this behaviour though.
I did get the "lines" if I made the cubes externally, even though they looked fine in Lightwave, as shown in my thread linked above.

@Circumdederunt: I resorted to creating the cube array at the point I needed them to become cubes, otherwise I use a standard geometry model version.

You can see the same cube problem which I had in these examples so I assemble the cubes at the point of destruction.



and this



Circumdederunt
6
Years of Service
User Offline
Joined: 9th Apr 2017
Location:
Posted: 8th Jun 2017 20:50
Quote: "otherwise I use a standard geometry model version"

So do you say that it's possible to display 3d arrays (not affected by physics) without using CreateObjectBox? This question is probably very noobish... but that's why I've come to the newcomers corner. Could you recreate my program (10x10 moving cubes) with "standard geometry model"? Also, examples are beautiful.
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 9th Jun 2017 01:36
When I say standard geometry, I mean make the cube 10x10 size as a single model. At the point you need it to be smaller cubes, then swap over to the small ones.
I guess this may not work for what you are intending, but it does for me if I want to shatter the original model into smaller cubes.

I also expect if you want to make environments, then it's not going to work well.

In my example the model on the left isn't made out of small cubes, but I recreate it out of cubes for the purpose of it falling apart. Probably more economical that way anyway.

I don't know what your group of cubes is for and my example may not help you.

When I was trying to fix this issue, I noticed that not lighting the objects sort of solved the problem, so it appears that the lines are the edge face of the cube adjacent to the front face.
If this is the case, then it would probably need a shader to draw the non-facing edges differently. It was all starting to be too much effort for something which you'd think was basic.
I also tried slightly overlapping the cubes (partially successful). Maybe putting a plane in front would help? Other ways could be making your own cube with 6 separate meshes and only activate the mesh facing the camera... Of course you'd have issues with the cubes on the edge then, but could still be done.. just seems like a lot of effort hence why I didn't pursue it further.

Circumdederunt
6
Years of Service
User Offline
Joined: 9th Apr 2017
Location:
Posted: 9th Jun 2017 10:53
I want to create program which reads txt file (first three numbers (width, height, length), then width*height*length groups of three numbers (r, g, b)) and then displays this 3D array using CreateObjectBox. All created cubes won't be affected by physics and won't move or rotate, only camera is movable (camera won't rotate too). So basically I need "draw rectangular parallelepiped of (W,H,L) at (X1,Y1,Z1) with camera being at (X2,Y2,Z2)" function and I tried to use AppGameKit camera and CreateObjectBox functions for this purpose, but black gaps are the problem. I've given 10x10 cubes example to illustrate gaps problem as simple as possible.
So uniting adjacent cells of the 3D array into single model won't work, because every cube could be of different color.
I tried using SetSunActive(0), and black gaps disappeared, but I need lighted cubes. So the only solution is to use shaders... That's a problem, because I have no idea how shaders work and how to create and use them. I would be grateful if you could explain this or link the explanation.
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 12th Jun 2017 00:58
I reckon the easiest way would be the 6 mesh cube. Only enable meshes that are either facing the camera (this is a different problem) and meshes that don't have an adjacent face (i.e. the ones on the outer edge).

To work out if a cube face is facing the camera (or can be seen in this case) maybe you can check it's normal, but like I say it's starting to get more complicated the more you think about it.

When I ask what it is you are trying to do, I meant for what purpose are you trying to make an array of cubes like this?
Circumdederunt
6
Years of Service
User Offline
Joined: 9th Apr 2017
Location:
Posted: 13th Jun 2017 10:30
So if I build cube from 6 meshes and hide some of them, which are currently not visible, black gaps will go away? If they will, that's good, then the only thing I need is to make boolean "mesh is visible" function. I want to create a simple voxel game, currently I'm working on voxel models editor.
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 13th Jun 2017 19:58
I see.
Well, you don't have to make it out of individual cubes unless you want to do something with those cubes individually.

My guess was that the edge you see was the vertex of the "side" face (adjacent to the one facing the camera), even though it's theoretically 0 thickness.
Every other 3D tool I have doesn't do this - i.e. shows the separate cubes or whatever without that line, so I don't really know exactly what's wrong.

My initial link shows the robot character made out of blocks in Lightwave which looks fine - no gaps. Same if I then load the same model into Assimp, which I thought AppGameKit used (could be wrong there) and again no gaps/lines.
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 14th Jun 2017 16:37 Edited at: 14th Jun 2017 18:01
Hello. I am just getting back into AppGameKit again. I converted your code to AppGameKit BASIC and cannot reproduce the issue. It could be something that was auto-created (when I created the new project for the test) fixed the issue OR maybe an update to AppGameKit fixed the issue (do you have the latest version?) OR it only happens in Tier 2.

Initially I converted the code thinking I would get the same behavior and wanted to try using Fixed Joints between the objects to see if that would solve the issue.

When I get time later I'll remove all code that was auto-created line by line commenting out and see if the issue shows up. If so we'll know how to easily fix it.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 14th Jun 2017 19:33 Edited at: 14th Jun 2017 19:36
Well on lunch break I looked at this again. I was able to reproduce the behavior. It was there I just couldn't see it. Had to greatly reduce the resolution then I could notice an occasional slight flicker where the lines appear.

I found something much better so as to not have to mess around with physics (I hate the physics stuff in these modern engines & frameworks ha ha)... FixObjectToObject.

In Unity I have seen the same behavior you describe and if you parent the objects to a container object it fixes the issue. However, it did not fix it here.



So... I am not sure. I really thought parenting them so they are locked to be updated at the same time would solve the problem.

Truthfully on my monitor it is so hard to see it is not a problem and only noticeable due to the white on black.

But you can try using the FixObjectToObject and see if it helps on your end.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Circumdederunt
6
Years of Service
User Offline
Joined: 9th Apr 2017
Location:
Posted: 14th Jun 2017 22:02
Hello, I tried using FixObjectToObject in Tier 2 and it didn't help. I think gaps appear because of insufficient accuracy of AGK's 3D display, so parenting won't help. I have a 1920x1080 monitor and gaps are clearly visible.

nz0, I'm working on voxel model editor, so I think I "want to do something with those cubes individually" (i.e. paint them)? Still I'm interested in how can I avoid using cubes in the game. Do I need to use 3D model? Is it better for the performance? Can I create model file from 3D RGB array? Indeed it's very strange that AppGameKit creates gaps. I'm still not sure if I need to look for a shader (since this problem has something to do with lighting) or try building cube from meshes...
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 15th Jun 2017 06:29

in the z buffer the surface that's drawn first ends up with priority over other surfaces, so if a bottom/top face is drawn beforfe a front/back/size face it's show through . What you could do, is split the object into a mesh containing only front / side faces and another mesh with top/bottom faces that get drawn after the first mesh. You should be able to make it all one mesh, which should fix errors at least when the camera is face on / above..

PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code

Login to post a reply

Server time is: 2024-03-29 02:37:47
Your offset time is: 2024-03-29 02:37:47