Replicating Plane Thickness and position w/ Cube

Blitz3D Forums/Blitz3D Beginners Area/Replicating Plane Thickness and position w/ Cube

RustyKristi(Posted 2016) [#1]
I'm trying to switch to cube and not using plane anymore. I'm getting some jittering effect when I used a flattened cube with a defined width and length along with primitives on top, say another cube (not flattened)

Any ideas on how you can create the same with cube at position 0,0,0 and the same thickness as CreatePlane().


Matty(Posted 2016) [#2]
Not sure what you mean. A plane is infinitely broad and of zero thickness. A cube has finite non zero dimensions. You can of course svale a cube so it is broad but thin....is that what you mean?


RustyKristi(Posted 2016) [#3]
Thanks Matty, Ok so nevermind the thickness. Any size will do, as long as it won't jitter when I put primitives on top. Kinda like floor (plane) and structure (cube,meshes)

Maybe start something like 100x100 in scale, I can't really line up the flattened cube and other meshes on top without experiencing any jittering. Is this still possible?


RemiD(Posted 2016) [#4]
You could simply create a big flat rectangle mesh (like 1000units*1000units), 4 vertices, 2 triangles. Also, make sure to define appropriate u,v coords so that the texture will be applied the same way than on the plane.


RustyKristi(Posted 2016) [#5]
I think that could work RemiD, will try it thanks!


Kryzon(Posted 2016) [#6]
I'm getting some jittering effect when I used a flattened cube

That's called Z-fighting, it's caused by geometry from different objects occupying the same location in space, so in certain frames some pixels of an object go in front of pixels of the other, and vice versa. They have equal values in the depth buffer.

https://en.wikipedia.org/wiki/Z-fighting


RustyKristi(Posted 2016) [#7]
Yes, that seems to be the case Kryzon. Do you have any example solution? thanks


Kryzon(Posted 2016) [#8]
Use a flat rectangle mesh like RemiD suggested, or use EntityOrder to render the ground first, before everything.


RemiD(Posted 2016) [#9]
If you problem is z-fighting, the solution is to move/position your meshes a bit higher so that they do not cross the plane... or to move their bottom vertices a bit higher in your modeling tool...


RustyKristi(Posted 2016) [#10]
sorry guys, I'm not good at calculating blitz3d units so maybe a simple example 1 cube flattened and 1 cube on top is all I need to see. It looks like I just need to create the plane from blender.


RemiD(Posted 2016) [#11]
using Fragmotion, i model everything with 1 fragmotionunit = 1 centimeter, then when i load the mesh inside Blitz3d, i scale down by 0.01.
This gives me perfectly sized meshes that i can then position/oriente precisely in the scene (essential if one day you want to procedurally build a scene with parts)

Firstly you want to decide at which size you want to model your meshes in Blender (preferably by using 1blenderunit = 1meter or 1decimeter or 1centimeter or 1millimeter), then export a 1w1h1d cube and load it inside Blitz3d. Then do some tests by scaling up or down to find the precise scale factor.
Then always use the same modeling size/grid and always use the same scale factor to load the mesh and all will work well.


RemiD(Posted 2016) [#12]
Btw, a Blitz3d cube, with default size, has a radius of 1 !
So in order to have a 1w1h1d cube inside Blitz3d, use this code :
1w1h1dCube = createcube()
scalemesh(1w1h1dCube,1.0/2,1.0/2,1.0/2)



RustyKristi(Posted 2016) [#13]
thanks, is that supposed to work in conjunction with the fakeplane?

btw you forgot about var name starts with 1 or num throws an error ;-)


RemiD(Posted 2016) [#14]

is that supposed to work in conjunction with the fakeplane?


it is supposed to help you modelize, export, load, scale, your meshes precisely so that the vertices/edges do not go through the plane/ground/floor.


Floyd(Posted 2016) [#15]
I'm getting some jittering effect when I used a flattened cube with a defined width and length along with primitives on top, say another cube (not flattened)

We could use an example of this to demonstrate the problem. Without it we are just guessing what needs to be fixed.


RustyKristi(Posted 2016) [#16]
Thanks guys. I know I can achieve this by just generating models in Blender and export it in B3D.

What I'm trying to do is replicate it without the use of any tool or through CreateCube() method. I'm curious if it is possible and without the z-fighting.

So far I'm failing and don't know the exact scale and position of the 2 objects to achieve this, that's why I'm asking this particular problem.


RemiD(Posted 2016) [#17]
What do you want exactly ?
A scene made in code with a plane and a 1w1h1d cube ?


RustyKristi(Posted 2016) [#18]
Yes please, without the z-fighting. If it's not possible then it's ok, I guess I have to do it in Blender.


RemiD(Posted 2016) [#19]
here :


Also note that to prevent z-fighting you want to have a factor of 1000 maximum between the near camerarange and the far camerarange (in this example 0.1,100)


RustyKristi(Posted 2016) [#20]
thanks RemiD. Looks like it works but I have not fully tested it yet. be back on this.


RemiD(Posted 2016) [#21]
There are 3 views from a humanoid pov in this scene :
-stand up view
-crouch down view
-lay down view

And as you can see, no z-fighting problem.


RustyKristi(Posted 2016) [#22]
got it, thanks. I'll be adding a freelook camera and some textures to check it out.

The z-fighting usually shows up when you move the camera.


RemiD(Posted 2016) [#23]
Are you sure that what you describe as z-fighting is not the min value of the camerarange which is too high ?


RustyKristi(Posted 2016) [#24]
I'm not sure but when I use plane at 0,0,0 there's no z-fighting when I place a cube on top.