I want to take screenshots of rendered scenes without displaying the game itself. The procedure I want to follow is:
createScene();
for(i = 0; i < num_screenshots; i++)
{
moveCameraRandomly();
saveScreenshot();
}
Basically, I want to randomly reposition the camera in the scene for each screenshot I take. However, I need to call this as a function, so I don't want to display the game itself (but I'm fine with it running in the background). Ideally, I would like to have two projects, one which creates screenshots and one which creates the game, where the first one calls the second one. Is there a way to do this?
Applications can be started in headless mode.
Application app = new Main();
app.start(JmeContext.Type.Headless);
http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:headless_server
The ScreenshotAppState can take screenshots:
http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:screenshots
Now you need to develop a combination of both, which is automatically taking screenshots. I recommend that you read the source code of ScreenshotAppState. A already did a similar thing and can tell it is possible.
Related
I am working on converting some of my games to android after already publishing them to the IOS App store. I wanted to add a little motion to the objects on the screen. In Spritekit, you can simply use the following to move a node a certain length:
Node.run(SKAction.move(by: CGVector(x,y), duration: time))
This is very useful for giving motion to stuff on the screen and wanted to replicate it in Java. Does anyone know how this can be done?
Unfortunately, it is not that easy to move objects in Android.
There is some difference in iOS and Android, where iOS provides easy to use framework, Android doesn't have any easy to use native framework.
Now how to do it, in Android?
First let's learn some basics:-
iOS has SpriteKit, Android has Canvas
SpriteKit can use concept of Node to display object on screen.
Canvas uses bitmaps to draw objects on screen.
Now, it is too big of a topic to cover on Stackoverflow, but the general things, we need to do is:-
Draw objects on screen, where they should have been initially
Then we have to setup game environment is such a way, that the game runs in a while loop, and which should atleast give user, 60 FPS.
Then add the move object logic, inside the while loop. Thus, giving the user, the illusion that the object moved (2, 6) position in 10 seconds.
I would literally just show you the code, which does that https://bitbucket.org/jenelleteaches/android2d-pongclone/src/master/MainActivity.java
And would recommend reading this book, before moving into 2d game development in Andorid :- Android Game Programming by Example. This is published by Packt
I'm developing a Java application that displays a counter, that sums one to itself every time a pixel in a certain position is equal to a color after a certain action. The number from the counter is obtained from a text file, and gets updated on close.
I'm quite new into Swing so I'm a bit confused on how should I manage the small version of my app, which is basically the same but smaller duh and always on top.
Since according to this thread making new JFrames is not ideal, especially since this application just shows an Integer in the end.
My thought was to make them as different classes that extend from JPanel. Is this okay? I'm a bit confused on how should I make the switch back and forth if so.
big version idea:
small version idea:
I don't see why making a small JFrame would be bad. Also, you cannot display anything on a JPanel without either a JFrame or a JWindow.
My final verdict is that it would be just fine to use a small JFrame, you aren't taking performance hits or anything like that.
I am working on a research project.The scenario is this.
I am taking the screenshot of my desktop and then I process it using an API to get the position of a certain text on my Desktop.e.g , say I have the browser open on my desktop and I am on stackoverflow.Now I want to search the position of the logo stackoverflow on the screenshot taken.Then I want to simulate a click on it.I am using Java platform.
Now I have 2 questions:
1)Is there any free API(OCR) which I can use to process the screenshot to fetch text position (or can be done by some trick) and gives good results.
Or Any way you can suggest that I can use (instead of taking screenshot and processing it) to get the position of any text on the screen.
2)How can I simulate the click on the screen using the code by a background program running(I mean I have done it in Swing and other language UIs but this time its different as Now I want to click on the screen.
If I understood you right you want to move your mouse and click on the screen. That not that hard you could use the robot class from Java!
For example:
Robot rob = new Robot();
rob.keyPress( KeyEvent.VK_ENTER );
or what ever, there are so much bottons and movements you could with it. A list of all methods you find here.
And your other question I can't answer. I think there is no API that is able to search a text and give you the position. But what I know is that the robot class is able to capture the screen and put it into a BufferedImage. With it you could compare two pictures.
Maybe you could get use of this but I don't know if it is what you search.
I'm currently attempting to use the openoffice API to display a powerpoint presentation from Java - I've got a fair way in that I've managed to open a presentation and display it. However, there's a couple of things that I'd like to be able to do I can't figure out with the API as it stands:
I don't want the main Impress window to appear, just the presentation window. Now, I can start it minimized no problem with a property, but then the actual presentation window is minimised as well, which I don't want. I can also grab the window and call setVisible(false) on it, but it's still visible for a second or so while it's loading.
I want to be able to control the monitor which the presentation appears on (I'm using it in a multi-monitor setup.) I thought I might be able to grab the Window of the presentation and move it around that way as I need to, but I can't see how - for the main window I can do something like:
XModel xModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc);
xModel.getCurrentController().getFrame().getContainerWindow().blah();
...but I haven't yet found a way to get the presentation Window. I'd like to be able to set the bounds of the window directly (x, y, width, height) rather than just being constrained by positioning on a single monitor.
I can live with the first point, the critical one I need to solve for my use case is the second.
Any ideas on the above? I'm an experienced Java programmer but new to UNO.
Seems the second point can be solved, ish, with the display property:
public void start() {
try {
xPresentation.setPropertyValue("Display", 1);
}
catch (Exception ex) {
ex.printStackTrace();
}
xPresentation.start();
}
Note however a few of things - firstly the display index is base 1, not 0. Secondly, trying to set the properties in an array and passing them to xPresentation on creation didn't seem to have any effect - it only worked for me setting the property later as above. Thirdly, it doesn't allow fine grained control over the window as I wanted, just control of the display the presentation appears on.
I am developing a small desktop application in Netbeans. The application is complete and working fine. A small description of application is as follow:
The application is basically an object manager, where user add new object, remove old objects and connect object with each other. What i did is that i simply add 3 panel and change its type to titled border. One for Add object one for remove and one for connect.
Status:
Every thing is working fine as expected.
What Left:
In order to make UI more appealing i added a new panel at the end and called it "Object Viewer". I am planing to visualize the steps which user performs e.g
If user add an object then i that pannel i will daraw a little
circle and fill it with green color
Similarly if user remove some object then again i will draw another
cricle and fill that with red
And when user connects two object then i will draw two circle and
connect them with a dotted line
This is my first java application, i only want to know how do i acheive this task. Some links or experience are highly appreciated
As for custom painting in swing, have a look here: http://download.oracle.com/javase/tutorial/uiswing/painting/
However, I'd suggest using a graph visualization library like JUNG etc. Using this you'd basically only have to define your object graph.
You can either do that manually with Java 2D, which I don't recommend, or, since you are using Netbeans (and I assume the Netbeans Platform, but this is not required), I would strongly suggest looking at the Netbeans Visual Library. It can do exactly what you want.
As Nico Huysamen said you can do that with Java 2D. But because it's your first Java application I strongly recommend to do it manually with this lybrary in order to understand how higer level lybraries work.