FLOOR.CPP
资源名称:tc3d.zip [点击查看]
上传用户:abcdshs
上传日期:2007-01-07
资源大小:1858k
文件大小:2k
源码类别:
游戏
开发平台:
Visual C++
- // (C) Copyright 1996 by Anthony J. Carin. All Rights Reserved.
- #include <stdafx.h>
- #include "floor.h"
- #include <3dtools.h>
- extern CString& getpath(CString& filename);
- const float FLOORRANGE = 6.0f;
- const float FLOORHIGHT = -.3f;
- floortype::floortype()
- {
- m_surface = new surfs();
- tilesize = FLOORRANGE*2;
- m_surface->setcolor(RGB(148,148,40));
- }
- floortype::floortype(CString& c)
- {
- m_surface = new bmpsurf(c);
- tilesize = FLOORRANGE*2;
- ((bmpsurf*)m_surface)->ExemptFromIntersect();
- }
- floortype::~floortype()
- {
- delete m_surface;
- }
- static float Material[] = {0.7f, 0.7f, 0.7f, 1.0f};
- void floortype::draw(coordinate& coord)
- {
- float cx,cz;
- tccolor color = m_surface->color();
- coordinate t_a,t_b,t_c,t_d;
- getentirearea(coord);
- Game->Tool3d()->material(color);
- for (float x = m_a.x(); x < m_b.x(); x += tilesize)
- {
- for (float z = m_a.z(); z < m_c.z(); z += tilesize)
- {
- cx = x;
- cz = z;
- t_a.setto(cx, FLOORHIGHT, cz);
- cx += tilesize;
- t_b.setto(cx, FLOORHIGHT, cz);
- cz += tilesize;
- t_c.setto(cx, FLOORHIGHT, cz);
- cx -= tilesize;
- t_d.setto(cx, FLOORHIGHT, cz);
- m_surface->setto(t_a,t_b,t_c,t_d);
- m_surface->draw();
- }
- }
- }
- void floortype::getentirearea(coordinate& coord)
- {
- int tmpx, tmpz;
- tmpx = (int) (coord.x() - FLOORRANGE);
- tmpz = (int) (coord.z() - FLOORRANGE);
- m_a.setto((float) tmpx, FLOORHIGHT, (float) tmpz);
- tmpx = (int) (coord.x() + FLOORRANGE);
- m_b.setto((float) tmpx, FLOORHIGHT, (float) tmpz);
- tmpz = (int) (coord.z() + FLOORRANGE);
- m_c.setto((float) tmpx, FLOORHIGHT, (float) tmpz);
- tmpx = (int) (coord.x() - FLOORRANGE);
- m_d.setto((float) tmpx, FLOORHIGHT, (float) tmpz);
- }
- void floortype::settexture(CString& c)
- {
- delete m_surface;
- m_surface = new bmpsurf(getpath(c));
- tilesize = FLOORRANGE*2;
- ((bmpsurf*)m_surface)->ExemptFromIntersect();
- }
- void floortype::cleartexture()
- {
- delete m_surface;
- m_surface = new surfs();
- tilesize = FLOORRANGE*2;
- m_surface->setcolor(RGB(148,148,40));
- }