grumpyOldDude

Members
  • Content count

    598
  • Joined

  • Last visited

Community Reputation

2741 Excellent

2 Followers

About grumpyOldDude

  • Rank
    **Maverick**

Personal Information

  • Interests
    Programming

Recent Profile Visitors

9315 profile views
  1. Fixed the problem. I doubt this solution will be useful for anyone else, since as it seems I'm probably the only one using JOGL here, but here it is anyway:: I never realised it - since I am porting my code from Android platform (OpenGL ES) - but JOGL, unlike ES required animator.start(); FPSAnimator animator = new FPSAnimator(canvas, FPS, true); for the display(GLAutoDrawable drawable) to be called continuously. FPSAnimator requires the header com.jogamp.opengl.util.FPSAnimator; Further information/tutorial can be found here https://www.ntu.edu.sg/home/ehchua/programming/opengl/JOGL2.0.html
  2. uploading profile photo is broken

    Many thanks!
  3. I was uploading a profile photo (not too large, 80X90, 3.49KB), jpeg, but it kept coming up blank. I suppose something is now broken in the software. I've loaded same profile photo without any problems in the past Just in case there is now a lower limit, I tried with various sizes - (296x347) 22KB, (148x174) 11KB, (74x87) 5KB but still no success
  4. I am trying to rotate my scene by rotating the camera at the press of 'x' key. The scene is rendered correctly but fails to rotate. I am using my own transformation matrix (for good reasons), and it does work fine (it actually rotates the camera position about the x-axis) as indicated in the output below the code. But the camera position in the display() function is not updated. In fact the problem is the display() function is not not called continuously so the rendered scene doesn't reflect the new camera position The print out below the code shows that the display function is not called again, because the x0 in the rotateAbtX(....) function is called and show the camera position changing, but the x1 in the display is called just once and never again so it is not updated Why is this? How can I adjust the code to allow display function to be called continuously so camera position can be updated? Thanks public class Game extends JFrame implements GLEventListener, KeyListener { private static final long serialVersionUID = 1L; final private int width = 800; final private int height = 600; int right=-100, bottom=-100, top=100, left=100, numOfUnits; GLU glu= new GLU(); List<CreateObjVertices> dataArray; ... ... public Game( int units, List<CreateObjVertices> vertXYZ ) { super("Puzzle Game"); Globals.camera = new Point3D(0.0f, 1.4f, 0.0f); Globals.view = new Point3D(0.0f, -1.0f, -3.0f); System.out.println( "x "+Globals.camera.x+" y "+Globals.camera.y+" z "+Globals.camera.z ); dataArray = vertXYZ; numOfUnits = units; t = new Transform3D(); xAxis = new Vector3D(1,0,0); yAxis = new Vector3D(0,1,0); zAxis = new Vector3D(0,0,1); GLProfile profile = GLProfile.get(GLProfile.GL2); GLCapabilities capabilities = new GLCapabilities(profile); GLCanvas canvas = new GLCanvas(capabilities); canvas.addGLEventListener(this); canvas.addKeyListener(this); canvas.setFocusable(true); // To receive key event canvas.requestFocus(); this.setName("Puzzle Game"); this.getContentPane().add(canvas); this.setSize(width, height); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); this.setResizable(false); canvas.requestFocusInWindow(); } public void play() { } @Override public void init(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); gl.glClearDepthf(1.0f); gl.glEnable(GL2.GL_DEPTH_TEST); gl.glDepthFunc(GL2.GL_LEQUAL); gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST); gl.glShadeModel(GL2.GL_SMOOTH); gl.glEnableClientState(GL2.GL_VERTEX_ARRAY); } @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL2 gl = drawable.getGL().getGL2(); if (height == 0) height = 1; float aspect = (float)width / height; gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective( 45, aspect, 0.1f, 100.0f); System.out.println( "x2 "+Globals.camera.x+" y2 "+Globals.camera.y+" z2 "+Globals.camera.z ); } @Override public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); glu.gluLookAt( Globals.camera.x, Globals.camera.y, Globals.camera.z, Globals.view.x, Globals.view.y, Globals.view.z, 0.0f, 1.0f, 0.0f); System.out.println( "x1 "+Globals.camera.x+" y1 "+Globals.camera.y+" z1 "+Globals.camera.z ); gl.glTranslatef(0.0f, 0.0f, -3.0f); gl.glBegin(GL.GL_TRIANGLE_STRIP); //=========================== START =========================================================== // ************* DRAWING SCENE AND OBJECTS HERE *************** //============================= end ============================================================ gl.glFlush(); } @Override public void dispose(GLAutoDrawable drawable) { } @Override public void keyPressed(KeyEvent e) { if( e.getKeyChar() == 'x'){ rotateAbtX( 1 ); } if( e.getKeyChar() == 'X'){ rotateAbtX( -1 ); } } @Override public void keyReleased(KeyEvent e) { } @Override public void keyTyped(KeyEvent e) { } Transform3D t; Vector3D xAxis, yAxis, zAxis; float rotAng = 60.0f, cosAngle = 0.0f; Vector3D normalAxisVec = new Vector3D(0,0,0), vecObj = new Vector3D(0,0,0), baseLineVec = new Vector3D(0,0,0); public void rotateAbtX( int direction ) { t.rotateCamera( xAxis, rotAng*direction, Globals.view, 0, Globals.camera ); System.out.println( "x0 "+Globals.camera.x+" y0 "+Globals.camera.y+" z0 "+Globals.camera.z ); } } x* 0.0 y* 1.4 z* 0.0 x2 0.0 y2 1.4 z2 0.0 x1 0.0 y1 1.4 z1 0.0 x0 0.0 y0 -2.3980765 z0 0.57846117 x0 0.0 y0 -4.7980766 z0 -2.4215393 x0 0.0 y0 -3.3999999 z0 -6.000001 x0 0.0 y0 0.39807725 z0 -6.578461 x0 0.0 y0 2.7980769 z0 -3.57846 x0 0.0 y0 1.3999994 z0 1.4305115E-6 x0 0.0 y0 -2.398078 z0 0.57846117 x0 0.0 y0 -4.7980776 z0 -2.4215407 x0 0.0 y0 -3.3999991 z0 -6.000002 x0 0.0 y0 0.39807856 z0 -6.578461 x0 0.0 y0 2.7980776 z0 -3.5784588 x0 0.0 y0 1.3999987 z0 2.3841858E-6 x0 0.0 y0 -2.3980794 z0 0.57846117 x0 0.0 y0 -4.798078 z0 -2.4215417
  5. Now he has all the excuses wants.

    Now Donald Trump has all the excuse to pursue with increased vigour his xenophobic ideas, his immigration bill waning, having failed 3 times through congress. I watched with some concerns as he made statements about tightening the borders more, shutting down lottery diversity program and chain immigration. New York type of brutal attack has been prevalent here in Europe where the borders border are more porous and immigration programs are generally much more lenient So he cannot easily see that minus 9/11, over 90% of US mass killings are carried out by US citizens, without religious motivation but other deep psychological problems. For the purpose of this thread I will use the word 'fringes' for both home grown non-faith based killings and foreign-faith based terrorism Of course this is "manna from heaven" to his fan base, but is he right? Is that the solution? Isn't there more intelligent, quicker and more effective solutions? Firstly i will briefly indulge in a bit of distraction:- when I made this thread a while ago I have been centre-left, now I am going right wing.... ..... ( wow!, someone has been working really hard... at downvoting me in that thread, well feel free to downvote this one also ). ... anyway... admittedly the linked thread has been a knee-jerk reaction from me, because the intensity of the European attacks has been ferocious. I have soon realised that taking such a seismic shift in mindset is tough mainly because - right wing mindset comes with its own bagadge most of which outright annoys me. And even if i filter out some narrow ideologies, maintaining such mind-set was always going to be a herculean task for me, so I have gladly bowed out of such mindset and thinking of better ways Back to topic. Some idea I have thinking might work: How about setting up public-government-anger forums, for deeply troubled people ... where there will be a deal that no one can be arrested on anything they say on the forum. Even if they talk about doing terrible things, as long as they keep the communication going and don't carry out their intentions. This will allow people on the fringes to freely express their deep-sitted anger and grudges against the west/governments. So at least a communication and dialogue can get started with some good people on the other side. And who knows a fraction may come to their senses through psychologically assessing them. ATM the one sided anger forums that exist (if they exist at all) are either heavily spied on and raided by the feds or hidden in the dark web, set up by disgruntles themselves, to fuel the fire of anger rather than to create a dialogue to quench it. Except if I've been leaving in a cave all this while and such sites/forums exist already. On the other hand it might be the dumbest and a too simplistic idea since the worst of the troubled and angered people may still feel its a bait or trap .... so feel free to call it bullshit (no sarcasm, I genuinely mean it, if you feel its BS, and kindly state why)
  6. I tried alternative suggested but no success. I soon got to learn from this Stack Overflow thread that there is no direct key binding for GLCanvas which is the canvas JOGL uses. This suggests why the key binding for my code in the original post failed. In the same thread there was a hint (link below) that there could be indirect key bindings GLCanvas, though no meaningful clues or code on how to do this was giving https://stackoverflow.com/a/18860666/1489197 I would appreciate any help and code on how to do this. Thanks for any help
  7. I have strip the code down to barest minimum for clarity With the window up and draw rendering correctly, I set the key press to take the 'x' key, but when I press 'x' and print anywhere (and everywhere) to test, nothing prints to console. I scrutinised to see why, but I can't find what is missing. Can anyone see why its not working? Thanks public class PuzzleG extends JFrame implements GLEventListener, KeyListener { private static final long serialVersionUID = 1L; final private int width = 800; final private int height = 600; int numOfUnits; GLU glu= new GLU(); List<ObjVertices> dataArray; public PuzzleG( int units, List<ObjVertices> vertXYZ ) { super(" Puzzle game "); Globals.camera = new Point3D(0.0f, 1.4f, 0.0f); Globals.view = new Point3D(0.0f, -1.0f, -3.0f); GLProfile profile = GLProfile.get(GLProfile.GL2); GLCapabilities capabilities = new GLCapabilities(profile); GLCanvas canvas = new GLCanvas(capabilities); canvas.addGLEventListener(this); this.setName("Minimal OpenGL"); this.getContentPane().add(canvas); this.setSize(width, height); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); this.setResizable(false); dataArray = vertXYZ; numOfUnits = units; canvas.requestFocusInWindow(); } public void play() { } @Override public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); glu.gluLookAt( Globals.camera.x, Globals.camera.y, Globals.camera.z, Globals.view.x, Globals.view.y, Globals.view.z, 0.0f, 1.0f, 0.0f); gl.glTranslatef(0.0f, 0.0f, -3.0f); gl.glBegin(GL.GL_LINE_LOOP); /*=========================== START =========================================================== ... draw object vertices ... ============================= end ============================================================ */ gl.glEnd(); gl.glFlush(); } @Override public void dispose(GLAutoDrawable drawable) { if( Globals.c == 'x')System.out.println(" 3333 "); } @Override public void init(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); gl.glClearDepthf(1.0f); gl.glEnable(GL2.GL_DEPTH_TEST); gl.glDepthFunc(GL2.GL_LEQUAL); gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST); gl.glShadeModel(GL2.GL_SMOOTH); gl.glEnableClientState(GL2.GL_VERTEX_ARRAY); if( Globals.c == 'x')System.out.println(" 1111 "); } @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL2 gl = drawable.getGL().getGL2(); if (height == 0) height = 1; float aspect = (float)width / height; gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective( 45, aspect, 0.1f, 100.0f); if( Globals.c == 'x')System.out.println(" 2222 "); } @Override public void keyPressed(KeyEvent e) { Globals.c = e.getKeyChar(); if( Globals.c == 'x'){ System.out.println(" 5555 "); } } @Override public void keyReleased(KeyEvent arg0) { // TODO Auto-generated method stub } @Override public void keyTyped(KeyEvent arg0) { // TODO Auto-generated method stub } } Just for the sake of checking I also tried the other key options as in the code below, but still didn't see any prints to console @Override public void keyReleased(KeyEvent e) { Globals.c = e.getKeyChar(); if( Globals.c == 'x'){ System.out.println(" 8888 "); } } @Override public void keyTyped(KeyEvent e) { Globals.c = e.getKeyChar(); if( Globals.c == 'x'){ System.out.println(" 7777 "); } }
  8. how do i erase my post?

    Or you could edit your original post (not vandalise or wipe off) to your current state There is a lot of necro'ing though. But in the OP's case on the Hobby project page, I don't think necro'ing goes on there, so I think its fine
  9. PAX Australia

    I live on the up side of the planet , so just wishing the best for your Game expo over the weekend. Well since you're more than half a day ahead you may already be in the heart of the show by now - good luck! (great! I got my head back)
  10. What am I not understanding about programming?

    A lot of very good advice had been given already, I have not read all previous posts though so maybe some of these steps has been mentioned - i don't know. In case its not, here is my 2 cents Seems to me you have no trouble writing isolated algorithms but have trouble putting it all together for a project. So my advice or methodology to get through this 1. At the initial stage think globally about your project:: a.) what you want to achieve in the project, b.) Inputs c.) outputs or outcomes 2a. Then think about the modules (functionalities) of your project. What different parts does it have? (write these down) 2b. Drawing a very simple interaction diagram between functions/classes might help. (though I rarely do this myself) 3. Identify the core part of the project 4. Start coding the core in the simplest way possible. Build it up gradually and gradually add functionalities (again one at time and in the simplest possible way) 5. Avoid thinking too much details on the parts you are not currently coding 6. When you add a functionality (or class), think about what the core is, and start coding this in the simplest possible way and build up gradually 7. Interaction between modules is going to be the toughest part, but if you start simple (and write things down and draw interaction an diagram to keep track then you will pull though. These days I don't have to write things down (or draw) any more, but years ago I had to write down to keep track (this come with experience))
  11. Java Pattern Matcher reads white space wrong

    Oh dear, I completely forgot ... Many thanks Nypyren, your answer triggered further inspiration on how it works. And so I replaced Pattern p = Pattern.compile("\\d+"); with Pattern p = Pattern.compile("\\d+\\.\\d+"); and the algorithm read my data correctly. Thanks
  12. As my project is beginning to take shape, most of the problems I've encountered, I've been able to solve, but this latest one cunningly beats me, not because of any complexities but because I don't know whats going on under the hood of the parser. I am using a pattern matcher() Pattern.compile("\\d+"); - (in JAVA) - to extract and read floats, but there were problems as white spaces are being interpreted as 0.0 808.00.0472.00.036.00.0202.00.018.00.024.00.0 782.00.096.00.036.00.0202.00.018.00.024.00.0 909.00.01028.00.036.00.0202.00.018.00.024.00.0 931.00.01149.00.036.00.0202.00.018.00.024.00.0 but should, correctly, be something like this 808.0 472.0 36.0 202.0 18.0 24.0 782.0 96.0 36.0 202.0 18.0 24.0 909.0 1028.0 36.0 202.0 18.0 24.0 931.0 1149.0 36.0 202.0 18.0 24.0 It was wrong because it was making white space to be 0.0 As said It was wrong because it was making white space to be 0.0 My quick fix was to use an if statement that exclude 0.0. Well I got away with it until the inevitable began to happen,- some of the real data started turning out to be 0.0, so my if statement was excluding the real data from being read. Any help on how to get this fixed? I need white space to be read as white space not as 0.0 public void readDataFromSelectedTextFile( File fPathplusName ){ List<Float> numbers = new LinkedList<Float>(); try { bufferedReader = new BufferedReader(new FileReader(fPathplusName)); while ((stringObjectData = bufferedReader.readLine()) != null){ Pattern p = Pattern.compile("\\d+"); Matcher m = p.matcher(stringObjectData); while (m.find()) { numbers.add(Float.parseFloat(m.group())); } } ListIterator<Float> floatIterator = numbers.listIterator(); int i=0, t=7, n=0; float s, size=0; while( floatIterator.hasNext() ){ if( (s = floatIterator.next()) > 0 ){ ... ... plenty of good coding here ... ... } } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }/**/ }
  13. Looking for advice on training a older colleague.

    Hmmm, The criteria your bosses use to score and choose who to lay-off seems a very childish one - so much that I (figuratively) recommend the bosses themselves need to be fired for yous to make progress I mean they are smart enough to recognise your skills and qualification, give you the lead for the team (despite you being young relative to some others), yet they base who they would choose to lay-off not on his/her productivity (or relevant skills) but based on what connections they have, who they know and how long they've spent in the company If they are dumb enough to lay off the more skillful and more productive team member merely because he is one of the newest workers rather than lay-off the dinosaur liability, then their incompetence beggars belief... Or maybe I'm still missing something Advice: From what you've discussed so far - that the bosses are aware of who's holding back the team... If the demonstration of your methods still doesn't convince your colleague -then shoulder-on and endure... till when the time is right to leave and find another place to work
  14. Btw thanks for the work around. Though my posting activities has not warranted me to use it yet. Speaking of usability, ... I don't know if this was intentional but the search field and algorithm before the upgrade allowed direct members search, in addition to a content search field. Now the search is restricted to content search only . Though one could still indirectly search members, but then you have to get the user-name spelling totally correct. Not so easy for users who have not post for along while. Before upgrade you just have to type starting letters and all users matching the starting letter come up, and this helped narrow down. Helpful when you can't get the name right and they haven't posted for a long while . Was it intentional to remove direct members search from the upgrade? EDIT: I finally made contact with the long-lost friend, former uni-mate and inactive GDNet member by finding his real life contacts . Ironically all social media contacts proved futile
  15. You are correct, there are ways around not using cancel button. But one thing made me still mention it with the quoting issue:: Due to my experience I had thought GUI coding -particularly adding a button- was so trivial, it could be coded in 3 minutes. Ease of use always attracts, I mean I've made decisions between browsers in the past based on gui ease of use. At least that's the way I felt anyway the other day I wanted to cancel the reply without leaving the page. But as I see from your reply that the code isn't quite straight forward Wasn't my intention to put undue pressure -the only reason I felt that way in my 3rd post was because I saw some presence. But I had still misunderstood,,