Jump to content
  • Advertisement

Thorin_nz

Member
  • Content Count

    95
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Thorin_nz

  • Rank
    Member
  1. Thorin_nz

    factorial question

    i'd say start by substituting m as n-1 to give m! / ( (m-i)! i! ) but I think your answer is incorrect as... substituting n as 6 and i as 2 gives... (n-1)! / ( (n-i-1)! i! ) (6-1)! / ( (6-2-1)! 2! ) 5! / (3!2!) 120 / 12 10 1/(n-i) + 1/i 1/(6-2) + 1/2 1/(4) + 1/2 3/4 Clearly 10 != 3/4 Are you sure thats the right answer?
  2. lol, I've asked a few questions in my time, service is free. Up my rating if you want Seeya round - Steve
  3. I managed to get it all working, Have a play round and see if you can see the logic in what Ive done... The key is realising that the rotate / translate commands do not work with world axes, they work with local axes instead. So thinking about it that way... To make something rotate about a point. You first translate to the point. Then rotate so the object is looking at where it should be in orbit. glRotatef(thetaSphere,0,1,0); Translate to the point... glTranslatef(0, 0, -3); And undo the rotation. (if you want to) glRotatef(-thetaSphere,0,1,0); #pragma hdrstop #include <windows.h> #include <stdio.h> #include <conio.h> #include <math.h> #include "glut.h" //--------------------------------------------------------------------------- static void myInit(); static void myDisplay(void); static void myIdle(void); static void myReshape(int w, int h); #define ImageRows 512 #define ImageCols 512 #define Image3bytesPerPixel 3 #define Image1bytePerPixel 1 static GLubyte earthTexture[ImageRows/2] [ImageCols/2] [Image3bytesPerPixel]; // sphere static GLsizei width, height, bytes; void loadTexture(const no, const char *iFilename, GLsizei iRows, GLsizei iCols, GLsizei iBytesPerPixel, void *iPixels); void loadImage(const char *iFilename, GLsizei iRows, GLsizei iCols, GLsizei iBytesPerPixel, void *iPixels); typedef float vertex[3]; typedef float vector[3]; static GLfloat vertices[][3] = { {-1.0,-1.0,+1.0}, {-1.0,+1.0,+1.0}, {+1.0,+1.0,+1.0}, {+1.0,-1.0,+1.0}, {-1.0,-1.0,-1.0}, {-1.0,+1.0,-1.0}, {+1.0,+1.0,-1.0}, {+1.0,-1.0,-1.0} }; static GLfloat thetaSphere; static GLfloat thetaMoon; static GLfloat nearPlane = 4.0; static GLfloat farPlane = 20.0; static GLfloat distance = 10; void loadImage(const char *iFilename, GLsizei iRows, GLsizei iCols, GLsizei iBytesPerPixel, void *iPixels) { FILE *iFile; if ((iFile=fopen(iFilename,"r"))!=NULL) { fread (iPixels, (long) iRows*iCols*iBytesPerPixel, 1 , iFile); // read file fclose (iFile); width=iCols; height=iRows; bytes=iBytesPerPixel; } } void loadTexture(const n, const char *iFilename, GLsizei iRows, GLsizei iCols, GLsizei iBytesPerPixel, void *iPixels) { loadImage(iFilename, iRows, iCols, iBytesPerPixel, iPixels); glPixelStorei(GL_UNPACK_ALIGNMENT,1); glBindTexture(GL_TEXTURE_2D, n); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); GLenum GL_format; if (iBytesPerPixel==1) GL_format=GL_LUMINANCE; else GL_format=GL_RGB; glTexImage2D(GL_TEXTURE_2D, 0, GL_format, iRows, iCols, 0, GL_format, GL_UNSIGNED_BYTE, iPixels); }; void drawTextureSphere() { glBindTexture(GL_TEXTURE_2D, 5); GLUquadricObj * object; object= gluNewQuadric(); gluQuadricDrawStyle(object, GLU_FILL); gluQuadricTexture( object, GL_TRUE ); gluSphere(object, 1.0, 50, 50); gluDeleteQuadric(object); } void drawTextureMoon() { glBindTexture(GL_TEXTURE_2D, 6); GLUquadricObj * object; object= gluNewQuadric(); gluQuadricDrawStyle(object, GLU_FILL); gluQuadricTexture( object, GL_TRUE ); gluSphere(object, 0.25, 10, 10); gluDeleteQuadric(object); } int main(int argc, char **argv) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize (600, 400); glutInitWindowPosition( 100, 100); glutCreateWindow("VT Demonstration 6"); glutDisplayFunc(myDisplay); glutIdleFunc(myIdle); glutReshapeFunc(myReshape); myInit(); glutMainLoop(); return 0; } static void myInit() { glEnable(GL_DEPTH_TEST); /* enable z buffer */ glClearColor (0.1, 0.1, 0.1, 1.0); //background is grey glColor3f (1.0, 1.0, 1.0); //drawing colour is white loadTexture(5, "earth.raw", ImageRows/2, ImageCols/2, Image3bytesPerPixel, earthTexture); loadTexture(6, "moon.raw", ImageRows/2, ImageCols/2, Image3bytesPerPixel, earthTexture); glEnable(GL_TEXTURE_2D); } static void myDisplay(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); // Save the matrix { glTranslatef(0, 0, -5); // Translate to the center of the system glRotatef(45,1,0,0); // Rotate so we can see it from above glRotatef(thetaSphere,0,1,0); // Rotate the axis so that z is pointing towards the earth glTranslatef(0, 0, -3); // Translate along z (towards the earth) glRotatef(-thetaSphere,0,1,0); // Rotate the axis back to where they were glPushMatrix(); // Save the matrix { glRotatef(thetaSphere*5,0,1,0); // Rotate the axis to the direction that the earth is spinning glRotatef(90,1,0,0); // Rotate the axis so that the earth is drawn upwards drawTextureSphere(); // Draw earth } glPopMatrix(); // Restore the matrix glPushMatrix(); // Save the matrix { glRotatef(thetaMoon,0,1,0); // Rotate the axis so that z is pointing towards the moon glTranslatef(0, 0, -1.5); // Translate along z (towards the moon) glRotatef(-thetaMoon,0,1,0); // Rotate the axis back to where they were glPushMatrix(); // Save the matrix { glRotatef(thetaMoon*5,0,1,0); // Rotate the axis to the direction that the earth is spinning glRotatef(90,1,0,0); // Rotate the axis so that the earth is drawn upwards drawTextureMoon(); // Draw moon } glPopMatrix(); // Restore the matrix } glPopMatrix(); // Restore the matrix } glPopMatrix(); // Restore the matrix glFlush(); glutSwapBuffers(); } void myIdle() { thetaSphere += 1.1; if ( thetaSphere > 360.0) thetaSphere -= 360.0; thetaMoon -= 3; if ( thetaMoon > 360.0) thetaMoon -= 360.0; glutPostRedisplay(); } void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45,w/h,nearPlane,farPlane); glMatrixMode(GL_MODELVIEW); // set and leave in MODELVIUEW mode glLoadIdentity(); glTranslatef(0.0, 0.0, -distance); //set camera position //redraw the objects glutPostRedisplay(); } Just mess around with it. I'm sure you'll see how it all works
  4. Thorin_nz

    Is C++ worth learning?

    Quote:Original post by khalligan If you dont have any necessity to learn C++ to do games development, and not over serious about programming. Id go with C# its easy and has most of the things that C++ has, good for doing GUI programs if you want to go down that route. If you like computers, problem solving and programming do a Computer Science degree. If you like mathematical theory and want to end up doing research or lecturing do a Mathematics degree. I'm currently doing a plain BSc, This year I had about 24 points of math, 18 In computer science and 6 in engineering ... This allowed me to major in both math or computer science next year... Might be worth thinking about if you don't know what you want to do yet.
  5. Thorin_nz

    new to network programming

    4. Is it possible to have *one* program that sends something to the network and receives it again? -- Tutorials usually only have a program that sends data and another that recieves the data the other sends. But yes its possible, Infact its highly likely you will have 2 way communication :P
  6. You would probably want to detect when the user is getting close to another tile. When they are in some threshold, you start the loading process, If the planned nicely, the data should be loaded a second or so before the user crosses to the next tile. You would have to allow the loading to either run in a thread or split it up somehow... They maybe a better way to do it, just throwing round ideas.
  7. Is using matlab really necessary? I've recently finished a course on mathematical computation that used matlab, It doesnt seem like the kind of software you would want to create a mini golf game with. Anyway, You would want to create various functions that gives you the forces on the ball, eg friction, wind, surface. The parameters for these should be time, position, velocity, mass and anything else you can think of. Then you have a function that sums all of these and divides by the mass to get acceleration. You can then integrate to get velocity, then integrate again to get the position. I think that should be all you need.
  8. Thorin_nz

    terrain patch stitching

    I drew this up a while ago... http://img86.exs.cx/img86/7880/dlod.gif Not sure how efficent it is, but it seems to work nicely
  9. Thorin_nz

    C++ Macro Challenge

    __COUNTER__ anyone? Its ms specific though =P Quote:Expands to an integer starting with 0 and incrementing by 1 every time it is used in a compiland. __COUNTER__ remembers its state when using precompiled headers. If the last __COUNTER__ value was 4 after building a precompiled header (PCH), it will start with 5 on each PCH use.
  10. Thorin_nz

    The Zoom Quilt

    Quote:Original post by Senses777 That was very cool. Too bad they don't explain how they made it. http://zoomquilt.nikkki.net/ Click on the [x] next to the participants names to see the images they made, im sure you can fiqure it out by looking at that...
  11. Thorin_nz

    What is your personality type?

    Your Type is INFJ Introverted Intuitive Feeling Judging Strength of the preferences % I: 39 N: 83 F: 11 J: 11 Quite like my Intuitive rating :p
  12. Thorin_nz

    Teaching Programming

    I've done a course like this using QBasic in the past, the students coming into the course had qbasic experience but who ever the hell taught them got them to label their lines with numbers instead of labels. Most of their code was total mess. goto 1020 isnt exactly descriptive... Anyway, With QBasic, it is fairly restrictive. I would say to just pick C as your language, but only teach them what they need to know. The basics of memory, pointers and functions should do. Maybe just start off building up a text based adventure then perhaps introduce glut when you feel they are ready for it. Good luck ~ Steve
  13. Meh, I learned OpenGL from NeHe before I knew what HWND was... At the time I understood everything I needed to know to use OpenGL, but for the win32 code I didnt know what the hell was going on. Since then I have however learned how to use the hidous win32 api. Just shows that it is possible, it just depends how ignorant you are :P
  14. Thorin_nz

    OT: wierd graphic problem

    If you have a GeForce, in the settings under opengl there is a tickbox, Enable conformant OpenGL texture clamp behaviour. If its not that, (not sure what it actually does) It maybe a problem with the card. I would try installing fresh drivers and trying things like that. If you still can't get it working, take it in to where ever you got it from, They should replace it after taking a quick look at it. - Steve
  15. Thorin_nz

    what do I need to add to this for loop?

    the following code will count from 0 to 99 im sure you can edit it to your needs /********************************************************** Loop that counts from 0 to 99 using a for loop Copyright (C) 2004 Steven Ashley This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. **********************************************************/ #include<iostream> using namespace std; int main() { for(int i = 0; i < 100; i++) { cout << i << endl; } return 0; } edit: bug fix
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!