x
Yes
No
Do you want to visit DriveHQ English website?
Inicio
Características
Precios
Prueba gratuita
Software cliente
Acerca de nosotros
Servidor de archivos
|
Solución de copias de seguridad
|
Servidor FTP
|
Servidor de correo electrónico
|
Alojamiento web
|
Software cliente
Servidor de archivos
Solución de copia de seguridad
Servidor FTP
Servidor de correo electrónico
Alojamiento web
Software cliente
DataTypes.h - Hosted on DriveHQ Cloud IT Platform
Arriba
Subir
Descargar
Compartir
Publicar
Nueva carpeta
Nuevo archivo
Copiar
Cortar
Eliminar
Pegar
Clasificación
Actualizar
Ruta de la carpeta: \\game3dprogramming\materials\DarkPuzzle\GameEngine\DataTypes.h
Girar
Efecto
Propiedad
Historial
#pragma once #include
#include
#include
namespace DarkBattle{ //tolua_begin class Vec3{ public: float x,y,z; static Vec3 make(){ return Vec3(); } static Vec3 make(float x,float y,float z){ return Vec3(x,y,z); } Vec3 operator+ (const Vec3 &op) const{ return Vec3(this->x+op.x,this->y+op.y,this->z+op.z); } Vec3 operator- (const Vec3 &op) const{ return Vec3(this->x-op.x,this->y-op.y,this->z-op.z); } Vec3 operator* (const float &op) const{ return Vec3(this->x*op,this->y*op,this->z*op); } Vec3 operator/ (const float &op) const{ return Vec3(this->x/op,this->y/op,this->z/op); } void Set(float px,float py,float pz){ x = px; y=py; z=pz; } void Set(Vec3 vec){ x=vec.x; y=vec.y; z=vec.z; } float Length() const { return sqrt(x*x+y*y+z*z); } float Length2D() const { return sqrt(x*x+y*y); } bool IsAt(Vec3 pos) const; //tolua_end ~Vec3(){}//tolua_export Vec3(){ x=y=z=0;} //tolua_export Vec3(float px,float py,float pz){ x = px;y=py;z=pz; } Vec3(btVector3 src){ x = src.getX(); y=src.getY(); z=src.getZ(); } Vec3(D3DXVECTOR3 src){ x= src.x; y=src.y;z=src.z; } btVector3 ToBtVector3() const{ return btVector3(x,y,z); } //Position(Position& pos){ // x = pos.x; y=pos.y; z=pos.z; //} //Position& operator= (const Position &op){ // return Position(op.x,op.y,op.z); //} };//tolua_export template
class Matrix{ protected: element* data; int sizeX,sizeY; inline int index(int x,int y){return x*sizeX+y;}; public: Matrix(int SizeX, int SizeY){sizeX=SizeX;sizeY=SizeY;data=new element[sizeX*sizeY];}; ~Matrix(){SAFE_DELETE_ARRAY(data);}; inline element get(int x,int y){return data[index(x,y)];}; inline void set(int x,int y, element val){data[index(x,y)]=val;}; void Fill(element value){ for(int i=0;i
{ public: inline bool IsClosed(int x,int y){return get(x,y);}; void Clean(){ for (int x=0;x
(sizeX,sizeY){}; }; class Vec2{ public: int x,y; Vec2(int X,int Y):x(X),y(Y){}; Vec2(){}; }; template
class PriorityElement{ public: float priority; DataType data; PriorityElement(float Priority, DataType Data):priority(Priority),data(Data){}; }; template
struct lessPriority { // functor for operator< inline bool operator()(const PriorityElement
& _Left, const PriorityElement
& _Right) const { // apply operator< to operands return (_Left.priority < _Right.priority); } }; class OpenListPriority{ private: priority_queue
,vector
>,lessPriority
> data; public: inline void Push(float priority,Vec2 pos){ data.push(PriorityElement
(-priority,pos));//to make the priority queue pop the smallest value } Vec2 Pop(){ Vec2 ret = data.top().data; data.pop(); return ret; } inline bool IsEmpty(){return data.empty();}; void Clean(){ while(!IsEmpty()){ data.pop(); } }; }; template
class MyQueue{ private: list
data; public: DataType Pop(){ DataType ret = data.back(); data.pop_back(); return ret; }; inline void Push(DataType pos){data.push_front(pos);}; inline void PushBack(DataType pos){data.push_back(pos);}; inline bool IsEmpty(){return data.empty();}; inline void Clean(){while (!data.empty()) data.pop_back();}; }; typedef MyQueue
Vec2Queue; typedef Matrix
DistanceMap; //Vec3Queue cannot be converted to template class because tolua doesn't support template class Vec3Queue{//tolua_export private: list
data; public: //tolua_begin Vec3 Pop(); inline void Push(Vec3 pos){data.push_front(pos);}; inline void PushBack(Vec3 pos){data.push_back(pos);}; inline bool IsEmpty(){return data.empty();}; inline void Clean(){while (!data.empty()) data.pop_back();}; inline int Size(){return data.size();}; //tolua_end };//tolua_export struct less_str { bool operator()(char* x, char* y) const { return (strcmp(x, y)>0); //differ } }; template
class MyIterator{ public: hash_map
::iterator iter; MyIterator(hash_map
::iterator iterator):iter(iterator){}; MyIterator(){hash_map
::iterator iterator;iter = hash_map
::iterator(iterator);}; void Next(){iter++;}; DataType* GetCurrent(){return (DataType*)iter->second;}; }; template
class MyHashTable{ private: hash_map
> mPool; public: DataType* Get(char* key){ return (DataType*)(mPool.find(key)->second); }; void Put(const char* key, const DataType* value){ char* localKey; CLONE_STR(localKey,key); mPool.insert(pair
(localKey,(void*)value)); }; bool Check(char* key){return mPool.find(key)!=mPool.end();}; MyIterator
Begin(){ return MyIterator
(mPool.begin()); } bool IsEnd(MyIterator
iter){ return iter.iter==mPool.end(); } }; }
DataTypes.h
Dirección de la página
Dirección del archivo
Anterior
13/65
Siguiente
Descargar
( 5 KB )
Comments
Total ratings:
0
Average rating:
No clasificado
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.