Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2931 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Nov 20, 2004, 1:33:51 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/importer: included mouse-speed-turning (touch the screen and the object will start to move). Also included windows.h if in WIN32. general cleanup of framework

Location:
orxonox/trunk/importer
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/importer/Makefile.am

    r2776 r2931  
    88importer_SOURCES=framework.cc windowHandler.cc object.cc array.cc material.cc
    99
    10 noinst_HEADERS=windowHandler.h object.h array.h material.h
     10noinst_HEADERS=framework.h windowHandler.h object.h array.h material.h
    1111
    1212
  • orxonox/trunk/importer/Makefile.in

    r2776 r2931  
    152152AM_LDFLAGS = "-L/usr/Mesa-6.0.1/lib  -L/usr/X11R6/lib -lXt -lX11" $(MWINDOWS)
    153153importer_SOURCES = framework.cc windowHandler.cc object.cc array.cc material.cc
    154 noinst_HEADERS = windowHandler.h object.h array.h material.h
     154noinst_HEADERS = framework.h windowHandler.h object.h array.h material.h
    155155all: all-am
    156156
  • orxonox/trunk/importer/framework.cc

    r2863 r2931  
    1 #include "windowHandler.h" // Include the Whandler Basecode
    2 #include "object.h"
     1#include "framework.h"
    32
    43int verbose = 1;
    5 WindowHandler wHandler;  // Create an instance of the whandler basecode class
    6 Object* obj;
    7 float rotator = 0.0;
    8   GLfloat whiteLight[] = {1.0, 1.0, 0.0,1.0};
    94
    105void DrawGLScene()
    116{
    12   rotator +=.001;
     7  rotatorP += rotatorV;
    138 
    149  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
     
    1813  glLoadIdentity();     
    1914  gluPerspective(45.0f,500/375,0.1f,100.0f);
    20   gluLookAt (5*sin(rotator),7.5,5*cos(rotator), 0,0,0, 0,1,0);
    21   whiteLight[1] = .5+.5*sin(rotator*10);
    22   whiteLight[2] = .5+.5*sin(rotator*10);
     15  gluLookAt (5*sin(rotatorP),7.5,5*cos(rotatorP), 0,0,0, 0,1,0);
    2316
    24   GLfloat lightPosition[] = {10.0*sin(rotator*10), 10, 19.0, 0.0};
    25   glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
    26 
    27   glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
    2817  obj->draw();
    2918
     
    5342    obj = new Object();
    5443 
     44  glEnable(GL_LIGHTING);
     45  glEnable(GL_DEPTH_TEST);
     46
     47  GLfloat whiteLight[] = {1.0, 1.0, 1.0,1.0};
     48  GLfloat light0Position[] = {10.0, 10.0, 10.0, 0.0};
     49  GLfloat light1Position[] = {-10.0, -7.0, -6.0, 0.0};
    5550  GLfloat lmodelAmbient[] = {.1, .1, .1, 1.0};
     51
     52  glEnable(GL_LIGHT0);
     53  glLightfv(GL_LIGHT0, GL_POSITION, light0Position);
    5654  glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
    5755  glLightfv(GL_LIGHT0, GL_SPECULAR, whiteLight);
    58   glEnable(GL_LIGHTING);
    59   glEnable(GL_LIGHT0);
    60   glEnable(GL_DEPTH_TEST);
    61 
     56 
     57  glEnable(GL_LIGHT1);
     58  glLightfv(GL_LIGHT1, GL_POSITION, light1Position);
     59  glLightfv(GL_LIGHT1, GL_DIFFUSE, whiteLight);
     60  glLightfv(GL_LIGHT1, GL_SPECULAR, whiteLight);
     61 
     62  rotatorP = .0;
     63  rotatorV = .0;
    6264  // Build the font from a TGA image font.tga in the data directory
    6365  // Hide the mouse cursor
    64   SDL_ShowCursor(0);
     66    SDL_ShowCursor(2);
    6567
    6668  // This is the main loop for the entire program and it will run until done==TRUE
     
    7375    while ( SDL_PollEvent(&event) ) {
    7476      switch (event.type) {
     77      case SDL_MOUSEMOTION:
     78        if (verbose >=3)
     79          printf("Mouse motion about %d,%d Pixels to (%d,%d).\n",
     80                 event.motion.xrel, event.motion.yrel,
     81                 event.motion.x, event.motion.y);
     82        break;
     83      case SDL_MOUSEBUTTONDOWN:
     84        printf("MouseButton %d pressed at (%d,%d).\n",
     85               event.button.button, event.button.x, event.button.y);
     86        rotatorV = ( 250-event.button.x) / 500.0 /100;
     87       
     88        break;
     89      case SDL_MOUSEBUTTONUP:
     90        printf("MouseButton %d released at (%d,%d).\n",
     91               event.button.button, event.button.x, event.button.y);
     92
     93       
     94        break;
     95
    7596        // If a quit event was recieved
    7697      case SDL_QUIT:
  • orxonox/trunk/importer/object.cc

    r2863 r2931  
    295295    }
    296296  objFileName = fileName;
    297   char Buffer[500];
     297  char Buffer[10000];
    298298  while(!OBJ_FILE->eof())
    299299    {
    300       OBJ_FILE->getline(Buffer, 500);
     300      OBJ_FILE->getline(Buffer, 10000);
    301301      if (verbose >=4)
    302302        printf ("Read input line: %s\n",Buffer);
  • orxonox/trunk/importer/windowHandler.cc

    r2759 r2931  
    33#include "windowHandler.h"
    44#include <stdio.h>
    5 void WindowHandler::ReSizeGLScene(GLsizei width, GLsizei height)                // Resize And Initialize The GL Window
     5void WindowHandler::ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
    66{
    7         if (height==0)                                                                          // Prevent A Divide By Zero By
     7        if (height==0)  // Prevent A Divide By Zero By
    88        {
    9                 height=1;                                                                               // Making Height Equal One
     9                height=1;// Making Height Equal One
    1010        }
    1111
    12         glViewport(0,0,width,height);                                           // Reset The Current Viewport
     12        glViewport(0,0,width,height); // Reset The Current Viewport
    1313
    14 
    15         glMatrixMode(GL_PROJECTION);                                            // Select The Projection Matrix
     14       
     15        glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
    1616        glLoadIdentity();       
    1717
     
    2121        gluLookAt (0,0,15, 0,0,0, 0,1,0);
    2222
    23         glMatrixMode(GL_MODELVIEW);                                                     // Select The Modelview Matrix
    24         glLoadIdentity();                                                                       // Reset The Modelview Matrix
     23        glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
     24        glLoadIdentity(); // Reset The Modelview Matrix
    2525
    2626}
     
    2929int WindowHandler::InitGL(GLvoid)                                                                               // All Setup For OpenGL Goes Here
    3030{
    31         glEnable(GL_TEXTURE_2D);                                                        // Enable Texture Mapping
    32         glShadeModel(GL_SMOOTH);                                                        // Enable Smooth Shading
    33         glClearColor(0.00f, 0.00f, 0.00f, 0.0f);                        // Black Background
    34         glClearDepth(1.0f);                                                                     // Depth Buffer Setup
    35         glEnable(GL_DEPTH_TEST);                                                        // Enables Depth Testing
    36         glDepthFunc(GL_LEQUAL);                                                         // The Type Of Depth Testing To Do
    37         glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);      // Really Nice Perspective Calculations
     31        glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
     32        glShadeModel(GL_SMOOTH); // Enable Smooth Shading
     33        glClearColor(0.00f, 0.00f, 0.00f, 0.0f); // Black Background
     34        glClearDepth(1.0f);  // Depth Buffer Setup
     35        glEnable(GL_DEPTH_TEST); // Enables Depth Testing
     36        glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
     37        glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);  // Really Nice Perspective Calculations
    3838
    3939    return TRUE;
     
    4141
    4242
    43 GLvoid WindowHandler::KillGLWindow(GLvoid)                                                              // Properly Kill The Window
     43GLvoid WindowHandler::KillGLWindow(GLvoid) // Properly Kill The Window
    4444{
    4545        SDL_Quit();
     
    6868        SDL_GL_GetAttribute( SDL_GL_STENCIL_SIZE, &size);
    6969
    70         ReSizeGLScene(width, height);                                           // Set Up Our Perspective GL Screen
     70        ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen
    7171
    72         if (!InitGL())                                                                          // Initialize Our Newly Created GL Window
     72        if (!InitGL()) // Initialize Our Newly Created GL Window
    7373        {
    74                 KillGLWindow();                                                                 // Reset The Display
    75                 return FALSE;                                                                   // Return FALSE
     74          KillGLWindow();  // Reset The Display
     75          return FALSE;
    7676        }
    7777
    78         return TRUE;                                                                            // Success
     78        return TRUE;
    7979}
    8080
  • orxonox/trunk/importer/windowHandler.h

    r2804 r2931  
    1414#include <math.h>
    1515
     16#ifdef __WIN32__
     17#include <windows.h>
     18#endif /* __WIN32__ */
    1619
    1720#define TRUE 1
Note: See TracChangeset for help on using the changeset viewer.