Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions PS4k/resource/bundle/LangBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,17 @@ toggle_floating_frame_button_tooltip = Toggle Floating
close_frame_button_tooltip = Close
replace_file_query = already exists. \nDo you want to replace it?
replace_file_query_title = Confirm Replace File
folder_not_empty_query = Folder not empty, all existing files will be replaced
folder_not_empty_query_title = Replace existing files
save_current_changes_title = Unsaved Changes
save_current_changes_query = Save current changes before proceeding?
import_voxel_limit_reached_pre = Limit of
import_voxel_limit_reached_post = Voxel on import reached!
min_max_voxel_error = This action would result in an overlarge layer or not affect any voxels at all.
export_file_successful = Export completed successfully in %s ms.
export_files_successful = Export completed successfully in %s ms, %d files were exported
export_file_error = Error: There was an error with the export!
export_files_error = Error: An error occurred during export, %d files were exported
error_on_file_load = Error: An error occurred while loading the file!
error_on_file_import = Error: There was an error with the import!
error_invalid_folder = You need to specify a folder that exists!
Expand Down
5 changes: 5 additions & 0 deletions PS4k/src/com/vitco/core/CCamera.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ private SimpleVector getOrigin() {
return new SimpleVector(-centerShift.x, -centerShift.y-amountShifted[1], -centerShift.z);
}

// getting the camera's position
public final float[] getCamPosition() {
return this.getPosition().toArray();
}

public void zoomIn(float speed) {
if (enableCamera && speed != 0) {
speed = Math.abs(speed);
Expand Down
21 changes: 20 additions & 1 deletion PS4k/src/com/vitco/core/EngineViewPrototype.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,28 @@ public final int getWidth() {
return container.getWidth();
}
// get the image rendered in container in high quality
public BufferedImage getImage() {
public BufferedImage getImage() throws Exception {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exception does this throw?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IOException while loading the font for the watermark

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make the Exception that is thrown explicit then? I.e. IOException instead of Exception?

return container.getImage();
}

// get camera position
public final float[] getCamPosition() { return this.camera.getCamPosition(); }
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't write these as one line, write as

public final float[] getCamPosition() {
    return this.camera.getCamPosition();
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's a single line of code, i tends to write such methods like that (Another bad Habit) will change.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't like long lines very much. There is a reason swift > objective-c :)


public BufferedImage getImage(final Color bgColor, final boolean addWatermark) throws Exception { return container.getImage(bgColor, addWatermark); }
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do the variables need to be final? I think you can remove the final keyword.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just an agreement that i will never modify it, will change it if you don't like it

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think final should only be used when there is a reason for it. That's how I'm usually handling it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change, but i will also love to know what your reasons are

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly "Shorter is better and faster to read".

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public BufferedImage getImage(SimpleVector camPos, final Color bgColor, final boolean addWatermark) throws Exception { return this.getImage(camPos, bgColor, addWatermark, false); }
public BufferedImage getImage(SimpleVector camPos, final Color bgColor, final boolean addWatermark, final boolean camLookAtOrigin) throws Exception {
// get camera's initial position
float[] initialCamPos = this.getCamPosition();
// set camera position for the "shot"
this.camera.setPosition(camPos.x, camPos.y, camPos.z);
// camera look at origin
if (camLookAtOrigin) this.camera.lookAt(new SimpleVector());

BufferedImage image = getImage(bgColor, addWatermark);
// reset camera to it initial position
this.camera.setView(new SimpleVector(initialCamPos));
return image;
}
// get the depth image
public BufferedImage getDepthImage() {
return container.getDepthImage();
Expand Down
24 changes: 23 additions & 1 deletion PS4k/src/com/vitco/core/container/DrawContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.vitco.settings.DynamicSettings;
import com.vitco.settings.VitcoSettings;
import com.vitco.util.graphic.G2DUtil;
import com.vitco.util.misc.SaveResourceLoader;

import javax.swing.*;
import java.awt.*;
Expand Down Expand Up @@ -807,7 +808,8 @@ public final int[] getPixels() {
}

// get the image currently rendered in high quality
public final BufferedImage getImage() {
public final BufferedImage getImage() throws Exception { return this.getImage(null, false); }
public final BufferedImage getImage(final Color bgColor, final boolean addWatermark) throws Exception {
Config.useFramebufferWithAlpha = true;
HackedFrameBuffer fb = new HackedFrameBuffer(getWidth()*2, getHeight()*2, FrameBuffer.SAMPLINGMODE_NORMAL);
Config.useFramebufferWithAlpha = false;
Expand Down Expand Up @@ -853,6 +855,26 @@ public final BufferedImage getImage() {
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

// background color
// null for transparent
if (bgColor != null) {
g2d.setPaint(bgColor);
g2d.fillRect(0, 0, largeResult.getWidth() / 2, largeResult.getHeight() / 2);
}

// render watermark
if (addWatermark) {
g2d.setPaint(VitcoSettings.RENDER_WATERMARK_TEXT_COLOR);
final Font font = Font.createFont(Font.TRUETYPE_FONT,
new SaveResourceLoader("resource/font/arcade.ttf").asInputStream()).deriveFont(Font.PLAIN,
VitcoSettings.RENDER_WATERMARK_TEXT_SIZE);
g2d.setFont(font);
final String renderWatermark = "VoxelShop";
final int textWidth = g2d.getFontMetrics().stringWidth(renderWatermark);
g2d.drawString(renderWatermark, (largeResult.getWidth() / 2) - textWidth - 20,
(largeResult.getHeight() / 2) - VitcoSettings.RENDER_WATERMARK_TEXT_SIZE);
}
g2d.drawImage(largeResult, 0, 0, largeResult.getWidth()/2, largeResult.getHeight()/2, null);
g2d.dispose();

Expand Down
Loading