基于OPGL的3D水波光影模型CODE(part)

class plane
{
public:
 
 float a,b,c,d;
 point n;

 plane();

 // constructors from a,b,c,d
 plane(float,float,float,float);
 void create(float,float,float,float);

 // constructors from 3 passing points
 plane(point,point,point);
 void create(point,point,point);
 void negate();

 // point comes in xyz. The result indicates the distance
 // to the plane's oriented surface from the point. Values
 // >0 mean point outside (in the normal side) of the plane.
 // <0 mean inside, and =0 mean point on surface.
 double testpoint (point);
 

 // line comes in the form of passing point + director vector.
 // result is 0 if line parallel to plane. !0 if colliding,
 // and then the third param returns the interesction point
 double testline(point,point,point &);

 
 int magicnumber (point);
 int testtri (point,point,point);
 
 point getpointfromplane();

 double evalxy(double,double);
 double evalxz(double,double);
 double evalyz(double,double);

 void operator=(plane);        // copy
 ~plane();

};

#endif 

#ifndef _POINT_INC
#define _POINT_INC

/*
Written by DSC aprox. 1996
1.7.98 Translation into good-looking C++
*/

#include "text.h"

class point
        {
        public:
                double x,y,z;    /* oops... this makes rendering faster! */

                point();
                point(double,double,double);
                point(text &);
                point(point &);

                void create(double,double,double);
                void load(text &);

                point operator+(point);       // addition
                point operator-(point);       // substraction
                int operator==(point);        // comparison
                int operator!=(point);        // negated comparison                       
                void operator=(point);        // copy
                point operator*(double);      // scaling
    point operator/(double);   // inv. scaling
                double operator*(point);      // dot product
                point operator^(point);       // cross product

                point interpolate(point,double,point,double);
                double modulo();
                double modulosq();
    double distance(point);
    double distanceman(point);
    double distancemanxz(point);

                void normalize();
                void negate();
                int into(point, point);
    float distancePointLine(point,point);//distance from point this to line ab

       void rotatex(double);
    void rotatey(double);
    void rotatey(float,float); //rotatey passing sin(ang) and cos(ang) values
    void rotatez(double);

    bool infrustum(point,double,double); // viewer,yaw of viewer,aperture,caller is point to test

    ~point();
        };

#endif

class texmanager
        {
  public:
   int numtextures;
   int allocatedmemory;
   texture *texdata;
   unsigned int *translationtable;
   int *available;
   int *type;
   
   texmanager();
   int load(char *);
   void usetexture(int);
   void removetexture(int);
   ~texmanager();
        };


#endif

class text
        {
        char *data;
        unsigned int sl;
        unsigned int size;
        public:
    text();
    text(char*);

                void create(char *);
                char *getword();
    char *getcommaword();
                int getint();
                double getfloat();

                int countword(char *);
    int countwordfromhere(char *);
                int countchar(char);
                void reset();
                void destroy();
                void goback();
    void seek(char *);
                int eof();
    ~text();
        };

#endif

 

lass texture
        {
  public:

   char *name;
   unsigned int ident;
   int sizex,sizey;
   int depth;    // in bytes per pixel
   bool alpha;
   
   texture();
   int loadtex(char *,int);
   int loadtga(char *,int);
   void use();
   ~texture();
        };


#endif

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值