Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3
1  Java Game APIs & Engines / Tools Discussion / Re: Eclipse and row counting on: 2005-03-23 13:45:52
Try this eclipse plugin

http://metrics.sourceforge.net/

hmmm ... I just tried installing it but couldn't get it to work.  Let me know if you have any luck.  
2  Game Development / Game Mechanics / Re: [odejava] constraing to 2d? on: 2004-11-18 18:32:34
I was actually wondering how to do this as well.  
3  Games Center / Archived Projects / Re: Survivor - first alpha! on: 2004-06-05 23:21:06
I get a java runtime error and the program crashes.  I see the menu screen for about half a second, the screen flickers and it dies.  Does this happen to anyone else?
4  Java Game APIs & Engines / Xith3D Forums / Using JNLP with the Quake Demo on: 2004-05-10 07:19:47
I was trying to get Dave's quake demo to work with JAva Web Start but I ran into a problem with the resources.  There doesn't seem to be a way to load the map using a url.  There is only a method for loading it with a String.  Does this mean I can't use java web start with the quake loader?
5  Java Game APIs & Engines / Xith3D Forums / UI Problems in Windowed Mode on: 2004-05-09 16:22:57
Hey Everyone,
   I've been away from xith for quite a while so I apologize if this has already been brought up.  There seems to be problems with the UI in windowed mode.  Most notably it has problems picking up mouse clicks in the right place and slight rendernig artifacts (mostly text)  Even taking Dave's GUI demo code and changing it to windowed doesn't work.  Is there some extra step that has to be taken or is this a bug?

Thanks for the help.
6  Java Game APIs & Engines / Xith3D Forums / Re: Converting Screen Coordinates to World Coordin on: 2003-12-24 17:45:34
I'm interested! Can you post source?  Did you use gluUnproject or did you come up with another way to do it?
7  Java Game APIs & Engines / Xith3D Forums / Re: spatial partitioning [octrees] on: 2003-12-19 17:51:50
If you are attempting to change the scenegraph but constantly attaching and detaching branchgroups things are going to get really slow.  

A better way to do it (not sure if it's the best way but definately better than the above method) is to load everything that you want at the beginning and then set the branchgroups you don't want rendered using the setLive() method.

For instance, I split my terrain up into blocks and for blocks that I don't need rendered I call setLive(false);.  Then when the blocks needs to be rendered I call setLive(true);  

I'm not positive this is the best way to do it, but it is definately faster than attaching detaching the entire branchgroups which is what i tried previously.

Let me know if that speeds anything up.
8  Java Game APIs & Engines / Xith3D Forums / Re: look down Z on: 2003-12-18 19:29:55
That should be correct. Are you sure you oriented your model correctly?  
9  Java Game APIs & Engines / Xith3D Forums / Re: GUI Demo on: 2003-12-16 05:44:52
Thanks David!
   THis will help a lot!!  You rock!!  Grin
10  Java Game APIs & Engines / Xith3D Forums / Using Sound Objects on: 2003-12-16 00:37:40
It seems that all the functions that tell you if a sound is already playing don't work.  Is there a way to check is a sound is currently playing?

What I want to do is play a sound at random times but I want to make sure that I'm not playing it if it's already being played.

THanks for the help.

~shochu
11  Java Game APIs & Engines / Xith3D Forums / Re: UIEventAdapter Usage on: 2003-12-16 00:05:47
Yes I agree hehe.  It's frustrating to know that it can be done but I can't figure out how  :-/

The magicosm UI makes me so jealous
hahah
12  Java Game APIs & Engines / Xith3D Forums / Re: UIEventAdapter Usage on: 2003-12-15 21:35:45
Hi David ....
  Do you have any examples of a complex GUI which uses things like text fields and text areas?  I'm stil having problems and I think if I had a more complex example to look at I'd be able to figure it out.  The UI example's already available are all too simple to help me.  Thanks you. ~shochu  
13  Java Game APIs & Engines / Xith3D Forums / Re: UIEventAdapter Usage on: 2003-12-15 18:08:54
Here's my test program.  I want to have three panels.  One panel is the main panel and it has two subpanels.  The chat panel and the button Panel.  I use BorderLayout.  At first I didn't set any sizes because I thought the componenets would all expand to the right size, but that didn't work.  I explicitly set the sizes of everything below and that still doesn't work.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
import java.awt.*; 
import java.awt.event.*;
import com.xith3d.scenegraph.*;
import com.xith3d.render.*;
import com.xith3d.render.jogl.*;
import javax.vecmath.*;
import javax.swing.*;
import com.xith3d.userinterface.*;

 
public class TryUI{
 UIWindowManager windowMgr;
 View view;
 String inputText = "";
 
 public void start(){
       while(true){
             view.renderOnce();
       }
 }
 
 
 public void init() throws Exception
  {
   Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
 
   VirtualUniverse universe = new VirtualUniverse();
   view = new View();
   view.setBackClipDistance(100f);
   view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
   view.getTransform().lookAt(new Vector3f(0, 0, 3), new Vector3f(0, 0, 0), new Vector3f(0, 1, 3));
   Locale locale = new Locale();
   universe.addLocale(locale);
   universe.addView(view);
   RenderPeer renderPeer = new RenderPeerImpl();
   CanvasPeer canvasPeer = renderPeer.makeCanvas(null,
                                                                            screenSize.width - 200,
                                                                            screenSize.height - 200,
                                                                            16, false);
   canvasPeer.getWindow().setLocation(100, 100);
   Canvas3D canvas = new Canvas3D();
   canvas.set3DPeer(canvasPeer);
   view.addCanvas3D(canvas);
 
   // construct a window manager for this canvas
  windowMgr = new UIWindowManager(canvas);
   TestWindow w = new TestWindow(800,200);
   windowMgr.addOverlay(w);
   windowMgr.setPosition(w,25,600);
   windowMgr.setVisible(w,true);
   
   UIEventAdapter eventAdapter = new UIEventAdapter(windowMgr);
   canvas.get3DPeer().getComponent().addKeyListener(eventAdapter);
   canvas.get3DPeer().getComponent().addMouseListener(eventAdapter);
   canvas.get3DPeer().getComponent().addMouseMotionListener(eventAdapter);
   canvas.get3DPeer().getComponent().setFocusable(true);
 
   start();
 }
 
 class TestWindow extends UIWindow{
 
  public TestWindow(int width, int height) {
     super(width, height, false, false );
     setRoot(buildGUI(width,height));
     this.pack();
     
  }
 
  private JComponent buildGUI (int width, int height) {
   JPanel mainPanel = new JPanel();
   JPanel chatPanel = new JPanel();
   JPanel buttonPanel = new JPanel();
   
   
   
   
   mainPanel.setDoubleBuffered(true);
   mainPanel.setLocation(0,0);
   mainPanel.setBackground(new Color(1.0f,1.0f,1.0f,0.5f)); //the 4th parameter changes the transparency setting
     
   //TextArea  
  final JTextArea textAreaScreen = new JTextArea();
   textAreaScreen.setEditable(false);
   textAreaScreen.setBackground(new Color(1f,1f,1f,.5f));
   textAreaScreen.setLineWrap(true);
   
   //ScrollPane
  final JScrollPane scrollPaneScreen = new JScrollPane(textAreaScreen);
   scrollPaneScreen.setBackground(new Color(1f,1f,1f, 0.5f));
   scrollPaneScreen.setSize(width, 100);
     
   scrollPaneScreen.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
        public void adjustmentValueChanged(AdjustmentEvent e) {
              scrollPaneScreen.repaint();
        }
   });

   //TextField
  final JTextField textFieldInput = new JTextField();
   textFieldInput.setSize(width, 100);
   textFieldInput.setBackground(new Color(1f,1f,1f,0.5f)); //the 4th parameter changes the transparency settings
  textFieldInput.addKeyListener(new KeyListener(){
       public void keyPressed(KeyEvent e) {}
         
       public void keyReleased(KeyEvent e) {}
 
       public void keyTyped(KeyEvent e) {
            if(e.getKeyChar() == 10){
                  textAreaScreen.append("\n" + textFieldInput.getText());
                  textFieldInput.setText("");
            }  
       }
    });
   
   //Button
  JButton logoutButton = new JButton();
   logoutButton.setText("Logout");
   logoutButton.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
        System.exit(0);
      }
   });  
   //Set Panel and Component SIze
  mainPanel.setSize(new Dimension(width,height));
   chatPanel.setSize(new Dimension(width, height/2));
   buttonPanel.setSize(new Dimension(width, height/2));
   scrollPaneScreen.setSize(new Dimension(width, height/4));
   textAreaScreen.setSize(new Dimension(width, height/4));
   textFieldInput.setSize(new Dimension(width, height/4));
   logoutButton.setSize(new Dimension(100,25));
   
   chatPanel.add(scrollPaneScreen, BorderLayout.CENTER);
   chatPanel.add(textFieldInput, BorderLayout.SOUTH);
   buttonPanel.add(logoutButton, BorderLayout.SOUTH);
   mainPanel.add(chatPanel, BorderLayout.CENTER);
   mainPanel.add(buttonPanel, BorderLayout.SOUTH);
 
   return mainPanel;
   
  }
   
 
 }
 
 public static void main(String[] args)
  {
   try
   {
      TryUI test = new TryUI();
      test.init();
   }
   catch (Exception e)
   {
      e.printStackTrace();
   }
 }
}



WHat could be causing the problem?  
14  Java Game APIs & Engines / Xith3D Forums / Re: UIEventAdapter Usage on: 2003-12-15 14:17:56
Also, I don't think the layoutManagers are working.  At least not in the way you can use them in normal SWing.
15  Java Game APIs & Engines / Xith3D Forums / Re: UIEventAdapter Usage on: 2003-12-15 12:46:12
Are you talking about adding this listener?

1  
2  
3  
4  
5  
6  
            scrollPaneScreen.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener(){
                  public void adjustmentValueChanged(AdjustmentEvent e){
                        scrollPaneScreen.repaint();
                  }
            }
            );


I added that and you can scroll with the keyboard but not by using the VerticalScrollBar.  I tried adding listeners for mouse events and repaint on those but that didn't do anything.  Any ideas?
16  Java Game APIs & Engines / Xith3D Forums / Re: The JWS thread *Xith3D demos only* on: 2003-12-15 04:09:33
WHere exactly is this warmUp() method??  SOrry to be a bother ... I'm just studying your code cause I want to learn how particle systems work hehe. It's really cool by the way.  THanks for making so many great demos available. ~shochu
17  Java Game APIs & Engines / Xith3D Forums / Re: The JWS thread *Xith3D demos only* on: 2003-12-15 03:35:12
JavaCoolDude,
   In your particle demo, how come the first wave of particles is always a halo shape and then the settings seem to kick in?
18  Java Game APIs & Engines / Xith3D Forums / Re: UI Problems, scrollpane issues on: 2003-12-15 02:07:55
Mabye add a CaretListener and listen for careUpdate events.  When you get a caret update event do a repaint on the text area?

That's what I would try at least.  Are your scroll panes working?  My scroll pane buttons aren't working as I posted previoulsy here http:// http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=xith3d;action=display;num=1071447510

If you get your scroll pane buttons and slider working please let me know how you did it.  Thanks =)

Also,  I tried jyang81's code above adding the fix David mentioned and I noticed that the textinput panel is transparent as should be but the textarea isn't.  

Did you guys have this problem too?  It seems both of them should be the same color right?  ANyone know how to fix this because I'm sure I will run into the problem soon.
19  Java Game APIs & Engines / Xith3D Forums / Re: UIEventAdapter Usage on: 2003-12-15 02:03:11
I just added a flag to UIWindow which tells me if the window is in focus.  For now I just check that before doing anything in my main window with key inputs.

However, I'm having another problem.  I think this one is similar to Jyang81's questions about scrollPanes.  I have a scrollpane and it works only if you are scolling up and down in the textarea with your keyboard arrow keys.  If you try to click on the scollpane buttons (the up and down arrow) using your mouse nothing happens.  Also, if you try to scoll the scoll pane bar nothing happens.

Any idea how to fix this or is this a problem with the UI system in xith??
20  Java Game APIs & Engines / Xith3D Forums / Re: UIEventAdapter Usage on: 2003-12-15 01:32:02
Both ideas sound good to me.  Both of them sound easy enough to use.  The flag seems very easy to implement.  Having xith pass the event first to to the overlay with focus and then if the event is not consumed passing the event to the main window is probably the best.  I'm not sure if this is technically possible though.  Until a fix is made I'll just hack the source and add a flag myself.   Thanks for the info David!

~shochu
21  Java Game APIs & Engines / Xith3D Forums / UIEventAdapter Usage on: 2003-12-14 22:18:30
I notice that the UIEVentAdapter receives all Mouse and Keyboard events.  It then dispatches the event to the proper overlay (i.e. the one with focus) However, the main canvas is not in the overlay list.  How do we set up the mouse and keyboard listeners for the main Canvas3D so that it is also considered an overlay.  

IN other words, right now, when I input text into a textfield overlay my keyboard inputs are also effecting the main cavas3D.

Am I supposed to add the Cavnas3D as an overlay??  Any example code would be greatly appreciated.  Thank you for the help. ~shochu
22  Java Game APIs & Engines / Xith3D Forums / Re: Keeping ActionEvents seperate for each Overlay on: 2003-12-14 02:02:49
RIght now I have a UI which is a text area and when I type text into any keys which I catch for my main window still affect the main window.

In the main program I do ...

1  
                  Toolkit.getDefaultToolkit().addAWTEventListener(new KeyboardEventListener(keyEventList),AWTEvent.KEY_EVENT_MASK);
                             

For the overlay I do

1  
2  
3  
4  
5  
            UIEventAdapter eventAdapter = new UIEventAdapter(windowMgr);
            canvas.get3DPeer().getComponent().addKeyListener(eventAdapter);
            canvas.get3DPeer().getComponent().addMouseListener(eventAdapter);
            canvas.get3DPeer().getComponent().addMouseMotionListener(eventAdapter);
            canvas.get3DPeer().getComponent().setFocusable(true);


Then in the actual class which extend UIOverlay I go
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
            textFieldInput.addKeyListener(new KeyListener(){
                  public void keyPressed(KeyEvent e) {}

                  public void keyReleased(KeyEvent e) {}

                  public void keyTyped(KeyEvent e) {
                        //this notices when 'enter' is pressed and the string in the text field should be sent to the
                       //text area for everyone to see when chatting
                       if(e.getKeyChar() == 10){
                              inputText = textFieldInput.getText();
                              System.out.println(inputText);
                              textFieldInput.setText(""); //clears the textfield after pressing enter
                             //textAreaScreen.append("\n" + inputText); //places the input text into the textArea
                             setMessage("\n" + inputText);
                              //client.processMessage(inputText);
                                   
                        }            
                              
                  }
                  
            });
                        

I have a feeling I must be setting the listeners improperly.  Are you able to tell just from those code snippets where I'm going wrong?  Perhaps I'm setting one too many listeners or I'm setting up the main program listener improperly?  Thank you very much for all your help.


--------------- EDIT ---------------

Okay, I looked through the UI source and I here's what I think is going on.  All events get caught by UIEventAdapter.  UIEventAdapter then passes the event along to the overlay which has focus.  

I got rid of the Toolkit.getDefaultToolkit code but now I'm not sure how I should set listeners for the main program window so that it receives events from the UIEventAdapter.  Thanks again.
~shochu
23  Java Game APIs & Engines / Xith3D Forums / Keeping ActionEvents seperate for each Overlay on: 2003-12-14 01:08:39
What's the best way to handle events for multiple overlays?

Is it best to have one mouse listener and one keyboard listener for your entire program then check which overlay has the focus to see where the actions should go.

Or should each overlay have it's own listener and the listener only reacts if its respective overlay has focus.  

I was thinking it would be better for each overlay to have it's own listeners which start with an if statement checking for focus.  If the overlay has focus then it does the appropriate action and consumes the event.  

Has anyone had to deal with this before?

My overlays include things like chat windows so they do more then just display data. Thanks for the advice.

Also, I just wanted to thank everyone who has been so helpful lately.  My classes are starting to wind down so I have a lot of time recently to program using xith3d for my own education and enjoyment.  Hence, the large influx of questions to the boards.  
24  Java Game APIs & Engines / Xith3D Forums / Re: How is the scengraph traversed? on: 2003-12-13 23:09:59
THanks =)  That helped.  I was assuming that the transformation were being applied from the root down to the leaf but I guess it's from the lead up to the root.  Smiley
25  Java Game APIs & Engines / Xith3D Forums / How is the scengraph traversed? on: 2003-12-13 19:19:28
A new question which has nothing to do with gluUnProject.


Suppose we have the following pseudocode

addChild(Translation)
Translation.addchild(Rotation)
Rotation.addChild(ourShape)

This should create a branch which looks like:
    Root --> Translation --> Rotation --> outShape

Supposed our object starts at (0,0,0)

I thought the above would first translate the object (lets say to (0,10,0))

Then it would do a rotation around the origin (0,0,0)

However, when I actually code this up it does the rotation around the center of the object.  I'm a little confused by that.  I thought if you want to rotate the object around it's own center you need to do the rotation first then the translation.  

Can someone point out where I'm wrong in my thinking?


On another note. Shouldn't these two blocks of code do the exact same thing?  BLock 1 works for me and Block 2 does not.

Block 1:  (Position is a vector3f)
 
1  
2  
3  
      translate.setTranslation(position);
      translateGroup.setTransform(translate);
 


Block 2:

1  
2  
3  
4  
5  
6  
  (position is the same as above)
            Matrix4f transMatrix = new Matrix4f();
            transMatrix.setTranslation(position);
            translate.set(transMatrix);
            translateGroup.setTransform(translate);
 

Thanks. ~shochu
26  Java Game APIs & Engines / Xith3D Forums / Re: Converting Screen Coordinates to World Coordin on: 2003-12-13 15:16:52
Yup, that makes sense.  I hate keep pestering you with questions but here comes another one.  (A little more concrete this time)


I have an object on the screen located at (50,0,50) in world coordinates.  It is currently at the center of the screen.

I click on the object.

I then call gluUnProject using the projection matrix and using a modelview matrix which only contains the camera's transformation (because I want world coordinates back).  In addition I pass the in the viewport, the mouseX and mouseY coordinates and the value 1.0 for winz which I beleive is for the far clipping plane.

For the viewport I am using
viewPort[] = {0, canvasHeight, canvasWidth, canvasHeight}  The first two values should be the location of the lower left of the screen.  I know the default is 0,0 but I think in xith3d 0,0 is the top left so I adjusted it accordingly.

I get back from the gluUnProject call the following values.

targetx: 49.99645
targety: -40.57691
targetz: 15.948797

Then I call gluUnProject again with the exact same parameters except with winz of 0 for the near clipping plane and I get.

eyex:  50.00118
eyey:  -43.640434
eyez:  13.434351

I'm a little concerned because I thought that at least one of the values in target and eye would have to be the same since the only paramter that changed was the winz.  Is that assumption in fact correct?




27  Java Game APIs & Engines / Xith3D Forums / Re: Converting Screen Coordinates to World Coordin on: 2003-12-13 03:35:30
Hi David,
  Isn't your suggestion pretty much the same as what I'm trying to do now?  I'm still having problems but will keep working on it.

On another note,
  I ported over the gluUnProject code for anyone that might want to use it.  I think it's pretty useful.  I'm pretty sure it works without any problems (the problems I'm having are related to how I use the gluUnProject ... i think)  I called it xithUnProject.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
      /**
       * Multiplies the 4x4 matrix 'M' by the column vector 'in.'  This is a helper function for the xithUnProject method
       * @param M
       * @param in
       * @return out a column vector with 4 elements
       */

      private float[] transform_point(Matrix4f M, float[] in)
      {
         float [] out = new float[4];
         out[0] =
              M.getElement(0, 0) * in[0] + M.getElement(0, 1) * in[1] + M.getElement(0, 2) * in[2] + M.getElement(0, 3) * in[3];
         out[1] =
              M.getElement(1, 0) * in[0] + M.getElement(1, 1) * in[1] + M.getElement(1, 2) * in[2] + M.getElement(1, 3) * in[3];
         out[2] =
              M.getElement(2, 0) * in[0] + M.getElement(2, 1) * in[1] + M.getElement(2, 2) * in[2] + M.getElement(2, 3) * in[3];
         out[3] =
              M.getElement(3, 0) * in[0] + M.getElement(3, 1) * in[1] + M.getElement(3, 2) * in[2] + M.getElement(3, 3) * in[3];
         
         return out;
      }
     
      /**
       * Converts the given screen coordinates into object coordiantes based on the given projection and modelview matrix.
       * @param winX  screen coordinate x
       * @param winY  screen coordinate y
       * @param winZ  screen coordinate z
       * @param model modelview matrix
       * @param projection projection matrix
       * @param viewPort viewport
       * @param results puts the final object coordinates into the results array where results[0] = x, results[1] = y results[2] = z
       * @return boolean stating whether the unprojection was succesful or not
       */

      public boolean xithUnProject(float winX, float winY, float winZ, Matrix4f model, Matrix4f projection, int []viewPort, float[] results){
            float in[] = new float[4];
            float out[] = new float[4];
           
            Matrix4f A = new Matrix4f();
            in[0] = (winX - (float)viewPort[0]) * 2.0f / (float)viewPort[2] - 1.0f;
            in[1] = (winY - (float)viewPort[1]) * 2.0f / (float)viewPort[3] - 1.0f;
            in[2] = 2.0f * winZ - 1.0f;
            in[3] = 1.0f;
           
            A.mul(projection, model);
            A.invert();
            out = transform_point(A, in);
            if(out[3] == 0)
                  return false;
           
            results[0] = out[0] / out[3];
            results[1] = out[1] / out[3];
            results[2] = out[2] / out[3];
            return true;
      }


Please let me know if you use it and think something isn't working properly.  
28  Java Game APIs & Engines / Xith3D Forums / Re: Converting Screen Coordinates to World Coordin on: 2003-12-13 01:58:20
I've got kind of a unique use so let me elaborate (Thanks for your reply by the way it helped a lot)

I'm making a 3D isometric game.  (I think that's an oxymoron) (Think Neverwinter Nights or any 3d RTS ala Warcraft 3)  The game is just for learning purposes of course.

For now the terrain is just a perfectly flat plane.
defined by Point(0,0,0) Normal (0,1,0)

When the user clicks on the screen I want to figure out where they are clicking on the terrain so I can decide where to move the avatar.

When the user clicks on the screen with the mouse I grab the screen coordiantes.  I then pass these to gluUnProject first with winZ set to 0 then winz set to 1.  

From this I can get the picking ray.

I'm a little confused as to what model view matrix I should use. The bottom right corner of the terrain is at point (0,0,0) and then grows from there.  Thus I thought that my world coordinates would coincide with the terrain coordinates.

But it seems that I need to use the Modelview matrix of the terrain?    If I use the modelview matrix of the terrain then is this giving me a ray which goes from the camera through the point clicked on by the user?  

If so then I was planning to then figure out where the ray intersected the plane.  When you say that if the modelview matrix only contains the camera transformation would this mean that it the same as the projection matrix? Thanks for your generous help! ~shochu

29  Java Game APIs & Engines / OpenGL Development / Re: clicking on sphere on: 2003-12-13 01:32:07
I had a few general questions about the ray casting technique here.

1)  What exactly is the ray given by dirOut in your example code.  Is this the ray which goes from the camera through the point clicked on by the mouse?

2) Does each object in  your scene have its own model view matrix?

3) If each object has its own model view matrix then which one do you use when you want to get the ray of the mouse pick?


THanks for your help!
30  Java Game APIs & Engines / Xith3D Forums / Re: Converting Screen Coordinates to World Coordin on: 2003-12-12 22:22:41
I've been working on porting the gluUnProject function from the mesa version of OpenGL into my xith program and I'm getting a little confused when it comes to the modelview matrix and using gluUnProject.


As taken from the openGL redbook gluUnProject maps the specified window (screen) coordinates into object coordinates.

From what I've read it seems that you use gluUnProject to convert screen coordinates obtained through mouse clicks into world coordinates.  

I assumed we could do the following

   Call gluUnProject twice to get the picking ray
   Once you have the picking ray check where the     picking ray intersects the objects in your scene.  (In this case I want to know where it intersects the terrain)  


However, if you are really getting object coordinates then how does this help you in determing if the picking ray intersects anything?  Do you have to use the model view matrix for the object you want to test intersection with?  

Thanks in advance for any clarification. ~shochu
Pages: [1] 2 3
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (50 views)
2014-04-15 18:08:23

BurntPizza (46 views)
2014-04-15 03:46:01

UprightPath (62 views)
2014-04-14 17:39:50

UprightPath (44 views)
2014-04-14 17:35:47

Porlus (61 views)
2014-04-14 15:48:38

tom_mai78101 (84 views)
2014-04-10 04:04:31

BurntPizza (142 views)
2014-04-08 23:06:04

tom_mai78101 (242 views)
2014-04-05 13:34:39

trollwarrior1 (201 views)
2014-04-04 12:06:45

CJLetsGame (208 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!