Changeset 5684


Ignore:
Timestamp:
Aug 26, 2008, 10:50:42 AM (16 years ago)
Author:
jack
Message:

Normal calculations for height quantities (broken).

Location:
anuga_work/development/anugavis/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/anugavis/src/anugavis.cc

    r5636 r5684  
    55#include <algorithm>
    66#include <string>
     7#include <boost/bind.hpp>
    78#include <boost/shared_ptr.hpp>
    89#ifdef HAVE_GL_GL_H
     
    2122#include "sww_file.hh"
    2223
     24using boost::bind;
    2325using boost::shared_ptr;
    2426using std::for_each;
     
    9193  static Uint32 lastframe;
    9294  bool more = true;
     95  float light[4];
    9396
    9497  if(ticks == 0) lastframe = ticks = SDL_GetTicks();
     
    102105    this->paused = 1;
    103106
     107  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     108  glMatrixMode(GL_MODELVIEW);
     109  glLoadIdentity();
     110  gluLookAt(this->eye  .x, this->eye  .y, this->eye  .z,
     111            this->focus.x, this->focus.y, this->focus.z,
     112                        0,             0,             1);
     113  light[0] = this->eye.x;
     114  light[1] = this->eye.y;
     115  light[2] = this->eye.z;
     116  light[3] = 1.0;
     117  glLightfv(GL_LIGHT0, GL_POSITION, light);
     118  for_each(this->heights.begin(),
     119           this->heights.end  (),
     120           bind(&HeightQuantity::draw, _1, this->frame));
    104121  return false;
    105122}
  • anuga_work/development/anugavis/src/height_quantity.cc

    r5636 r5684  
    1616#include <netcdf.h>
    1717#include "height_quantity.hh"
     18#include "vector.hh"
    1819
    1920using std::string;
     
    6364  size_t span_2[2] = {1, 0};
    6465  int ncstatus;
    65   int volume;
    66   int vertex;
    6766  int vertIndex;
    6867  if(this->dynamic){
     
    7877  if(ncstatus != NC_NOERR) throw nc_strerror(ncstatus);
    7978  glNewList(this->display_list, GL_COMPILE);
    80   glBegin(GL_TRIANGLES);
    81   {
    82    
    83     for(volume = 0 ; volume = this->sww_file->number_of_volumes ; ++volume){
    84       for(vertex = 0 ; vertex < 3 ; ++vertex){
     79  glBegin(GL_TRIANGLES);{
     80    for(int volume = 0 ; volume = this->sww_file->number_of_volumes ; ++volume){
     81      /* Compute normal. */
     82      Vector vs[3];
     83      for(int vertex = 0 ; vertex < 3 ; ++vertex){
     84        int offset = volume * this->sww_file->number_of_vertices + vertex;
     85        vertIndex = this->sww_file->volumes[offset];
     86        vs[vertex] = Vector(this->sww_file->x[vertIndex],
     87                            this->sww_file->y[vertIndex],
     88                            this->points     [vertIndex]);
     89      }
     90      Vector normal = (vs[1] - vs[0]).cross(vs[2] - vs[0]);
     91      if(normal.magnitude() < 0) normal = normal.scale(-1.0);
     92      glNormal3f(normal.x, normal.y, normal.z);
     93
     94      /* Insert vertices. */
     95      for(int vertex = 0 ; vertex < 3 ; ++vertex){
    8596        vertIndex = this->sww_file->volumes[volume *
    8697                                            this->sww_file->number_of_vertices +
     
    91102      }
    92103    }
    93   }
    94   glEnd();
     104  }glEnd();
    95105  glEndList();
    96106}
Note: See TracChangeset for help on using the changeset viewer.