asdru
asdru
JCHJava Community | Help. Code. Learn.
Created by asdru on 10/24/2024 in #java-help
Optimizing draw function for texured triangle
thanks for the advice!
20 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 10/24/2024 in #java-help
Optimizing draw function for texured triangle
but i should test it further
20 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 10/24/2024 in #java-help
Optimizing draw function for texured triangle
its not super slow so far i have 50 triangles on my screen and its still running at 60fps
20 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 10/24/2024 in #java-help
Optimizing draw function for texured triangle
i tried lwjgl too but didn't like it since ur working with ints
20 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 10/24/2024 in #java-help
Optimizing draw function for texured triangle
lets say its a personal challenge and im trying to learn 3d graphics
20 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 10/24/2024 in #java-help
Optimizing draw function for texured triangle
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.BLACK);
g2.fillRect(0, 0, getWidth(), getHeight());


// Creazione del BufferedImage e del zBuffer
BufferedImage img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
double[] zBuffer = new double[img.getWidth() * img.getHeight()];
Arrays.fill(zBuffer, Double.NEGATIVE_INFINITY);

// Draw the scene
//scene.draw(img,zBuffer);
GrassBlock gblock = new GrassBlock(0, 0, 0);
gblock.draw(img, zBuffer, new Camera(this.getWidth(), this.getHeight(), new Vertex(0, 500, 1000)));
g2.drawImage(img, 0, 0, null);
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.BLACK);
g2.fillRect(0, 0, getWidth(), getHeight());


// Creazione del BufferedImage e del zBuffer
BufferedImage img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
double[] zBuffer = new double[img.getWidth() * img.getHeight()];
Arrays.fill(zBuffer, Double.NEGATIVE_INFINITY);

// Draw the scene
//scene.draw(img,zBuffer);
GrassBlock gblock = new GrassBlock(0, 0, 0);
gblock.draw(img, zBuffer, new Camera(this.getWidth(), this.getHeight(), new Vertex(0, 500, 1000)));
g2.drawImage(img, 0, 0, null);
}
do you know why this draws a cube but if i call the scene.draw method
public class RenderingScene {
private final RenderingPanel renderingPanel;
private Camera camera;
private final ArrayList<Cube> cubes = new ArrayList<>();

public RenderingScene(RenderingPanel renderingPanel) {
this.renderingPanel = renderingPanel;
this.camera = new Camera(renderingPanel.getWidth(), renderingPanel.getHeight(), new Vertex(0, 500, 1000));
this.cubes.add(new GrassBlock(0, 0, 0));
this.cubes.add(new Dirt(0, -100, 0));

}

public void update() {

}

public void draw(BufferedImage img, double[] zBuffer) {
for (Cube cube : cubes) {
cube.draw(img, zBuffer, camera);
}
}

}
public class RenderingScene {
private final RenderingPanel renderingPanel;
private Camera camera;
private final ArrayList<Cube> cubes = new ArrayList<>();

public RenderingScene(RenderingPanel renderingPanel) {
this.renderingPanel = renderingPanel;
this.camera = new Camera(renderingPanel.getWidth(), renderingPanel.getHeight(), new Vertex(0, 500, 1000));
this.cubes.add(new GrassBlock(0, 0, 0));
this.cubes.add(new Dirt(0, -100, 0));

}

public void update() {

}

public void draw(BufferedImage img, double[] zBuffer) {
for (Cube cube : cubes) {
cube.draw(img, zBuffer, camera);
}
}

}
it doesnt draw the cubes?
20 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 10/24/2024 in #java-help
Optimizing draw function for texured triangle
No description
20 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 10/24/2024 in #java-help
Optimizing draw function for texured triangle
If there's a better solution that involves built in functions im all ears but i couldn't find anything
20 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 9/19/2024 in #java-help
scanner blocking thread close
:shrugging:
24 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 9/19/2024 in #java-help
scanner blocking thread close
I switched to using a buffered reader since its nextline function isnt blocking and that fixed it
24 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 9/19/2024 in #java-help
scanner blocking thread close
I did try that and i still had the same issue
24 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 9/19/2024 in #java-help
scanner blocking thread close
If i try closing the sender thread drom the reciever nothing happens because the interrupt function gets stuck wating for the sender's scanner to close/recieve input First
24 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 9/19/2024 in #java-help
scanner blocking thread close
Anyone?
24 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 8/7/2024 in #java-help
isometric tile setup
it helped but its still not perfect 😩 since its a 32x32 tile is it better to just write a function to round numbers up to the closest multiple of 32?
26 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 8/7/2024 in #java-help
isometric tile setup
yeah i know its bad practise
26 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 8/7/2024 in #java-help
isometric tile setup
thanks :)
26 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 8/7/2024 in #java-help
isometric tile setup
public void toIso(){
int screenWidth = GamePanel.instance.getScreenWidth();
int screenHeight = GamePanel.instance.getScreenHeight();

int newX = (int) ((x-y)*0.66)+screenWidth/2;
int newY = (int) ((x+y)*0.33)+screenHeight/3;
x = newX;
y = newY;
}
public void toIso(){
int screenWidth = GamePanel.instance.getScreenWidth();
int screenHeight = GamePanel.instance.getScreenHeight();

int newX = (int) ((x-y)*0.66)+screenWidth/2;
int newY = (int) ((x+y)*0.33)+screenHeight/3;
x = newX;
y = newY;
}
this is the new function but as u can see from the image the tiles arent perfectly aligned due to float multiplication. so instead of getting 48 i get 47 for example. is there a way to get the right value?
26 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 8/7/2024 in #java-help
isometric tile setup
No description
26 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 8/7/2024 in #java-help
isometric tile setup
No description
26 replies