AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with Viewing and translating the Stereo-pair Images

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> 3D Graphics API's for Java
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Tue Mar 28, 2006 4:59 pm    Post subject: Problem with Viewing and translating the Stereo-pair Images Reply with quote



Dear All,

I am using NVDIA Quadro 980 XGL graphics card. I am trying to call the
quad buffer for stereo rendering through java3d.

I am facing two problems

1) When I am trying to render the stereo images in immediate mode I do
not get any results (even with the stereo flag is set to true). However
if I draw a grphic like a small color cube I get the proper result that
is stereo rendering happens.
I am not able to figure out why this is happening is it a bug in
Java3D?

If I uncomment the following lines in paint method then my programs
works fine.

//If the line below uncommented then this test program
//runs correctly
// _gc3D.draw(new ColorCube(0.00));


2) Once the stereo rendering is switched on I want to translate the
image when a Mouse Drag event occurs. But when I am calling repaint
with in the mouse drag method , my program is hangging.

I would be grateful if anyone can share there experince or shed some
light on these problems.

Thank you in advance

Regards
-Chintan

PS: If anyone is intereseted in looking at the code I am posting it
with this mail

Following is the code.

import java.awt.*;
import java.awt.image.*;
import java.awt.color.*;
import javax.vecmath.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.universe.SimpleUniverse;
import javax.swing.event.*;
import java.awt.event.*;
import javax.media.j3d.*;
import javax.media.jai.*;
import com.sun.media.jai.codec.ImageCodec;
import com.sun.j3d.utils.geometry.ColorCube;
import java.awt.image.renderable.*;
import java.io.*;
import javax.swing.*;
import java.awt.geom.AffineTransform;
import javax.media.j3d.Transform3D;
import javax.vecmath.Vector3d;




public class IDLTestJava3D extends Canvas3D implements MouseListener,
MouseMotionListener {


private GraphicsContext3D _gc3D;
private J3DGraphics2D _j3DG2D;
private BufferedImage _imageLeft;
private BufferedImage _imageRight;
private MouseEventHandler eventHandler=null;
private AffineTransform _aft = null;
private Transform3D _t3d = null;
int X;
int Y;
int dx;
int dy;








public IDLTestJava3D(GraphicsConfiguration config,
BufferedImage imageLeft,
BufferedImage imageRight)
{
super(config);
this.dx=0;
this.dy=0;


_imageLeft = imageLeft;
_imageRight = imageRight;

addMouseListener(this);
addMouseMotionListener(this);
//Make sure that stereo is enabled
setStereoEnable(true);
this._aft=AffineTransform.getTranslateInstance(0,0);
this._t3d = new Transform3D();
this.X=0;
this.Y=0;
this.dx=0;
this.dx=0;




//Stop the renderer, since we use immediate mode rendering.
stopRenderer();




// Create a simple scene and attach it to the virtual universe
SimpleUniverse universe = new SimpleUniverse(this);

// This will move the ViewPlatform back a bit so the
// objects in the scene can be viewed.

universe.getViewingPlatform().setNominalViewingTransform();
}

public void paint(Graphics g)
{
super.paint(g);


if(_gc3D == null || _j3DG2D == null) {

setDoubleBufferEnable(false);

_gc3D = getGraphicsContext3D();
_gc3D.setBufferOverride(true);
_gc3D.setAppearance(new Appearance());
_gc3D.setBackground(new Background(new
Color3f(Color.black)));

}


_j3DG2D = getGraphics2D();
_gc3D.clear();
_j3DG2D.flush(true);


_gc3D.setModelTransform(this._t3d);


_gc3D.setStereoMode(GraphicsContext3D.STEREO_LEFT);


//If the line below uncommented then this test program
//runs correctly
// _gc3D.draw(new ColorCube(0.00));

_j3DG2D.drawAndFlushImage(_imageLeft, this.dx, this.dy,
null);



_gc3D.setStereoMode(GraphicsContext3D.STEREO_RIGHT);
//If the line below uncommented then this test program
//runs correctly
//_gc3D.draw(new ColorCube(0.0));

_j3DG2D.drawAndFlushImage(_imageRight, this.dx, this.dy,
null);









}




public void mouseClicked(MouseEvent e) {

}

public void mouseEntered(MouseEvent e) {

}
public void mouseExited(MouseEvent e) {


}

public void mousePressed(MouseEvent e) {


}

public void mouseReleased(MouseEvent e) {

}
public void mouseDragged(MouseEvent e) {
int X,Y,dx,dy;

X= e.getX();
Y= e.getY();

dx = X - this.X;
dy = Y - this.Y;
this.dx = dx;
this.dy = dy;

this._aft.translate(dx,dy);

this.X = X;
this.Y = Y;
repaint()


}

public void mouseMoved(MouseEvent e) {


}









public static void main(String[] argv)
{
if(argv.length != 2) {
System.out.println("Usage: java StereoCanvas
imageLeftFileName imageRightFileName");
}
GraphicsConfigTemplate3D template = new
GraphicsConfigTemplate3D();
template.setStereo(GraphicsConfigTemplate.REQUIRED) ;
GraphicsConfiguration config
=
GraphicsEnvironment.getLocalGraphicsEnvironment().

getDefaultScreenDevice().getBestConfiguration(template);
PlanarImage imageLeft = JAI.create("fileload", argv[0]);
PlanarImage imageRight = JAI.create("fileload", argv[1]);
IDLTestJava3D myCanvas3D =
new IDLTestJava3D(config,
imageLeft.getAsBufferedImage(),
imageRight.getAsBufferedImage());

JFrame jFrame = new JFrame();
jFrame.getContentPane().setLayout(new BorderLayout());

jFrame.getContentPane().add(myCanvas3D,
BorderLayout.CENTER);

jFrame.pack();
jFrame.setSize(200, 300);
jFrame.setVisible(true);
}
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> 3D Graphics API's for Java All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.