3DENGINE.H
资源名称:tc3d.zip [点击查看]
上传用户:abcdshs
上传日期:2007-01-07
资源大小:1858k
文件大小:3k
源码类别:
游戏
开发平台:
Visual C++
- // (C) Copyright 1996 by Anthony J. Carin. All Rights Reserved.
- #ifndef _3DENGINE_H
- #define _3DENGINE_H
- #include "3dshapes.h"
- #include <stdio.h>
- const long VIEWRANGE = 17;
- extern view camera;
- class surfs : public polygon
- {
- public:
- surfs() : polygon() {};
- virtual ~surfs() {}
- surfs(surfs& s) : polygon(s) {}
- surfs(coordinate& a, coordinate& b, coordinate& c);
- surfs(coordinate& a, coordinate& b, coordinate& c, coordinate& d);
- virtual char IsABmp() { return FALSE; }
- virtual void CalcNormals();
- virtual void xrotate(direction& d);
- virtual void yrotate(direction& d);
- virtual void zrotate(direction& d);
- virtual void operator +=(coordinate& c);
- virtual void operator =(surfs& s);
- virtual char iswithin(coordinate& c);
- virtual void draw();
- protected:
- float NormalX;
- float NormalY;
- float NormalZ;
- };
- inline surfs::surfs(coordinate& a, coordinate& b, coordinate& c) :
- polygon(a,b,c) {}
- inline surfs::surfs(coordinate& a, coordinate& b, coordinate& c, coordinate& d) :
- polygon(a,b,c,d) {}
- class bmpsurf;
- class image
- {
- public:
- image(LPCTSTR filename, direction ydir = 0);
- virtual ~image();
- void setto(coordinate& p) { m_view.setto(p); }
- void setto(view& p) { m_view = p; }
- void setxdir(direction& dir) { m_view.setxdir(dir); }
- void setydir(direction& dir) { m_view.setydir(dir); }
- void setzdir(direction& dir) { m_view.setzdir(dir); }
- void setyoff(direction& dir) { m_yoff = dir; }
- void setcolor(COLORREF c);
- void setbmpsurf(short index, CString& face);
- void draw();
- void OnlySurfExemptFromIntersect();
- CString GeneralUseString() { return m_genstring; }
- surfs *OnlySurf();
- protected:
- float m_dist;
- private:
- FILE *fptr;
- short numpoints;
- short numsurfs;
- point *m_points;
- surfs **m_surfs;
- surfs **m_mysurfs;
- tccolor color;
- view m_view;
- float m_size;
- direction m_yoff;
- direction xdirfromcamera;
- direction ydirfromcamera;
- CString m_genstring;
- void readfile(LPCTSTR filename);
- void getsize(char *buf);
- void getsurfaces(char *buf);
- void getpoints(char *buf);
- char *findend(char *ptr);
- float convertfloat(char *ptr) { return (float)atof(ptr)/100.0f; }
- void copysurfs();
- void getdistance();
- char outofrange();
- int multiplesurfs(char *ptr);
- };
- inline void image::getdistance()
- {
- m_dist = m_view.distanceto(camera);
- }
- inline void image::setcolor(COLORREF c)
- {
- color = c;
- }
- #endif