Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
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 ... 5
1  Java Game APIs & Engines / JOGL Development / Re: Picking Problem on: 2011-12-13 10:05:55
Thank you for the solution but I still get a black flicker when I click my snowman, is that normal?
Also why do I keep getting 2 hits? I only hit one snowman so I should only get 1 hit i think no?

Also another question, If i use a lot of models (self made with vertexes and textures) should I use displaylists
or go for VBO's?

thx
2  Java Game APIs & Engines / JOGL Development / Re: Profile GL_DEFAULT is not available on null, but: [] on: 2011-12-13 10:02:17
Have u tried with

1  
GLProfile glp = GLProfile.getMaxFixedFunc();


Are the libraries and jars correctly linked?
3  Java Game APIs & Engines / JOGL Development / Picking Problem on: 2011-12-09 09:51:05
Hello, I was digging into picking the other day when I found an example about picking using 4 snowmen.

The tutorial was written in C++ so I converted it to JOGL 2.0 code but I ran into some trouble.

When I click 3 out of 4 snowmen I get 2 hits, instead of 1. How ever the eventual number of the snowman clicked
then matches (1 to 3). When i click the first snowman (bottom left), I get only 1 hit, like it is supposed to be i think but
I still get the result that I clicked snowmen nr 1 (instead of 0). I attached code here. Does any1 have any idea what i do wrong?
Also every time i click on my screen, it blinks black for a second. Is this normal and is there any way to avoid this?

Thx

The JFRame class and other GUI stuff
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  
package snowmanpicking;

import com.jogamp.opengl.util.FPSAnimator;

import java.awt.Dimension;
import java.awt.event.*;

import javax.media.opengl.*;
import javax.media.opengl.awt.GLJPanel;

import javax.swing.*;

/**
 *
 * @author Grand Poeba
 */

public class SnowmanFrame extends JFrame {
    private GLJPanel gljPanel;
   
    public SnowmanFrame(){
        this.initGUI();
    }
   
    private void initGUI(){
        // Choose the GL profile
        GLProfile glp = GLProfile.getMaxFixedFunc();
        // Configure the GL capabilities
        GLCapabilities caps = new GLCapabilities(glp);
       
        this.gljPanel = new GLJPanel(caps);
        final Render r = new Render();
        this.gljPanel.addGLEventListener(r);
       
        this.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getButton() != MouseEvent.BUTTON1) return;

                r.cursorX = e.getX();
                r.cursorY = e.getY();
                r.mode = GL2.GL_SELECT;
                System.out.println("Swapped mode to GL_SELECT");
            }
       
        });
        this.getContentPane().add(this.gljPanel);        
       
        this.setMinimumSize(new Dimension(800,600));  
       
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
    }
   
    public GLJPanel getGLJPanel() {
        return this.gljPanel;
    }

    public static void main (String[] args){
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                SnowmanFrame sf = new SnowmanFrame();
                FPSAnimator animator = new FPSAnimator(sf.getGLJPanel(), 60);
                animator.add(sf.getGLJPanel());
                animator.start();
            }
        });
    }
}


The actual renderer with picking code
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  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
package snowmanpicking;

import com.jogamp.common.nio.Buffers;

import com.jogamp.opengl.util.gl2.GLUT;

import java.nio.IntBuffer;

import javax.media.opengl.*;
import javax.media.opengl.glu.GLU;

/**
 *
 * @author Grand Poeba
 */

public class Render implements GLEventListener {

    public static int cursorX, cursorY;
    private float posX, posY, posZ, lookAtX, lookAtY, lookAtZ;
    public static int mode, hits;
   
    // Picking Stuff //
    int BUFSIZE = 1024;
    IntBuffer selectBuf = Buffers.newDirectIntBuffer(BUFSIZE);
    // display list of our snowman
    public static int snowman_display_list;

    void processKeyboard(char key, int x, int y) {
        System.out.printf("key: %d\n", key);
    }

    void picked(int name, int sw) {
        System.out.printf("my name = %d in %d\n", name, sw);
    }

    void drawSnowMan(GL2 gl, GLUT glut) {
        gl.glColor3f(1.0f, 1.0f, 1.0f);

// Draw Body  
        gl.glTranslatef(0.0f, 0.75f, 0.0f);
        glut.glutSolidSphere(0.75f, 20, 20);


// Draw Head
        gl.glTranslatef(0.0f, 1.0f, 0.0f);
        glut.glutSolidSphere(0.25f, 20, 20);

// Draw Eyes
        gl.glPushMatrix();
        gl.glColor3f(0.0f, 0.0f, 0.0f);
        gl.glTranslatef(0.05f, 0.10f, 0.18f);
        glut.glutSolidSphere(0.05f, 10, 10);
        gl.glTranslatef(-0.1f, 0.0f, 0.0f);
        glut.glutSolidSphere(0.05f, 10, 10);
        gl.glPopMatrix();

// Draw Nose
        gl.glColor3f(1.0f, 0.5f, 0.5f);
        gl.glRotatef(0.0f, 1.0f, 0.0f, 0.0f);
        glut.glutSolidCone(0.08f, 0.5f, 10, 2);
    }

    int createDL(GL2 gl) {
        int snowManDL;

        // Create the id for the list
        snowManDL = gl.glGenLists(1);

        gl.glNewList(snowManDL, GL2.GL_COMPILE);
        drawSnowMan(gl, new GLUT());
        gl.glEndList();

        return (snowManDL);
    }

    void draw(GL2 gl) {
        // Draw ground
        gl.glColor3f(0.9f, 0.9f, 0.9f);
        gl.glBegin(GL2.GL_QUADS);
        gl.glVertex3f(-100.0f, 0.0f, -100.0f);
        gl.glVertex3f(-100.0f, 0.0f, 100.0f);
        gl.glVertex3f(100.0f, 0.0f, 100.0f);
        gl.glVertex3f(100.0f, 0.0f, -100.0f);
        gl.glEnd();

        // Draw 4 SnowMen
         
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                gl.glPushMatrix();
                gl.glPushName(i * 2 + j);
                gl.glTranslated(i * 3.0, 0, -j * 3.0);
                gl.glCallList(snowman_display_list);
                gl.glPopName();
                gl.glPopMatrix();
            }
        }
    }

    @Override
    public void dispose(GLAutoDrawable drawable) {
    }

    @Override
    public void display(GLAutoDrawable drawable) {
        final GL2 gl = drawable.getGL().getGL2();

        gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);

        if (mode == GL2.GL_SELECT) startPicking(gl);

        gl.glLoadIdentity();

        GLU glu = new GLU();
        glu.gluLookAt(posX, posY, posZ, lookAtX, lookAtY, lookAtZ, 0.0f, 1.0f, 0.0f);

        draw(gl);

        if (mode == GL2.GL_SELECT) stopPicking(gl);
    }

    @Override
    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        final GL2 gl = drawable.getGL().getGL2();
        GLU glu = new GLU();

        float ratio;
        // Prevent a divide by zero, when window is too short
        // (you cant make a window of zero width).

        if (height == 0) height = 1;
       
        ratio = 1.0f * width / height;
        // Reset the coordinate system before modifying
        gl.glMatrixMode(GL2.GL_PROJECTION);
        gl.glLoadIdentity();

        // Set the viewport to be the entire window
        gl.glViewport(0, 0, width, height);

        // Set the clipping volume
        glu.gluPerspective(45, ratio, 0.1, 1000);

        // setting the camera now
        gl.glMatrixMode(GL2.GL_MODELVIEW);
    }

    @Override
    public void init(GLAutoDrawable drawable) {
        final GL2 gl = drawable.getGL().getGL2();

        posX = 1.5f;
        posY = 3.75f;
        posZ = 3f;

        lookAtX = 1.5f;
        lookAtY = 1.75f;
        lookAtZ = 0f;

        gl.glEnable(GL2.GL_DEPTH_TEST);
        gl.glEnable(GL2.GL_CULL_FACE);

        snowman_display_list = createDL(gl);
       
        // enable vsync
        gl.setSwapInterval(1);    
    }

    void startPicking(GL2 gl) {
        System.out.println("Start Picking");
        IntBuffer viewport = Buffers.newDirectIntBuffer(4);
        float ratio;

        gl.glSelectBuffer(BUFSIZE, selectBuf);

        gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport);

        gl.glRenderMode(GL2.GL_SELECT);

        gl.glInitNames();

        gl.glMatrixMode(GL2.GL_PROJECTION);
        gl.glPushMatrix();
        gl.glLoadIdentity();

        GLU glu = new GLU();
        glu.gluPickMatrix(cursorX, viewport.get(3) - cursorY, 5, 5, viewport);

        ratio = (float) (viewport.get(2) + 0.0f) / (float) viewport.get(3);
        glu.gluPerspective(45, ratio, 0.1, 1000);
        gl.glMatrixMode(GL2.GL_MODELVIEW);
    }

    void stopPicking(GL2 gl) {
        System.out.println("Stop Picking");

        gl.glMatrixMode(GL2.GL_PROJECTION);
        gl.glPopMatrix();
        gl.glMatrixMode(GL2.GL_MODELVIEW);
        gl.glFlush();

        hits = gl.glRenderMode(GL2.GL_RENDER);

        if (hits > 0) {
            System.out.println("# of hits: " + hits);
            processHits(hits, selectBuf);
        } else {
            System.out.println("no hits");
        }
        mode = GL2.GL_RENDER;
    }

    void processHits(int hits, IntBuffer buffer) {        
        int name = -1;
        int i = 0, nrOfHits = 0;
        while(nrOfHits < hits && i < BUFSIZE) {
            if(buffer.get(i) > 0){
                name = buffer.get(i);
                nrOfHits++;
            }
            i++;
        }
       
        if (name < 0) {
            System.out.printf("You didn't click a snowman!");
        } else {
            System.out.printf("You picked snowman  ");
            System.out.printf("%d ",  name);
        }
        System.out.printf("\n");
    }
}
4  Java Game APIs & Engines / JOGL Development / Re: Transform mouse coordinates to world XZ coordinates on: 2011-11-23 09:11:04
Ah nevermind if found the solution Smiley

I forgot to reset the camera to its place after drawing the scene before doing the picking

The coordinates are correct now when i click on a square i draw. Thx for any help
5  Java Game APIs & Engines / JOGL Development / Re: Transform mouse coordinates to world XZ coordinates on: 2011-11-23 09:03:46
I have enabled GL.GL_DETPH and changed converting code to

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
        winX = (float)this.pickX;                                               // Holds The Mouse X Coordinate
        winY = (float)this.pickY;                                               // Holds The Mouse Y Coordinate
        winY = (float)this.viewport.get(3) - winY;                              // Subtract The Current Mouse Y Coordinate From The Screen Height.
                         
       
        FloatBuffer fb = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asFloatBuffer();
        gl.glReadPixels((int)winX, (int)winY, 1, 1, GL2.GL_DEPTH_COMPONENT, GL2.GL_FLOAT, fb);
        fb.rewind();
       
        System.out.println("Coordinates at cursor are (" + winX + ", " + winY+")");
       
        FloatBuffer projectedPositions = FloatBuffer.allocate(3);
        new GLU().gluUnProject(winX, winY, fb.get(0), //
               this.modelview, this.projectionview, this.viewport, projectedPositions);
       
         System.out.println("World coords at z="+fb.get(0)+" are ( " //
                             + projectedPositions.get(0)+" "+projectedPositions.get(1)+" "+projectedPositions.get(2)
                             + ")");


The results are much realistic now, but the there is still deviation, except for points near the center of my screen.
Should i also update the projection matrix each from or is modelmatrix enough?

thx
6  Java Game APIs & Engines / JOGL Development / Transform mouse coordinates to world XZ coordinates on: 2011-11-21 17:35:23
Hi

I am currently working on a some sort of editor. The terrain of this editor is a map built out of tiles (squares).
When i click my GLJPanel i sent a mouseevent because I want to check if I click on a tile.

So basicly I want to convert my X and Y mouse coordinate to Coordinate in the XZ plane (since Y axis is the one pointing up).

So far I tried to do this using glu.gluUnProject but i have no success doing so

During init methode of GLEventListener
1  
2  
3  
        this.viewport = IntBuffer.allocate(4);                                  // Where The Viewport Values Will Be Stored
        this.modelview = FloatBuffer.allocate(16);                              // Where The 16 Doubles Of The Modelview Matrix Are To Be Stored
        this.projectionview = FloatBuffer.allocate(16);                         // Where The 16 Doubles Of The Projection Matrix Are To Be Stored


Whenever I reshape my window I update the buffers
1  
2  
        gl.glGetIntegerv(GL2.GL_VIEWPORT, this.viewport);
        gl.glGetFloatv(GL2.GL_PROJECTION_MATRIX, this.projectionview);


Every time a frame is drawn i update modelview buffer in display method
1  
        gl.glGetFloatv(GL2.GL_MODELVIEW_MATRIX, this.modelview);


This is the code i execute when i want to convert the mouse to XZ plane coordinates
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
        float winX, winY;                                                         // Holds Our X, Y and Z Coordinates
 
        winX = (float)this.pickX;                                               // Holds The Mouse X Coordinate
        winY = (float)this.pickY;                                               // Holds The Mouse Y Coordinate
        winY = (float)this.viewport.get(3) - winY - 1;                   // Subtract The Current Mouse Y Coordinate From The Screen Height.
                 
        FloatBuffer projectedPositions = FloatBuffer.allocate(3);

        boolean succes = new GLU().gluUnProject(winX, winY, 0.0f, this.modelview, this.projectionview, this.viewport, projectedPositions);
       
        System.out.println(projectedPositions.get(0)+" "+projectedPositions.get(1)+" "+projectedPositions.get(2)+" "+succes);


Am I using the wrong method or am I passing along the wrong arguments?


When i see at least 10 tiles on my screen, each tile = 1.0f x 1.0f the difference between most left and most right tile on my screen is maybe 0.1f so something is obviously going wrong

Thx for any help
7  Java Game APIs & Engines / JOGL Development / Re: Nehe tutorials ported to jogl 2.0 (1-13 so far) on: 2011-11-08 09:03:26
I uploaded the new code to include tutorials 11 to 13.

I solved the problem in tutorial 10 with the textures by adjusting the original nehe world.txt to something more suitable
In tutorial 13 however i dont see the text being printed on the screen.

Maybe ask some help on the official JOGL forum (JogAmp.org). You should ask Michael Bien (bienator here) to add your tutorials to our wiki.

I made topic there too, I solved the tutorial 13 problem by adjusting the translate position
In tutorial 12 however it seems for every triangle it draws and extra black sqaure/triangle that interferes with the cubes rendered thus making it look like corners of the cubes are missing
8  Java Game APIs & Engines / JOGL Development / Re: Nehe tutorials ported to jogl 2.0 (1-13 so far) on: 2011-11-07 13:23:19
I uploaded the new code to include tutorials 11 to 13.

I solved the problem in tutorial 10 with the textures by adjusting the original nehe world.txt to something more suitable
In tutorial 13 however i dont see the text being printed on the screen.
9  Java Game APIs & Engines / JOGL Development / Re: Nehe tutorials ported to jogl 2.0 (1-10 so far) on: 2011-11-02 11:32:48
Hi

Can you tell me which version of JOGL 2.0 you use? Which build exactly? Can you rather put a ZIP? I cannot open RAR files. Some tutorials for JOGL are always welcome. Thanks.

I used version 2.0-b41-20110916 and I uploaded the archive as zip now
10  Java Game APIs & Engines / JOGL Development / Nehe tutorials ported to jogl 2.0 (1-13 so far) on: 2011-11-02 09:52:07
Hi everyone,

Recently I decided to pick up on java and opengl again using JOGL.
I was only used to 1.1 version so I decided to port the Nehe tutorials to Jogl 2.0.
However I ran into some trouble with tutorial 9 and 10.

Tutorial 9: No matter what color I specify before drawing the squares/stars they are always white/grayish

I have attached the code from all current Tutorials i have converted (first 10). I also made a selection menu so u can easy run each
different tutorial.

If anyone has any idea I would like to hear em. Remarks on the current converted code are also welcome.
I will also try and convert eventualy all tutorials and if people are interested in all tutorialcode let me know and I might upload them

Thx

EDIT updated link to lessons 13 : File name: tutorials.zip File size: 417.38 KB
11  Java Game APIs & Engines / JOGL Development / Re: Some problems with new version :) on: 2007-02-17 13:15:58
is there anyway is can still work with glu.gluLookAt()? cause i am quite used to it
when i do GLU glu = new GLU() in my init the glu appears to be null? :s
quite confused here Sad
thx for any helpa
12  Java Game APIs & Engines / JOGL Development / Re: Some problems with new version :) on: 2007-02-16 08:00:15
so what class/methods do i best use to make some sort of camera?
13  Java Game APIs & Engines / JOGL Development / Re: Some problems with new version :) on: 2007-02-15 13:15:14
maybe it's because you are in the projection matrix mode. try changing that to the modelview mode.

also, you dont seem to specifiy a viewport, in the init or reshape function as well as some other necessary stuff seems to be missing.

did this code ever work before?

i use the lookat method instead of a viewport at least that worked with earlier versions
14  Java Game APIs & Engines / JOGL Development / Some problems with new version :) on: 2007-02-15 11:41:30
hi its been a while since i used jogl and i have noticed quite some changes
so i took a look at some examples but i am still a bit stuck with glu.gluLookAt()
is there some new method to do this now or?

this is my code:
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  
import javax.media.opengl.*;
import javax.media.opengl.glu.*;

public class TestRenderer implements GLEventListener
{
    private GL gl;
    private GLU glu;
    private GLAutoDrawable glDrawable;

    public void init(GLAutoDrawable drawable)
    {
       this.gl = drawable.getGL();
        this.glDrawable = drawable;
        glu = new GLU();
       
        drawable.setGL( new DebugGL(gl));

        System.out.println("Init GL is " + gl.getClass().getName());
    }

    public void display(GLAutoDrawable drawable)
    {
        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();

        gl.glColor3f(1.0f, 0.0f, 0.0f );

        gl.glBegin( GL.GL_TRIANGLES );
            gl.glVertex3f( 0.0f, 0.0f, 0.0f );
            gl.glVertex3f( 1.0f, 0.0f, 0.0f );
            gl.glVertex3f( 1.0f, 1.0f, 0.0f );
        gl.glEnd();
       
        gl.glBegin( GL.GL_TRIANGLES );
           gl.glVertex3f( 0.0f, 0.0f, 0.0f );
           gl.glVertex3f( -1.0f, 0.0f, 0.0f );
           gl.glVertex3f( -1.0f, -1.0f, 0.0f );
        gl.glEnd();
       
       glu.gluLookAt(   0.0, 10.0, -10.0,
            0.0, 0.0, 0.0,
            0.0, 1.0, 0.0);
    }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
    {
    }

    public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
    {
    }
}


i can change the values of first line in glu.gluLookAt at anything i want the view still doenst change?
what do i do wrong? thx for the help
15  Game Development / Networking & Multiplayer / Re: p2p on: 2006-10-20 12:10:23
well, if you think that the buffers are causing you to run out of memory then I would suggest not using an in-memory buffer.

assuming that this is on the recieving end simply use a random access file and write the block to the appropriate position in the file.

Actually i dont see the need to have a buffer of blocks at all in memory... On the client side simply remember the indecies of the blocks you have recieved and on the server side there is no need to remember anything.



I used buffers for the simple reason that the file you wonna send is continiously read so you dont have to start reading a part when you need it, you have allready it so it should speed up things
16  Game Development / Networking & Multiplayer / Re: p2p on: 2006-10-19 14:45:28
Well i sort got it going well but now the problem is that when i send files bigger then 60 mb i get an error

exception in thread: java heap space exceeded
How can he exceed this when i use 2 buffers (arraylist) of 100 packes of 64kb so *6.4mb = 13mb the buffer should be more then big enough
17  Game Development / Networking & Multiplayer / Re: p2p on: 2006-10-09 16:22:23
this is an overview of streamsi use

to read file: FileInputStream, write: FileOutputStream
to send data: ObjectOutputStream, receive/read: ObjectInputStream

should i read the file continious (thread) and stack the objects?
The current method involves reading the next part when needed

and similar for writing the file should i stack some object to a number of 100 and then write those 100 at once?
Current method is writing an object when receiving.
18  Game Development / Networking & Multiplayer / Re: p2p on: 2006-10-08 22:12:05
Well i kinda allready do something simular to your things here

I read the "packages" of a file at server side (like byte[1024])
then i transfor those to an object which i wrie to client with an ObjectOutputStream

at client side i read the object with a ObjectInputStream and then get the byte[] packages from it
which i write to the file then
it works but i only get a speed of 6 kb/s or even slower
this is realy low i think.
19  Game Development / Networking & Multiplayer / p2p on: 2006-10-08 10:00:38
Hi

i am currently developping a p2p program like emule/gnutella ... for a school project
I am using a server/client tcp/ip protocol to send data between clients
Sending strings and giving commands works fine but i cant seem to send files.
Is there any1 here who could post a small example code of sever/client sending a file

thanks
20  Java Game APIs & Engines / Xith3D Forums / Re: Using in eclipse + Canvas3D and SWING on: 2006-07-05 19:26:47
Got a question about Xith3DEnvironment.
does this replace the code with the universe and where you add a scene and view to it? or is this something else?
thx

Look into the constructor of Xith3DEnvironment. There are VirtualUniverse, Locale and View created and stored in the instance. You can access them through appropriate methods. In the current CVS version there is the possibility to add more Views to an instance of (Ext)Xith3DEnvironment.

You can anyway add a scene to the Environment by calling addChild on the (Ext)Xith3DEnvironment instance.

How does this cvs thing work? is thare a jar available with all cvs in or do you no need to manualy dl and intergrate eme?
21  Java Game APIs & Engines / Xith3D Forums / Re: Using in eclipse + Canvas3D and SWING on: 2006-07-05 11:51:31
Got a question about Xith3DEnvironment.
does this replace the code with the universe and where you add a scene and view to it? or is this something else?
thx
22  Java Game APIs & Engines / Xith3D Forums / Re: Using in eclipse + Canvas3D and SWING on: 2006-07-01 12:20:08
Tried it. It's just the same behaviour with JPanels.

So please describe your symptoms again and with other words. Maybe I get you right this time.

as long as i keep my mousepointer over the dividers while i resize
everything goes fine
but as soon as my mousepointer gets mover over a canvas3dPanel the resizing stops eventhougth you are still dragging

the resizing cant keep up with the mouse
or should i first add Canvas3dPanel to a Jpanel and then add JPanel to JFrame? now is directly kinda add Canvas3dPanel to JFrame -> has evne worse result

i have uploaded the 2 versions (all including code)
http://users.skynet.be/fa006997/FourPanelSplitPaneUsingJPanel.jar
http://users.skynet.be/fa006997/FourPanelSplitPane.jar
23  Java Game APIs & Engines / Xith3D Forums / Re: Using in eclipse + Canvas3D and SWING on: 2006-06-30 23:27:37
i just removed the complete method and now it works but when when i want to resize now the dragging is almost directly stopped so i cant resize the panels fluently

Well, I think what you want to say, is that the canvas gets resized when the mouse is released. If this is the case, it is caused by the fact, that the event causing the children of a container component to be resized is fired when the mouse is released. AFAIK this is fixed to the window environment (M$ Windows in your case).

But maybe I misunderstood you.

well i have the same program but with jpanels and that works fine
the panels are dynamicly resized when you drag mouse like you do with a jsplitpane but when the panels are vcanva3Dpanel it gets all lagy and resizing isnt good at all
24  Java Game APIs & Engines / Xith3D Forums / Re: Using in eclipse + Canvas3D and SWING on: 2006-06-30 22:33:26
You missed the super constructor call.

EDIT: You're extending the Canvas3DPanel class and have you own constructor. Call the constructor of the super class (Canvas3DPanel) and it will be initialized. You should always call a super constructor when extending classes.

you dont have to explicit call the super in the constructor so that is not the problem
i have added it as well and the error remains

Try it this way: (class XithView)
1  
2  
3  
4  
   public Canvas3D getCanvas3D(){
-       return getCanvas3D();
+          return super.getCanvas();
   }


But you can even directly use the inherited method getCanvas() of the Cavas3DPanel class and leave this whole method. But if you like this method to be named like this...

i just removed the complete method and now it works but when when i want to resize now the dragging is almost directly stopped so i cant resize the panels fluently
25  Java Game APIs & Engines / Xith3D Forums / Re: Using in eclipse + Canvas3D and SWING on: 2006-06-30 21:23:57
You missed the super constructor call.

EDIT: You're extending the Canvas3DPanel class and have you own constructor. Call the constructor of the super class (Canvas3DPanel) and it will be initialized. You should always call a super constructor when extending classes.

you dont have to explicit call the super in the constructor so that is not the problem
i have added it as well and the error remains
26  Java Game APIs & Engines / Xith3D Forums / Re: Using in eclipse + Canvas3D and SWING on: 2006-06-30 18:34:01
You're doing View v = new View() but you have a field named view. Shouldn't you do view = new View(), simply ?

it is basicly the same since the method returns an object of the type View
so that shouldnt be a problem
27  Java Game APIs & Engines / Xith3D Forums / Re: Using in eclipse on: 2006-06-30 12:47:51
do you perhaps have small appl which uses a canvas3dpanel? so i can see how this now works? thx

Yes, I do. Take a look at org.xith3d.test.ui.SwingGUIEnvironmentTest. Dig into the method initGUI, it is used there. But you should use the CVS version. I have simplified this test a little. But the version in the release works as well.

The basic usage of Canvas3DPanel is very simple. Treat it like any other Component and add it to another Container like this:
1  
2  
3  
4  
JFrame f = new JFrame("sdfsdfsdf");
f.setLayout(new GridLayout(1, 1));
Canvas3DPanel c3dp = new Canvas3DPanel(); // there are other constructors that could be interesting, too.
f.getContentPane().add(c3dp, null);


Add it to an (Ext)Xith3DEnvironment like this:
1  
2  
ExtXith3DEnvironment env = new ExtXith3DEnvironment();
env.addCanvas(c3dp);


Or add it to a View if you are not using Xith3DEnvironment:
1  
2  
View view = new View();
view.addCanvas3D(c3dp.getCanvas());


Hope this helps.

Qudus

i tried to adjust my code so i took your advise here and pasted it in but i get an error
Exception in thread "main" java.lang.StackOverflowError
   at gui.XithView.getCanvas3D(XithView.java:42)

the jar with code can be found here: (I am sorry but my comments are in dutch since i am belgian Wink )
http://users.skynet.be/fa006997/FourPanelSplitPane.jar
28  Java Game APIs & Engines / Xith3D Forums / Re: Using in eclipse on: 2006-06-29 20:54:16
is t his canvas3Dpanel and actual canvas3D yet or do you have to add a canvas3D to it?

A Canvas3DPanel creates a Canvas3D on its own.

Please have a look at the release notes of 0.8.0. They are really short and easy to read. You will get a hint of the most important new features of 0.8

Here is a link: http://www.java-gaming.org/forums/index.php?action=dlattach;topic=14194.0;id=496

do you perhaps have small appl which uses a canvas3dpanel? so i can see how this now works? thx
29  Java Game APIs & Engines / Xith3D Forums / Re: Using in eclipse on: 2006-06-29 16:50:25
Just use org.xith3d.render.Canvas3DPanel. This is done for you previously.
Well, this is part of 0.8.0. So be sure to have a recent version.

Qudus


yes i have new version but wasnt aware of that new feature Smiley
cool thx Wink

is t his canvas3Dpanel and actual canvas3D yet or do you have to add a canvas3D to it?
30  Java Game APIs & Engines / Xith3D Forums / Re: Using in eclipse on: 2006-06-29 16:46:48
Um, wouldn't:

Quote
it gives error unstatisfied link no jogl found

Imply its the native not the jars that are the problem - unsatisfied linking? How are you running your program?

Kev

found the problem
it seems i just put jar with dlls in folder instead of the dlls extracted from the jar
now it is working fine thanks for the help anyway Smiley

can you perhaps answer another small question can i add a canvas to a JPanel in any way? or how can i view somehting inside a Jpanel?

thx for the respons
Pages: [1] 2 3 ... 5
 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (43 views)
2014-10-16 15:22:06

Norakomi (33 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (68 views)
2014-10-14 00:35:47

TehJavaDev (60 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (86 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!