Hi,
I am trying to develop an application similar to http://mydeco.com/rooms/austin/ and I thought about using jreality to generate 3d previews in jpg format and to generate renderman rib files in order to feed aqsys for high quality 3d rendering.
After reading jreality documentation and having a look at the code I have some questions:
1. how could I use jreality from my java code in order to generate and export a jpg file (without a display as it will run in a linux server)?
2. how could I set the camera position at x0,y0,z0 looking at x1,y1,z1? I have been playing with the camera path but I do not actually understand how it works
Thanks for your help,
Miguel
some questions
-
- Posts: 48
- Joined: Mon 16. May 2011, 16:29
Re: some questions
There are transformation matrices on the camera path. They have to add up to a translation by x0, y0, z0 and a rotation that maps the z axis (0,0,1) to the normalized (x1-x0,y1-y0,z1-z0).
For manipulating these transformation matrices easily, have a look at the javadoc of the MatrixBuilder class:
http://www3.math.tu-berlin.de/jreality/ ... lder_class
I'm not sure whether jReality can do 3D-rendering without a window.
For manipulating these transformation matrices easily, have a look at the javadoc of the MatrixBuilder class:
http://www3.math.tu-berlin.de/jreality/ ... lder_class
I'm not sure whether jReality can do 3D-rendering without a window.
Re: some questions
Thanks Benjamin for your quick response.
I will try and come back.
Thanks,
Miguel
I will try and come back.
Thanks,
Miguel
Re: some questions
Hi,
I have tried the following code but I always get the same image. I think I do not actually understand how the camera path works and how Jamie's transformations must be applied to the camera path. Can anyone tell me what's wrong?
package test;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Date;
import de.jreality.geometry.Primitives;
import de.jreality.math.MatrixBuilder;
import de.jreality.plugin.JRViewer;
import de.jreality.scene.Camera;
import de.jreality.scene.SceneGraphComponent;
import de.jreality.scene.SceneGraphPath;
import de.jreality.util.ImageUtility;
import de.jreality.util.SceneGraphUtility;
public class JRTester {
public String preview() {
String fn = "/home/miguel/preview" + new Date().getTime() + ".jpg";
SceneGraphComponent world = new SceneGraphComponent();
world.setGeometry(Primitives.coloredCube(60, 60, 60));
JRViewer v = new JRViewer();
v.setContent(world);
v.startup();
double x0 = 50;
double y0 = 50;
double z0 = 0;
double x1 = 150;
double y1 = 300;
double z1 = 60;
Camera camara = null;
for (int i = 0; i < v.getViewer().getCameraPath().getLength(); i++) if (v.getViewer().getCameraPath().get(i) instanceof Camera) {
camara = (Camera) v.getViewer().getCameraPath().get(i);
}
SceneGraphComponent lookAt = SceneGraphUtility.createFullSceneGraphComponent("hasta");
MatrixBuilder.euclidean().translate(x0, y0, z0).assignTo(lookAt);
SceneGraphComponent lookFrom = SceneGraphUtility.createFullSceneGraphComponent("desde");
MatrixBuilder.euclidean().translate(x1, y1, z1).assignTo(lookFrom);
v.getViewer().setCameraPath(new SceneGraphPath(lookAt, lookFrom, camara));
v.getViewer().render();
BufferedImage img = ImageUtility.captureScreenshot(v.getViewer());
ImageUtility.writeBufferedImage(new File(fn), img);
v.dispose();
return fn.substring(fn.lastIndexOf("/"));
}
public static void main(String[] args) {
System.out.println(new JRTester().preview());
}
}
Thanks a lot for your help,
Miguel
I have tried the following code but I always get the same image. I think I do not actually understand how the camera path works and how Jamie's transformations must be applied to the camera path. Can anyone tell me what's wrong?
package test;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Date;
import de.jreality.geometry.Primitives;
import de.jreality.math.MatrixBuilder;
import de.jreality.plugin.JRViewer;
import de.jreality.scene.Camera;
import de.jreality.scene.SceneGraphComponent;
import de.jreality.scene.SceneGraphPath;
import de.jreality.util.ImageUtility;
import de.jreality.util.SceneGraphUtility;
public class JRTester {
public String preview() {
String fn = "/home/miguel/preview" + new Date().getTime() + ".jpg";
SceneGraphComponent world = new SceneGraphComponent();
world.setGeometry(Primitives.coloredCube(60, 60, 60));
JRViewer v = new JRViewer();
v.setContent(world);
v.startup();
double x0 = 50;
double y0 = 50;
double z0 = 0;
double x1 = 150;
double y1 = 300;
double z1 = 60;
Camera camara = null;
for (int i = 0; i < v.getViewer().getCameraPath().getLength(); i++) if (v.getViewer().getCameraPath().get(i) instanceof Camera) {
camara = (Camera) v.getViewer().getCameraPath().get(i);
}
SceneGraphComponent lookAt = SceneGraphUtility.createFullSceneGraphComponent("hasta");
MatrixBuilder.euclidean().translate(x0, y0, z0).assignTo(lookAt);
SceneGraphComponent lookFrom = SceneGraphUtility.createFullSceneGraphComponent("desde");
MatrixBuilder.euclidean().translate(x1, y1, z1).assignTo(lookFrom);
v.getViewer().setCameraPath(new SceneGraphPath(lookAt, lookFrom, camara));
v.getViewer().render();
BufferedImage img = ImageUtility.captureScreenshot(v.getViewer());
ImageUtility.writeBufferedImage(new File(fn), img);
v.dispose();
return fn.substring(fn.lastIndexOf("/"));
}
public static void main(String[] args) {
System.out.println(new JRTester().preview());
}
}
Thanks a lot for your help,
Miguel
-
- Posts: 48
- Joined: Mon 16. May 2011, 16:29
Re: some questions
Hi,
looking at the javadoc of de.jreality.scene.Viewer.setCameraPath(...)
If you want to set the Transformation of the Camera try this:
the file
(Edit: I probably meant miguel.jpg)
should appear in your workspace directory.
I see that it is hard in the beginning to grasp how to do things the right way in jReality.
If you want to specify rotations, maybe this helps
looking at the javadoc of de.jreality.scene.Viewer.setCameraPath(...)
I read that the first element of the cameraPath has to be the scene root and the last one a Camera. In your code the first is "hasta" which is just a simple SceneGraphComponent. It has to be of the class Camera which inherits from SceneGraphComponent.Set the camera path. Some backends assume that this is a valid (existing) path starting at the scene root. This implies that one first needs to set the scene root. A camera path must have a Camera as the last element.
If you want to set the Transformation of the Camera try this:
Code: Select all
package test;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Date;
import de.jreality.geometry.Primitives;
import de.jreality.math.MatrixBuilder;
import de.jreality.plugin.JRViewer;
import de.jreality.scene.Camera;
import de.jreality.scene.SceneGraphComponent;
import de.jreality.scene.SceneGraphNode;
import de.jreality.scene.SceneGraphPath;
import de.jreality.util.ImageUtility;
import de.jreality.util.SceneGraphUtility;
public class JRTester {
public static void preview() {
SceneGraphComponent world = new SceneGraphComponent();
world.setGeometry(Primitives.coloredCube(60, 60, 60));
JRViewer v = new JRViewer();
v.setContent(world);
v.startup();
double x0 = 50;
double y0 = 50;
double z0 = 0;
double x1 = 150;
double y1 = 300;
double z1 = 60;
SceneGraphComponent cameraContainer = null;
cameraContainer = (SceneGraphComponent)v.getViewer().getCameraPath().get(v.getViewer().getCameraPath().getLength()-2);
MatrixBuilder.euclidean().translate(50,50,50).assignTo(cameraContainer);
v.getViewer().render();
BufferedImage img = ImageUtility.captureScreenshot(v.getViewer());
File f = new File("miguel.jpg");
try{
f.createNewFile();
ImageUtility.writeBufferedImage(f, img);
}catch(Exception e){
System.out.println(e.getMessage());
}
//v.dispose();
//return fn.substring(fn.lastIndexOf("/"));
}
public static void main(String[] args) {
JRTester.preview();
}
}
test
(Edit: I probably meant miguel.jpg)
should appear in your workspace directory.
I see that it is hard in the beginning to grasp how to do things the right way in jReality.
If you want to specify rotations, maybe this helps
Code: Select all
MatrixBuilder.euclidean().rotateFromTo(v1, v2)
-
- Posts: 48
- Joined: Mon 16. May 2011, 16:29
Re: some questions
By the way I get the following picture:
https://picasaweb.google.com/lh/photo/D ... directlink
https://picasaweb.google.com/lh/photo/D ... directlink