JRViewer issues

General discussion area.
Shaguar
Posts: 12
Joined: Mon 27. Feb 2012, 14:31

Re: JRViewer issues

Post by Shaguar » Thu 1. Mar 2012, 09:59

I've installed a driver update, but it is still lagging. I think i just need a better graphic card.

Shaguar
Posts: 12
Joined: Mon 27. Feb 2012, 14:31

Re: JRViewer issues

Post by Shaguar » Thu 1. Mar 2012, 11:39

I want to try this with the standalone viewer. Maybe its better with less overhead from the JRViewer.
But can you tell me how to set the camera postion. I've tried the http://www3.math.tu-berlin.de/jreality/ ... one_viewer Example, but it doesnt show how to position the the camera, because the camera is way to near at start. and i also have this weird fish-eye effect. Can is disabled that somehow? It should look like my first attempt with JRViewer where these lines did all the "work":

Code: Select all

JRViewer v = new JRViewer();
v.addContentSupport(ContentType.CenteredAndScaled);
One more important thing, as i mentioned before i want to apply custom texture to the models, but not to the whole model only to certain parts.
How can i list or select the parts/groups of the model? (which are defined in the model.obj)

Edit: Ok i've figured out how to list them with the "Use the mouse-over input slot" example but i want to select the parts by clicking not hovering. can i do this too with the AbstractTool? And is there a possibility to store some informations along with the childNodes? like isSelected, isTextureApplicable, texturePath etc ...
or do i have to write my own container for storing these informations?

Shaguar
Posts: 12
Joined: Mon 27. Feb 2012, 14:31

Re: JRViewer issues

Post by Shaguar » Fri 2. Mar 2012, 12:56

Forget the camera thing and the fish-eye problem.

I've just tried the texture2d example but it doesnt work for me.
In the examples they use a cylinder or this CatenoidHelicoid for demonstration. They work for me too but my custom model wont show any textures on it.
This is my source code:

Code: Select all

import static de.jreality.shader.CommonAttributes.EDGE_DRAW;
import static de.jreality.shader.CommonAttributes.VERTEX_DRAW;

import java.awt.Color;
import java.io.IOException;

import de.jreality.math.MatrixBuilder;
import de.jreality.plugin.JRViewer;
import de.jreality.plugin.JRViewer.ContentType;
import de.jreality.plugin.content.ContentAppearance;
import de.jreality.plugin.content.ContentLoader;
import de.jreality.plugin.content.ContentTools;
import de.jreality.reader.Readers;
import de.jreality.scene.Appearance;
import de.jreality.scene.SceneGraphComponent;
import de.jreality.shader.CommonAttributes;
import de.jreality.shader.DefaultGeometryShader;
import de.jreality.shader.DefaultPolygonShader;
import de.jreality.shader.ImageData;
import de.jreality.shader.ShaderUtility;
import de.jreality.shader.Texture2D;
import de.jreality.shader.TextureUtility;
import de.jreality.util.Input;

public class FirstStart {
		
	public static void main(String[] args) {
		// customize a JRViewer to have Virtual Reality support (skyboxes, terrain, etc)
		JRViewer v = new JRViewer();
		v.addContentSupport(ContentType.CenteredAndScaled);
		
		v.registerPlugin(new ContentAppearance());
		v.registerPlugin(new ContentLoader());
		v.registerPlugin(new ContentTools());
//		v.setShowMenuBar(false);
		
		Input inp = null;
		SceneGraphComponent cont = null;
		try {
			inp = Input.getInput("AL.obj");
			cont = Readers.read(inp);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
			
		Appearance ap = cont.getAppearance();
		ap.setAttribute(EDGE_DRAW, false);
		ap.setAttribute(VERTEX_DRAW, false);
		cont.setAppearance(ap);
		
		DefaultGeometryShader dgs = (DefaultGeometryShader) ShaderUtility.createDefaultGeometryShader(ap, true);
	    dgs.setShowLines(false);
	    dgs.setShowPoints(false);
	    DefaultPolygonShader dps = (DefaultPolygonShader) dgs.createPolygonShader("default");
	    dps.setDiffuseColor(Color.white);
	    ImageData id = null;
	    double scale = 1;
	    
	    args = new String[1];
	    args[0] = "textures/gridsmall.jpg";
	    // get the image for the texture first
	    if (args.length > 0) {
	      try {
			id = ImageData.load(Input.getInput(args[0]));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	    } else { // use a procedural texture
	      SimpleTextureFactory stf = new SimpleTextureFactory();
	      stf.update();
	      id = stf.getImageData();
	      scale = 10;
	      dps.setDiffuseColor(Color.yellow);
	    }
	    Texture2D tex = TextureUtility.createTexture(cont.getAppearance(), CommonAttributes.POLYGON_SHADER,id);
	    tex.setTextureMatrix(MatrixBuilder.euclidean().scale(scale).getMatrix());
		
		v.setContent(cont);
		
		v.startup();
	}

}

Am i missing anything??
Ps: I cant apply texture with the JRViewer (GUI) too. I load an object, then i select the content node then right cklick -> Appeparance -> Load texture .... but nothing happens

Andre
Posts: 226
Joined: Fri 18. Sep 2009, 11:30

Re: JRViewer issues

Post by Andre » Fri 2. Mar 2012, 18:53

First of all, yes it is possible to give different textures to different scenegraphs. I've checked once again your AI.obj and he is divided to a bunch of subscenegraphs.

I'm not really good with textures but I can tell you some hints I've experienced with textures in jReality. First it is just possible to attach textures to a sliced surface. If the surface is closed it is not possible, because of the "old" geometry structure of jReality. As a good further tutorial for textures I can recommend you this thread: http://www3.math.tu-berlin.de/jreality/ ... ?f=3&t=583

I don't have time to check your code right now, maybe I'm able at the weekend.

best
Andre

Shaguar
Posts: 12
Joined: Mon 27. Feb 2012, 14:31

Re: JRViewer issues

Post by Shaguar » Mon 5. Mar 2012, 11:57

Ok, i tried a lot but it is still not working.
Maybe its because all surfaces of the subscenegraphs of al.obj are closed?
How can i figure this out?

Andre
Posts: 226
Joined: Fri 18. Sep 2009, 11:30

Re: JRViewer issues

Post by Andre » Mon 5. Mar 2012, 13:05

Shaguar wrote:Ok, i tried a lot but it is still not working.
Maybe its because all surfaces of the subscenegraphs of al.obj are closed?
How can i figure this out?
It depends on, how the models are generated. In general they are closed...

Shaguar
Posts: 12
Joined: Mon 27. Feb 2012, 14:31

Re: JRViewer issues

Post by Shaguar » Mon 5. Mar 2012, 13:13

Do you know a tool/possibility to cut these surfaces wihtout changing the "appearance".
Is this possible? It's very important for me to get this working with the textures.

Andre
Posts: 226
Joined: Fri 18. Sep 2009, 11:30

Re: JRViewer issues

Post by Andre » Mon 5. Mar 2012, 15:52

I'm sorry, I don't know such a tool.

Maybe it is possible with halfedge/halfedgetools from jtem:
http://www3.math.tu-berlin.de/jtem/projects.html

If you don't find a tool there you have to write it for your own.

User avatar
steffen
Posts: 186
Joined: Fri 16. Jun 2006, 13:30
Location: TU Berlin
Contact:

Re: JRViewer issues

Post by steffen » Sun 11. Mar 2012, 21:45

Probably the data does not have texture coordinates. Otherwise you would see the texture.

Post Reply