x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
DataTypes.h - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\DataTypes.h
旋转
特效
属性
历史版本
#pragma once #include "precompiled.h" #include
#include
#include
#include
#include
#include
using namespace std; using namespace stdext; namespace GameFactory{ //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(NxVec3 src){ x = src.x; y=src.y; z=src.z; } Vec3(Vector3 src){ x= src.x; y=src.y;z=src.z; } operator NxVec3(){ return NxVec3(x,y,z); } operator Vector3(){ return Vector3(x,y,z); } //NxVec3 ToNxVec3() const{ // return NxVec3(x,y,z); //} //Vector3 ToVector3() const{ // return Vector3(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();};//true means already have MyIterator
Begin(){ return MyIterator
(mPool.begin()); } bool IsEnd(MyIterator
iter){ return iter.iter==mPool.end(); } }; }
DataTypes.h
网页地址
文件地址
上一页
12/45
下一页
下载
( 5 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.