Commit fb0bc2f13a22ec3579c5d48970eec944e31b59bc

Authored by Pavel Govyadinov
1 parent 5f54af5b

added the gl_spider skeleton class

Showing 1 changed file with 145 additions and 0 deletions   Show diff stats
gl/gl_spider.h 0 → 100644
  1 +#ifndef STIM_GL_SPIDER_H
  2 +#define STIM_GL_SPIDER_H
  3 +
  4 +#include <GL/glut.h>
  5 +#include "../visualization/camera.h"
  6 +#include "./error.h"
  7 +#include "../math/vector.h"
  8 +
  9 +
  10 +namespace stim
  11 +{
  12 +
  13 +template<typename T>
  14 +class gl_spider : public virtual gl_texture<T>
  15 +{
  16 + //doen't use gl_texture really, just needs the GLuint id.
  17 + private:
  18 + stim::camera rotator;
  19 + stim::vec<float> position; //vector designating the position of the spider.
  20 + stim::vec<float> direction; //vector designating the orientation of the spider
  21 + //always a unit vector.
  22 + stim::vec<float> magnitude; //magnitude of the direction vector.
  23 + //maybe a vector in order to scale the spider
  24 + // in the x, y, z directions.
  25 +
  26 + // Also maybe we some texture representation of
  27 + // of the spider i.e [WH_pxl, BL_pxl, WH_pxl].
  28 + stim::gl_texture<T>;
  29 +
  30 +
  31 + void
  32 + findOptimalDirection()
  33 + {
  34 + /* Method for finding the best direction for the spider.
  35 + Uses the camera to rotate. Then Calls Evaluate to find new cost.
  36 + */
  37 + }
  38 +
  39 + void
  40 + findOptimalPosition()
  41 + {
  42 + /* Method for finding the best direction for the spider.
  43 + Not sure if necessary since the next position for the spider
  44 + will be at direction * magnitude. */
  45 + }
  46 +
  47 + void
  48 + findOptimalScale()
  49 + {
  50 + /* Method for finding the best scale for the spider.
  51 + changes the x, y, z size of the spider to minimize the cost
  52 + function. */
  53 + }
  54 +
  55 + void
  56 + Evaluate()
  57 + {
  58 + /* Uses uniform sampler2D in order to take a difference between
  59 + the colors of two textures. 1st texture is the spider template,
  60 + the 2nd is the location of the spider's overlap with the
  61 + gl_template
  62 +
  63 + does the spider need to track it's location? Prob not since
  64 + position can be set with gl_texture coordinates */
  65 +
  66 + }
  67 +
  68 + void
  69 + Optimize()
  70 + {
  71 + /*find the optimum direction and scale */
  72 + }
  73 +
  74 + void
  75 + Step()
  76 + {
  77 + /* move to the new position */
  78 + }
  79 +
  80 + public:
  81 + vec<float>
  82 + getCurrentPosition()
  83 + {
  84 + return position;
  85 + }
  86 +
  87 + vec<float>
  88 + getCurrentDirection()
  89 + {
  90 + return direction;
  91 + }
  92 +
  93 + vec<float>
  94 + getCurrentMagnitude()
  95 + {
  96 + return magnitude;
  97 + }
  98 +
  99 + void
  100 + setPosition(vec<float> pos)
  101 + {
  102 + position = pos;
  103 + }
  104 +
  105 + void
  106 + setPosition(float x, float y, float z)
  107 + {
  108 + position[0] = x;
  109 + position[1] = y;
  110 + position[2] = z;
  111 + }
  112 +
  113 + void
  114 + setDirection(vec<float> dir)
  115 + {
  116 + direction = dir;
  117 + }
  118 +
  119 + void
  120 + setDirection(float x, float y, float z)
  121 + {
  122 + direction[0] = x;
  123 + direction[1] = y;
  124 + direction[2] = z;
  125 + }
  126 +
  127 + void
  128 + setMagnitude(vec<float> mag)
  129 + {
  130 + magnitude = mag;
  131 + }
  132 +
  133 + void
  134 + setPosition(float x, float y, float z)
  135 + {
  136 + magnitude[0] = x;
  137 + magnitude[1] = y;
  138 + magnitude[2] = z;
  139 + }
  140 +
  141 +
  142 +
  143 +}
  144 +}
  145 +#endif
... ...