Jump to content
  • Advertisement

nippysaurus

Member
  • Content Count

    48
  • Joined

  • Last visited

Community Reputation

128 Neutral

About nippysaurus

  • Rank
    Member
  1. Wow, thank you all for such detailed replies, it is much appreciated :) I am not starting this project yet, just getting a feeler for what is involved to help decide whether to pursue it or not. Basically I was inspired by a TED talk which showed a 3d model of the known universe, it was very impressive. I thought it would be a cool project and thought maybe starting small and simulating the objects in our solar system. So yeah thats as far as I got ... if any progress is made on this I will post it up for all to see :)
  2. I am considering making a model of our solar system (a simple one, nothing too somplicated). I have not done anything like this for a few years and am very rusty on my mathematics. I need to calculate the alterations made to an objects movement as it passes other objects, sort of like the game "osmos" on the iphone/ipad. I do not expect anyone to explain it, but pointing me in the right directions would be greatly appreciated :)
  3. nippysaurus

    fps camera

    Thanks a million mate :)
  4. nippysaurus

    fps camera

    I have searched quite a bit but cannot find any sources which can help me implement various types of camera. Specifically I would like to have a camera which can be moved around from a first person perspective, but would also like other types such as a chase camera. Does anyone know of any useful resources? Thank you :)
  5. nippysaurus

    picking ... always nothing selected

    Thanks Brother Bob :) It works now ... but it is not well implemented because in my display function I switch to ortho mode to display some UI stuff ... and I am sure that because of that there is ALWAYS one item in the picking list. I need to split the functions up so that the pickable objects can be drawn in a single function :) Thank you for your help :)
  6. I have a simple opengl scene with some boxes ... I am using glut ... I have given the boxes names. I dont know what else you would need to know to help me, but I have implemented some picking code from various sites, never gives any errors but the items I have given names to, when clicked, still gives no results. I am going to just paste all my code just to make sure that nothing is missed. Any help would be greatly appreciated. #include <stdlib.h> #include <stdio.h> #include <GL/glut.h> // Header File For The GLUT Library #include <GL/gl.h> // Header File For The OpenGL32 Library #include <GL/glu.h> // Header File For The GLu32 Library #define DEBUG #ifdef DEBUG #define debugmsg(msg) {printf("DEBUG:%s\n",msg);} #else #define debugmsg(msg) {} #endif #define DEFAULT_WIDTH 800 #define DEFAULT_HEIGHT 600 #define LEFT (0-(WIDTH/2)) #define RIGHT (WIDTH/2) #define TOP (HEIGHT/2) #define BOTTOM (0-(HEIGHT/2)) //#define WIREFRAME #define ONE 1 #define TWO 2 #define THREE 3 #define FOUR 4 #define FIVE 5 #define SIX 6 #define SEVEN 7 #define EIGHT 8 float r = 0.0f; float m = 0.0f; bool MouseLeftDown = false; bool MouseRightDown = false; unsigned int width = DEFAULT_WIDTH; unsigned int height = DEFAULT_HEIGHT; #define BUFSIZE 512 GLuint selectBuf[BUFSIZE]; // ============================================================================= // Cube. // ============================================================================= class Cube { private: float _wl; // Width/Length! float _left,_right,_top,_bottom,_front,_back; public: Cube(float wl) { _wl = wl; _right = _top = _front = _wl / 2; _left = _bottom = _back = -_right; } void Draw() { glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_QUADS); glVertex3f(_left, _top, _front); // FRONT glVertex3f(_left, _bottom, _front); glVertex3f(_right, _bottom, _front); glVertex3f(_right, _top, _front); glVertex3f(_left, _top, _back); // BACK glVertex3f(_right, _top, _back); glVertex3f(_right, _bottom, _back); glVertex3f(_left, _bottom, _back); glVertex3f(_left, _top, _front); // TOP glVertex3f(_right, _top, _front); glVertex3f(_right, _top, _back); glVertex3f(_left, _top, _back); glVertex3f(_left, _bottom, _front); // BOTTOM glVertex3f(_left, _bottom, _back); glVertex3f(_right, _bottom, _back); glVertex3f(_right, _bottom, _front); glVertex3f(_left, _bottom, _back); // LEFT glVertex3f(_left, _bottom, _front); glVertex3f(_left, _top, _front); glVertex3f(_left, _top, _back); glVertex3f(_right, _bottom, _front); // RIGHT glVertex3f(_right, _bottom, _back); glVertex3f(_right, _top, _back); glVertex3f(_right, _top, _front); glEnd(); } }; // ============================================================================= // Drawaxis. // ============================================================================= void DrawAxis() { #define AXISLINELENGTH 0.25f // X glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(AXISLINELENGTH, 0.0f, 0.0f); glEnd(); glRasterPos3f(AXISLINELENGTH, 0.0f, 0.0f); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, 'X'); // Y glColor3f(0.0f, 1.0f, 0.0f); glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, AXISLINELENGTH, 0.0f); glEnd(); glRasterPos3f(0.0f, AXISLINELENGTH, 0.0f); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, 'Y'); // Z glColor3f(0.0f, 0.0f, 1.0f); glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, 0.0f, AXISLINELENGTH); glEnd(); glRasterPos3f(0.0f, 0.0f, AXISLINELENGTH); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, 'Z'); } // ============================================================================= // Start Ortho. // ============================================================================= void StartOrtho(void) { glMatrixMode(GL_PROJECTION); // Select Projection glPushMatrix(); // Push The Matrix glLoadIdentity(); // Reset The Matrix glOrtho(0,width,height,0,-1,1); // Select Ortho Mode glMatrixMode(GL_MODELVIEW); // Select Modelview Matrix glPushMatrix(); // Push The Matrix glLoadIdentity(); // Reset The Matrix } // ============================================================================= // End Ortho. // ============================================================================= void EndOrtho(void) { glMatrixMode(GL_PROJECTION); // Select Projection glPopMatrix(); // Pop The Matrix glMatrixMode(GL_MODELVIEW); // Select Modelview glPopMatrix(); // Pop The Matrix } // ============================================================================= // Process Hits. // ============================================================================= void processHits(int hits, unsigned int buffer[]) { debugmsg("processing hits"); // } // ============================================================================= // Select. // ============================================================================= void select(int x, int y) { debugmsg("checking for hits"); GLint viewport[4]; glSelectBuffer(BUFSIZE,selectBuf); glRenderMode(GL_SELECT); glInitNames(); glPushName(0); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glGetIntegerv(GL_VIEWPORT,viewport); gluPickMatrix(x,viewport[3]-y,5,5,viewport); gluPerspective(45,(1.0f*width/height),1.0f,100.0f); glMatrixMode(GL_MODELVIEW); int hits; // restoring the original projection matrix glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glFlush(); // returning to normal rendering mode hits = glRenderMode(GL_RENDER); // if there are hits process them if (hits != 0) processHits(hits,selectBuf); debugmsg("finished checking for hits"); } // ============================================================================= // Display. // ============================================================================= void display(void) { //glTranslatef(0.0f,0.0f,0.0f); //glRotatef(0.0f, 0.0f, 0.0f, 0.0f); //GL_POLYGON //GL_LINES //GL_QUADS glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0f, 0.0f, -4.0f); { Cube* SmallCube = new Cube(0.3f); glPushMatrix(); glTranslatef(0.5f, 0.5f, 0.5f); glPushName(ONE); SmallCube->Draw(); glPopName(); glPopMatrix(); glPushMatrix(); glTranslatef(0.5f, -0.5f, 0.5f); glPushName(TWO); SmallCube->Draw(); glPopName(); glPopMatrix(); glPushMatrix(); glTranslatef(-0.5f, -0.5f, 0.5f); glPushName(THREE); SmallCube->Draw(); glPopName(); glPopMatrix(); glPushMatrix(); glTranslatef(-0.5f, 0.5f, 0.5f); glPushName(FOUR); SmallCube->Draw(); glPopName(); glPopMatrix(); glPushMatrix(); glTranslatef(0.5f, 0.5f, -0.5f); glPushName(FIVE); SmallCube->Draw(); glPopName(); glPopMatrix(); glPushMatrix(); glTranslatef(0.5f, -0.5f, -0.5f); glPushName(SIX); SmallCube->Draw(); glPopName(); glPopMatrix(); glPushMatrix(); glTranslatef(-0.5f, -0.5f, -0.5f); glPushName(SEVEN); SmallCube->Draw(); glPopName(); glPopMatrix(); glPushMatrix(); glTranslatef(-0.5f, 0.5f, -0.5f); glPushName(EIGHT); SmallCube->Draw(); glPopName(); glPopMatrix(); delete SmallCube; } DrawAxis(); StartOrtho(); glBegin(GL_QUADS); glVertex2f(10, 10); glVertex2f(10, height-10); glVertex2f(50, height-10); glVertex2f(50, 10); glEnd(); EndOrtho(); glutSwapBuffers(); } // ============================================================================= // Keyboard. // ============================================================================= void keyboard(unsigned char key, int x, int y) { if( key == 'q' || key == 'Q') exit(0); } int MouseX = -1; int MouseY = -1; // ============================================================================= // Mousemove. // ============================================================================= void mousemove(int x, int y) { //int DiffX = x - MouseX; //int DiffY = y - MouseY; if (MouseLeftDown && MouseRightDown) { // } else if (MouseLeftDown) { // } else if (MouseRightDown) { // } MouseX = x; MouseY = y; } // ============================================================================= // Mouseclick. // ============================================================================= void mouseclick(int button, int state, int x, int y) { // button can be: // GLUT_LEFT_BUTTON // GLUT_MIDDLE_BUTTON // GLUT_RIGHT_BUTTON // state can be: // GLUT_DOWN // GLUT_UP // compatibility with original GLUT #if !defined(GLUT_WHEEL_UP) # define GLUT_WHEEL_UP 3 # define GLUT_WHEEL_DOWN 4 #endif if (state == GLUT_DOWN) select(x,y); switch(button) { case GLUT_LEFT_BUTTON: MouseLeftDown = ((state==GLUT_DOWN) ? true : false); break; case GLUT_MIDDLE_BUTTON: break; case GLUT_RIGHT_BUTTON: MouseRightDown = ((state==GLUT_DOWN) ? true : false); break; case GLUT_WHEEL_UP: break; case GLUT_WHEEL_DOWN: break; } MouseX = x; MouseY = y; } // ============================================================================= // Init. // ============================================================================= void init(void) { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glEnable(GL_CULL_FACE); glClearDepth(1.0f); #ifdef WIREFRAME glPolygonMode(GL_FRONT,GL_LINE); #else glPolygonMode(GL_FRONT,GL_FILL); #endif glInitNames(); } // ============================================================================= // Resize. // ============================================================================= void resize(int w, int h) { width = w; height = h; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(0, 0, width, height); gluPerspective(45.0f, 1.0f * width / height, 1.0f, 100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } // ============================================================================= // Entry. // ============================================================================= int main(int argc, char* argv[]) { debugmsg("creating window"); // Create window. glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(width, height); glutCreateWindow("Seen"); debugmsg("doing init"); init(); debugmsg("event loop functions"); // Event loop functions. glutDisplayFunc(display); glutIdleFunc(display); glutKeyboardFunc(keyboard); glutReshapeFunc(resize); glutMotionFunc(mousemove); glutMouseFunc(mouseclick); debugmsg("starting main loop"); // Start event loop. glutMainLoop(); return 0; }
  7. nippysaurus

    Weird Class Problem

    Quote:Original post by NUCLEAR RABBIT Quote:Original post by rip-off Quote:Original post by NUCLEAR RABBIT Quote:Original post by nippysaurus Yes, but the object you create needs to be of type Player to use them. Try changing your declaration and see if the problem goes away :-) im so confused! :( haha whats the point of doing this: Human player = new Player() when u cant even use the functions defined in player?? ughh :( Humans don't have levels, only Players do. To use the functions in player, you would need to cast the object to a Player. Otherwise, consider what would happen if you made some other class derived from Human. It wouldn't make sense to be able to call GetLevel on that object, would it? by using: Human player = new Player(), doesnt it make it a Player object? Sure does! :) EDIT: ummm, not sure O.o [Edited by - nippysaurus on November 10, 2007 9:52:58 PM]
  8. nippysaurus

    Weird Class Problem

    +1. You are trying to access a function declared in Player, not Human. Consider a case where you create a "baby" and extend it with "adult", you cannot create a "baby" class and try and invoke "make babies" because you would declare that kind of thing in the "adult" class. :) Thats basically what you are trying to do though, but you cant, you need to declare it as an "adult" then "make babies" :)
  9. nippysaurus

    Weird Class Problem

    Yes, but the object you create needs to be of type Player to use them. Try changing your declaration and see if the problem goes away :-)
  10. nippysaurus

    Weird Class Problem

    Because GetLevel() is declared in Player, not Human. The object you are trying to invoke GetLevel() on is a Player :) Its an inheritance problem. Let me know if you don't know what I mean.
  11. nippysaurus

    OpenGL - Object Line Colour

    You might also be interested to know that you can change line thickness with the glLineWidth(w) function. As for the colouring, use a normal colour chart and divide the values by 256? I'm pretty sure that will work.
  12. nippysaurus

    making a menu

    I am making a menu system for OpenGL, but have got to a point where I do not know the best way to continue. I have implemented the Binary Tree abstract data type and it works very well. The idea I have is to have a binary tree for the entire menu structure, and another one which contains only elements which are being displayed at the current time. I am not sure of the best way to do about moving them from one tree to another.
  13. nippysaurus

    depth testing problems, i think

    Quote:Original post by extralongpants Quote:Original post by nippysaurus Ooooooh ;) Well you knew I didn't know that, but instead of helping you mocked my lack of knowledge :p Anyways, thanks for helping guys :) For what it's worth, I was giving you the benefit of the doubt by assuming that you might have known and just posted the wrong snippet of code. I certainly wasn't mocking you. After all, I've been through the same stuff before. I'm sorry if I sounded mean. I really wasn't trying to. Thats alright dude, no hard feelings :)
  14. nippysaurus

    depth testing problems, i think

    Ooooooh ;) Well you knew I didn't know that, but instead of helping you mocked my lack of knowledge :p Anyways, thanks for helping guys :)
  15. nippysaurus

    depth testing problems, i think

    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); GLUT_DEPTH enables depth testing. And when I draw glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); The GL_DEPTH_BUFFER_BIT mask clears the depth buffer. Doesn't your browser have a search function? Try firefox :p
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!