Doesnt render in 3D with Bitwise Operator '&'
Ive bin making a small game engine and right now im working on the 3Drender portion of it is giving me alot of trouble.
Ive re wrote it twice and for the most part its working but when i try to put them together the screen turns black. My fps counter still counts though so im not sure whats wrong.
Code :
public class Render3D extends Render {
public Render3D(int WIDTH, int LENGTH) {
super(WIDTH, LENGTH);
}
public void floor() {
for (int y = 0; y < LENGTH; y++) {
double yDepth = y - LENGTH / 2;
double z = 100.0 / yDepth;
for (int x = 0; x < WIDTH; x++) {
double xDepth = x - WIDTH / 2;
xDepth *= z;
[B]int xx = (int) (xDepth) & 5;[/B]
PIXELS[x + y * WIDTH] = xx * 135;
}
}
}
}
if you look near the bottom theres a portion with the bold tags, thats where im getting the issue I think
Re: Doesnt render in 3D with Bitwise Operator '&'
Edin....5 in binary is 101. Your operation int xx = (int) (xDepth) & 5; delivers only 4 values: 101 or 5, 100 or 4, 1 and 0. Is that what you want?
Re: Doesnt render in 3D with Bitwise Operator '&'
so since like its not a consistent value I cant use the & operator?
Re: Doesnt render in 3D with Bitwise Operator '&'
Quote:
Originally Posted by
Edin
so since like its not a consistent value I cant use the & operator?
frankly, I don't understand what you mean. You got whatever xDepth is one of the 4 above mentioned values.
Re: Doesnt render in 3D with Bitwise Operator '&'
Quote:
Originally Posted by
Voodoo
frankly, I don't understand what you mean. You got whatever xDepth is one of the 4 above mentioned values.
do you have skype or something where you can show me what im doing wrong?
Re: Doesnt render in 3D with Bitwise Operator '&'
Quote:
thats where im getting the issue I think
How do you know? Your posted code demonstrates nothing of the problem for us because it lacks context, let alone comments on what the methods are actually trying to do, and you've mentioned nothing as far as the calculations - what you expect and what you get. This leaves us with nothing but to guess, sometimes correctly, more often than not incorrectly. Here's my advice: add some println's in there to inspect the values, or throw the code through a debugger. How do the values of these variables differ from what you expect? And finally, if you wish to put your problem into context, then I recommend that you post an SSCCE
2 Attachment(s)
Re: Doesnt render in 3D with Bitwise Operator '&'
Quote:
Originally Posted by
copeg
How do you know? Your posted code demonstrates nothing of the problem for us because it lacks context, let alone comments on what the methods are actually trying to do, and you've mentioned nothing as far as the calculations - what you expect and what you get. This leaves us with nothing but to guess, sometimes correctly, more often than not incorrectly. Here's my advice: add some println's in there to inspect the values, or throw the code through a debugger. How do the values of these variables differ from what you expect? And finally, if you wish to put your problem into context, then I recommend that you post an SSCCE
its not an error per say because I've ran it through me debugger and everything was fine no error codes or anything. its just I was to merge the screens together ill post a pic:
Shifting:
Attachment 1323
Using AND to put the images together:
Attachment 1324
Re: Doesnt render in 3D with Bitwise Operator '&'
I still don't understand how that code relates to your problem: you have yet to provide an explanation as to what the code is supposed to do - either through an SSCCE, comments, or a description. Why do you want to bitwise and operate against the value 5? What is the method floor supposed to accomplish? As written, how does it try to accomplish that?
Re: Doesnt render in 3D with Bitwise Operator '&'
as written it is suppose to give me the basic floor and roof 3D model for my game. I used a demonstration of how Notch created his 3Dmodel for early minecraft using the same model as his cave demo. The value of 5 is the definition of the floor and roof, as I increase or lower the number the definitions change, Im using 5 as that was the definition used in his demonstration and is what he used in a later step of adding on textures.
Re: Doesnt render in 3D with Bitwise Operator '&'
Edin,
I assume that you misunderstand the & and the shifting operation << or >>
Shift left 5 positions: int xx = (int) (xDepth) << 5 (or multiply by 32)
Shift right 5 positions: int xx = (int) (xDepth) >> 5 (or divide by 32)
Re: Doesnt render in 3D with Bitwise Operator '&'