code
stringlengths 1
2.01M
| repo_name
stringlengths 3
62
| path
stringlengths 1
267
| language
stringclasses 231
values | license
stringclasses 13
values | size
int64 1
2.01M
|
|---|---|---|---|---|---|
#pragma once
#include <zGraphicsConfig.hpp>
#include <Utility\HasFlag.hpp>
#include <Math\Vector3.hpp>
#include "Mesh.hpp"
namespace zzz {
class ZGRAPHICS_CLASS HalfEdgeMesh {
public:
struct HalfEdge;
struct Vertex;
struct Face;
//////////////////////////////////////////////////////////////////////////
struct HalfEdge : public HasFlags {
HalfEdge *twin_, *prev_, *next_;
Vertex *start_;
Face *left_face_;
bool boundary_;
bool valid_;
HalfEdge(bool boundary)
:boundary_(boundary), twin_(NULL), prev_(NULL), next_(NULL),
start_(NULL), left_face_(NULL), valid_(true) {
}
Vertex *end_vertex() {
return next_->start_;
}
};
//////////////////////////////////////////////////////////////////////////
struct Vertex : public HasFlags {
Vector3f pos_;
HalfEdge *half_edge_;
zuint index_; // index of original position
bool valid_;
vector<HalfEdge*> adj_edges_;
Vertex(const Vector3f &pos, zuint idx)
:pos_(pos), half_edge_(NULL), valid_(true), index_(idx) {
}
};
//////////////////////////////////////////////////////////////////////////
struct Face {
HalfEdge *half_edge_;
bool valid_;
zuint index_; // index from original mesh group
Face(zuint idx)
:half_edge_(NULL), valid_(true), index_(idx) {
}
};
public:
vector<HalfEdge*> half_edges_;
vector<HalfEdge*> boundary_half_edges_;
vector<Vertex*> vertices_;
vector<Face*> faces_;
~HalfEdgeMesh();
void Clear();
void LoadTriMeshGroup(const TriMesh &mesh, zuint group);
private:
inline void ConnectEdges(HalfEdge *he1, HalfEdge *he2);
inline void SetTwins(HalfEdge *he1, HalfEdge *he2);
inline void ConnectFaceEdge(Face *f, HalfEdge *e);
};
}; // namespace zzz
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/HalfEdgeMesh.hpp
|
C++
|
gpl3
| 1,829
|
#pragma once
#include <zGraphicsConfig.hpp>
#include <Math/Array.hpp>
#include <Utility/Tools.hpp>
#include <Utility/STLVector.hpp>
#include <Utility/HasFlag.hpp>
#include <Utility/StaticTools.hpp>
#include "../../Graphics/GeometryHelper.hpp"
#include "../ResourceManager.hpp"
#include "../Texture/Texture2D.hpp"
#include "../../Context/Context.hpp"
#include "../../VBO/VBO.hpp"
#include "../../VBO/ElementVBO.hpp"
#include "../../Graphics/AABB.hpp"
#include "../../Graphics/Rotation.hpp"
#include "../../Graphics/Translation.hpp"
#include "../../Graphics/Transformation.hpp"
namespace zzz{
const int MESH_POS =0x00000001;
const int MESH_NOR =0x00000002;
const int MESH_TEX =0x00000004;
const int MESH_COLOR =0x00000008;
const int MESH_ALL=MESH_POS|MESH_NOR|MESH_TEX|MESH_COLOR;
const int MESH_POSNOR =0x00000100;
const int MESH_POSTAN =0x00000200;
const int MESH_POSBINO =0x00000400;
const int MESH_POSRATIO =0x00000800;
const int MESH_POSALL=MESH_POSNOR|MESH_POSTAN|MESH_POSBINO|MESH_POSRATIO;
const int MESH_VBOPOS =0x00010000;
const int MESH_VBONOR =0x00020000;
const int MESH_VBOTEX =0x00040000;
const int MESH_VBOCOLOR =0x00080000;
const int MESH_VBOALL=MESH_VBOPOS|MESH_VBONOR|MESH_VBOTEX|MESH_VBOCOLOR;
const int MESH_EVBOPOS =0x01000000;
const int MESH_EVBONOR =0x02000000;
const int MESH_EVBOTEX =0x04000000;
const int MESH_EVBOCOLOR =0x08000000;
const int MESH_EVBOALL=MESH_EVBOPOS|MESH_EVBONOR|MESH_EVBOTEX|MESH_EVBOCOLOR;
//PN: Position Number: number of position in one face
//since VBO handles only float, to make it simpler, we think position type is always float
//since inside GPU, texture coordinate is always 3, we make it always Vector3f
template<zuint PN>
class ZGRAPHICS_CLASS Mesh : public HasFlags {
public:
zzz::StaticAssert< PN>=3 > AT_LEAST_3_POINT_FACE;
struct MeshGroup : public HasFlags {
string name_;
string matname_;
//original data
STLVector<Vector<PN,zint32> > facep_,facen_,facet_,facec_;
//normal VBO
VBO VBOPos_, VBONor_, VBOTex_, VBOColor_;
//element data
STLVector<Vector<PN,zuint32> > eindex_;
ElementVBO VBOeIndex_;
};
//original data
STLVector<Vector3f32> pos_,nor_,tex_,color_;
STLVector<MeshGroup*> groups_;
//per vertex generalized data
STLVector<Vector3f32> posnor_,postan_,posbino_;
STLVector<zfloat32> posratio_;
zfloat32 allarea_;
//in element, data are shared, only index is group wise
STLVector<Vector3f32> epos_,enor_,etex_,ecolor_;
VBO VBOePos_,VBOeNor_,VBOeTex_,VBOeColor_;
Vector3f32 MeshOffset_;
AABB3f32 AABB_;
// bool loaded_,vbodone_,eledone_;
Mesh():allarea_(0){}
virtual ~Mesh(){Clear();}
void SetDataFlags() {
ClrFlag(MESH_ALL);
if (!pos_.empty()) SetFlag(MESH_POS);
if (!nor_.empty()) SetFlag(MESH_NOR);
if (!tex_.empty()) SetFlag(MESH_TEX);
if (!color_.empty()) SetFlag(MESH_COLOR);
for (zuint i=0; i<groups_.size(); i++)
{
MeshGroup *g=groups_[i];
g->ClrFlag(MESH_ALL);
if (!g->facep_.empty()) g->SetFlag(MESH_POS);
if (!g->facen_.empty()) g->SetFlag(MESH_NOR);
if (!g->facet_.empty()) g->SetFlag(MESH_TEX);
if (!g->facec_.empty()) g->SetFlag(MESH_COLOR);
}
}
bool Clear() {
nor_.clear();
pos_.clear();
tex_.clear();
for (zuint i=0; i<groups_.size(); i++)
delete groups_[i];
groups_.clear();
posnor_.clear();
postan_.clear();
posbino_.clear();
posratio_.clear();
AABB_.Reset();
ClrAllFlags();
return true;
}
bool Apply(const Translation<float> &offset) {
if (HasNoFlag(MESH_POS)) return false;
int len=pos_.size();
for (int i=0; i<len; i++)
pos_[i]=offset.Apply(pos_[i]);
AABB_.SetOffset(offset);
for (zuint i=0; i<groups_.size(); i++)
groups_[i]->ClrFlag(MESH_VBOALL);
ClrFlag(MESH_EVBOALL);
return true;
}
bool Apply(const Rotation<float> &t) {
if (HasNoFlag(MESH_POS)) return false;
int len=pos_.size();
for (int i=0; i<len; i++)
pos_[i]=t.Apply(pos_[i]);
len=nor_.size();
for (int i=0; i<len; i++) {
nor_[i]=t.Apply(nor_[i]);
if (nor_[i].SafeNormalize()==0) ZLOG(ZVERBOSE)<<"Found a 0-length normal\n";
}
AABB_.Reset();
AABB_+=pos_;
for (zuint i=0; i<groups_.size(); i++)
groups_[i]->ClrFlag(MESH_VBOALL);
ClrFlag(MESH_EVBOALL);
return true;
}
bool Apply(const Transformation<float> &t) {
if (HasNoFlag(MESH_POS)) return false;
int len=pos_.size();
for (int i=0; i<len; i++)
pos_[i]=t.Apply(pos_[i]);
len=nor_.size();
for (int i=0; i<len; i++) {
nor_[i]=t.Apply(nor_[i]);
nor_[i].Normalize();
}
AABB_.Reset();
AABB_+=pos_;
for (zuint i=0; i<groups_.size(); i++)
groups_[i]->ClrFlag(MESH_VBOALL);
ClrFlag(MESH_EVBOALL);
return true;
}
bool Scale(float coef) {
if (HasNoFlag(MESH_POS)) return false;
for (zuint i=0; i<pos_.size(); i++)
pos_[i]*=coef;
AABB_.Min()*=coef;
AABB_.Max()*=coef;
for (zuint i=0; i<groups_.size(); i++)
groups_[i]->ClrFlag(MESH_VBOALL);
ClrFlag(MESH_EVBOALL);
return true;
}
bool Scale(const Vector3f &coef) {
if (HasNoFlag(MESH_POS)) return false;
for (zuint i=0; i<pos_.size(); i++)
pos_[i]*=coef;
AABB_.Min()*=coef;
AABB_.Max()*=coef;
for (zuint i=0; i<groups_.size(); i++)
groups_[i]->ClrFlag(MESH_VBOALL);
ClrFlag(MESH_EVBOALL);
return true;
}
bool ChangeCoordinate(const string &from, const string &to) {
if (HasNoFlag(MESH_POS)) return false;
if (from==to) {
return true;
} else if ((from=="xy" && to=="yx") || (from=="yz" && to=="xy")) {
//swap xy and inverse z
for (zuint i=0; i<pos_.size(); i++) {
Swap(pos_[i].x(),pos_[i].y());
pos_[i].z()=-pos_[i].z();
}
for (zuint i=0; i<nor_.size(); i++) {
Swap(nor_[i].x(),nor_[i].y());
nor_[i].z()=-nor_[i].z();
}
} else if ((from=="xy" && to=="x-y") || (from=="x-y" && to=="xy")) {
//inverse x and y
for (zuint i=0; i<pos_.size(); i++) {
pos_[i].y()=-pos_[i].y();
pos_[i].z()=-pos_[i].z();
}
for (zuint i=0; i<nor_.size(); i++) {
nor_[i].y()=-nor_[i].z();
nor_[i].z()=-nor_[i].z();
}
} else if ((from=="xz" && to=="x-y") || (from=="x-y" && to=="xz") ||\
(from=="xz" && to=="xy") || (from=="xy" && to=="xz")) {
//inverse z and swap yz
for (zuint i=0; i<pos_.size(); i++) {
pos_[i].z()=-pos_[i].z();
Swap(pos_[i].y(),pos_[i].z());
}
for (zuint i=0; i<nor_.size(); i++) {
nor_[i].z()=-nor_[i].z();
Swap(nor_[i].y(),nor_[i].z());
}
}
//reset aabb
AABB_.Reset();
AABB_+=pos_;
for (zuint i=0; i<groups_.size(); i++)
groups_[i]->ClrFlag(MESH_VBOALL);
ClrFlag(MESH_EVBOALL);
return true;
}
bool MakeCenter() {
return Apply(Translation<float>(-AABB_.Center()));
}
bool Normalize() {
return Scale(1.0/AABB_.Diff().Max());
}
bool CalPosNormal(const bool area_weighted=false) {
//calculate normal
if (HasNoFlag(MESH_POS)) return false;
//calculate posnor_
const zuint posn=pos_.size();
posnor_.assign(posn,Vector3f(0));
SetFlag(MESH_POSNOR);
posratio_.assign(posn,0);
allarea_=0;
SetFlag(MESH_POSRATIO);
for (zuint idx=0;idx<groups_.size();idx++) {
MeshGroup *g=groups_[idx];
zuint facelen=g->facep_.size();
STLVector<Vector<PN,int> > &facep=g->facep_, &facet=g->facet_;
for (zuint i=0; i<facelen; i++) {
//calculate area
float thisarea;
switch(PN) {
case 3:
thisarea=GeometryHelper::TriangleArea(pos_[facep[i][0]], pos_[facep[i][1]], pos_[facep[i][2]]);
break;
default:
{
STLVector<Vector3f> points;
for (zuint j=0; j<PN; j++) points.push_back(pos_[facep[i][j]]);
STLVector<Vector2f> points2;
GeometryHelper::ProjectTo2D<3,float>(points,points2);
thisarea=GeometryHelper::PolygonArea(points2);
}
}
allarea_+=thisarea;
posratio_[facep[i][0]]+=thisarea;
posratio_[facep[i][1]]+=thisarea;
posratio_[facep[i][2]]+=thisarea;
//calculate face normal
Vector3f v1=pos_[facep[i][1]]-pos_[facep[i][0]];
Vector3f v2=pos_[facep[i][2]]-pos_[facep[i][0]];
Vector3f facenormal=v1.Cross(v2);
for (int j=0; j<3; j++)
posnor_[facep[i][j]]+=area_weighted?facenormal*thisarea:facenormal;
}
}
for (unsigned int i=0; i<posn; i++) {
posnor_[i].SafeNormalize();
posratio_[i]/=(allarea_*3.0);
}
//copy posnor to normal if normal does no exist
if (HasNoFlag(MESH_NOR)) {
nor_=posnor_;
SetFlag(MESH_NOR);
for (zuint idx=0;idx<groups_.size();idx++) {
groups_[idx]->facen_=groups_[idx]->facep_;
groups_[idx]->SetFlag(MESH_NOR);
}
}
if (HasNoFlag(MESH_TEX)) return true;
//calculate postan_ posbino_ from UV
postan_.assign(posn,Vector3f(0));
posbino_.assign(posn,Vector3f(0));
SetFlag(MESH_POSTAN);
SetFlag(MESH_POSBINO);
for (zuint idx=0;idx<groups_.size();idx++) {
MeshGroup *g=groups_[idx];
if (g->HasNoFlag(MESH_TEX)) continue;
zuint facelen=g->facep_.size();
STLVector<Vector<PN,int> > &facep=g->facep_, &facet=g->facet_;
for (zuint i=0; i<facelen; i++) {
//calculate face normal
Vector3f v1=pos_[facep[i][1]]-pos_[facep[i][0]];
Vector3f v2=pos_[facep[i][2]]-pos_[facep[i][0]];
//use tex coord to calculate face tangent and binormal
Vector3f t1=tex_[facet[i][1]]-tex_[facet[i][0]];
Vector3f t2=tex_[facet[i][1]]-tex_[facet[i][0]];
Vector3f tan;
tan[0]=v1[0]*t2[1]-v2[0]*t1[1];
tan[1]=v1[1]*t2[1]-v2[1]*t1[1];
tan[2]=v1[2]*t2[1]-v2[2]*t1[1];
if (t1[0]*t2[1]-t2[0]*t1[1]<0.0f) tan=-tan;
Vector3f bino;
bino[0]=v1[0]*t2[0]-v2[0]*t1[0];
bino[1]=v1[1]*t2[0]-v2[1]*t1[0];
bino[2]=v1[2]*t2[0]-v2[2]*t1[0];
if (t2[0]*t1[1]-t2[1]*t1[0]<0.0f) bino=-bino;
for (int j=0; j<3; j++) {
postan_[facep[i][j]]+=tan;
posbino_[facep[i][j]]+=bino;
}
}
g->SetFlag(MESH_POSTAN | MESH_POSBINO);
}
for (unsigned int i=0; i<posn; i++) {
postan_[i].SafeNormalize();
posbino_[i].SafeNormalize();
}
return true;
}
//simple draw and vbo draw
bool Draw(int bt=MESH_ALL) const {
if (HasNoFlag(MESH_POS)) return false;
for (zuint i=0; i<groups_.size(); i++) {
if (!Draw(i,bt))
return false;
}
return true;
}
bool Draw(int idx, int bt) const {
if (HasNoFlag(MESH_POS)) return false;
MeshGroup *g=groups_[idx];
bool donor=CheckBit(bt,MESH_NOR) && g->HasFlag(MESH_NOR);
bool dotex=CheckBit(bt,MESH_TEX) && g->HasFlag(MESH_TEX);
bool docolor=CheckBit(bt,MESH_COLOR) && g->HasFlag(MESH_COLOR);
STLVector<Vector<PN,int> > &facep=g->facep_, &facen=g->facen_, &facet=g->facet_, &facec=g->facec_;
switch(PN) {
case 0:
case 1:
case 2:
return false;
case 3: glBegin(GL_TRIANGLES); break;
case 4: glBegin(GL_QUADS); break;
default: glBegin(GL_POLYGON); break;
}
for (zuint i=0; i<facep.size(); i++) {
for (int j=0; j<PN; j++) {
if (donor) glNormal3fv(nor_[facen[i][j]].Data());
if (dotex) glTexCoord3fv(tex_[facet[i][j]].Data());
if (docolor) glColor3fv(color_[facec[i][j]].Data());
glVertex3fv(pos_[facep[i][j]].Data());
}
}
glEnd();
return true;
}
bool Draw(const string &name, int bt) const {
if (HasNoFlag(MESH_POS)) return false;
for (zuint i=0; i<groups_.size(); i++)
if (groups_[i]->name_==name) return Draw(i,bt);
return false;
}
bool CreateVBO(int bt=MESH_ALL) {
if (HasNoFlag(MESH_POS)) return false;
if (HasNoFlag(MESH_NOR)) ClrFlag(MESH_NOR);
if (HasNoFlag(MESH_TEX)) ClrFlag(MESH_TEX);
if (HasNoFlag(MESH_COLOR)) ClrFlag(MESH_COLOR);
for (zuint i=0; i<groups_.size(); i++)
if (!CreateVBO(i,bt)) return false;
return true;
}
bool DrawVBO(int bt=MESH_ALL) {
for (zuint i=0; i<groups_.size(); i++)
if (!DrawVBO(i,bt)) return false;
return true;
}
bool DrawVBO(int idx, int bt) {
MeshGroup *g=groups_[idx];
if (g->HasNoFlag(MESH_VBOPOS)) {
if (!CreateVBO(idx, bt)) return false;
}
// if (g->HasNoFlag(MESH_VBONOR)) g->ClrFlag(MESH_NOR);
// if (g->HasNoFlag(MESH_VBOTEX)) g->ClrFlag(MESH_TEX);
// if (g->HasNoFlag(MESH_VBOCOLOR)) g->ClrFlag(MESH_COLOR);
if (BindVBO(idx, bt)==false) return false;
switch(PN) {
case 0:
case 1:
case 2:
default:
return false;
case 3: glDrawArrays(GL_TRIANGLES,0,(int)groups_[idx]->facep_.size()*3); break;
case 4: glDrawArrays(GL_QUADS,0,(int)groups_[idx]->facep_.size()*4); break;
}
UnbindVBO(idx);
return true;
}
bool DrawVBO(const string &name, int bt) {
for (zuint i=0; i<groups_.size(); i++)
if (groups_[i]->name_==name) return DrawVBO(i,bt);
ZLOG(ZERROR)<<"Cannot find group: "<<name<<endl;
return false;
}
bool CreateElement(int bt=MESH_ALL) {
if (HasNoFlag(MESH_POS)) return false;
ClrFlag(MESH_EVBOALL);
epos_.clear();
enor_.clear();
etex_.clear();
ecolor_.clear();
bool donor=CheckBit(bt,MESH_NOR) && HasFlag(MESH_NOR);
bool dotex=CheckBit(bt,MESH_TEX) && HasFlag(MESH_TEX);
bool docolor=CheckBit(bt,MESH_COLOR) && HasFlag(MESH_COLOR);
typedef Vector<4,zuint> elementpoint;
map<elementpoint,zuint> elementpointmap;
for (zuint idx=0;idx<groups_.size();idx++) {
MeshGroup *g=groups_[idx];
bool thisdonor=donor && g->HasFlag(MESH_NOR);
bool thisdotex=dotex && g->HasFlag(MESH_TEX);
bool thisdocolor=docolor && g->HasFlag(MESH_COLOR);
STLVector<Vector<PN,int> > &facep=g->facep_, &facen=g->facen_, &facet=g->facet_, &facec=g->facec_;
g->eindex_.clear();
int facesize=facep.size();
for (int i=0; i<facesize; i++) {
Vector<PN,zuint> index;
for (int j=0; j<PN; j++) {
elementpoint p(0);
p[0]=facep[i][j];
if (thisdonor) p[1]=facen[i][j];
if (thisdotex) p[2]=facet[i][j];
if (thisdocolor) p[3]=facec[i][j];
map<elementpoint,zuint>::const_iterator mi=elementpointmap.find(p);
if (mi==elementpointmap.end()) {
epos_.push_back(pos_[facep[i][j]]);
if (thisdonor) enor_.push_back(nor_[facen[i][j]]);
else if (donor) enor_.push_back(Vector3f(0));
if (thisdotex) etex_.push_back(tex_[facet[i][j]]);
else if (dotex) etex_.push_back(Vector3f(0));
if (thisdocolor) ecolor_.push_back(color_[facec[i][j]]);
else if (docolor) ecolor_.push_back(Vector3f(0));
index[j]=epos_.size()-1;
elementpointmap[p]=index[j];
} else {
index[j]=mi->second;
}
}
g->eindex_.push_back(index);
}
if (GLExists())
g->VBOeIndex_.Create(g->eindex_[0].Data(),(int)g->eindex_.size(),VBODescript::Element3ui);
}
//Create Element VBO
ClrFlag(MESH_EVBOALL);
if (GLExists()) {
SetFlag(MESH_EVBOPOS);
VBOePos_.Create(epos_[0].Data(),(int)epos_.size(),VBODescript::Vertex3f);
if (donor) {
SetFlag(MESH_EVBONOR);
VBOeNor_.Create(enor_[0].Data(),(int)enor_.size(),VBODescript::Normalf);
}
if (dotex) {
SetFlag(MESH_EVBOTEX);
VBOeTex_.Create(etex_[0].Data(),(int)etex_.size(),VBODescript::TexCoord3f);
}
if (docolor) {
SetFlag(MESH_EVBOCOLOR);
VBOeColor_.Create(ecolor_[0].Data(),(int)ecolor_.size(),VBODescript::Color3f);
}
}
return true;
}
bool DrawElement(int bt=MESH_ALL) {
if (HasNoFlag(MESH_EVBOPOS)) {
if (!CreateElement(bt))
return false;
}
for (zuint i=0; i<groups_.size(); i++)
if (!DrawElement(i,bt)) return false;
return true;
}
bool DrawElement(int idx, int bt) {
if (HasNoFlag(MESH_EVBOPOS)) return false;
if (HasNoFlag(MESH_EVBONOR)) ClrFlag(MESH_NOR);
if (HasNoFlag(MESH_EVBOTEX)) ClrFlag(MESH_TEX);
if (HasNoFlag(MESH_EVBOCOLOR)) ClrFlag(MESH_COLOR);
if (BindElement(idx,bt)==false) return false;
switch(PN) {
case 0:
case 1:
case 2:
default: return false;
case 3: glDrawElements(GL_TRIANGLES,(int)groups_[idx]->eindex_.size()*3,GL_UNSIGNED_INT,0); break;
case 4: glDrawElements(GL_QUADS,(int)groups_[idx]->eindex_.size()*4,GL_UNSIGNED_INT,0); break;
}
UnbindElement(idx);
return true;
}
bool DrawElement(const string &name, int bt) {
if (HasNoFlag(MESH_EVBOPOS)) return false;
for (zuint i=0; i<groups_.size(); i++)
if (groups_[i]->name_==name) return DrawElement(i,bt);
return false;
}
private:
//normal VBO manipulation
bool CreateVBO(int idx, int bt) {
MeshGroup *g=groups_[idx];
bool donor=CheckBit(bt,MESH_NOR) && g->HasFlag(MESH_NOR);
bool dotex=CheckBit(bt,MESH_TEX) && g->HasFlag(MESH_TEX);
bool docolor=CheckBit(bt,MESH_COLOR) && g->HasFlag(MESH_COLOR);
STLVector<Vector<PN,int> > &facep=g->facep_, &facen=g->facen_, &facet=g->facet_, &facec=g->facec_;
int nVert=(int)facep.size()*PN;
Vector3f *buffer=new Vector3f[nVert];
{
int size=facep.size(), cur=0;
for (int j=0; j<size; j++) for (int k=0; k<PN; k++)
buffer[cur++]=pos_[facep[j][k]];
g->VBOPos_.Create(buffer,nVert,VBODescript::Vertex3f);
g->SetFlag(MESH_VBOPOS);
}
if (donor) {
int size=facen.size(), cur=0;
for (int j=0; j<size; j++) for (int k=0; k<PN; k++)
buffer[cur++]=nor_[facen[j][k]];
g->VBONor_.Create(buffer,nVert,VBODescript::Normalf);
g->SetFlag(MESH_VBONOR);
}
if (dotex) {
int size=facet.size(), cur=0;
for (int j=0; j<size; j++) for (int k=0; k<PN; k++)
buffer[cur++]=tex_[facet[j][k]];
g->VBOTex_.Create(buffer,nVert,VBODescript::TexCoord3f);
g->SetFlag(MESH_VBOTEX);
}
if (docolor) {
int size=facep.size(), cur=0;
for (int j=0; j<size; j++) for (int k=0; k<PN; k++)
buffer[cur++]=color_[facec[j][k]];
g->VBOColor_.Create(buffer,nVert,VBODescript::Color3f);
g->SetFlag(MESH_VBOCOLOR);
}
delete[] buffer;
return true;
}
bool BindVBO(int idx, int bt) {
// It's not MESH_VBOPOS, since BT always accept MESH_POS
if (CheckBit(bt, MESH_POS)) groups_[idx]->VBOPos_.Bind();
if (CheckBit(bt, MESH_NOR)) groups_[idx]->VBONor_.Bind();
if (CheckBit(bt, MESH_TEX)) groups_[idx]->VBOTex_.Bind();
if (CheckBit(bt, MESH_COLOR)) groups_[idx]->VBOColor_.Bind();
return true;
}
bool UnbindVBO(int idx) {
groups_[idx]->VBOPos_.Unbind();
groups_[idx]->VBONor_.Unbind();
groups_[idx]->VBOTex_.Unbind();
groups_[idx]->VBOColor_.Unbind();
return true;
}
//element manipulation
bool BindElement(int idx, int bt) {
// It's not MESH_VBOPOS, since BT always accept MESH_POS
if (CheckBit(bt, MESH_POS)) VBOePos_.Bind();
if (CheckBit(bt, MESH_NOR)) VBOeNor_.Bind();
if (CheckBit(bt, MESH_TEX)) VBOeTex_.Bind();
if (CheckBit(bt, MESH_COLOR)) VBOeColor_.Bind();
groups_[idx]->VBOeIndex_.Bind();
return true;
}
bool UnbindElement(int idx) {
VBOePos_.Unbind();
VBOeNor_.Unbind();
VBOeTex_.Unbind();
VBOeColor_.Unbind();
groups_[idx]->VBOeIndex_.Unbind();
return true;
}
};
typedef Mesh<3> TriMesh;
typedef Mesh<4> QuadMesh;
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/Mesh.hpp
|
C++
|
gpl3
| 20,463
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "../SimpleMesh.hpp"
#include "../Mesh.hpp"
namespace zzz{
class ZGRAPHICS_CLASS WrlIO {
public:
static bool Load(const string &filename, TriMesh &mesh,bool load_mat=true);
static bool Save(const string &filename, TriMesh &mesh,bool save_mat=true);
static bool Load(const string &filename, SimpleMesh &mesh,bool load_mat=true);
static bool Save(const string &filename, SimpleMesh &mesh,bool save_mat=true);
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/MeshIO/WrlIO.hpp
|
C++
|
gpl3
| 489
|
#include "WrlIO.hpp"
#include <common.hpp>
#include "../Material.hpp"
#include <Utility/StringPrintf.hpp>
#include <Utility/FileTools.hpp>
#include <Utility/BraceFile.hpp>
#undef RGB
namespace zzz{
bool WrlIO::Load(const string &filename, TriMesh &mesh,bool load_mat)
{
BraceFile bf;
if (!bf.LoadFile(filename)) return false;
mesh.Clear();
// Actually I don't know what it should be according specification.
// However this code can deal with some case
// The second case is for the file generated by Peng Zhao
BraceNode objNode=bf.GetFirstNode("Transform");
if (!objNode.IsValid())
objNode=bf.GetFirstNode("Group");
BraceNode childrenNode=objNode.GetFirstNode("children");
for (zuint g=0; g<childrenNode.NodeNumber(); g++) {
BraceNode shapeNode=childrenNode.GetNode(g);
mesh.groups_.push_back(new TriMesh::MeshGroup());
TriMesh::MeshGroup *group=mesh.groups_.back();
BraceNode appearanceNode=shapeNode.GetFirstNodeInclude("appearance");
// material exist
if (appearanceNode.IsValid()) {
// create material
Material *mat=new Material;
string matName=GetBase(GetFilename(filename))+"_Material";
matName<<g;
group->matname_=matName;
ZRM->Add(mat,matName);
BraceNode materialNode=appearanceNode.GetFirstNodeInclude("material");
if (materialNode.IsValid()) {
for (zuint i=0; i<materialNode.NodeNumber(); i++) {
istringstream iss(materialNode.GetNode(i).GetText());
string colorname;
iss>>colorname;
if (colorname=="diffuseColor") {
iss>>mat->diffuse_.RGB();
mat->SetFlag(MAT_DIF);
} else if (colorname=="emissiveColor") {
iss>>mat->emission_.RGB();
mat->SetFlag(MAT_EMI);
} else if (colorname=="specularColor") {
iss>>mat->specular_.RGB();
mat->SetFlag(MAT_SPE);
} else if (colorname=="shininess") {
iss>>mat->shininess_;
}
}
}
BraceNode textureNode=appearanceNode.GetFirstNodeInclude("texture");
if (load_mat && textureNode.IsValid()) {
istringstream iss(textureNode.GetFirstNodeInclude("url").GetText());
string storefilename;
iss>>storefilename>>storefilename;
if (storefilename[0]=='\"') storefilename.assign(storefilename.begin()+1,storefilename.end()-1);
storefilename=PathFile(GetPath(filename),storefilename);
if (GLExists()) {
mat->ambientTex_.FileToTexture<Vector3uc>(storefilename.c_str());
mat->SetFlag(MAT_AMBTEX);
} else {
mat->ambientTexName_=storefilename;
}
}
}
//position and texture coordinate
BraceNode geometryNode=shapeNode.GetFirstNodeInclude("geometry");
Vector3f v;
Vector3i vi;
string data;
BraceNode coordPointNode=geometryNode.GetFirstNodeInclude("coord").GetFirstNode("point");
int coordBase=mesh.pos_.size();
coordPointNode.GetChildrenText(data);
{
istringstream iss(data);
while(true) {
iss>>v;
if (iss.fail()) break;
mesh.pos_.push_back(v);
}
}
BraceNode coordIndexNode=geometryNode.GetFirstNode("coordIndex");
coordIndexNode.GetChildrenText(data);
{
istringstream iss(data);
while(true) {
//support triangle only
iss>>vi;
if (iss.fail()) break;
vi+=coordBase;
group->facep_.push_back(vi);
iss>>vi[0]; //eat -1
}
}
BraceNode texPointNode=geometryNode.GetFirstNodeInclude("texCoord").GetFirstNode("point");
if (!texPointNode.IsValid()) continue;
int texCoordBase=mesh.tex_.size();
texPointNode.GetChildrenText(data);
{
istringstream iss(data);
v[2]=0;
while(true) {
iss>>v[0]>>v[1];
if (iss.fail()) break;
mesh.tex_.push_back(v);
}
}
BraceNode texCoordIndexNode=geometryNode.GetFirstNode("texCoordIndex");
if (!texCoordIndexNode.IsValid()) continue;
coordIndexNode.GetChildrenText(data);
{
istringstream iss(data);
while(true) {
//support triangle only
iss>>vi;
if (iss.fail()) break;
vi+=texCoordBase;
group->facet_.push_back(vi);
iss>>vi[0]; //eat -1
}
}
}
return true;
}
bool WrlIO::Save(const string &filename, TriMesh &mesh, bool save_mat)
{
BraceFile bf;
bf.AppendNode("#VRML V2.0 utf8");
BraceNode objNode=bf.AppendNode("DEF object0 Transform",'{','}');
BraceNode childrenNode=objNode.AppendNode("children",'[',']');
for (zuint g=0; g<mesh.groups_.size(); g++)
{
BraceNode shapeNode=childrenNode.AppendNode("Shape",'{','}');
if (save_mat && !mesh.groups_[g]->matname_.empty())
{
Material *mat=ZRM->Get<Material*>(mesh.groups_[g]->matname_);
BraceNode appearanceNode=shapeNode.AppendNode("appearance Appearance", '{', '}');
if (mat->HasFlag(MAT_DIF) || mat->HasFlag(MAT_SPE) || mat->HasFlag(MAT_EMI))
{
BraceNode materialNode=appearanceNode.AppendNode("material Material", '{', '}');
if (mat->HasFlag(MAT_DIF))
materialNode.AppendNode(string("diffuseColor ")<<mat->diffuse_.RGB());
if (mat->HasFlag(MAT_EMI))
materialNode.AppendNode(string("emissiveColor ")<<mat->emission_.RGB());
if (mat->HasFlag(MAT_SPE)) {
materialNode.AppendNode(string("specularColor ")<<mat->specular_.RGB());
materialNode.AppendNode(string("shininess ")<<mat->shininess_);
}
}
// VRML only support diffuse texture
if (mat->HasFlag(MAT_DIFTEX)) {
string storefilename=GetBase(filename);
storefilename<<'_'<<mesh.groups_[g]->matname_<<"_dif.png";
BraceNode textureNode=appearanceNode.AppendNode("texture ImageTexture", '{', '}');
textureNode.AppendNode(StringPrintf("url \"%s\"",storefilename.c_str()));
appearanceNode.AppendNode("textureTransform TextureTransform", '{', '}')<<"translation 0 0"<<"scale 1 1";
storefilename=PathFile(GetPath(filename),storefilename);
Image4uc img;
mat->diffuseTex_.TextureToImage(img);
ZLOG(ZDEBUG)<<"Saved texture: "<<storefilename<<" size: "<<img.Cols()<<'x'<<img.Rows()<<endl;
img.SaveFile(storefilename.c_str());
} else if (!mat->diffuseTexName_.empty()) {
BraceNode textureNode=appearanceNode.AppendNode("texture ImageTexture", '{', '}');
textureNode.AppendNode(string("url \"")+mat->diffuseTexName_+"\"");
appearanceNode.AppendNode("textureTransform TextureTransform", '{', '}')<<"translation 0 0"<<"scale 1 1";
}
}
//position and texture coordinate
vector<Vector3f*> pos;
vector<Vector3f*> tex;
vector<Vector3ui> posi;
vector<Vector3ui> texi;
map<zuint,zuint> old_new;
for (zuint i=0; i<mesh.groups_[g]->facep_.size(); i++) {
Vector3ui pi;
for (zuint j=0; j<3; j++) {
zuint old=mesh.groups_[g]->facep_[i][j];
map<zuint,zuint>::iterator mi=old_new.find(old);
// new
if (mi==old_new.end()) {
pi[j]=pos.size();
old_new[old]=pos.size();
pos.push_back(&(mesh.pos_[old]));
} else
pi[j]=mi->second;
}
posi.push_back(pi);
}
old_new.clear();
for (zuint i=0; i<mesh.groups_[g]->facet_.size(); i++) {
Vector3ui ti;
for (zuint j=0; j<3; j++) {
zuint old=mesh.groups_[g]->facet_[i][j];
map<zuint,zuint>::iterator mi=old_new.find(old);
// new
if (mi==old_new.end()) {
ti[j]=tex.size();
old_new[old]=tex.size();
tex.push_back(&(mesh.tex_[old]));
} else
ti[j]=mi->second;
}
texi.push_back(ti);
}
BraceNode geometryNode=shapeNode.AppendNode("geometry IndexedFaceSet", '{', '}');
BraceNode coordPointNode=geometryNode.AppendNode("coord Coordinate", '{', '}').AppendNode("point", '[', ']');
for (zuint i=0; i<pos.size(); i++) {
string line;
line<<*(pos[i]);
coordPointNode.AppendNode(line.c_str());
}
BraceNode texPoint=geometryNode.AppendNode("texCoord TextureCoordinate",'{','}').AppendNode("point",'[',']');
for (zuint i=0; i<tex.size(); i++) {
string line;
line<<tex[i]->at(0)<<' '<<tex[i]->at(1);
texPoint.AppendNode(line.c_str());
}
BraceNode coordIndexNode=geometryNode.AppendNode("coordIndex",'[',']');
for (zuint i=0; i<posi.size(); i++) {
string line;
line<<posi[i]<<" -1";
coordIndexNode.AppendNode(line.c_str());
}
BraceNode texCoordIndexNode=geometryNode.AppendNode("texCoordIndex",'[',']');
for (zuint i=0; i<texi.size(); i++) {
string line;
line<<texi[i]<<" -1";
texCoordIndexNode.AppendNode(line.c_str());
}
}
return bf.SaveFile(filename);
}
//bool WrlIO::Load(const string &filename, SimpleMesh &mesh);
//bool WrlIO::Save(const string &filename, SimpleMesh &mesh);
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/MeshIO/WrlIO.cpp
|
C++
|
gpl3
| 9,249
|
#pragma once
#include <Utility/IOObject.hpp>
#include "../Mesh.hpp"
#include "../Material.hpp"
namespace zzz {
template<zuint PN>
class IOObject<Mesh<PN> >
{
public:
static const zint32 RF_POS = 1;
static const zint32 RF_NOR = 2;
static const zint32 RF_TEX = 3;
static const zint32 RF_COLOR = 4;
static const zint32 RF_GROUP = 5;
static const zint32 RF_GROUP_FACEP = 1;
static const zint32 RF_GROUP_FACEN = 2;
static const zint32 RF_GROUP_FACET = 3;
static const zint32 RF_GROUP_FACEC = 4;
static const zint32 RF_GROUP_NAME = 5;
static const zint32 RF_GROUP_MATNAME = 6;
static const zint32 RF_GROUP_MATERIAL = 7;
static void WriteFileR(RecordFile &rf, const zint32 label, const Mesh<PN> &src)
{
rf.WriteChildBegin(label);
IOObj::WriteFileR(rf, RF_POS, src.pos_);
IOObj::WriteFileR(rf, RF_NOR, src.nor_);
IOObj::WriteFileR(rf, RF_TEX, src.tex_);
IOObj::WriteFileR(rf, RF_COLOR, src.color_);
rf.WriteRepeatBegin(RF_GROUP);
for (zuint i=0; i<src.groups_.size(); i++) {
rf.WriteRepeatChild();
IOObj::WriteFileR(rf, RF_GROUP_FACEP, src.groups_[i]->facep_);
IOObj::WriteFileR(rf, RF_GROUP_FACEN, src.groups_[i]->facen_);
IOObj::WriteFileR(rf, RF_GROUP_FACET, src.groups_[i]->facet_);
IOObj::WriteFileR(rf, RF_GROUP_FACEC, src.groups_[i]->facec_);
IOObj::WriteFileR(rf, RF_GROUP_NAME, src.groups_[i]->name_);
IOObj::WriteFileR(rf, RF_GROUP_MATNAME, src.groups_[i]->matname_);
if (!src.groups_[i]->matname_.empty()) {
IOObj::WriteFileR(rf, RF_GROUP_MATERIAL, *(ZRM->Get<Material*>(src.groups_[i]->matname_)));
}
}
rf.WriteRepeatEnd();
rf.WriteChildEnd();
}
static void ReadFileR(RecordFile &rf, const zint32 label, Mesh<PN> &dst)
{
dst.Clear();
rf.ReadChildBegin(label);
IOObj::ReadFileR(rf, RF_POS, dst.pos_);
IOObj::ReadFileR(rf, RF_NOR, dst.nor_);
IOObj::ReadFileR(rf, RF_TEX, dst.tex_);
IOObj::ReadFileR(rf, RF_COLOR, dst.color_);
rf.ReadRepeatBegin(RF_GROUP);
while(rf.ReadRepeatChild()) {
Mesh<PN>::MeshGroup *group = new Mesh<PN>::MeshGroup();
dst.groups_.push_back(group);
IOObj::ReadFileR(rf, RF_GROUP_FACEP, group->facep_);
IOObj::ReadFileR(rf, RF_GROUP_FACEN, group->facen_);
IOObj::ReadFileR(rf, RF_GROUP_FACET, group->facet_);
IOObj::ReadFileR(rf, RF_GROUP_FACEC, group->facec_);
IOObj::ReadFileR(rf, RF_GROUP_NAME, group->name_);
IOObj::ReadFileR(rf, RF_GROUP_MATNAME, group->matname_);
if (!group->matname_.empty()) {
Material *mat = new Material();
IOObj::ReadFileR(rf, RF_GROUP_MATERIAL, *mat);
ZRM->Add(mat, group->matname_);
}
}
rf.ReadRepeatEnd();
rf.ReadChildEnd();
dst.SetDataFlags();
}
};
}; // namespace zzz
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/MeshIO/IOObjectMesh.hpp
|
C++
|
gpl3
| 3,002
|
#include "Ply2IO.hpp"
#include <common.hpp>
namespace zzz{
bool Ply2IO::Load(const string &filename, TriMesh &mesh, bool load_mat)
{
ifstream fi(filename);
if (!fi.good()) return false;
int posn,facen;
fi>>posn>>facen;
if (fi.fail()) return false;
mesh.Clear();
Vector3f p;
for (int i=0; i<posn; i++)
{
fi>>p;
if (fi.fail()) return false;
mesh.pos_.push_back(p);
}
mesh.SetFlag(MESH_POS);
mesh.groups_.push_back(new TriMesh::MeshGroup);
TriMesh::MeshGroup *g=mesh.groups_.back();
int x;
Vector3i f;
for (int i=0; i<facen; i++)
{
fi>>x>>f;
if (x!=3 || fi.fail()) return false;
g->facep_.push_back(f);
}
g->SetFlag(MESH_POS);
fi.close();
return true;
}
bool Ply2IO::Save(const string &filename, TriMesh &mesh, bool save_mat)
{
ofstream fo(filename);
if (!fo.good()) return false;
fo<<mesh.pos_.size()<<endl;
int facen=0;
for (zuint i=0; i<mesh.groups_.size(); i++) facen+=mesh.groups_[i]->facep_.size();
fo<<facen<<endl;
for (zuint i=0; i<mesh.pos_.size(); i++)
{
fo<<mesh.pos_[i]<<endl;
}
for (zuint g=0; g<mesh.groups_.size(); g++)
{
for (zuint i=0; i<mesh.groups_[g]->facep_.size(); i++)
fo<<"3 "<<mesh.groups_[g]->facep_[i]<<endl;
}
fo.close();
return true;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/MeshIO/Ply2IO.cpp
|
C++
|
gpl3
| 1,336
|
#include "DaeIO.hpp"
#include <Xml/RapidXML.hpp>
#include <Utility/FileTools.hpp>
#include "../Material.hpp"
#include "../../ResourceManager.hpp"
#include "../../../Context/Context.hpp"
#include "../../../Graphics/GeometryHelper.hpp"
namespace zzz{
bool DaeIO::load_mat_=true;
bool DaeIO::save_mat_=true;
string DaeIO::dae_path_;
string DaeIO::ToId(const string &str)
{
if (str[0]=='#') return string(str.begin()+1,str.end());
return str;
}
string DaeIO::ToSource(const string &str)
{
if (str[0]=='#') return str;
string ret="#";
return ret + str;
}
RapidXMLNode DaeIO::FindNodeById(RapidXMLNode &father, const string &name, string &id)
{
string myid = ToId(id);
for (RapidXMLNode node=father.GetFirstNode();node.IsValid();node=node.GetNextSibling()) {
if (name == node.GetName() && myid == node.GetAttribute("id")) return node;
}
return RapidXMLNode(NULL, NULL);
}
const int SEM_VERTEX=0;
const int SEM_TEXCOORD=1;
const int SEM_NORMAL=2;
const int SEM_COLOR=3;
string dae_path;
void DaeIO::ReadMaterial(TriMesh &mesh, DaeData &dae, string &url)
{
RapidXMLNode matNode=FindNodeById(dae.libMaterialsNode,"material",url);
string effUrl=matNode.GetFirstNode().GetAttribute("url");
RapidXMLNode effNode(FindNodeById(dae.libEffectsNode,"effect",effUrl));
RapidXMLNode phongNode=effNode.GetFirstNode().GetFirstNode().GetFirstNode();
Material *mat=new Material;
if (phongNode.HasNode("emission")) {
RapidXMLNode node=phongNode.GetNode("emission").GetFirstNode();
if (strcmp(node.GetName(),"color")==0) {
string data=node.GetText();
istringstream iss(data);
iss>>mat->emission_;
mat->SetFlag(MAT_EMI);
}
}
if (phongNode.HasNode("ambient")) {
RapidXMLNode node=phongNode.GetNode("ambient").GetFirstNode();
if (strcmp(node.GetName(),"color")==0) {
string data=node.GetText();
istringstream iss(data);
iss>>mat->ambient_;
mat->SetFlag(MAT_AMB);
} else if (strcmp(node.GetName(),"texture")==0) {
//read texture
string tex_id=node.GetAttribute("texture");
string filename=FindNodeById(dae.libImagesNode,"image",tex_id).GetFirstNode().GetText();
filename=PathFile(dae_path,filename);
if (GLExists()) {
Image3uc img(filename.c_str());
mat->ambientTex_.ImageToTexture(img);
mat->SetFlag(MAT_AMBTEX);
} else {
mat->ambientTexName_=filename;
}
}
}
ZRM->Add(mat,url);
}
void DaeIO::ReadGeometry(TriMesh &mesh, DaeData &dae, string &url)
{
RapidXMLNode geoNode(FindNodeById(dae.libGeometriesNode,"geometry",url));
RapidXMLNode meshNode=geoNode.GetNode("mesh");
map<string,int> bases; //input base number
for (RapidXMLNode triNode=meshNode.GetFirstNode("triangles");triNode.IsValid();triNode.GotoNextSibling("triangles")) {
int inputn=0; //input number
int inputt[10]; //input type
int inputb[10];
//load source and set offsets
for (zuint i=0; i<triNode.NodeNumber(); i++) {
RapidXMLNode node=triNode.GetNode(i);
if (strcmp(node.GetName(),"input")!=0) continue;
int offset=FromString<int>(node.GetAttribute("offset"));
if (offset>=inputn) inputn=offset+1;
string semantic=node.GetAttribute("semantic");
//set offsets
int base;
if (semantic=="VERTEX") {
inputt[offset]=SEM_VERTEX;
base=mesh.pos_.size();
} else if (semantic=="NORMAL") {
inputt[offset]=SEM_NORMAL;
base=mesh.nor_.size();
} else if (semantic=="TEXCOORD") {
inputt[offset]=SEM_TEXCOORD;
base=mesh.tex_.size();
} else if (semantic=="COLOR") {
inputt[offset]=SEM_COLOR;
base=mesh.color_.size();
} else {
ZLOGF<<"Unknown semantic: "<<semantic<<endl;
continue;
}
//load source
string source=node.GetAttribute("source");
if (bases.find(ToId(source))!=bases.end()) { //already loaded
inputb[offset]=bases[ToId(source)];
continue;
}
bases[ToId(source)]=base;
inputb[offset]=base;
if (inputt[offset]==SEM_VERTEX) {
RapidXMLNode vertexNode=FindNodeById(meshNode,"vertices",source);
string possource=vertexNode.GetFirstNode().GetAttribute("source");
RapidXMLNode sourceNode=FindNodeById(meshNode,"source",possource);
RapidXMLNode arrayNode=sourceNode.GetNode("float_array");
int arrayn=FromString<int>(arrayNode.GetAttribute("count"))/3;
string data=arrayNode.GetText();
istringstream iss(data);
Vector3f v;
for (int j=0; j<arrayn; j++) {
iss>>v;
if (iss.fail()) {
ZLOGE<<"Error in DaeIO::Load. \"count\" in <float_array> of "<<possource<<" does not match the actual data size."<<endl;
break;
}
mesh.pos_.push_back(v);
}
} else if (inputt[offset]==SEM_NORMAL) {
RapidXMLNode sourceNode=FindNodeById(meshNode,"source",source);
RapidXMLNode arrayNode=sourceNode.GetNode("float_array");
int arrayn=FromString<int>(arrayNode.GetAttribute("count"))/3;
string data=arrayNode.GetText();
istringstream iss(data);
Vector3f v;
for (int j=0; j<arrayn; j++) {
iss>>v;
if (iss.fail()) {
ZLOGE<<"Error in DaeIO::Load. \"count\" in <float_array> of "<<source<<" does not match the actual data size."<<endl;
break;
}
mesh.nor_.push_back(v);
}
} else if (inputt[offset]==SEM_TEXCOORD) {
RapidXMLNode sourceNode=FindNodeById(meshNode,"source",source);
RapidXMLNode arrayNode=sourceNode.GetNode("float_array");
int arrayn=FromString<int>(arrayNode.GetAttribute("count"))/2;
string data=arrayNode.GetText();
istringstream iss(data);
Vector3f v(0);
for (int j=0; j<arrayn; j++) {
iss>>v[0]>>v[1];
if (iss.fail()) {
ZLOGE<<"Error in DaeIO::Load. \"count\" in <float_array> of "<<source<<" does not match the actual data size."<<endl;
break;
}
mesh.tex_.push_back(v);
}
} else if (inputt[offset]==SEM_COLOR) {
RapidXMLNode sourceNode=FindNodeById(meshNode,"source",source);
RapidXMLNode arrayNode=sourceNode.GetNode("float_array");
int arrayn=FromString<int>(arrayNode.GetAttribute("count"))/3;
string data=arrayNode.GetText();
istringstream iss(data);
Vector3f v;
for (int j=0; j<arrayn; j++) {
iss>>v;
if (iss.fail()) {
ZLOGE<<"Error in DaeIO::Load. \"count\" in <float_array> of "<<source<<" does not match the actual data size."<<endl;
break;
}
mesh.color_.push_back(v);
}
}
}
int trin=FromString<int>(triNode.GetAttribute("count"));
string data=triNode.GetNode("p").GetText();
istringstream iss(data);
mesh.groups_.push_back(new TriMesh::MeshGroup());
TriMesh::MeshGroup *group=mesh.groups_.back();
int v;
for (int i=0; i<trin; i++) {
Vector3i facep,facet,facen,facec;
for (int k=0; k<3; k++) {
for (int j=0; j<inputn; j++) {
iss>>v;
if (iss.fail()) {
ZLOGE<<"Error in DaeIO::Load. \"count\" in <triangles> does not match the actual data size.\n";
goto BREAK_OUTSIDE;
}
if (inputt[j]==SEM_VERTEX) facep[k]=v+inputb[j];
else if (inputt[j]==SEM_NORMAL) facen[k]=v+inputb[j];
else if (inputt[j]==SEM_TEXCOORD) facet[k]=v+inputb[j];
else if (inputt[j]==SEM_COLOR) facec[k]=v+inputb[j];
}
}
for (int j=0; j<inputn; j++) {
if (inputt[j]==SEM_VERTEX) group->facep_.push_back(facep);
else if (inputt[j]==SEM_NORMAL) group->facen_.push_back(facen);
else if (inputt[j]==SEM_TEXCOORD) group->facet_.push_back(facet);
else if (inputt[j]==SEM_COLOR) group->facec_.push_back(facec);
}
}
BREAK_OUTSIDE:
if (load_mat_ && triNode.HasAttribute("material")) {
string matname=triNode.GetAttribute("material");
ReadMaterial(mesh,dae,matname);
group->matname_=matname;
}
}
}
void DaeIO::ReadVisual(TriMesh &mesh, DaeData &dae, string &url)
{
RapidXMLNode sceneNode=FindNodeById(dae.libVisualsNode,"visual_scene",url);
for (zuint modeli=0;modeli<sceneNode.NodeNumber();modeli++)
{
RapidXMLNode modelNode=sceneNode.GetNode(modeli);
string geometryUrl=modelNode.GetNode("instance_geometry").GetAttribute("url");
ReadGeometry(mesh,dae,geometryUrl);
}
}
bool DaeIO::Load(const string &filename, TriMesh &mesh, bool loadtex)
{
load_mat_ = loadtex;
RapidXML xml;
if (!xml.LoadFile(filename)) return false;
RapidXMLNode head=xml.GetNode("COLLADA");
dae_path=GetPath(filename);
mesh.Clear();
DaeData dae(head.GetNode("library_images"),
head.GetNode("library_materials"),
head.GetNode("library_effects"),
head.GetNode("library_geometries"),
head.GetNode("library_visual_scenes"));
RapidXMLNode sceneNode=head.GetNode("scene");
string visualUrl=sceneNode.GetNode("instance_visual_scene").GetAttribute("url");
ReadVisual(mesh,dae,visualUrl);
mesh.AABB_.Reset();
mesh.AABB_+=mesh.pos_;
mesh.SetDataFlags();
return true;
}
/////////////////////////////////////////////////////////////////////
void DaeIO::WriteMaterial(TriMesh &mesh, DaeData &dae, string &url)
{
//material
if (FindNodeById(dae.libMaterialsNode,"material",url).IsValid()) return;
RapidXMLNode matNode=dae.libMaterialsNode.AppendNode("material");
matNode.SetAttribute("id",url);
matNode.SetAttribute("name",url);
string effUrl=url+"-effect";
matNode.AppendNode("instance_effect")<<make_pair("url",ToSource(effUrl));
//effect
RapidXMLNode effNode=dae.libEffectsNode.AppendNode("effect");
effNode.SetAttribute("id",ToId(effUrl));
effNode.SetAttribute("name",ToId(effUrl));
RapidXMLNode techNode=effNode.AppendNode("profile_COMMON").AppendNode("technique");
techNode.SetAttribute("sid","COMMON");
RapidXMLNode phongNode=techNode.AppendNode("phong");
Material *mat=ZRM->Get<Material*>(url);
if (mat->HasFlag(MAT_EMI))
phongNode.AppendNode("emission").AppendNode("color")<<ToString(mat->emission_);
if (mat->HasFlag(MAT_DIF))
phongNode.AppendNode("emission").AppendNode("color")<<ToString(mat->diffuse_);
if (mat->HasFlag(MAT_AMB))
phongNode.AppendNode("emission").AppendNode("color")<<ToString(mat->ambient_);
if (mat->HasFlag(MAT_SPE))
phongNode.AppendNode("emission").AppendNode("color")<<ToString(mat->specular_);
if (mat->HasFlag(MAT_AMBTEX) || !mat->ambientTexName_.empty())
{
string imgid=ToId(url)+"-ambimg";
phongNode.AppendNode("ambient").AppendNode("texture")<<make_pair("texture",ToId(imgid));
RapidXMLNode imgNode=dae.libImagesNode.AppendNode("image");
imgNode.SetAttribute("id",ToId(imgid));
imgNode.SetAttribute("name",ToId(imgid));
if (mat->ambientTexName_.empty())
{
mat->ambientTex_.TextureToFile<Vector3uc>((imgid+".png").c_str());
imgNode.AppendNode("init_from")<<imgid+".png";
}
else
imgNode.AppendNode("init_from")<<mat->ambientTexName_;
}
if (mat->HasFlag(MAT_DIFTEX) || !mat->diffuseTexName_.empty())
{
string imgid=ToId(url)+"-difimg";
phongNode.AppendNode("diffuse").AppendNode("texture")<<make_pair("texture",ToId(imgid));
RapidXMLNode imgNode=dae.libImagesNode.AppendNode("image");
imgNode.SetAttribute("id",ToId(imgid));
imgNode.SetAttribute("name",ToId(imgid));
if (mat->diffuseTexName_.empty())
{
mat->diffuseTex_.TextureToFile<Vector3uc>((imgid+".png").c_str());
imgNode.AppendNode("init_from")<<imgid+".png";
}
else
imgNode.AppendNode("init_from")<<mat->diffuseTexName_;
}
}
void DaeIO::WriteGeometry(TriMesh &mesh, DaeData &dae, string &url)
{
RapidXMLNode geoNode=dae.libGeometriesNode.AppendNode("geometry");
geoNode.SetAttribute("id",ToId(url));
geoNode.SetAttribute("name",ToId(url));
RapidXMLNode meshNode=geoNode.AppendNode("mesh");
//for now, only output position and texcoord
//since i don't have a file to demonstrate how normal is stored
//1 output position
string verid="mesh-geometry-vertex";
{
RapidXMLNode vertexNode=meshNode.AppendNode("vertices");
vertexNode.SetAttribute("id",ToId(verid));
string sourceid="mesh-geometry-position";
vertexNode.AppendNode("input")<<make_pair("semantic","POSITION")<<make_pair("source",ToSource(sourceid));
RapidXMLNode sourceNode=meshNode.AppendNode("source");
sourceNode.SetAttribute("id",ToId(sourceid));
RapidXMLNode arrayNode=sourceNode.AppendNode("float_array");
arrayNode.SetAttribute("id",ToId(sourceid)+"-array");
arrayNode.SetAttribute("count",mesh.pos_.size()*3);
ostringstream oss;
for (zuint j=0; j<mesh.pos_.size(); j++)
oss<<mesh.pos_[j];
arrayNode<<oss.str();
RapidXMLNode accNode=sourceNode.AppendNode("technique_common").AppendNode("accessor");
accNode.SetAttribute("source",ToSource(sourceid+"-array"));
accNode.SetAttribute("count",mesh.pos_.size());
accNode.SetAttribute("stride","3");
accNode.AppendNode("param")<<make_pair("name","X")<<make_pair("type","float");
accNode.AppendNode("param")<<make_pair("name","Y")<<make_pair("type","float");
accNode.AppendNode("param")<<make_pair("name","Z")<<make_pair("type","float");
}
//2 output uv
string uvsourceid="mesh-geometry-uv";
if (!mesh.tex_.empty())
{
RapidXMLNode sourceNode=meshNode.AppendNode("source");
sourceNode.SetAttribute("id",ToId(uvsourceid));
RapidXMLNode arrayNode=sourceNode.AppendNode("float_array");
arrayNode.SetAttribute("id",ToId(uvsourceid)+"-array");
arrayNode.SetAttribute("count",mesh.tex_.size()*2);
ostringstream oss;
for (zuint j=0; j<mesh.tex_.size(); j++)
oss<<mesh.tex_[j][0]<<' '<<mesh.tex_[j][1]<<' ';
arrayNode<<oss.str();
RapidXMLNode accNode=sourceNode.AppendNode("technique_common").AppendNode("accessor");
accNode.SetAttribute("source",ToSource(ToId(uvsourceid)+"-array"));
accNode.SetAttribute("count",mesh.tex_.size());
accNode.SetAttribute("stride","2");
accNode.AppendNode("param")<<make_pair("name","S")<<make_pair("type","float");
accNode.AppendNode("param")<<make_pair("name","T")<<make_pair("type","float");
}
//3 output normal
string norsourceid="mesh-geometry-normal";
if (!mesh.nor_.empty())
{
RapidXMLNode sourceNode=meshNode.AppendNode("source");
sourceNode.SetAttribute("id",ToId(norsourceid));
RapidXMLNode arrayNode=sourceNode.AppendNode("float_array");
arrayNode.SetAttribute("id",ToId(norsourceid)+"-array");
arrayNode.SetAttribute("count",mesh.nor_.size()*3);
ostringstream oss;
for (zuint j=0; j<mesh.nor_.size(); j++)
oss<<mesh.nor_[j];
arrayNode<<oss.str();
RapidXMLNode accNode=sourceNode.AppendNode("technique_common").AppendNode("accessor");
accNode.SetAttribute("source",ToSource(ToId(norsourceid)+"-array"));
accNode.SetAttribute("count",mesh.nor_.size());
accNode.SetAttribute("stride","3");
accNode.AppendNode("param")<<make_pair("name","X")<<make_pair("type","float");
accNode.AppendNode("param")<<make_pair("name","Y")<<make_pair("type","float");
accNode.AppendNode("param")<<make_pair("name","Z")<<make_pair("type","float");
}
//4 output color
string colorsourceid="mesh-geometry-color";
{
RapidXMLNode sourceNode=meshNode.AppendNode("source");
sourceNode.SetAttribute("id",ToId(colorsourceid));
RapidXMLNode arrayNode=sourceNode.AppendNode("float_array");
arrayNode.SetAttribute("id",ToId(colorsourceid)+"-array");
arrayNode.SetAttribute("count",mesh.color_.size()*3);
ostringstream oss;
for (zuint j=0; j<mesh.color_.size(); j++)
oss<<mesh.tex_[j];
arrayNode<<oss.str();
RapidXMLNode accNode=sourceNode.AppendNode("technique_common").AppendNode("accessor");
accNode.SetAttribute("source",ToSource(ToId(colorsourceid)+"-array"));
accNode.SetAttribute("count",mesh.color_.size());
accNode.SetAttribute("stride","3");
accNode.AppendNode("param")<<make_pair("name","R")<<make_pair("type","float");
accNode.AppendNode("param")<<make_pair("name","G")<<make_pair("type","float");
accNode.AppendNode("param")<<make_pair("name","B")<<make_pair("type","float");
}
//4 output triangles
for (zuint groupi=0;groupi<mesh.groups_.size();groupi++)
{
int inputn=1;
int inputt[10];
inputt[0]=SEM_VERTEX;
TriMesh::MeshGroup *g=mesh.groups_[groupi];
if (!g->facet_.empty()) inputt[inputn++]=SEM_TEXCOORD;
if (!g->facen_.empty()) inputt[inputn++]=SEM_NORMAL;
if (!g->facec_.empty()) inputt[inputn++]=SEM_COLOR;
RapidXMLNode triNode=meshNode.AppendNode("triangles");
for (int i=0; i<inputn; i++)
{
switch(inputt[i])
{
case SEM_VERTEX:
triNode.AppendNode("input")<<make_pair("semantic","VERTEX")<<make_pair("source",ToSource(verid))<<make_pair("offset",ToString(i));
break;
case SEM_TEXCOORD:
triNode.AppendNode("input")<<make_pair("semantic","TEXCOORD")<<make_pair("source",ToSource(uvsourceid))<<make_pair("offset",ToString(i));
break;
case SEM_NORMAL:
triNode.AppendNode("input")<<make_pair("semantic","NORMAL")<<make_pair("source",ToSource(norsourceid))<<make_pair("offset",ToString(i));
break;
case SEM_COLOR:
triNode.AppendNode("input")<<make_pair("semantic","COLOR")<<make_pair("source",ToSource(colorsourceid))<<make_pair("offset",ToString(i));
break;
}
}
int trin=mesh.groups_[groupi]->facep_.size();
if (!g->matname_.empty())
triNode.SetAttribute("material",ToId(g->matname_));
triNode.SetAttribute("count",g->facep_.size());
{
ostringstream oss;
for (zuint i=0; i<g->facep_.size(); i++) for (zuint j=0; j<3; j++)
{
for (int k=0; k<inputn; k++)
{
switch(inputt[k])
{
case SEM_VERTEX: oss<<g->facep_[i][j]<<' '; break;
case SEM_TEXCOORD: oss<<g->facet_[i][j]<<' '; break;
case SEM_NORMAL: oss<<g->facen_[i][j]<<' '; break;
case SEM_COLOR: oss<<g->facec_[i][j]<<' '; break;
}
}
}
triNode.AppendNode("p")<<oss.str();
}
if (save_mat_ && !mesh.groups_[groupi]->matname_.empty())
WriteMaterial(mesh,dae,mesh.groups_[groupi]->matname_);
}
}
void DaeIO::WriteVisual(TriMesh &mesh, DaeData &dae, string &url)
{
RapidXMLNode sceneNode=dae.libVisualsNode.AppendNode("visual_scene");
sceneNode<<make_pair("id",ToId(url));
sceneNode<<make_pair("name",ToId(url));
RapidXMLNode modelNode=sceneNode.AppendNode("node");
modelNode<<make_pair("id","Model0");
modelNode<<make_pair("name","Model0");
string geometryUrl="mesh-geometry";
modelNode.AppendNode("instance_geometry").SetAttribute("url",ToSource(geometryUrl));
WriteGeometry(mesh,dae,geometryUrl);
}
bool DaeIO::Save(const string &filename, TriMesh &mesh, bool savetex)
{
save_mat_ = savetex;
RapidXML xml;
RapidXMLNode head=xml.AppendNode("COLLADA");
head<<make_pair("xmlns","http://www.collada.org/2005/11/COLLADASchema");
head<<make_pair("version","1.4.0");
//assert
RapidXMLNode assetnode=head.AppendNode("asset");
RapidXMLNode contributornode=assetnode.AppendNode("contributor");
contributornode.AppendNode("authoring_tool")<<"zzzEngine";
contributornode.AppendNode("author")<<"Zhexi Wang";
assetnode.AppendNode("up_axis")<<"Z_UP";
DaeData dae(head.AppendNode("library_images"),
head.AppendNode("library_materials"),
head.AppendNode("library_effects"),
head.AppendNode("library_geometries"),
head.AppendNode("library_visual_scenes"));
RapidXMLNode sceneNode=head.AppendNode("scene");
string visualUrl=GetBase(filename)+"Scene";
sceneNode.AppendNode("instance_visual_scene")<<make_pair("url",ToSource(visualUrl));
WriteVisual(mesh,dae,visualUrl);
xml.SaveFile(filename);
return true;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/MeshIO/DaeIO.cpp
|
C++
|
gpl3
| 20,693
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "../SimpleMesh.hpp"
#include "../Mesh.hpp"
namespace zzz{
class ZGRAPHICS_CLASS Ply2IO {
public:
static bool Load(const string &filename, TriMesh &mesh,bool load_mat=true);
static bool Save(const string &filename, TriMesh &mesh,bool save_mat=true);
static bool Load(const string &filename, SimpleMesh &mesh,bool load_mat=true);
static bool Save(const string &filename, SimpleMesh &mesh,bool save_mat=true);
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/MeshIO/Ply2IO.hpp
|
C++
|
gpl3
| 486
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "../SimpleMesh.hpp"
#include "../Mesh.hpp"
namespace zzz{
class ZGRAPHICS_CLASS ObjIO {
public:
static bool Load(const string &filename, TriMesh &mesh, bool load_mat=true);
static bool Save(const string &filename, TriMesh &mesh, bool save_mat=true);
static bool Load(const string &filename, SimpleMesh &mesh, bool load_mat=true);
static bool Save(const string &filename, SimpleMesh &mesh, bool save_mat=true);
static bool ReadMtl(const string &filename);
static bool WriteMtl(const string &filename, const vector<string> &texnames);
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/MeshIO/ObjIO.hpp
|
C++
|
gpl3
| 624
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "../SimpleMesh.hpp"
#include "../Mesh.hpp"
namespace zzz{
class ZGRAPHICS_CLASS XIO {
public:
static bool Load(const string &filename, TriMesh &mesh, bool load_mat=true);
static bool Save(const string &filename, TriMesh &mesh, bool save_mat=true);
static bool Load(const string &filename, SimpleMesh &mesh, bool load_mat=true);
static bool Save(const string &filename, SimpleMesh &mesh, bool save_mat=true);
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/MeshIO/XIO.hpp
|
C++
|
gpl3
| 487
|
#include "ObjIO.hpp"
#include <Utility/FileTools.hpp>
#include "../Material.hpp"
#include "../../ResourceManager.hpp"
#include "../../../Context/Context.hpp"
#include "../../../Graphics/GeometryHelper.hpp"
#undef RGB
namespace zzz{
void StringTo3Int(const char *str, int &f1, int &f2, int &f3)
{
int len=strlen(str);
f1=0;
int i=0;
for (; i<len; i++) {
if (str[i]=='/') break;
f1=f1*10+str[i]-'0';
}
i++;
if (str[i]!='/') {
f2=0;
for (; i<len; i++) {
if (str[i]=='/') break;
f2=f2*10+str[i]-'0';
}
}
i++;
if (i<len) {
f3=0;
for (; i<len; i++) {
if (str[i]=='/') break;
f3=f3*10+str[i]-'0';
}
}
}
bool ObjIO::Load(const string &filename, TriMesh &mesh, bool load_mat)
{
FILE *pf=fopen(filename.c_str(),"r");
if (pf==NULL) {
ZLOGE<<"CANNOT OPEN FILE: "<<filename<<endl;
return false;
}
mesh.Clear();
char line[1024];
string current_mtl_name("");
Vector3f tmpf;
TriMesh::MeshGroup *current_group = new TriMesh::MeshGroup;
while(fgets(line,1024,pf)!=NULL) {
while(line[strlen(line)-2]=='\\') {
char extline[1024];
if (fgets(extline,1024,pf)==NULL) break;
line[strlen(line)-2]=' ';
line[strlen(line)-1]=' ';
strcat(line,extline);
}
if (line[0]=='#')
continue;
else if (line[0]=='v') {
if (line[1]=='n') {
char *cur=line+2;
while(*cur==' ') cur++;
sscanf(cur,"%f %f %f",&(tmpf[0]),&(tmpf[1]),&(tmpf[2]));
mesh.nor_.push_back(tmpf);
continue;
} else if (line[1]=='t') {
char *cur=line+2;
while(*cur==' ') cur++;
sscanf(cur,"%f %f",&(tmpf[0]),&(tmpf[1]));
tmpf[2]=0;
mesh.tex_.push_back(tmpf);
continue;
} else {
char *cur=line+1;
while(*cur==' ') cur++;
sscanf(cur,"%f %f %f",&(tmpf[0]),&(tmpf[1]),&(tmpf[2]));
mesh.pos_.push_back(tmpf);
continue;
}
} else if (line[0]=='f') {
char *cur=line+1;
while(*cur==' ') cur++; //skip spaces
//handle polygon
string curstr(cur);
vector<string> fs;
StringToVector(curstr,fs);
vector<int> fps,fns,fts;
for (zuint i=0; i<fs.size(); i++) {
int fp,ft(-1),fn(-1);
StringTo3Int(fs[i].c_str(),fp,ft,fn); //may not have t or n
fp--;
if (ft>0) ft--;
if (fn>0) fn--;
fps.push_back(fp);
fns.push_back(fn);
fts.push_back(ft);
}
ZCHECK_GE(fps.size(), 3)<<"Error while reading line: "<<line;
if (mesh.groups_.empty()) mesh.groups_.push_back(new TriMesh::MeshGroup());
if (fps.size()==3) {
current_group->facep_.push_back(Vector3i(fps[0],fps[1],fps[2]));
if (fts[0]>=0) current_group->facet_.push_back(Vector3i(fts[0],fts[1],fts[2]));
if (fns[0]>=0) current_group->facen_.push_back(Vector3i(fns[0],fns[1],fns[2]));
} else { //split polygon to triangles
vector<Vector3f> points;
//May cause error if face if read before vertex position
for (zuint i=0; i<fps.size(); i++) points.push_back(mesh.pos_[fps[i]]);
//project to plane
Matrix3x3f evector;
Vector3f evalue;
PCA<3,float>(points,evector,evalue);
vector<Vector2f> newp;
for (zuint i=0; i<points.size(); i++) {
Vector3f tmp=evector*points[i];
newp.push_back(Vector2f(tmp[0],tmp[1]));
}
//split into triangles
vector<Vector3i> triangles;
GeometryHelper::PolygonToTriangles(newp,triangles);
//put in triangles
for(zuint i=0; i<triangles.size(); i++) {
current_group->facep_.push_back(Vector3i(fps[triangles[i][0]],fps[triangles[i][1]],fps[triangles[i][2]]));
if (fts[0]>=0) current_group->facet_.push_back(Vector3i(fts[triangles[i][0]],fts[triangles[i][1]],fts[triangles[i][2]]));
if (fns[0]>=0) current_group->facen_.push_back(Vector3i(fns[triangles[i][0]],fns[triangles[i][1]],fns[triangles[i][2]]));
}
}
continue;
} else if (line[0] == 'g' || line[0] == 'o') { //treat o as g
char *cur = line+1;
while(*cur == ' ') cur++;
char name[1024]="";
current_group->matname_ = current_mtl_name;
mesh.groups_.push_back(current_group);
current_group = new TriMesh::MeshGroup();
current_group->name_ = cur; // read whole line after it
current_group->name_ = Trim(current_group->name_);
} else if (load_mat && StartsWith(line,"mtllib")) {
char *cur=line+6;
while(*cur==' ') cur++;
char name[1024];
sscanf(cur, "%s", name);
ReadMtl(PathFile(GetPath(filename),name).c_str());
} else if (load_mat && StartsWith(line,"usemtl")) {
char *cur=line+6;
while(*cur==' ') cur++;
current_mtl_name = cur;
current_mtl_name = Trim(current_mtl_name);
}
}
current_group->matname_ = current_mtl_name;
mesh.groups_.push_back(current_group);
fclose(pf);
mesh.SetDataFlags();
//calculate diameter
mesh.AABB_.Reset();
mesh.AABB_+=mesh.pos_;
return true;
}
bool ObjIO::Save(const string &filename, TriMesh &mesh, bool save_mat)
{
ofstream fo(filename);
if (!fo.good()) {
cout<<"cannot open file: "<<filename<<endl;
return false;
}
fo<<"# Save by zzzEngine\n\n";
vector<string> matname;
for (zuint i=0; i<mesh.groups_.size(); i++)
if (save_mat && !mesh.groups_[i]->matname_.empty()) matname.push_back(mesh.groups_[i]->matname_);
string path=GetPath(filename);
string base=GetBase(filename);
if (save_mat && !matname.empty()) {
string mtlname=base+".mtl";
mtlname=PathFile(path,mtlname);
WriteMtl(mtlname.c_str(),matname);
fo<<"mtllib "<<GetFilename(mtlname)<<endl;
}
for (zuint i=0; i<mesh.pos_.size(); i++)
fo<<"v "<<mesh.pos_[i]<<endl;
for (zuint i=0; i<mesh.nor_.size(); i++)
fo<<"vn "<<mesh.nor_[i]<<endl;
for (zuint i=0; i<mesh.tex_.size(); i++)
fo<<"vt "<<mesh.tex_[i]<<endl;
for (zuint i=0; i<mesh.groups_.size(); i++) {
fo<<"g "<<mesh.groups_[i]->name_<<endl;
if (!mesh.groups_[i]->matname_.empty())
fo<<"usemtl "<<mesh.groups_[i]->matname_<<endl;
if (!mesh.groups_[i]->facet_.empty() && !mesh.groups_[i]->facen_.empty()) {
for (zuint j=0; j<mesh.groups_[i]->facep_.size(); j++) {
fo<<"f";
for (zuint k=0; k<3; k++)
fo<<' '<<mesh.groups_[i]->facep_[j][k]+1<<'/'<<mesh.groups_[i]->facet_[j][k]+1<<'/'<<mesh.groups_[i]->facen_[j][k]+1;
fo<<endl;
}
} else if (!mesh.groups_[i]->facet_.empty()) {
for (zuint j=0; j<mesh.groups_[i]->facep_.size(); j++) {
fo<<"f";
for (zuint k=0; k<3; k++)
fo<<' '<<mesh.groups_[i]->facep_[j][k]+1<<'/'<<mesh.groups_[i]->facet_[j][k]+1;
fo<<endl;
}
} else if (!mesh.groups_[i]->facen_.empty()) {
for (zuint j=0; j<mesh.groups_[i]->facep_.size(); j++) {
fo<<"f";
for (zuint k=0; k<3; k++)
fo<<' '<<mesh.groups_[i]->facep_[j][k]+1<<"//"<<mesh.groups_[i]->facen_[j][k]+1;
fo<<endl;
}
} else {
for (zuint j=0; j<mesh.groups_[i]->facep_.size(); j++) {
fo<<"f";
for (zuint k=0; k<3; k++)
fo<<' '<<mesh.groups_[i]->facep_[j][k]+1;
fo<<endl;
}
}
}
return true;
}
//bool Load(const string &filename, SimpleMesh &mesh);
//bool Save(const string &filename, SimpleMesh &mesh);
bool ObjIO::ReadMtl(const string &filename)
{
ifstream fi(filename);
if (!fi.good()) {
cout<<"cannot open file: "<<filename<<endl;
return false;
}
string line,name,file;
Material *newmat=NULL;
while(getline(fi,line,'\n')) {
istringstream iss(line);
string head;
iss>>head;
ToLow(head);
if (head=="newmtl") {
if (!name.empty()) {//add new material
if (!ZRM->Add(newmat,name)) delete newmat; //add failed
name.clear();
}
iss>>name;
newmat=new Material();
} else if (head=="ka") {
if (newmat==NULL) continue;
iss>>newmat->ambient_.r()>>newmat->ambient_.g()>>newmat->ambient_.b();
if (iss.fail()) continue;
newmat->SetFlag(MAT_AMB);
} else if (head=="kd") {
if (newmat==NULL) continue;
iss>>newmat->diffuse_.r()>>newmat->diffuse_.g()>>newmat->diffuse_.b();
if (iss.fail()) continue;
newmat->SetFlag(MAT_DIF);
} else if (head=="ks") {
if (newmat==NULL) continue;
iss>>newmat->specular_.r()>>newmat->specular_.g()>>newmat->specular_.b();
if (iss.fail()) continue;
newmat->SetFlag(MAT_SPE);
} else if (head=="ns") {
if (newmat==NULL) continue;
iss>>newmat->shininess_;
if (iss.fail()) continue;
} else if (head=="map_ka") {
//actually, should accept some parameters, too troublesome,,,
if (newmat==NULL) continue;
iss>>file;
if (iss.fail()) continue;
file=PathFile(GetPath(filename),file);
if (GLExists()) {
Image3uc img(file.c_str());
newmat->ambientTex_.ChangeInternalFormat(GL_RGBA);
newmat->ambientTex_.ImageToTexture(img);
newmat->SetFlag(MAT_AMBTEX);
} else {
newmat->ambientTexName_=file;
}
} else if (head=="map_kd") {
//actually, should accept some parameters, too troublesome,,,
if (newmat==NULL) continue;
iss>>file;
if (iss.fail()) continue;
file=PathFile(GetPath(filename),file);
if (GLExists()) {
Image3uc img(file.c_str());
newmat->diffuseTex_.ImageToTexture(img);
newmat->SetFlag(MAT_DIFTEX);
} else {
newmat->diffuseTexName_=file;
}
} else if (head=="map_bump") {
//actually, should accept some parameters, too troublesome,,,
if (newmat==NULL) continue;
iss>>file;
if (iss.fail()) continue;
file=PathFile(GetPath(filename),file);
if (GLExists()) {
Image3uc img(file.c_str());
newmat->bumpTex_.ImageToTexture(img);
newmat->SetFlag(MAT_BUMTEX);
} else {
newmat->bumpTexName_=file;
}
}
} if (!name.empty()) { //add new material
if (!ZRM->Add(newmat,name)) delete newmat; //add failed
name.clear();
}
fi.close();
return true;
}
bool ObjIO::WriteMtl(const string &filename, const vector<string> &texname)
{
ofstream fo(filename);
if (!fo.good()) {
cout<<"cannot open file: "<<filename<<endl;
return false;
}
fo<<"# Save by zzzEngine\n\n";
string path=GetPath(filename);
string base=GetBase(filename);
set<string> saved;
for (zuint i=0; i<texname.size(); i++) {
if (saved.find(texname[i])!=saved.end()) //saved
continue;
saved.insert(texname[i]);
Material *mat=ZRM->Get<Material*>(texname[i]);
if (mat==NULL) {
cout<<"cannot find material: "<<texname[i]<<endl;
continue;
}
//write a material
fo<<"newmtl "<<texname[i]<<endl;
if (mat->HasFlag(MAT_AMB))
fo<<"Ka "<<mat->ambient_.RGB()<<endl;
if (mat->HasFlag(MAT_DIF))
fo<<"Kd "<<mat->diffuse_.RGB()<<endl;
if (mat->HasFlag(MAT_SPE)) {
fo<<"Ks "<<mat->specular_.RGB()<<endl;
fo<<"Ns "<<mat->shininess_<<endl;
}
if (mat->HasFlag(MAT_AMBTEX)) {
string storefilename=base;
storefilename<<'_'<<texname[i]<<"_amb.png";
storefilename=PathFile(path,storefilename);
mat->ambientTex_.TextureToFile<Vector4uc>(storefilename.c_str());
fo<<"map_ka "<<storefilename<<endl;
} else if (!mat->ambientTexName_.empty())
fo<<"map_ka "<<mat->ambientTexName_.c_str()<<endl;
if (mat->HasFlag(MAT_DIFTEX)) {
string storefilename=base;
storefilename<<'_'<<texname[i]<<"_dif.png";
fo<<"map_kd "<<storefilename<<endl;
storefilename=PathFile(path,storefilename);
mat->diffuseTex_.TextureToFile<Vector4uc>(storefilename.c_str());
} else if (!mat->diffuseTexName_.empty())
fo<<"map_kd "<<mat->diffuseTexName_<<endl;
if (mat->HasFlag(MAT_BUMTEX)) {
string storefilename=base;
storefilename<<'_'<<texname[i]<<"_bump.png";
fo<<"map_bump "<<storefilename<<endl;
storefilename=PathFile(path,storefilename);
mat->bumpTex_.TextureToFile<Vector4f>(storefilename.c_str());
} else if (!mat->bumpTexName_.empty())
fo<<"map_bump "<<mat->bumpTexName_<<endl;
}
fo.close();
return true;
}
} // namespace zzz;
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/MeshIO/ObjIO.cpp
|
C++
|
gpl3
| 12,791
|
#pragma once
#include "../Mesh.hpp"
#include <Utility/FileTools.hpp>
#include "ObjIO.hpp"
#include "DaeIO.hpp"
#include "WrlIO.hpp"
#include "Ply2IO.hpp"
#include "XIO.hpp"
#include <Utility/Timer.hpp>
#include "IOObjectMesh.hpp"
#include <Utility/IOFile.hpp>
namespace zzz{
class MeshIO
{
public:
static bool Load(const string &filename, TriMesh &mesh, bool load_mat=true)
{
ZLOG(ZVERBOSE)<<"Loading "<<filename<<" ...\n";
Timer timer;
bool result=false;
string ext=ToLow_copy(GetExt(filename));
if (ext==".obj") result=ObjIO::Load(filename,mesh,load_mat);
else if (ext==".dae") result=DaeIO::Load(filename,mesh,load_mat);
else if (ext==".wrl") result=WrlIO::Load(filename,mesh,load_mat);
else if (ext==".vrml") result=WrlIO::Load(filename,mesh,load_mat);
else if (ext==".ply2") result=Ply2IO::Load(filename,mesh,load_mat);
else if (ext==".x") result=XIO::Load(filename,mesh,load_mat);
else if (ext==".rfmesh") result=IOFile::LoadFileR(filename, mesh);
mesh.AABB_.Reset();
mesh.AABB_+=mesh.pos_;
if (result)
ZLOG(ZVERBOSE)<<"Loaded "<<filename<<" in "<<timer.Elapsed()<<" seconds.\n";
else
ZLOG(ZVERBOSE)<<"Loaded "<<filename<<" FAILED!\n";
return result;
}
static bool Save(const string &filename, TriMesh &mesh, bool save_mat=true)
{
ZLOG(ZVERBOSE)<<"Saving "<<filename<<" ...\n";
Timer timer;
bool result=false;
string ext=ToLow_copy(GetExt(filename));
if (ext==".obj") result=ObjIO::Save(filename,mesh,save_mat);
else if (ext==".dae") result=DaeIO::Save(filename,mesh,save_mat);
else if (ext==".wrl") result=WrlIO::Save(filename,mesh,save_mat);
else if (ext==".vrml") result=WrlIO::Save(filename,mesh,save_mat);
else if (ext==".ply2") result=Ply2IO::Save(filename,mesh,save_mat);
else if (ext==".x") result=XIO::Save(filename,mesh,save_mat);
else if (ext==".rfmesh") result=IOFile::SaveFileR(filename, mesh);
if (result)
ZLOG(ZVERBOSE)<<"Saved "<<filename<<" in "<<timer.Elapsed()<<" seconds.\n";
else
ZLOG(ZVERBOSE)<<"Saved "<<filename<<" FAILED!\n";
return result;
}
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/MeshIO/MeshIO.hpp
|
C++
|
gpl3
| 2,216
|
#include "XIO.hpp"
#include <common.hpp>
#include "../Material.hpp"
#include <Utility/FileTools.hpp>
#include <Utility/BraceFile.hpp>
namespace zzz{
void EatUntil(istringstream &iss, char c)
{
char tmpchar;
do
{
iss>>tmpchar;
if (iss.fail()) return;
}while (tmpchar!=c);
}
bool XIO::Load(const string &filename, TriMesh &mesh, bool load_mat)
{
BraceFile bf("{}");
if (!bf.LoadFile(filename)) return false;
BraceNode meshNode=bf.GetFirstNode("Mesh");
if (!meshNode.IsValid()) return false;
mesh.Clear();
int npos,nface;
string data;
Vector3f v;
Vector3i vi;
vector<Vector3i> facep,facen;
//position
meshNode.GetChildrenText(data);
{
istringstream iss(data);
iss>>npos;
EatUntil(iss,';');
for (int i=0; i<npos; i++)
{
iss>>v[0];
EatUntil(iss,';');
iss>>v[1];
EatUntil(iss,';');
iss>>v[2];
EatUntil(iss,';');
if (i<npos-1) EatUntil(iss,',');
else EatUntil(iss,';');
mesh.pos_.push_back(v);
mesh.AABB_+=v;
}
mesh.SetFlag(MESH_POS);
iss>>nface;
EatUntil(iss,';');
for (int i=0; i<nface; i++)
{
EatUntil(iss,'3');
EatUntil(iss,';');
iss>>vi[0];
EatUntil(iss,',');
iss>>vi[1];
EatUntil(iss,',');
iss>>vi[2];
EatUntil(iss,';');
if (i<nface-1) EatUntil(iss,',');
else EatUntil(iss,';');
facep.push_back(vi);
}
}
//normal
BraceNode normalNode=meshNode.GetFirstNode("MeshNormals");
if (normalNode.IsValid())
{
normalNode.GetChildrenText(data);
istringstream iss(data);
iss>>npos;
EatUntil(iss,';');
for (int i=0; i<npos; i++)
{
iss>>v[0];
EatUntil(iss,';');
iss>>v[1];
EatUntil(iss,';');
iss>>v[2];
EatUntil(iss,';');
if (i<npos-1) EatUntil(iss,',');
else EatUntil(iss,';');
mesh.nor_.push_back(v);
}
mesh.SetFlag(MESH_NOR);
iss>>nface;
EatUntil(iss,';');
for (int i=0; i<nface; i++)
{
EatUntil(iss,'3');
EatUntil(iss,';');
iss>>vi[0];
EatUntil(iss,',');
iss>>vi[1];
EatUntil(iss,',');
iss>>vi[2];
EatUntil(iss,';');
if (i<nface-1) EatUntil(iss,',');
else EatUntil(iss,';');
facen.push_back(vi);
}
}
//texcoord
BraceNode texNode=meshNode.GetFirstNode("MeshTextureCoords");
if (texNode.IsValid())
{
texNode.GetChildrenText(data);
istringstream iss(data);
iss>>npos;
EatUntil(iss,';');
v[2]=0;
for (int i=0; i<npos; i++)
{
iss>>v[0];
EatUntil(iss,';');
iss>>v[1];
EatUntil(iss,';');
if (i<npos-1) EatUntil(iss,',');
else EatUntil(iss,';');
mesh.tex_.push_back(v);
}
mesh.SetFlag(MESH_TEX);
}
//mat group
BraceNode matNode=meshNode.GetFirstNode("MeshMaterialList");
if (matNode.IsValid())
{
matNode.GetChildrenText(data);
istringstream iss(data);
int nmat;
iss>>nmat;
EatUntil(iss,';');
for (int i=0; i<nmat; i++)
mesh.groups_.push_back(new TriMesh::MeshGroup());
iss>>nface;
EatUntil(iss,';');
int facem;
for (int i=0; i<nface; i++)
{
iss>>facem;
if (i<nface-1) EatUntil(iss,',');
else EatUntil(iss,';');
mesh.groups_[facem]->facep_.push_back(facep[i]);
if (!facen.empty()) mesh.groups_[facem]->facen_.push_back(facen[i]);
}
for (int i=0; i<nmat; i++)
{
mesh.groups_[i]->SetFlag(MESH_POS);
if (!facen.empty()) mesh.groups_[i]->SetFlag(MESH_NOR);
if (mesh.HasFlag(MESH_TEX))
{
mesh.groups_[i]->facet_=mesh.groups_[i]->facep_;
mesh.groups_[i]->SetFlag(MESH_TEX);
mesh.groups_[i]->matname_="Material";
mesh.groups_[i]->matname_<<i;
}
}
//read material
for (int i=0; i<nmat; i++)
{
BraceNode materialNode=matNode.GetNode(i);
materialNode.GetChildrenText(data);
istringstream iss(data);
Material *mat=new Material;
ZRM->Add(mat,mesh.groups_[i]->matname_.c_str());
iss>>mat->ambient_[0];EatUntil(iss,';');
iss>>mat->ambient_[1];EatUntil(iss,';');
iss>>mat->ambient_[2];EatUntil(iss,';');
iss>>mat->ambient_[3];EatUntil(iss,';');EatUntil(iss,';');
mat->diffuse_=mat->ambient_;
iss>>mat->shininess_;EatUntil(iss,';');
iss>>mat->specular_[0];EatUntil(iss,';');
iss>>mat->specular_[1];EatUntil(iss,';');
iss>>mat->specular_[2];EatUntil(iss,';');EatUntil(iss,';');
iss>>mat->emission_[0];EatUntil(iss,';');
iss>>mat->emission_[1];EatUntil(iss,';');
iss>>mat->emission_[2];EatUntil(iss,';');EatUntil(iss,';');
mat->SetFlag(MAT_AMB);
mat->SetFlag(MAT_DIF);
mat->SetFlag(MAT_SPE);
mat->SetFlag(MAT_EMI);
BraceNode textureNode=materialNode.GetFirstNode("TextureFilename");
if (textureNode.IsValid())
{
string texfilename=textureNode.GetFirstNode().GetText();
texfilename = Trim(texfilename);
texfilename = TrimBack(texfilename, ";");
texfilename = Trim(texfilename,"\"");
if (!texfilename.empty())
{
//BUG: path bug
if (GLExists())
{
mat->diffuseTex_.FileToTexture<Vector3uc>(texfilename.c_str());
mat->SetFlag(MAT_DIFTEX);
}
else
mat->diffuseTexName_=texfilename;
}
}
}
}
else
{
//only one group
mesh.groups_.push_back(new TriMesh::MeshGroup());
TriMesh::MeshGroup *group=mesh.groups_.back();
group->facep_=facep;
group->SetFlag(MESH_POS);
if (mesh.HasFlag(MESH_NOR)) {group->facen_=facen;group->SetFlag(MESH_NOR);}
if (mesh.HasFlag(MESH_TEX)) {group->facet_=facep;group->SetFlag(MESH_TEX);}
}
return true;
}
bool XIO::Save(const string &filename, TriMesh &mesh, bool save_mat)
{
BraceFile bf;
//head
bf.AppendNode("xof 0303txt 0032");
bf.AppendNode("template Vector",'{','}')<<"<3d82ab5e-62da-11cf-ab39-0020af71e433>"<<"FLOAT x; "<<"FLOAT y; "<<"FLOAT z; ";
bf.AppendNode("template MeshFace",'{','}')<<"<3d82ab5f-62da-11cf-ab39-0020af71e433>"<<"DWORD nFaceVertexIndices; "<<"array DWORD faceVertexIndices[nFaceVertexIndices]; ";
bf.AppendNode("template Mesh",'{','}')<<"<3d82ab44-62da-11cf-ab39-0020af71e433>"<<"DWORD nVertices; "<<"array Vector vertices[nVertices]; "<<"DWORD nFaces; "<<"array MeshFace faces[nFaces]; "<<"[...]";
bf.AppendNode("template MeshNormals",'{','}')<<"<f6f23f43-7686-11cf-8f52-0040333594a3>"<<"DWORD nNormals; "<<"array Vector normals[nNormals]; "<<"DWORD nFaceNormals; "<<"array MeshFace faceNormals[nFaceNormals]; ";
bf.AppendNode("template Coords2d",'{','}')<<"<f6f23f44-7686-11cf-8f52-0040333594a3>"<<"FLOAT u; "<<"FLOAT v; ";
bf.AppendNode("template MeshTextureCoords",'{','}')<<"<f6f23f40-7686-11cf-8f52-0040333594a3>"<<"DWORD nTextureCoords; "<<"array Coords2d textureCoords[nTextureCoords]; ";
bf.AppendNode("template ColorRGBA",'{','}')<<"<35ff44e0-6c7c-11cf-8f52-0040333594a3>"<<"FLOAT red; "<<"FLOAT green; "<<"FLOAT blue; "<<"FLOAT alpha; ";
bf.AppendNode("template ColorRGB",'{','}')<<"<d3e16e81-7835-11cf-8f52-0040333594a3>"<<"FLOAT red; "<<"FLOAT green; "<<"FLOAT blue; ";
bf.AppendNode("template Material",'{','}')<<"<3d82ab4d-62da-11cf-ab39-0020af71e433>"<<"ColorRGBA faceColor; "<<"FLOAT power; "<<"ColorRGB specularColor; "<<"ColorRGB emissiveColor; "<<"[...]";
bf.AppendNode("template MeshMaterialList",'{','}')<<"<f6f23f42-7686-11cf-8f52-0040333594a3>"<<"DWORD nMaterials; "<<"DWORD nFaceIndexes; "<<"array DWORD faceIndexes[nFaceIndexes]; "<<"[Material <3d82ab4d-62da-11cf-ab39-0020af71e433>]";
bf.AppendNode("template TextureFilename",'{','}')<<"<a42790e1-7810-11cf-8f52-0040333594a3>"<<"STRING filename; ";
mesh.CreateElement();
BraceNode meshNode=bf.AppendNode("Mesh",'{','}');
zuint nface=0;
for (zuint i=0; i<mesh.groups_.size(); i++) nface+=mesh.groups_[i]->eindex_.size();
zuint npos=mesh.epos_.size();
//position
{
meshNode<<ToString(npos)+"; ";
for (zuint i=0; i<mesh.epos_.size(); i++)
{
ostringstream oss;
oss.precision(6);
oss<<fixed;
oss<<mesh.epos_[i][0]<<';'<<mesh.epos_[i][1]<<';'<<mesh.epos_[i][2]<<';';
if (i<npos-1) oss<<',';
else oss<<';';
meshNode<<oss.str();
}
meshNode<<ToString(nface)+"; ";
for (zuint i=0; i<mesh.groups_.size(); i++) for (zuint j=0; j<mesh.groups_[i]->eindex_.size(); j++)
{
ostringstream oss;
oss<<"3; "<<mesh.groups_[i]->eindex_[j][0]<<','<<mesh.groups_[i]->eindex_[j][1]<<','<<mesh.groups_[i]->eindex_[j][2]<<';';
if (i!=mesh.groups_.size()-1 || j!=mesh.groups_.back()->eindex_.size()-1) oss<<',';
else oss<<';';
meshNode<<oss.str();
}
}
//normal
if (mesh.HasFlag(MESH_NOR))
{
BraceNode normalNode=meshNode.AppendNode("MeshNormals",'{','}');
normalNode<<ToString(npos)+"; ";
for (zuint i=0; i<mesh.enor_.size(); i++)
{
ostringstream oss;
oss.precision(6);
oss<<fixed;
oss<<mesh.enor_[i][0]<<';'<<mesh.enor_[i][1]<<';'<<mesh.enor_[i][2]<<';';
if (i<npos-1) oss<<',';
else oss<<';';
normalNode<<oss.str();
}
normalNode<<ToString(nface)+"; ";
for (zuint i=0; i<mesh.groups_.size(); i++) for (zuint j=0; j<mesh.groups_[i]->eindex_.size(); j++)
{
ostringstream oss;
oss<<"3; "<<mesh.groups_[i]->eindex_[j][0]<<','<<mesh.groups_[i]->eindex_[j][1]<<','<<mesh.groups_[i]->eindex_[j][2]<<';';
if (i!=mesh.groups_.size()-1 || j!=mesh.groups_.back()->eindex_.size()-1) oss<<',';
else oss<<';';
normalNode<<oss.str();
}
}
//texcoord
if (mesh.HasFlag(MESH_TEX))
{
BraceNode texNode=meshNode.AppendNode("MeshTextureCoords",'{','}');
texNode<<ToString(npos)+"; ";
for (zuint i=0; i<mesh.etex_.size(); i++)
{
ostringstream oss;
oss.precision(6);
oss<<fixed;
oss<<mesh.etex_[i][0]<<';'<<mesh.etex_[i][1]<<';';
if (i<npos-1) oss<<',';
else oss<<';';
texNode<<oss.str();
}
}
//mat group
BraceNode matNode=meshNode.AppendNode("MeshMaterialList",'{','}');
matNode<<ToString(mesh.groups_.size())+"; ";
matNode<<ToString(nface)+"; ";
for (zuint i=0; i<mesh.groups_.size(); i++)
{
for (zuint j=0; j<mesh.groups_[i]->eindex_.size(); j++)
{
ostringstream oss;
oss<<i;
if (i!=mesh.groups_.size()-1 || j!=mesh.groups_.back()->eindex_.size()-1)
oss<<",";
else
oss<<"; ";
matNode<<oss.str();
}
}
//material
for (zuint i=0; i<mesh.groups_.size(); i++)
{
BraceNode materialNode=matNode.AppendNode("Material",'{','}');
if (mesh.groups_[i]->matname_.empty())
{
materialNode<<"0.8; 0.8; 0.8; 0; ;"<<"0; "<<"1; 1; 1; ;"<<"0; 0; 0; ;";
}
else
{
Material *mat=ZRM->Get<Material*>(mesh.groups_[i]->matname_.c_str());
string line;
if (mat->HasFlag(MAT_AMB)) line<<mat->ambient_.r()<<"; "<<mat->ambient_.g()<<"; "<<mat->ambient_.b()<<"; "<<mat->ambient_.a()<<"; ;";
else if (mat->HasFlag(MAT_DIF)) line<<mat->diffuse_.r()<<"; "<<mat->diffuse_.g()<<"; "<<mat->diffuse_.b()<<"; "<<mat->diffuse_.a()<<"; ;";
else line="0.8; 0.8; 0.8; 0; ;";
materialNode<<line;
line.clear();
if (mat->HasFlag(MAT_SPE))
{
materialNode<<ToString(mat->shininess_)+"; ";
line<<mat->specular_.r()<<"; "<<mat->specular_.g()<<"; "<<mat->specular_.b()<<"; ;";
materialNode<<line;
}
else
materialNode<<"0; "<<"1; 1; 1; ;";
line.clear();
if (mat->HasFlag(MAT_EMI))
{
line<<mat->emission_.r()<<"; "<<mat->emission_.g()<<"; "<<mat->emission_.b()<<"; ;";
materialNode<<line;
}
else
materialNode<<"1; 1; 1; ;";
if (mat->HasFlag(MAT_DIFTEX))
{
BraceNode textureNode=matNode.AppendNode("TextureFilename",'{','}');
string storefilename=GetBase(filename);
storefilename<<'_'<<mesh.groups_[i]->matname_<<"_dif.png";
mat->diffuseTex_.TextureToFile<Vector4uc>(storefilename.c_str());
line="\"";
line<<storefilename<<"\"; ";
textureNode<<line;
}
}
}
if (!bf.SaveFile(filename," ")) return false;
return true;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/MeshIO/XIO.cpp
|
C++
|
gpl3
| 12,702
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "../Mesh.hpp"
#include <Xml/RapidXMLNode.hpp>
namespace zzz{
class ZGRAPHICS_CLASS DaeIO {
public:
static bool Load(const string &filename, TriMesh &mesh, bool load_mat=true);
static bool Save(const string &filename, TriMesh &mesh, bool save_mat=true);
private:
static bool load_mat_;
static bool save_mat_;
static string dae_path_;
struct DaeData
{
DaeData(RapidXMLNode _libImagesNode, RapidXMLNode _libMaterialsNode, RapidXMLNode _libEffectsNode, RapidXMLNode _libGeometriesNode, RapidXMLNode _libVisualsNode)
:libImagesNode(_libImagesNode),
libMaterialsNode(_libMaterialsNode),
libEffectsNode(_libEffectsNode),
libGeometriesNode(_libGeometriesNode),
libVisualsNode(_libVisualsNode){}
RapidXMLNode libImagesNode;
RapidXMLNode libMaterialsNode;
RapidXMLNode libEffectsNode;
RapidXMLNode libGeometriesNode;
RapidXMLNode libVisualsNode;
};
static string ToId(const string &str);
static string ToSource(const string &str);
static RapidXMLNode FindNodeById(RapidXMLNode &father, const string &name, string &id);
static const int SEM_VERTEX=0;
static const int SEM_TEXCOORD=1;
static const int SEM_NORMAL=2;
static const int SEM_COLOR=3;
static void ReadMaterial(TriMesh &mesh, DaeData &dae, string &url);
static void ReadGeometry(TriMesh &mesh, DaeData &dae, string &url);
static void ReadVisual(TriMesh &mesh, DaeData &dae, string &url);
static void WriteMaterial(TriMesh &mesh, DaeData &dae, string &url);
static void WriteGeometry(TriMesh &mesh, DaeData &dae, string &url);
static void WriteVisual(TriMesh &mesh, DaeData &dae, string &url);
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/MeshIO/DaeIO.hpp
|
C++
|
gpl3
| 1,747
|
#include "HalfEdgeMesh.hpp"
namespace zzz {
zzz::HalfEdgeMesh::~HalfEdgeMesh() {
Clear();
}
void HalfEdgeMesh::Clear() {
for (zuint i=0; i<half_edges_.size(); i++)
delete half_edges_[i];
half_edges_.clear();
for (zuint i=0; i<boundary_half_edges_.size(); i++)
delete boundary_half_edges_[i];
boundary_half_edges_.clear();
for (zuint i=0; i<vertices_.size(); i++)
delete vertices_[i];
vertices_.clear();
for (zuint i=0; i<faces_.size(); i++)
delete faces_[i];
faces_.clear();
}
void HalfEdgeMesh::ConnectEdges(HalfEdge *he1, HalfEdge *he2)
{
he1->next_=he2;
he2->prev_=he1;
}
void HalfEdgeMesh::SetTwins(HalfEdge *he1, HalfEdge *he2)
{
he1->twin_=he2;
he2->twin_=he1;
}
void HalfEdgeMesh::ConnectFaceEdge(Face *f, HalfEdge *e)
{
f->half_edge_=e;
e->left_face_=f;
}
void HalfEdgeMesh::LoadTriMeshGroup(const TriMesh &mesh, zuint group)
{
for (zuint i=0; i<mesh.pos_.size(); i++) {
vertices_.push_back(new Vertex(mesh.pos_[i], i));
}
vector<HalfEdge*> back_half_edges;
TriMesh::MeshGroup *g=mesh.groups_[group];
for (zuint i=0; i<g->facep_.size(); i++) {
// One face has three half edge and each has a twin edge
HalfEdge *he[3]={new HalfEdge(false), new HalfEdge(false), new HalfEdge(false)};
HalfEdge *bhe[3]={new HalfEdge(true), new HalfEdge(true), new HalfEdge(true)};
Vertex *v[3]={vertices_[g->facep_[i][0]], vertices_[g->facep_[i][1]], vertices_[g->facep_[i][2]]};
Face *f = new Face(i);
for (zuint j=0; j<3; j++) {
// edge and edge
ConnectEdges(he[j], he[(j+1)%3]);
ConnectEdges(bhe[j], bhe[(j+1)%3]);
SetTwins(he[j], bhe[j]);
// edge and point
he[j]->start_=v[j];
v[j]->half_edge_=he[j];
bhe[j]->start_=v[(j+1)%3];
v[j]->adj_edges_.push_back(he[j]);
v[j]->adj_edges_.push_back(bhe[j]);
// edge and face
ConnectFaceEdge(f, he[j]);
half_edges_.push_back(he[i]);
back_half_edges.push_back(bhe[i]);
}
faces_.push_back(f);
// merge boundary edge
for (int k=0; k<3; k++) {
Vertex *start= bhe[k]->start_;
Vertex *end = bhe[k]->end_vertex();
for (zuint j=0; j<end->adj_edges_.size(); j++) {
HalfEdge *curr = end->adj_edges_[j];
if (curr->boundary_ && curr->end_vertex() == start) {
ConnectEdges(bhe[k]->prev_, curr->next_);
ConnectEdges(curr->prev_, bhe[k]->next_);
SetTwins(bhe[k]->twin_, curr->twin_);
bhe[k]->start_=NULL;
curr->start_=NULL;
break;
}
}
}
} // for (zuint i=0; i<g->facep_.size(); i++) {
for (zuint i=0; i<back_half_edges.size(); i++) {
if (back_half_edges[i]->start_)
boundary_half_edges_.push_back(back_half_edges[i]);
else
delete back_half_edges[i];
}
}
}; // namespace zzz
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/HalfEdgeMesh.cpp
|
C++
|
gpl3
| 2,934
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "Mesh.hpp"
namespace zzz{
class ZGRAPHICS_CLASS PolygonMesh
{
public:
struct PolygonMeshGroup
{
string name_;
string matname_;
//original data
vector<vector<int> > facep_,facen_,facet_;
};
PolygonMesh();
~PolygonMesh();
bool Clear();
bool Apply(const Translation<float>&);
bool Apply(const Rotation<float>&);
bool Apply(const Transformation<float>&);
bool Scale(float coef);
bool MakeCenter();
bool Normalize();
//simple draw and vbo draw
bool Draw(int bt=MESH_POS|MESH_NOR);
bool Draw(int idx, int bt);
bool Draw(const string &name, int bt);
//original data
vector<Vector3f> pos_,nor_,tex_,color_;
vector<PolygonMeshGroup*> groups_;
//per vertex generalized data
vector<Vector3f> posnor_,postan_,posbino_;
vector<float> posratio_;
float allarea_;
float MeshScale_;
Vector3f MeshOffset_;
float Diameter_;
AABB<3,float> AABB_;
Vector3f OriCenter_;
bool loaded_;
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/PolygonMesh.hpp
|
C++
|
gpl3
| 1,049
|
#ifdef ZZZ_OPENMESH
#include "OTriMesh.hpp"
#include "../../Utility/Tools.hpp"
namespace zzz{
OTriMesh::OTriMesh()
{
mat_emi_[0]=0; mat_emi_[1]=0; mat_emi_[2]=0; mat_emi_[3]=1;
mat_amb_[0]=1; mat_amb_[1]=1; mat_amb_[2]=1; mat_amb_[3]=1;
mat_dif_[0]=1; mat_dif_[1]=1; mat_dif_[2]=1; mat_dif_[3]=1;
mat_spe_[0]=1; mat_spe_[1]=1; mat_spe_[2]=1; mat_spe_[3]=1;
mat_shi_=1;
}
bool OTriMesh::LoadFromFile(const string &filename)
{
mesh_.request_face_normals();
mesh_.request_vertex_normals();
mesh_.request_vertex_texcoords3D();
OpenMesh::IO::Options opt;
if (! OpenMesh::IO::read_mesh(mesh_,filename,opt))
return false;
if (! opt.check(OpenMesh::IO::Options::FaceNormal))
mesh_.update_face_normals();
if (! opt.check(OpenMesh::IO::Options::VertexNormal))
mesh_.update_vertex_normals();
return true;
}
bool OTriMesh::Clear()
{
mesh_.clear();
return true;
}
bool OTriMesh::Draw(int bt)
{
glMaterialfv(GL_FRONT,GL_EMISSION,mat_emi_);
glMaterialfv(GL_FRONT,GL_AMBIENT,mat_amb_);
glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_dif_);
glMaterialfv(GL_FRONT,GL_SPECULAR,mat_spe_);
glMaterialfv(GL_FRONT,GL_SHININESS,&mat_shi_);
MyMesh::FaceIter v_it,v_end(mesh_.faces_end());
glBegin(GL_TRIANGLES);
for (v_it=mesh_.faces_begin();v_it!=v_end; ++v_it)
{
for (MyMesh::FaceVertexIter fv_it=mesh_.fv_iter(v_it);fv_it; ++fv_it)
{
if (CheckFlag(bt,Mesh::MESH_VERTEX))
glVertex3fv(mesh_.point(fv_it).data());
if (CheckFlag(bt,Mesh::MESH_NORMAL))
glNormal3fv(mesh_.normal(fv_it).data());
}
}
glEnd();
return true;
}
bool OTriMesh::DrawVBO(int bt)
{
return true;
}
bool OTriMesh::CreateVBO(int bt)
{
return true;
}
bool OTriMesh::Rotate(float angle, float x, float y, float z)
{
return true;
}
bool OTriMesh::Translate(float x, float y, float z)
{
return true;
}
bool OTriMesh::MultiMatrix(float *rotatematrix)
{
return true;
}
bool OTriMesh::BindVBO(int bt/*=MESH_ALL*/)
{
return true;
}
}
#endif
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/OTriMesh.cpp
|
C++
|
gpl3
| 2,091
|
#pragma once
#include <zGraphicsConfig.hpp>
#pragma warning(disable:4267)
#pragma warning(disable:4244)
#include "../../Graphics/Graphics.hpp"
#include "Mesh.hpp"
#include "../../Math/Coordinate.hpp"
#define _USE_MATH_DEFINES
#include <OpenMesh/Core/io/MeshIO.hh>
#include <OpenMesh/Core/Mesh/Types/TriMesh_ArrayKernelT.hh>
#ifdef _DEBUG
#pragma comment(lib,"OpenMeshCored.lib")
#pragma comment(lib,"OpenMeshToolsd.lib")
#else
#pragma comment(lib,"OpenMeshCore.lib")
#pragma comment(lib,"OpenMeshTools.lib")
#endif
namespace zzz{
class ZGRAPHICS_CLASS OTriMesh : public Mesh
{
public:
OTriMesh();
bool Clear();
bool LoadFromFile(const string &filename);
bool Draw(int bt=Mesh::MESH_VERTEX|Mesh::MESH_NORMAL);
bool DrawVBO(int bt);
bool CreateVBO(int bt);
bool Apply(Rotation<float> &r);
bool Apply(Translation<float> &t);
bool Apply(Transformation<float> &t);
bool BindVBO(int bt=MESH_ALL);
private:
typedef OpenMesh::TriMesh_ArrayKernelT<> MyMesh;
MyMesh mesh_;
//meterial
GLfloat mat_emi_[4],mat_amb_[4],mat_dif_[4],mat_spe_[4],mat_shi_;
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/OTriMesh.hpp
|
C++
|
gpl3
| 1,119
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "../../Graphics/Color.hpp"
#include "../Texture/Texture2D.hpp"
#include "../Texture/Texture2DIOObject.hpp"
#include <Utility/HasFlag.hpp>
//OPENGL material model
namespace zzz{
const zuint MAT_DIF=0x0001;
const zuint MAT_AMB=0x0002;
const zuint MAT_SPE=0x0004;
const zuint MAT_EMI=0x0008;
const zuint MAT_AMBTEX=0x0010;
const zuint MAT_DIFTEX=0x0020;
const zuint MAT_BUMTEX=0x0100;
class ZGRAPHICS_CLASS Material : public HasFlags
{
public:
Material();
~Material();
void ApplyMaterial();
void BindDiffuseTexture(GLenum bindto = GL_TEXTURE0);
void UnbindDiffuseTexture();
void BindAmbientTexture(GLenum bindto = GL_TEXTURE0);
void UnbindAmbientTexture();
Colorf diffuse_, ambient_, specular_, emission_;
float shininess_;
Texture2D ambientTex_;
string ambientTexName_;
Texture2D diffuseTex_;
string diffuseTexName_;
Texture2D bumpTex_;
string bumpTexName_;
};
template<>
class IOObject<Material>
{
public:
static const zint32 RF_HASFLAGS=999;
static const zint32 RF_DIFFUSE=1;
static const zint32 RF_AMBIENT=2;
static const zint32 RF_SPECULAR=3;
static const zint32 RF_EMISSION=4;
static const zint32 RF_SHININESS=5;
static const zint32 RF_AMBIENTTEX=10;
static const zint32 RF_AMBIENTTEXIMG=12;
static const zint32 RF_DIFFUSETEX=20;
static const zint32 RF_DIFFUSETEXIMG=22;
static const zint32 RF_BUMPTEX=30;
static const zint32 RF_BUMPTEXIMG=32;
static void WriteFileR(RecordFile &fp, const zint32 label, const Material& src) {
fp.WriteChildBegin(label);
IOObject<HasFlags>::WriteFileR(fp, RF_HASFLAGS, src);
if (src.HasFlag(MAT_DIF)) IOObj::WriteFileR(fp, RF_DIFFUSE, src.diffuse_);
if (src.HasFlag(MAT_AMB)) IOObj::WriteFileR(fp, RF_AMBIENT, src.ambient_);
if (src.HasFlag(MAT_SPE)) {
IOObj::WriteFileR(fp, RF_SPECULAR, src.specular_);
IOObj::WriteFileR(fp, RF_SHININESS, src.shininess_);
}
if (src.HasFlag(MAT_EMI)) IOObj::WriteFileR(fp, RF_EMISSION, src.emission_);
if (src.HasFlag(MAT_AMBTEX)) {
if (!src.ambientTexName_.empty()) {
Image3uc img;
img.LoadFile(src.ambientTexName_.c_str());
IOObj::WriteFileR(fp, RF_AMBIENTTEXIMG, img);
} else {
IOObj::WriteFileR(fp, RF_AMBIENTTEX, src.ambientTex_);
}
}
if (src.HasFlag(MAT_DIFTEX)) {
if (!src.diffuseTexName_.empty()) {
Image3uc img;
img.LoadFile(src.diffuseTexName_.c_str());
IOObj::WriteFileR(fp, RF_DIFFUSETEXIMG, img);
} else {
IOObj::WriteFileR(fp, RF_DIFFUSETEX, src.diffuseTex_);
}
}
if (src.HasFlag(MAT_BUMTEX)) {
if (!src.bumpTexName_.empty()) {
Image3f img;
img.LoadFile(src.bumpTexName_.c_str());
IOObj::WriteFileR(fp, RF_BUMPTEXIMG, img);
} else {
IOObj::WriteFileR(fp, RF_BUMPTEX, src.bumpTex_);
}
}
fp.WriteChildEnd();
}
static void ReadFileR(RecordFile &fp, const zint32 label, Material& dst) {
fp.ReadChildBegin(label);
IOObject<HasFlags>::ReadFileR(fp, RF_HASFLAGS, dst);
if (dst.HasFlag(MAT_DIF)) IOObj::ReadFileR(fp, RF_DIFFUSE, dst.diffuse_);
if (dst.HasFlag(MAT_AMB)) IOObj::ReadFileR(fp, RF_AMBIENT, dst.ambient_);
if (dst.HasFlag(MAT_SPE)) {
IOObj::ReadFileR(fp, RF_SPECULAR, dst.specular_);
IOObj::ReadFileR(fp, RF_SHININESS, dst.shininess_);
}
if (dst.HasFlag(MAT_EMI)) IOObj::ReadFileR(fp, RF_EMISSION, dst.emission_);
if (dst.HasFlag(MAT_AMBTEX)) {
if (fp.LabelExist(RF_AMBIENTTEXIMG) && Context::current_context_) {
Image3uc img;
IOObj::ReadFileR(fp, RF_AMBIENTTEXIMG, img);
dst.ambientTex_.ImageToTexture(img);
} else if (fp.LabelExist(RF_AMBIENTTEX) && Context::current_context_)
IOObj::ReadFileR(fp, RF_AMBIENTTEX, dst.ambientTex_);
}
if (dst.HasFlag(MAT_DIFTEX)) {
if (fp.LabelExist(RF_DIFFUSETEXIMG) && Context::current_context_) {
Image3uc img;
IOObj::ReadFileR(fp, RF_DIFFUSETEXIMG, img);
dst.diffuseTex_.ImageToTexture(img);
} else if (fp.LabelExist(RF_DIFFUSETEX) && Context::current_context_)
IOObj::ReadFileR(fp, RF_DIFFUSETEX, dst.diffuseTex_);
}
if (dst.HasFlag(MAT_BUMTEX)) {
if (fp.LabelExist(RF_BUMPTEXIMG) && Context::current_context_) {
Image3f img;
IOObj::ReadFileR(fp, RF_BUMPTEXIMG, img);
dst.bumpTex_.ImageToTexture(img);
} else if (fp.LabelExist(RF_BUMPTEX) && Context::current_context_)
IOObj::ReadFileR(fp, RF_BUMPTEX, dst.bumpTex_);
}
fp.ReadChildEnd();
}
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/Material.hpp
|
C++
|
gpl3
| 4,761
|
#include "PolygonMesh.hpp"
namespace zzz{
PolygonMesh::PolygonMesh():loaded_(false){}
PolygonMesh::~PolygonMesh(){Clear();}
bool PolygonMesh::Clear()
{
nor_.clear();
pos_.clear();
tex_.clear();
for (zuint i=0; i<groups_.size(); i++)
delete groups_[i];
groups_.clear();
loaded_=false;
return true;
}
bool PolygonMesh::Apply(const Translation<float> &offset)
{
if (!loaded_) return false;
int len=pos_.size();
for (int i=0; i<len; i++)
pos_[i]=offset.Apply(pos_[i]);
AABB_.SetOffset(offset);
OriCenter_=offset.Apply(OriCenter_);
return true;
}
bool PolygonMesh::Apply(const Rotation<float> &t)
{
if (!loaded_) return false;
int len=pos_.size();
for (int i=0; i<len; i++)
pos_[i]=t.Apply(pos_[i]);
len=nor_.size();
for (int i=0; i<len; i++)
{
nor_[i]=t.Apply(nor_[i]);
nor_[i].Normalize();
}
AABB_.Reset();
AABB_+=pos_;
OriCenter_=AABB_.Center();
return true;
}
bool PolygonMesh::Apply(const Transformation<float> &t)
{
if (!loaded_) return false;
int len=pos_.size();
for (int i=0; i<len; i++)
pos_[i]=t.Apply(pos_[i]);
len=nor_.size();
for (int i=0; i<len; i++)
{
nor_[i]=t.Apply(nor_[i]);
nor_[i].Normalize();
}
AABB_.Reset();
AABB_+=pos_;
OriCenter_=AABB_.Center();
return true;
}
bool PolygonMesh::Scale(float coef)
{
if (!loaded_) return false;
for (zuint i=0; i<pos_.size(); i++)
pos_[i]*=coef;
AABB_.Min()*=coef;
AABB_.Max()*=coef;
Diameter_*=coef;
return true;
}
bool PolygonMesh::MakeCenter(){return Apply(Translation<float>(-OriCenter_));}
bool PolygonMesh::Normalize(){return Scale(1.0/Diameter_);}
//simple draw and vbo draw
bool PolygonMesh::Draw(int bt)
{
if (!loaded_) return false;
for (zuint i=0; i<groups_.size(); i++)
if (!Draw(i,bt)) return false;
return true;
}
bool PolygonMesh::Draw(int idx, int bt)
{
PolygonMeshGroup *g=groups_[idx];
vector<vector<int> > &facep=g->facep_, &facen=g->facen_, &facet=g->facet_;
for (zuint i=0; i<facep.size(); i++)
{
glBegin(GL_POLYGON);
int cur=0;
for (zuint j=0; j<facep[i].size(); j++)
{
if (CheckBit(bt, MESH_NOR)) glNormal3fv(nor_[facen[i][j]].Data());
if (CheckBit(bt, MESH_TEX)) glTexCoord3fv(tex_[facet[i][j]].Data());
if (CheckBit(bt, MESH_COLOR)) glColor3fv(color_[facep[i][j]].Data());
if (CheckBit(bt, MESH_POS)) glVertex3fv(pos_[facep[i][j]].Data());
}
glEnd();
}
return true;
}
bool PolygonMesh::Draw(const string &name, int bt)
{
for (zuint i=0; i<groups_.size(); i++)
if (groups_[i]->name_==name) return Draw(i,bt);
return false;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Mesh/PolygonMesh.cpp
|
C++
|
gpl3
| 2,736
|
#pragma once
#include <zGraphicsConfig.hpp>
#include <Utility/AnyHolder.hpp>
// This is basically AnyHolder.
// Only that it will delete the object when needed.
// So remove is overloaded.
namespace zzz{
class Texture2D;
class Shader;
class Material;
class ZGRAPHICS_CLASS ResourceManager : public AnyHolder
{
public:
bool Add(Texture2D *tex, const string &name, bool cover=true);
bool Add(Shader *shader, const string &name, bool cover=true);
bool Add(Material *mat, const string &name, bool cover=true);
private:
void Destroy(Any &v);
};
extern ResourceManager __default_RM; //used to the program that does not have OPENGL
//for convinience
#define ZRM ((Context::current_context_==NULL)?&__default_RM:Context::current_context_->GetRM())
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/ResourceManager.hpp
|
C++
|
gpl3
| 783
|
#include "Shader.hpp"
#include "../../Renderer/ArcBallRenderer.hpp"
#include <Utility/FileTools.hpp>
#include <Utility/StringTools.hpp>
#include <Utility/Log.hpp>
namespace zzz{
//same reason as in texture, cannot initialize in constructor
Shader::Shader()
:vert(NULL),vert_hold(false),
frag(NULL),frag_hold(false),
geom(NULL),geohold_(false),
ProgramObject(0),is_linked(false)
{}
Shader::Shader(const char *vertfile, const char *fragfile, const char *geomfile) {
if (ProgramObject==0) ProgramObject = glCreateProgram();
if (vertfile!=NULL) LoadVertexFile(vertfile);
if (fragfile!=NULL) LoadFragmentFile(fragfile);
if (geomfile!=NULL) LoadGeometryFile(geomfile);
CHECK_GL_ERROR()
}
Shader::Shader(GLVertexShader *verts, GLFragmentShader *frags, GLGeometryShader *geoms) {
if (ProgramObject==0) ProgramObject = glCreateProgram();
if (verts) AddShader(verts);
if (frags) AddShader(frags);
if (geoms) AddShader(geoms);
CHECK_GL_ERROR()
}
Shader::~Shader() {
if (vert)
glDetachShader(ProgramObject,vert->ShaderObject);
if (vert_hold)
delete vert;
if (frag)
glDetachShader(ProgramObject,frag->ShaderObject);
if (frag_hold)
delete frag;
if (geom)
glDetachShader(ProgramObject,geom->ShaderObject);
if (geohold_)
delete geom;
glDeleteShader(ProgramObject);
CHECK_GL_ERROR()
}
bool Shader::AddShader(GLShaderObject* ShaderProgram) {
if (ProgramObject==0)
ProgramObject = glCreateProgram();
if (!ShaderProgram->is_compiled)
return false;
if (ShaderProgram->progratype_==GLShaderObject::VERT) {
vert=ShaderProgram;
vert_hold=false;
}
else if (ShaderProgram->progratype_==GLShaderObject::FRAG) {
frag=ShaderProgram;
frag_hold=false;
}
else if (ShaderProgram->progratype_==GLShaderObject::GEOM) {
geom=ShaderProgram;
geohold_=false;
}
CHECK_GL_ERROR()
return true;
}
bool Shader::LoadVertexFile(const char *file) {
if (ProgramObject==0)
ProgramObject = glCreateProgram();
if (!file) return true;
vert=new GLVertexShader;
bool ret=vert->LoadFromFile(file);
vert_hold=true;
CHECK_GL_ERROR()
return ret;
}
bool Shader::LoadVertexMemory(const char *mem) {
if (ProgramObject==0)
ProgramObject = glCreateProgram();
if (!mem) return true;
vert=new GLVertexShader;
bool ret=vert->LoadFromMemory(mem);
vert_hold=true;
CHECK_GL_ERROR()
return ret;
}
bool Shader::LoadFragmentFile(const char *file) {
if (ProgramObject==0)
ProgramObject = glCreateProgram();
if (!file) return true;
frag=new GLFragmentShader;
bool ret=frag->LoadFromFile(file);
frag_hold=true;
CHECK_GL_ERROR()
return ret;
}
bool Shader::LoadFragmentMemory(const char *mem) {
if (ProgramObject==0)
ProgramObject = glCreateProgram();
if (!mem) return true;
frag=new GLFragmentShader;
bool ret=frag->LoadFromMemory(mem);
frag_hold=true;
CHECK_GL_ERROR()
return ret;
}
bool Shader::LoadGeometryFile(const char *file) {
if (ProgramObject==0)
ProgramObject = glCreateProgram();
if (!file) return true;
geom=new GLGeometryShader;
bool ret=geom->LoadFromFile(file);
geohold_=true;
CHECK_GL_ERROR()
return ret;
}
bool Shader::LoadGeometryMemory(const char *mem) {
if (ProgramObject==0)
ProgramObject = glCreateProgram();
if (!mem) return true;
geom=new GLGeometryShader;
bool ret=geom->LoadFromMemory(mem);
geohold_=true;
CHECK_GL_ERROR()
return ret;
}
bool Shader::Link(void) {
if (vert) glAttachShader(ProgramObject,vert->ShaderObject);
if (frag) glAttachShader(ProgramObject,frag->ShaderObject);
if (geom) glAttachShader(ProgramObject,geom->ShaderObject);
int linked;
glLinkProgram(ProgramObject);
glGetProgramiv(ProgramObject, GL_LINK_STATUS, &linked);
CHECK_GL_ERROR()
if (linked) {
is_linked = true;
return true;
} else {
char *msg=GetLinkerError();
ZLOGE << "Shader Linker ERROR:"<<msg<<endl;
delete[] msg;
return false;
}
}
char* Shader::GetLinkerError(void) {
int blen = 0;
int slen = 0;
glGetProgramiv(ProgramObject, GL_INFO_LOG_LENGTH , &blen);
char *linker_log;
if ((linker_log = (GLcharARB*)malloc(blen)) == NULL) {
ZLOGE << "ERROR: Could not allocate compiler_log buffer\n";
return NULL;
}
glGetProgramInfoLog(ProgramObject, blen, &slen, linker_log);
CHECK_GL_ERROR()
return (char*) linker_log;
}
void Shader::Begin(void) {
if (ProgramObject == 0) return;
if (is_linked) glUseProgram(ProgramObject);
CHECK_GL_ERROR()
}
void Shader::End(void) {
glUseProgram(0);
CHECK_GL_ERROR()
}
bool Shader::SetUniform1f(char* varname, GLfloat v0) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform1f(loc, v0);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform2f(char* varname, GLfloat v0, GLfloat v1) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform2f(loc, v0, v1);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform3f(char* varname, GLfloat v0, GLfloat v1, GLfloat v2) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform3f(loc, v0, v1, v2);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform4f(char* varname, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
{
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform4f(loc, v0, v1, v2, v3);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform1i(char* varname, GLint v0) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform1i(loc, v0);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform2i(char* varname, GLint v0, GLint v1) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform2i(loc, v0, v1);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform3i(char* varname, GLint v0, GLint v1, GLint v2) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform3i(loc, v0, v1, v2);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform4i(char* varname, GLint v0, GLint v1, GLint v2, GLint v3) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform4i(loc, v0, v1, v2, v3);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform1fv(char* varname, GLsizei count, const GLfloat *value) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform1fv(loc, count, value);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform2fv(char* varname, GLsizei count, const GLfloat *value) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform2fv(loc, count, value);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform3fv(char* varname, GLsizei count, const GLfloat *value) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform3fv(loc, count, value);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform4fv(char* varname, GLsizei count, const GLfloat *value) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform4fv(loc, count, value);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform1iv(char* varname, GLsizei count, const GLint *value) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform1iv(loc, count, value);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform2iv(char* varname, GLsizei count, const GLint *value) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform2iv(loc, count, value);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform3iv(char* varname, GLsizei count, const GLint *value) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform3iv(loc, count, value);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniform4iv(char* varname, GLsizei count, const GLint *value) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniform4iv(loc, count, value);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniformMatrix2fv(char* varname, GLsizei count, GLboolean transpose, const GLfloat *value) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniformMatrix2fv(loc, count, transpose, value);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniformMatrix3fv(char* varname, GLsizei count, GLboolean transpose, const GLfloat *value) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniformMatrix3fv(loc, count, transpose, value);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniformMatrix4fv(char* varname, GLsizei count, GLboolean transpose, const GLfloat *value) {
GLint loc = GetUniLoc(varname);
if (loc==-1) return false; // can't find variable
glUniformMatrix4fv(loc, count, transpose, value);
CHECK_GL_ERROR()
return true;
}
GLint Shader::GetUniLoc(const GLchar *name) {
GLint loc;
loc = glGetUniformLocation(ProgramObject, name);
if (loc == -1) ZLOGE << "Error: can't find uniform variable \"" << name << "\"\n";
CHECK_GL_ERROR()
return loc;
}
GLint Shader::GetAttLoc(const GLchar *name) {
GLint loc;
loc = glGetAttribLocation(ProgramObject, name);
if (loc == -1) ZLOGE << "Error: can't find attribute variable \"" << name << "\"\n";
CHECK_GL_ERROR()
return loc;
}
void Shader::GetUniformfv(char* name, GLfloat* values)
{
GLint loc;
loc = glGetUniformLocation(ProgramObject, name);
if (loc == -1) ZLOGE << "Error: can't find uniform variable \"" << name << "\"\n";
else glGetUniformfv(ProgramObject, loc, values);
CHECK_GL_ERROR()
}
void Shader::GetUniformiv(char* name, GLint* values)
{
GLint loc;
loc = glGetUniformLocation(ProgramObject, name);
if (loc == -1) ZLOGE << "Error: can't find uniform variable \"" << name << "\"\n";
else glGetUniformiv(ProgramObject, loc, values);
CHECK_GL_ERROR()
}
bool Shader::SetVertexAttrib1s(GLuint index, GLshort v0) {
glVertexAttrib1s(index, v0);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetVertexAttrib2s(GLuint index, GLshort v0, GLshort v1) {
glVertexAttrib2s(index, v0, v1);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetVertexAttrib3s(GLuint index, GLshort v0, GLshort v1, GLshort v2) {
glVertexAttrib3s(index, v0, v1, v2);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetVertexAttrib4s(GLuint index, GLshort v0, GLshort v1, GLshort v2, GLshort v3) {
glVertexAttrib4s(index, v0, v1, v2, v3);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetVertexAttrib1f(GLuint index, GLfloat v0) {
glVertexAttrib1f(index, v0);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1) {
glVertexAttrib2f(index, v0, v1);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2) {
glVertexAttrib3f(index, v0, v1, v2);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetVertexAttrib4f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
glVertexAttrib4f(index, v0, v1, v2, v3);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetVertexAttrib1d(GLuint index, GLdouble v0) {
glVertexAttrib1d(index, v0);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetVertexAttrib2d(GLuint index, GLdouble v0, GLdouble v1) {
glVertexAttrib2d(index, v0, v1);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetVertexAttrib3d(GLuint index, GLdouble v0, GLdouble v1, GLdouble v2) {
glVertexAttrib3d(index, v0, v1, v2);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetVertexAttrib4d(GLuint index, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3) {
glVertexAttrib4d(index, v0, v1, v2, v3);
CHECK_GL_ERROR()
return true;
}
bool Shader::SetUniforms(Renderer *currenderer)
{
if (ProgramObject == 0) return false;
if (!is_linked) return false;
for (zuint i=0; i<UniformParamList.size(); i++) {
UniformParam *tmp=&UniformParamList[i];
char varname[100];
strcpy(varname,tmp->name.c_str());
if (tmp->type==UniformParam::F1)
SetUniform1f(varname,tmp->f1);
else if (tmp->type==UniformParam::F2)
SetUniform2f(varname,tmp->f2[0],tmp->f2[1]);
else if (tmp->type==UniformParam::F3)
SetUniform3f(varname,tmp->f3[0],tmp->f3[1],tmp->f3[2]);
else if (tmp->type==UniformParam::F4)
SetUniform4f(varname,tmp->f4[0],tmp->f4[1],tmp->f4[2],tmp->f4[3]);
else if (tmp->type==UniformParam::I1)
SetUniform1i(varname,tmp->i1);
else if (tmp->type==UniformParam::I2)
SetUniform2i(varname,tmp->i2[0],tmp->i2[1]);
else if (tmp->type==UniformParam::I3)
SetUniform3i(varname,tmp->i3[0],tmp->i3[1],tmp->i3[2]);
else if (tmp->type==UniformParam::I4)
SetUniform4i(varname,tmp->i4[0],tmp->i4[1],tmp->i4[2],tmp->i4[3]);
else if (tmp->type==UniformParam::M2)
SetUniformMatrix2fv(varname, 1, GL_FALSE, tmp->m2);
else if (tmp->type==UniformParam::M3)
SetUniformMatrix3fv(varname, 1, GL_FALSE, tmp->m3);
else if (tmp->type==UniformParam::M4)
SetUniformMatrix4fv(varname, 1, GL_FALSE, tmp->m4);
else if (currenderer==NULL)
{
printf("ERROR: SetUniforms: no Renderer is specified\n");
continue;
}
// else if (tmp->type==UniformParam::OBJROT)
// {
// ArcBallRenderer *renderer=dynamic_cast<ArcBallRenderer*>(currenderer);
// SetUniformMatrix4fv(varname,1,0,renderer->pCurObjArcBall_->GetGLRotateMatrix());
// }
// else if (tmp->type==UniformParam::OBJROTTRANS)
// {
// ArcBallRenderer *renderer=dynamic_cast<ArcBallRenderer*>(currenderer);
// SetUniformMatrix4fv(varname,1,1,renderer->pCurObjArcBall_->GetGLRotateMatrix());
// }
// else if (tmp->type==UniformParam::ENVROT)
// {
// ArcBallRenderer *renderer=dynamic_cast<ArcBallRenderer*>(currenderer);
// SetUniformMatrix4fv(varname,1,0,renderer->pCurEnvArcBall_->GetGLRotateMatrix());
// }
// else if (tmp->type==UniformParam::ENVROTTRANS)
// {
// ArcBallRenderer *renderer=dynamic_cast<ArcBallRenderer*>(currenderer);
// SetUniformMatrix4fv(varname,1,1,renderer->pCurEnvArcBall_->GetGLRotateMatrix());
// }
}
CHECK_GL_ERROR()
return true;
}
bool Shader::ChangeUniform(const string &name,GLint i1)
{
vector<UniformParam>::iterator vupi=find(UniformParamList.begin(),UniformParamList.end(),name);
if (vupi==UniformParamList.end()) return false;
vupi->i1=i1;
CHECK_GL_ERROR()
return true;
}
bool Shader::ChangeUniform(const string &name,GLfloat f1)
{
vector<UniformParam>::iterator vupi=find(UniformParamList.begin(),UniformParamList.end(),name);
if (vupi==UniformParamList.end()) return false;
vupi->f1=f1;
CHECK_GL_ERROR()
return true;
}
bool Shader::Clear()
{
UniformParamList.clear();
CHECK_GL_ERROR()
return true;
}
//////////////////////////////////////////////////////////////////////////
GLShaderObject::GLShaderObject(ShaderType type)
:progratype_(type),is_compiled(false),ShaderObject(0)
{}
GLShaderObject::~GLShaderObject()
{
if (is_compiled)
glDeleteObjectARB(ShaderObject);
CHECK_GL_ERROR()
}
bool GLShaderObject::LoadFromFile(const char * filename)
{
char *source;
if (!ReadFileToString(filename,&source)) return false;
bool ret=Compile(source);
delete source;
CHECK_GL_ERROR()
return ret;
}
bool GLShaderObject::LoadFromMemory(const char * program)
{
char *source = (char*)program;
return Compile(source);
}
char* GLShaderObject::GetCompilerError(void)
{
int blen = 0;
int slen = 0;
glGetShaderiv(ShaderObject, GL_INFO_LOG_LENGTH , &blen);
char *compiler_log;
if ((compiler_log = (GLcharARB*)malloc(blen)) == NULL)
{
ZLOGE<< "ERROR: Could not allocate compiler_log buffer\n";
return NULL;
}
glGetInfoLogARB(ShaderObject, blen, &slen, compiler_log);
CHECK_GL_ERROR()
return compiler_log;
}
bool GLShaderObject::Compile(char *source)
{
is_compiled = false;
int compiled = 0;
GLint length = (GLint) strlen((const char *)source);
glShaderSource(ShaderObject, 1, (const GLcharARB **)&source, &length);
glCompileShader(ShaderObject);
glGetObjectParameterivARB(ShaderObject, GL_COMPILE_STATUS, &compiled);
CHECK_GL_ERROR()
if (compiled)
{
is_compiled=true;
return true;
}
else
{
char *msg=GetCompilerError();
if (progratype_==VERT) ZLOGE << "Vertex Shader Compiler ERROR:"<<msg<<endl;
else if (progratype_==FRAG) ZLOGE << "Fragment Shader Compiler ERROR:"<<msg<<endl;
delete[] msg;
return false;
}
}
GLint GLShaderObject::GetAttribLocation(char* attribName)
{
return glGetAttribLocationARB(ShaderObject, attribName);
}
//////////////////////////////////////////////////////////////////////////
GLVertexShader::GLVertexShader()
:GLShaderObject(VERT)
{
ShaderObject = glCreateShaderObjectARB(GL_VERTEX_SHADER);
CHECK_GL_ERROR()
}
//////////////////////////////////////////////////////////////////////////
GLFragmentShader::GLFragmentShader()
:GLShaderObject(FRAG)
{
ShaderObject = glCreateShaderObjectARB(GL_FRAGMENT_SHADER);
CHECK_GL_ERROR()
}
//////////////////////////////////////////////////////////////////////////
GLGeometryShader::GLGeometryShader()
:GLShaderObject(GEOM)
{
ShaderObject = glCreateShaderObjectARB(GL_GEOMETRY_SHADER);
CHECK_GL_ERROR()
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Shader/Shader.cpp
|
C++
|
gpl3
| 18,179
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "Shader.hpp"
#include "../Script/ShaderScript.hpp"
namespace zzz{
ZGRAPHICS_FUNC void MakeShaders();
}
#define ZCOLORSHADER ZRM->Get<Shader*>("ColorShader")
#define ZDIFFUSESHADER ZRM->Get<Shader*>("DiffuseShader")
#define ZLIGHTSHADER ZRM->Get<Shader*>("LightShader")
#define ZTEXTURESHADER ZRM->Get<Shader*>("TextureShader")
#define ZTEXTURELIGHTSHADER ZRM->Get<Shader*>("TextureLightShader")
#define ZTEXCOORDSHADER ZRM->Get<Shader*>("TexCoordShader")
#define ZCUBEMAPSHADER ZRM->Get<Shader*>("CubemapShader")
#define ZSHADEREND() Shader::End();
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Shader/ShaderSpecify.hpp
|
C++
|
gpl3
| 623
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "../../Renderer/Renderer.hpp"
#include <common.hpp>
#include <Utility/Tools.hpp>
/*
ATTENTION:
use begin() FIRST
then setUniform
otherwise INVALID_OPERATION occurs
*/
namespace zzz{
class ZGRAPHICS_CLASS GLShaderObject : public Uncopyable {
friend class Shader;
public:
typedef enum {VERT,FRAG,GEOM} ShaderType;
GLShaderObject(ShaderType type);
virtual ~GLShaderObject();
bool LoadFromFile(const char * filename);
bool LoadFromMemory(const char * program);
bool Compile(char *source);
char* GetCompilerError(void);
GLint GetAttribLocation(char* attribName);
ShaderType progratype_;
GLuint ShaderObject;
bool is_compiled;
};
class ZGRAPHICS_CLASS GLVertexShader : public GLShaderObject {
public:
GLVertexShader();
};
class ZGRAPHICS_CLASS GLFragmentShader : public GLShaderObject {
public:
GLFragmentShader();
};
class ZGRAPHICS_CLASS GLGeometryShader : public GLShaderObject {
public:
GLGeometryShader();
};
struct UniformParam {
enum {F1,F2,F3,F4,I1,I2,I3,I4,M2,M3,M4,OBJROT,OBJROTTRANS,ENVROT,ENVROTTRANS} type;
string name;
union {
float f1;
float f2[2];
float f3[3];
float f4[4];
int i1;
int i2[2];
int i3[3];
int i4[4];
float m2[4];
float m3[9];
float m4[16];
};
bool operator==(const string &str)const {return name==str;}
};
class ZGRAPHICS_CLASS Shader : public Uncopyable {
public:
Shader();
Shader(const char *vertfile, const char *fragfile, const char *geomfile);
Shader(GLVertexShader *verts, GLFragmentShader *frags, GLGeometryShader *geoms);
virtual ~Shader();
bool AddShader(GLShaderObject* ShaderProgram); //!< add a Vertex or Fragment Program
bool LoadVertexFile(const char *file);
bool LoadVertexMemory(const char *mem);
bool LoadFragmentFile(const char *file);
bool LoadFragmentMemory(const char *mem);
bool LoadGeometryFile(const char *file);
bool LoadGeometryMemory(const char *mem);
bool Link(void); //!< Link all Shaders
char* GetLinkerError(void); //!< get Linker messages
void Begin(); //!< use Shader. OpenGL calls will go through shader.
static void End(); //!< Stop using this shader. OpenGL calls will go through regular pipeline.
// Uniform Variables
bool SetUniform1f(char* varname, GLfloat v0); //!< set float uniform to program
bool SetUniform2f(char* varname, GLfloat v0, GLfloat v1); //!< set vec2 uniform to program
bool SetUniform3f(char* varname, GLfloat v0, GLfloat v1, GLfloat v2); //!< set vec3 uniform to program
bool SetUniform4f(char* varname, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); //!< set vec4 uniform to program
bool SetUniform1i(char* varname, GLint v0);
bool SetUniform2i(char* varname, GLint v0, GLint v1);
bool SetUniform3i(char* varname, GLint v0, GLint v1, GLint v2);
bool SetUniform4i(char* varname, GLint v0, GLint v1, GLint v2, GLint v3);
bool SetUniform1fv(char* varname, GLsizei count, const GLfloat *value);
bool SetUniform2fv(char* varname, GLsizei count, const GLfloat *value);
bool SetUniform3fv(char* varname, GLsizei count, const GLfloat *value);
bool SetUniform4fv(char* varname, GLsizei count, const GLfloat *value);
bool SetUniform1iv(char* varname, GLsizei count, const GLint *value);
bool SetUniform2iv(char* varname, GLsizei count, const GLint *value);
bool SetUniform3iv(char* varname, GLsizei count, const GLint *value);
bool SetUniform4iv(char* varname, GLsizei count, const GLint *value);
bool SetUniformMatrix2fv(char* varname, GLsizei count, GLboolean transpose, const GLfloat *value);
bool SetUniformMatrix3fv(char* varname, GLsizei count, GLboolean transpose, const GLfloat *value);
bool SetUniformMatrix4fv(char* varname, GLsizei count, GLboolean transpose, const GLfloat *value);
// Receive Uniform variables:
void GetUniformfv(char* name, GLfloat* values);
void GetUniformiv(char* name, GLint* values);
// Vertex Attributes, use in glVertex(...) method
bool SetVertexAttrib1s(GLuint index, GLshort v0);
bool SetVertexAttrib2s(GLuint index, GLshort v0, GLshort v1);
bool SetVertexAttrib3s(GLuint index, GLshort v0, GLshort v1, GLshort v2);
bool SetVertexAttrib4s(GLuint index, GLshort v0, GLshort v1, GLshort v2, GLshort v3);
bool SetVertexAttrib1f(GLuint index, GLfloat v0);
bool SetVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1);
bool SetVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2);
bool SetVertexAttrib4f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
bool SetVertexAttrib1d(GLuint index, GLdouble v0);
bool SetVertexAttrib2d(GLuint index, GLdouble v0, GLdouble v1);
bool SetVertexAttrib3d(GLuint index, GLdouble v0, GLdouble v1, GLdouble v2);
bool SetVertexAttrib4d(GLuint index, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3);
vector <UniformParam> UniformParamList;
bool Clear();
bool SetUniforms(Renderer *currenderer=NULL);
bool ChangeUniform(const string &name,GLint i1);
bool ChangeUniform(const string &name,GLfloat f1);
bool Init();
GLint GetUniLoc(const GLchar *name); // get location of a variable
GLint GetAttLoc(const GLchar *name);
GLuint ProgramObject; // GLProgramObject
bool is_linked;
GLShaderObject *vert,*frag,*geom;
bool vert_hold,frag_hold,geohold_;
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Shader/Shader.hpp
|
C++
|
gpl3
| 5,444
|
#include "ShaderSpecify.hpp"
namespace zzz{
//////////////////////////////////////////////////////////////////////////
//COLORSHADER
const char ColorShaderVert[]="\
varying vec4 color; \
void main(void)\
{\
gl_Position=ftransform(); \
color=gl_Color; \
}\
";
const char ColorShaderFrag[]="\
varying vec4 color; \
void main(void)\
{\
gl_FragColor=color; \
}\
";
//////////////////////////////////////////////////////////////////////////
//DIFFUSESHADER
// NORMAL SHOULD NOT BE -
// BUT THE RESULT IS ALWAYS WRONG
// DON'T KNOW WHY
const char DiffuseShaderVert[]="\
varying vec4 color; \
varying vec3 N,v; \
void main(void)\
{\
N=-gl_NormalMatrix*gl_Normal; \
color=gl_Color; \
gl_Position=gl_ModelViewProjectionMatrix * gl_Vertex; \
}\
";
const char DiffuseShaderFrag[]="\
varying vec4 color; \
varying vec3 N,v; \
void main(void)\
{\
vec3 L=normalize(vec3(0,0,-100)); \
gl_FragColor=color * max(dot(N,L),0.0); \
gl_FragColor[3]=1; \
}\
";
//////////////////////////////////////////////////////////////////////////
//LIGHTSHADER
// NORMAL SHOULD NOT BE -
// BUT THE RESULT IS ALWAYS WRONG
// DON'T KNOW WHY
const char LightShaderVert[]="\
varying vec4 color; \
varying vec3 N,v; \
void main(void)\
{\
v=vec3(gl_ModelViewMatrix*gl_Vertex); \
N=-gl_NormalMatrix*gl_Normal; \
color=gl_Color; \
gl_Position=gl_ModelViewProjectionMatrix * gl_Vertex; \
}\
";
const char LightShaderFrag[]="\
varying vec4 color; \
varying vec3 N,v; \
void main(void)\
{\
vec3 L=normalize(vec3(0,0,-100)-v); \
vec3 E=normalize(-v); \
vec3 R=-reflect(L,N); \
gl_FragColor=color * max(dot(N,L),0.0) + color * pow(max(dot(R,E),0.0),50.0); \
gl_FragColor[3]=1; \
}\
";
//////////////////////////////////////////////////////////////////////////
//TEXTURESHADER
const char TextureShaderVert[]="\
varying vec2 texc; \
void main(void)\
{\
gl_Position=ftransform(); \
texc=vec2(gl_MultiTexCoord0); \
}\
";
const char TextureShaderFrag[]="\
varying vec2 texc; \
uniform sampler2D tex; \
void main(void)\
{\
gl_FragColor=texture2D(tex,texc); \
gl_FragColor[3]=1; \
}\
";
//////////////////////////////////////////////////////////////////////////
//TEXTURELIGHTSHADER
const char TextureLightShaderVert[]="\
varying vec2 texc; \
varying vec4 color; \
varying vec3 N,v; \
void main(void)\
{\
v=vec3(gl_ModelViewMatrix*gl_Vertex); \
N=-gl_NormalMatrix*gl_Normal; \
color=gl_Color; \
gl_Position=gl_ModelViewProjectionMatrix * gl_Vertex; \
texc=vec2(gl_MultiTexCoord0); \
}\
";
const char TextureLightShaderFrag[]="\
varying vec2 texc; \
uniform sampler2D tex; \
varying vec4 color; \
varying vec3 N,v; \
void main(void)\
{\
vec3 L=normalize(vec3(0,0,-100)-v); \
vec3 E=normalize(-v); \
vec3 R=-reflect(L,N); \
gl_FragColor=color * max(dot(N,L),0.0) + color * pow(max(dot(R,E),0.0),50.0); \
gl_FragColor = gl_FragColor * texture2D(tex,texc); \
gl_FragColor[3]=1; \
}\
";
//////////////////////////////////////////////////////////////////////////
//TEXCOORDSHADER
const char TexCoordShaderVert[]="\
varying vec2 texc; \
void main(void)\
{\
gl_Position=ftransform(); \
texc=vec2(gl_MultiTexCoord0); \
}\
";
const char TexCoordShaderFrag[]="\
varying vec2 texc; \
void main(void)\
{\
gl_FragColor=vec4(texc[0], texc[1], 0, 1); \
}\
";
//////////////////////////////////////////////////////////////////////////
//CUBEMAPSHADER
const char CubemapShaderVert[]="\
varying vec3 texc; \
void main(void)\
{\
gl_Position=ftransform(); \
texc=vec3(gl_MultiTexCoord0); \
}\
";
const char CubemapShaderFrag[]="\
varying vec3 texc; \
uniform samplerCube tex; \
void main(void)\
{\
gl_FragColor=textureCube(tex,texc); \
}\
";
void MakeShaders()
{
if (ZRM->IsExist("ColorShader")) return;
printf("Prepare general shaders...\n");
ZRM->Add(ShaderScript::LoadShaderMemory(ColorShaderVert,ColorShaderFrag,NULL),"ColorShader");
ZRM->Add(ShaderScript::LoadShaderMemory(DiffuseShaderVert,DiffuseShaderFrag,NULL),"DiffuseShader");
ZRM->Add(ShaderScript::LoadShaderMemory(LightShaderVert,LightShaderFrag,NULL),"LightShader");
ZRM->Add(ShaderScript::LoadShaderMemory(TextureShaderVert,TextureShaderFrag,NULL),"TextureShader");
ZRM->Add(ShaderScript::LoadShaderMemory(TextureLightShaderVert,TextureLightShaderFrag,NULL),"TextureLightShader");
ZRM->Add(ShaderScript::LoadShaderMemory(TexCoordShaderVert,TexCoordShaderFrag,NULL),"TexCoordShader");
ZRM->Add(ShaderScript::LoadShaderMemory(CubemapShaderVert,CubemapShaderFrag,NULL),"CubemapShader");
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Shader/ShaderSpecify.cpp
|
C++
|
gpl3
| 4,647
|
#include "TextureScript.hpp"
#include <Utility/Tools.hpp>
#include <Utility/FileTools.hpp>
#include <Utility/StringTools.hpp>
namespace zzz{
int TextureInt(const string &str)
{
string str1;
if (str[0]=='g' && str[1]=='l' && str[2]=='_') str1.assign(str.begin()+3,str.end());
else str1=str;
//internal
if (str1=="alpha") return GL_ALPHA;
if (str1=="alpha4") return GL_ALPHA4;
if (str1=="alpha8") return GL_ALPHA8;
if (str1=="alpha12") return GL_ALPHA12;
if (str1=="alpha16") return GL_ALPHA16;
if (str1=="luminance") return GL_LUMINANCE;
if (str1=="luminance4") return GL_LUMINANCE4;
if (str1=="luminance8") return GL_LUMINANCE8;
if (str1=="luminance12") return GL_LUMINANCE12;
if (str1=="luminance12") return GL_LUMINANCE16;
if (str1=="luminance_alpha") return GL_LUMINANCE_ALPHA;
if (str1=="luminance4_alpha4") return GL_LUMINANCE4_ALPHA4;
if (str1=="luminance6_alpha2") return GL_LUMINANCE6_ALPHA2;
if (str1=="luminance8_alpha8") return GL_LUMINANCE8_ALPHA8;
if (str1=="luminance12_alpha4") return GL_LUMINANCE12_ALPHA4;
if (str1=="luminance12_alpha12") return GL_LUMINANCE12_ALPHA12;
if (str1=="luminance16_alpha16") return GL_LUMINANCE16_ALPHA16;
if (str1=="intensity") return GL_INTENSITY;
if (str1=="intensity4") return GL_INTENSITY4;
if (str1=="intensity8") return GL_INTENSITY8;
if (str1=="intensity12") return GL_INTENSITY12;
if (str1=="intensity16") return GL_INTENSITY16;
if (str1=="r3_g3_b2") return GL_R3_G3_B2;
if (str1=="rgb") return GL_RGB;
if (str1=="rgb4") return GL_RGB4;
if (str1=="rgb5") return GL_RGB5;
if (str1=="rgb8") return GL_RGB8;
if (str1=="rgb10") return GL_RGB10;
if (str1=="rgb12") return GL_RGB12;
if (str1=="rgb16") return GL_RGB16;
if (str1=="rgba") return GL_RGBA;
if (str1=="rgba2") return GL_RGBA2;
if (str1=="rgba4") return GL_RGBA4;
if (str1=="rgb5_a1") return GL_RGB5_A1;
if (str1=="rgba8") return GL_RGBA8;
if (str1=="rgb10_a2") return GL_RGB10_A2;
if (str1=="rgba12") return GL_RGBA12;
if (str1=="rgba16") return GL_RGBA16;
if (str1=="rgba32f") return GL_RGBA32F_ARB;
if (str1=="rgb32f") return GL_RGB32F_ARB;
if (str1=="alpha32f") return GL_ALPHA32F_ARB;
if (str1=="intensity32f") return GL_INTENSITY32F_ARB;
if (str1=="luminance32f") return GL_LUMINANCE32F_ARB;
if (str1=="luminance_alpha32f") return GL_LUMINANCE_ALPHA32F_ARB;
if (str1=="rgba16f") return GL_RGBA16F_ARB;
if (str1=="rgb16f") return GL_RGB16F_ARB;
if (str1=="alpha16f") return GL_ALPHA16F_ARB;
if (str1=="intensity16f") return GL_INTENSITY16F_ARB;
if (str1=="luminance16f") return GL_LUMINANCE16F_ARB;
if (str1=="luminance_alpha16f") return GL_LUMINANCE_ALPHA16F_ARB;
if (str1=="depth_component") return GL_DEPTH_COMPONENT;
if (str1=="depth_component16") return GL_DEPTH_COMPONENT16;
if (str1=="depth_component24") return GL_DEPTH_COMPONENT24;
if (str1=="depth_component32") return GL_DEPTH_COMPONENT32;
//format
if (str1=="color_index") return GL_COLOR_INDEX;
if (str1=="red") return GL_RED;
if (str1=="blue") return GL_BLUE;
if (str1=="green") return GL_GREEN;
if (str1=="bgr") return GL_BGR;
if (str1=="bgra") return GL_BGRA;
//type
if (str1=="double") return GL_DOUBLE;
if (str1=="float") return GL_FLOAT;
if (str1=="unsigned_byte") return GL_UNSIGNED_BYTE;
if (str1=="byte") return GL_BYTE;
if (str1=="bitmap") return GL_BITMAP;
if (str1=="unsigned_short") return GL_UNSIGNED_SHORT;
if (str1=="short") return GL_SHORT;
if (str1=="unsigned_int") return GL_UNSIGNED_INT;
if (str1=="int") return GL_INT;
return 0;
}
inline bool TextureConst(const string &str, int &ret)
{
ret=TextureInt(str);
if (ret==0) return false;
else return true;
}
bool Script<Texture2D>::LoadFromMemory( istringstream &iss, Texture2D &t, const string &path )
{
string tmp;
int tmpi;
while(true)
{
iss>>tmp;
if (iss.fail()) break;
ToLow(tmp);
if (tmp=="f" || tmp=="file")
{
iss>>tmp;
tmp=PathFile(path,tmp);
t.Create(tmp.c_str());
}
else if (tmp=="s" || tmp=="size")
{
float width,height;
iss>>width>>height;
t.ChangeSize(width,height);
}
else if (tmp=="i" || tmp=="iformat" || tmp=="internalformat")
{
iss>>tmp;
if (TextureConst(tmp,tmpi)) t.ChangeInternalFormat(tmpi);
else printf("UNKNOWN CONSTANT: %s\n",tmp.c_str());
}
else
{
printf("UNKNOWN PARAMETER: %s\n",tmp.c_str());
return false;
}
}
return true;
}
bool Script<TextureCube>::LoadFromMemory( istringstream &iss, TextureCube &t, const string &path )
{
string tmp;
int tmpi;
while(true)
{
iss>>tmp;
if (iss.fail()) break;
ToLow(tmp);
if (tmp=="f" || tmp=="file")
{
iss>>tmp;
tmp=PathFile(path,tmp);
t.Create(tmp.c_str());
}
else if (tmp=="files")
{
string posx,posy,posz,negx,negy,negz;
iss>>posx;
posx=PathFile(path,posx);
iss>>negx;
negx=PathFile(path,negx);
iss>>posy;
posy=PathFile(path,posy);
iss>>negy;
negy=PathFile(path,negy);
iss>>posz;
posz=PathFile(path,posz);
iss>>negz;
negz=PathFile(path,negz);
t.Create(posx.c_str(),negx.c_str(),posy.c_str(),negy.c_str(),posz.c_str(),negz.c_str());
}
else if (tmp=="s" || tmp=="size")
{
float width,height;
iss>>width>>height;
t.ChangeSize(width,height);
}
else if (tmp=="c" || tmp=="cubesize")
{
float size;
iss>>size;
t.ChangeSize(size);
}
else if (tmp=="i" || tmp=="internalformat")
{
iss>>tmp;
if (TextureConst(tmp,tmpi)) t.ChangeInternalFormat(tmpi);
else printf("UNKNOWN CONSTANT: %s\n",tmp.c_str());
}
else
{
printf("UNKNOWN PARAMETER: %s\n",tmp.c_str());
return false;
}
}
return true;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Script/TextureScript.cpp
|
C++
|
gpl3
| 6,049
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "../Shader/Shader.hpp"
#include "Script.hpp"
namespace zzz {
//template<>
//static bool Script<Shader>::LoadFromMemory(istringstream &iss, Shader &shader, const string &path);
class ZGRAPHICS_CLASS ShaderScriptHelper {
public:
static bool LoadShaderFile(const char * vertexFile, const char * fragmentFile, const char * geometryFile, Shader *shader);
static bool LoadShaderMemory(const char * vertexMem,const char * fragmentMem, const char *geometryMen, Shader *shader);
static Shader *LoadShaderFile(const char * vertexFile, const char * fragmentFile, const char * geometryFile);
static Shader *LoadShaderMemory(const char * vertexMem,const char * fragmentMem, const char *geometryMen);
};
class ZGRAPHICS_CLASS ShaderScript : public Script<Shader>, public ShaderScriptHelper {
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Script/ShaderScript.hpp
|
C++
|
gpl3
| 849
|
#pragma once
#include "Script.hpp"
#include "../Light/Light.hpp"
namespace zzz{
static bool Script<Light>::LoadFromMemory(istringstream &mem, Light &l, const string &path);
typedef Script<Light> LightScript;
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Script/LightScript.hpp
|
C++
|
gpl3
| 211
|
#pragma once
#include "Script.hpp"
#include "../Texture/TextureSpecify.hpp"
namespace zzz{
static bool Script<Texture2D>::LoadFromMemory(istringstream &mem, Texture2D &t, const string &path);
typedef Script<Texture2D> Texture2DScript;
static bool Script<TextureCube>::LoadFromMemory(istringstream &mem, TextureCube &t, const string &path);
typedef Script<TextureCube> TextureCubeScript;
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Script/TextureScript.hpp
|
C++
|
gpl3
| 400
|
#include "ObjectScript.hpp"
#include <Utility/Tools.hpp>
namespace zzz{
bool Script<ObjMesh>::LoadFromMemory(istringstream &iss, TriMesh &o, const string &path)
{
float trans[3],rot[4],scaleto;
string tmp,filename;
bool normalize=true,createvbo=true,calnormal=false,translate=false,rotate=false,scale=false;
while(true)
{
iss>>tmp;
if (iss.fail()) break;
ToLow(tmp);
if (tmp=="f" || tmp=="file" || tmp=="filename")
{
iss>>tmp;
filename=PathFile(path,tmp);
}
// else if (tmp=="e" || tmp=="emi" || tmp=="emission" || tmp=="ems")
// {
// iss>>o.m_mat_emi[0]>>o.m_mat_emi[1]>>o.m_mat_emi[2]>>o.m_mat_emi[3];
// }
// else if (tmp=="a" || tmp=="amb" || tmp=="ambient" || tmp=="abt")
// {
// iss>>o.m_mat_amb[0]>>o.m_mat_amb[1]>>o.m_mat_amb[2]>>o.m_mat_amb[3];
// }
// else if (tmp=="d" || tmp=="dif" || tmp=="diffuse" || tmp=="dfs")
// {
// iss>>o.m_mat_dif[0]>>o.m_mat_dif[1]>>o.m_mat_dif[2]>>o.m_mat_dif[3];
// }
// else if (tmp=="s" || tmp=="spe" || tmp=="specular" || tmp=="spc")
// {
// iss>>o.m_mat_spe[0]>>o.m_mat_spe[1]>>o.m_mat_spe[2]>>o.m_mat_spe[3];
// }
// else if (tmp=="i" || tmp=="shi" || tmp=="shininess" || tmp=="shn")
// {
// iss>>o.m_mat_shi;
// }
else if (tmp=="normalize")
{
iss>>tmp;
ToLow(tmp);
if (tmp=="true" || tmp=="t" || tmp=="1") normalize=true;
else if (tmp=="false" || tmp=="f" || tmp=="0") normalize=false;
else
{
printf("UNKNOWN PARAMETER: %s\n",tmp.c_str());
return false;
}
}
else if (tmp=="createvbo")
{
iss>>tmp;
ToLow(tmp);
if (tmp=="true" || tmp=="t" || tmp=="1") createvbo=true;
else if (tmp=="false" || tmp=="f" || tmp=="0") createvbo=false;
else
{
printf("UNKNOWN PARAMETER: %s\n",tmp.c_str());
return false;
}
}
else if (tmp=="calnormal")
{
iss>>tmp;
ToLow(tmp);
if (tmp=="true" || tmp=="t" || tmp=="1") calnormal=true;
else if (tmp=="false" || tmp=="f" || tmp=="0") calnormal=false;
else
{
printf("UNKNOWN PARAMETER: %s\n",tmp.c_str());
return false;
}
}
else if (tmp=="translate" || tmp=="t")
{
iss>>trans[0]>>trans[1]>>trans[2];
translate=true;
}
else if (tmp=="rotate" || tmp=="r")
{
iss>>rot[0]>>rot[1]>>rot[2]>>rot[3];
rotate=true;
}
else if (tmp=="scale")
{
iss>>scaleto;
scale=true;
}
else
{
printf("UNKNOWN PARAMETER: %s\n",tmp.c_str());
return false;
}
}
printf("Load obj file: %s\n",filename.c_str());
if (!o.LoadFromFile(filename.c_str()))
{
printf("ERROR: Load Obj: %s\n",filename.c_str());
return false;
}
if (normalize) o.Normalize();
if (scale) o.Scale(scaleto);
if (rotate) o.Rotate(rot[0],rot[1],rot[2],rot[3]);
if (translate) o.Translate(trans[0],trans[1],trans[2]);
if (createvbo) o.CreateVBO();
if (calnormal) o.CalPosNormal();
return true;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Script/ObjectScript.cpp
|
C++
|
gpl3
| 3,062
|
#include "LightScript.hpp"
#include <Utility/StringTools.hpp>
namespace zzz{
bool Script<Light>::LoadFromMemory( istringstream &iss, Light &l, const string &path )
{
string tmp;
while(true)
{
iss>>tmp;
if (iss.fail()) break;
ToLow(tmp);
if (tmp=="p" || tmp=="pos" || tmp=="position" || tmp=="pst")
{
iss>>l.m_pos[0]>>l.m_pos[1]>>l.m_pos[2]>>l.m_pos[3];
memcpy(l.m_oripos,l.m_pos,sizeof(float)*4);
}
else if (tmp=="a" || tmp=="amb" || tmp=="ambient" || tmp=="abt")
{
iss>>l.m_amb[0]>>l.m_amb[1]>>l.m_amb[2]>>l.m_amb[3];
}
else if (tmp=="d" || tmp=="dif" || tmp=="diffuse" || tmp=="dfs")
{
iss>>l.m_dif[0]>>l.m_dif[1]>>l.m_dif[2]>>l.m_dif[3];
}
else if (tmp=="s" || tmp=="spe" || tmp=="specular" || tmp=="spc")
{
iss>>l.m_spe[0]>>l.m_spe[1]>>l.m_spe[2]>>l.m_spe[3];
}
else if (tmp=="l" || tmp=="lig" || tmp=="light" || tmp=="lit")
{
int x;
iss>>x;
if (x==0) l.m_mylight=GL_LIGHT0;
else if (x==1) l.m_mylight=GL_LIGHT1;
else if (x==2) l.m_mylight=GL_LIGHT2;
else if (x==3) l.m_mylight=GL_LIGHT3;
else if (x==4) l.m_mylight=GL_LIGHT4;
else if (x==5) l.m_mylight=GL_LIGHT5;
else if (x==6) l.m_mylight=GL_LIGHT6;
else if (x==7) l.m_mylight=GL_LIGHT7;
}
else
{
printf("UNKNOWN PARAMETER: %s\n",tmp.c_str());
return false;
}
}
l.m_inited=true;
return true;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Script/LightScript.cpp
|
C++
|
gpl3
| 1,452
|
#pragma once
#include "Script.hpp"
#include "../Mesh/Mesh.hpp"
namespace zzz{
static bool Script<TriMesh>::LoadFromMemory(istringstream &iss, TriMesh &o, const string &path);
typedef Script<TriMesh> ObjectScript;
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Script/ObjectScript.hpp
|
C++
|
gpl3
| 217
|
/********************************************************************
created: 2007/06/11
created: 11:6:2007 16:36
filename: d:\WZX\zzz\Render\Render\WZX\Render\Script\Script.hpp
file path: d:\WZX\zzz\Render\Render\WZX\Render\Script
file base: Script
file ext: hpp
author: WZX
purpose: zzz script load base class. should be used to load zzz script only,
since it removed comments and ignored letter cases which may not compatible with other script.
*********************************************************************/
#pragma once
#include <common.hpp>
#include <Utility/Tools.hpp>
#include <Utility/FileTools.hpp>
namespace zzz{
template <class T>class Script
{
public:
static bool LoadFromMemory(istringstream &mem, T &ret, const string &path);
static inline bool LoadFromMemory(const char *mem, T &ret, const string &path);
static inline bool LoadFromMemory(const string &mem, T &ret, const string &path);
static inline T* LoadFromMemory(const char *mem, const string &path);
static inline T* LoadFromMemory(const string &mem, const string &path);
static inline T* LoadFromMemory(const istringstream &mem, const string &path);
static inline bool LoadFromFile(const char *filename, T &ret);
static inline T* LoadFromFile(const char *filename);
string m_path;
};
template <class T>
T* zzz::Script<T>::LoadFromFile( const char *filename )
{
T *ret=new T;
if (LoadFromFile(filename,*ret))
return ret;
delete ret;
return 0;
}
template <class T>
bool zzz::Script<T>::LoadFromFile( const char *filename, T &ret )
{
printf("Load script: %s\n",filename);
string m_path=filename;
m_path=GetPath(m_path);
string str;
ReadFileToString(filename,str);
return LoadFromMemory(str,ret,m_path);
}
template <class T>
T* zzz::Script<T>::LoadFromMemory( const istringstream &mem, const string &path )
{
T* ret=new T;
if (LoadFromMemory(mem,*ret,path))
return ret;
delete ret;
return 0;
}
template <class T>
T* zzz::Script<T>::LoadFromMemory( const string &mem, const string &path )
{
T* ret=new T;
if (LoadFromMemory(mem,*ret,path))
return ret;
delete ret;
return 0;
}
template <class T>
T* zzz::Script<T>::LoadFromMemory( const char *mem, const string &path )
{
T* ret=new T;
if (LoadFromMemory(mem,*ret,path))
return ret;
delete ret;
return 0;
}
template <class T>
bool zzz::Script<T>::LoadFromMemory( const string &mem, T &ret, const string &path )
{
istringstream iss(RemoveComments_copy(mem));
return LoadFromMemory(iss,ret,path);
}
template <class T>
bool zzz::Script<T>::LoadFromMemory( const char *mem, T &ret, const string &path )
{
string str=mem;
return LoadFromMemory(str,ret,path);
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Script/Script.hpp
|
C++
|
gpl3
| 2,814
|
#include "ShaderScript.hpp"
#include <Utility/StringTools.hpp>
#include <Utility/FileTools.hpp>
#include <Utility/Log.hpp>
namespace zzz{
bool Script<Shader>::LoadFromMemory(istringstream &iss, Shader &shader, const string &path)
{
string FragmentShaderFilename="",VertexShaderFilename="";
string buf;
while(true)
{
iss>>buf;
if (iss.fail()) break;
ToLow(buf);
if (buf=="v" || buf=="vert" || buf=="vertfile" || buf=="vertfilename")
{
iss>>buf;
VertexShaderFilename=PathFile(path,buf);
}
else if (buf=="f" || buf=="frag" || buf=="fragfile" || buf=="fragfilename")
{
iss>>buf;
FragmentShaderFilename=PathFile(path,buf);
}
else if (buf=="f1" || buf=="float1")
{
UniformParam tmp;
tmp.type=UniformParam::F1;
iss>>tmp.name;
iss>>tmp.f1;
shader.UniformParamList.push_back(tmp);
}
else if (buf=="f2" || buf=="float2")
{
UniformParam tmp;
tmp.type=UniformParam::F2;
iss>>tmp.name;
iss>>tmp.f2[0]>>tmp.f2[1];
shader.UniformParamList.push_back(tmp);
}
else if (buf=="f3" || buf=="float3")
{
UniformParam tmp;
tmp.type=UniformParam::F3;
iss>>tmp.name;
iss>>tmp.f3[0]>>tmp.f3[1]>>tmp.f3[2];
shader.UniformParamList.push_back(tmp);
}
else if (buf=="f4" || buf=="float4")
{
UniformParam tmp;
tmp.type=UniformParam::F4;
iss>>tmp.name;
iss>>tmp.f4[0]>>tmp.f4[1]>>tmp.f4[2]>>tmp.f4[3];
shader.UniformParamList.push_back(tmp);
}
else if (buf=="i1" || buf=="int1")
{
UniformParam tmp;
tmp.type=UniformParam::I1;
iss>>tmp.name;
iss>>tmp.i1;
shader.UniformParamList.push_back(tmp);
}
else if (buf=="i2" || buf=="int2")
{
UniformParam tmp;
tmp.type=UniformParam::I2;
iss>>tmp.name;
iss>>tmp.i2[0]>>tmp.i2[1];
shader.UniformParamList.push_back(tmp);
}
else if (buf=="i3" || buf=="int3")
{
UniformParam tmp;
tmp.type=UniformParam::I3;
iss>>tmp.name;
iss>>tmp.i3[0]>>tmp.i3[1]>>tmp.i3[2];
shader.UniformParamList.push_back(tmp);
}
else if (buf=="i4" || buf=="int4")
{
UniformParam tmp;
tmp.type=UniformParam::I4;
iss>>tmp.name;
iss>>tmp.i4[0]>>tmp.i4[1]>>tmp.i4[2]>>tmp.i4[3];
shader.UniformParamList.push_back(tmp);
}
else if (buf=="m2" || buf=="mat2" || buf=="matrix2" || buf=="mat2x2" || buf=="matrix2x2")
{
UniformParam tmp;
tmp.type=UniformParam::M2;
iss>>tmp.name;
iss>>tmp.m2[0]>>tmp.m2[1]>>\
tmp.m2[2]>>tmp.m2[3];
shader.UniformParamList.push_back(tmp);
}
else if (buf=="m3" || buf=="mat3" || buf=="matrix3" || buf=="mat3x3" || buf=="matrix3x3")
{
UniformParam tmp;
tmp.type=UniformParam::M3;
iss>>tmp.name;
iss>>tmp.m3[0]>>tmp.m3[1]>>tmp.m3[2]>>\
tmp.m3[3]>>tmp.m3[4]>>tmp.m3[5]>>\
tmp.m3[6]>>tmp.m3[7]>>tmp.m3[8];
shader.UniformParamList.push_back(tmp);
}
else if (buf=="m4" || buf=="mat4" || buf=="matrix4" || buf=="mat4x4" || buf=="matrix4x4")
{
UniformParam tmp;
tmp.type=UniformParam::M4;
iss>>tmp.name;
iss>>tmp.m4[0]>>tmp.m4[1]>>tmp.m4[2]>>tmp.m4[3]>>\
tmp.m4[4]>>tmp.m4[5]>>tmp.m4[6]>>tmp.m4[7]>>\
tmp.m4[8]>>tmp.m4[9]>>tmp.m4[10]>>tmp.m4[11]>>\
tmp.m4[12]>>tmp.m4[13]>>tmp.m4[14]>>tmp.m4[15];
shader.UniformParamList.push_back(tmp);
}
else if (buf=="objrot" || buf=="objrotate" || buf=="objrotmat" || buf=="objrotatematrix")
{
UniformParam tmp;
tmp.type=UniformParam::OBJROT;
iss>>tmp.name;
shader.UniformParamList.push_back(tmp);
}
else if (buf=="objrottrans" || buf=="objrotatetranspose" || buf=="objrottransmat" || buf=="objrotatetransposematrix")
{
UniformParam tmp;
tmp.type=UniformParam::OBJROTTRANS;
iss>>tmp.name;
shader.UniformParamList.push_back(tmp);
}
else if (buf=="envrot" || buf=="envrotate" || buf=="envrotmat" || buf=="envrotatematrix")
{
UniformParam tmp;
tmp.type=UniformParam::ENVROT;
iss>>tmp.name;
shader.UniformParamList.push_back(tmp);
}
else if (buf=="envrottrans" || buf=="envrotatetranspose" || buf=="envrottransmat" || buf=="envrotatetransposematrix")
{
UniformParam tmp;
tmp.type=UniformParam::ENVROTTRANS;
iss>>tmp.name;
shader.UniformParamList.push_back(tmp);
}
else
{
printf("UNKNOWN PARAMETER: %s\n",buf.c_str());
return false;
}
}
return ShaderScriptHelper::LoadShaderFile(VertexShaderFilename.c_str(),FragmentShaderFilename.c_str(),0,&shader);
}
bool ShaderScriptHelper::LoadShaderFile(const char * vertexFile, const char * fragmentFile,const char * geometryFile, Shader *o)
{
zout<<"Load shader from file: ["<<vertexFile<<"],["<<fragmentFile<<"],["<<geometryFile<<"]...\n";
bool ret=o->LoadVertexFile(vertexFile)\
&& o->LoadFragmentFile(fragmentFile)\
&& o->LoadGeometryFile(geometryFile)\
&& o->Link();
return ret;
}
bool ShaderScriptHelper::LoadShaderMemory(const char * vertexMem, const char * fragmentMem, const char * geometryMem, Shader *o)
{
zout<<"Load shader from memory...\n";
bool ret=o->LoadVertexMemory(vertexMem)\
&& o->LoadFragmentMemory(fragmentMem)\
&& o->LoadGeometryMemory(geometryMem)\
&& o->Link();
return ret;
}
Shader *ShaderScriptHelper::LoadShaderFile(const char * vertexFile, const char * fragmentFile,const char * geometryFile)
{
zout<<"Load shader from file: ["<<vertexFile<<"],["<<fragmentFile<<"],["<<geometryFile<<"]...\n";
Shader *o = new Shader;
bool ret=o->LoadVertexFile(vertexFile)\
&& o->LoadFragmentFile(fragmentFile)\
&& o->LoadGeometryFile(geometryFile)\
&& o->Link();
if (ret) return o;
delete o;
return NULL;
}
Shader *ShaderScriptHelper::LoadShaderMemory(const char * vertexMem, const char * fragmentMem, const char * geometryMem)
{
zout<<"Load shader from memory...\n";
Shader *o = new Shader;
bool ret=o->LoadVertexMemory(vertexMem)\
&& o->LoadFragmentMemory(fragmentMem)\
&& o->LoadGeometryMemory(geometryMem)\
&& o->Link();
if (ret) return o;
delete o;
return NULL;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Resource/Script/ShaderScript.cpp
|
C++
|
gpl3
| 6,286
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "../Graphics/Graphics.hpp"
namespace zzz{
//////////////////////////////////////////////////////////////////////////
//There may be something wrong when using unsigned byte type or something like that
//since because of the memory align, sizeof(struct) may not be equal to sum(sizeof(element))
struct ZGRAPHICS_CLASS VBODescript {
VBODescript(GLenum arraytype,GLint size,GLenum type)
:ArrayType(arraytype),Size(size),Type(type),Loc(0){}
GLenum ArrayType; //GL_VERTEX_ARRAY or so on
GLint Size; //number of component per vertex
GLenum Type; //GL_FLOAT or so on
GLint Loc; //the location of attribute
int GetElementSize();
static VBODescript Vertex4f;
static VBODescript Vertex3f;
static VBODescript Vertex2f;
static VBODescript Vertex4d;
static VBODescript Vertex3d;
static VBODescript Vertex2d;
static VBODescript Color3f;
static VBODescript Color3ub;
static VBODescript Normalf;
static VBODescript Indexui;
static VBODescript EdgeFlag;
static VBODescript TexCoord3f;
static VBODescript TexCoord2f;
static VBODescript Attribute1ub;
static VBODescript Attribute2ub;
static VBODescript Attribute3ub;
static VBODescript Attribute4ub;
static VBODescript Attribute1i;
static VBODescript Attribute2i;
static VBODescript Attribute3i;
static VBODescript Attribute4i;
static VBODescript Attribute1f;
static VBODescript Attribute2f;
static VBODescript Attribute3f;
static VBODescript Attribute4f;
//ONLY the following three is available for GL_ELEMENT_ARRAY_BUFFER
static VBODescript Element3ub;
static VBODescript Element3us;
static VBODescript Element3ui;
static VBODescript Element4ui;
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/VBO/VBODescript.hpp
|
C++
|
gpl3
| 1,723
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "VBO.hpp"
namespace zzz{
class ZGRAPHICS_CLASS PBOHelper {
public:
static bool FBOToVBO(int x,int y,int width,int height,GLenum from, VBO &to);
static bool FBOToVBO(int x,int y,int width,int height,GLenum format,GLenum from, VBO &to);
static bool FBOToVBO(int x,int y,int width,int height,GLenum format,GLenum type, GLenum from, VBO &to);
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/VBO/PBOHelper.hpp
|
C++
|
gpl3
| 414
|
#include <common.hpp>
#include "VBODescript.hpp"
namespace zzz
{
VBODescript VBODescript::Vertex4f(GL_VERTEX_ARRAY,4,GL_FLOAT);
VBODescript VBODescript::Vertex3f(GL_VERTEX_ARRAY,3,GL_FLOAT);
VBODescript VBODescript::Vertex2f(GL_VERTEX_ARRAY,2,GL_FLOAT);
VBODescript VBODescript::Vertex4d(GL_VERTEX_ARRAY,4,GL_DOUBLE);
VBODescript VBODescript::Vertex3d(GL_VERTEX_ARRAY,3,GL_DOUBLE);
VBODescript VBODescript::Vertex2d(GL_VERTEX_ARRAY,2,GL_DOUBLE);
VBODescript VBODescript::Color3f(GL_COLOR_ARRAY,3,GL_FLOAT);
VBODescript VBODescript::Color3ub(GL_COLOR_ARRAY,3,GL_UNSIGNED_BYTE);
VBODescript VBODescript::Normalf(GL_NORMAL_ARRAY,3,GL_FLOAT);
VBODescript VBODescript::Indexui(GL_NORMAL_ARRAY,3,GL_UNSIGNED_INT);
VBODescript VBODescript::EdgeFlag(GL_EDGE_FLAG_ARRAY,1,GL_BOOL);
VBODescript VBODescript::TexCoord3f(GL_TEXTURE_COORD_ARRAY,3,GL_FLOAT);
VBODescript VBODescript::TexCoord2f(GL_TEXTURE_COORD_ARRAY,2,GL_FLOAT);
VBODescript VBODescript::Attribute1ub(0,1,GL_UNSIGNED_BYTE);
VBODescript VBODescript::Attribute2ub(0,2,GL_UNSIGNED_BYTE);
VBODescript VBODescript::Attribute3ub(0,3,GL_UNSIGNED_BYTE);
VBODescript VBODescript::Attribute4ub(0,4,GL_UNSIGNED_BYTE);
VBODescript VBODescript::Attribute1i(0,1,GL_INT);
VBODescript VBODescript::Attribute2i(0,2,GL_INT);
VBODescript VBODescript::Attribute3i(0,3,GL_INT);
VBODescript VBODescript::Attribute4i(0,4,GL_INT);
VBODescript VBODescript::Attribute1f(0,1,GL_FLOAT);
VBODescript VBODescript::Attribute2f(0,2,GL_FLOAT);
VBODescript VBODescript::Attribute3f(0,3,GL_FLOAT);
VBODescript VBODescript::Attribute4f(0,4,GL_FLOAT);
VBODescript VBODescript::Element3ub(0,3,GL_UNSIGNED_BYTE);
VBODescript VBODescript::Element3us(0,3,GL_UNSIGNED_SHORT);
VBODescript VBODescript::Element3ui(0,3,GL_UNSIGNED_INT);
VBODescript VBODescript::Element4ui(0,4,GL_UNSIGNED_INT);
int VBODescript::GetElementSize() {
int typesize;
switch(Type) {
case GL_FLOAT:
typesize=sizeof(GLfloat);
break;
case GL_UNSIGNED_BYTE:
typesize=sizeof(GLubyte);
break;
case GL_BYTE:
typesize=sizeof(GLbyte);
break;
case GL_UNSIGNED_INT:
typesize=sizeof(GLuint);
break;
case GL_INT:
typesize=sizeof(GLint);
break;
case GL_DOUBLE:
typesize=sizeof(GLdouble);
break;
case GL_SHORT:
typesize=sizeof(GLshort);
break;
case GL_UNSIGNED_SHORT:
typesize=sizeof(GLushort);
break;
case GL_BOOL:
typesize=sizeof(GLboolean);
break;
default:
printf("UNKNOWN type: %d\n",Type);
return 0;
}
return typesize*Size;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/VBO/VBODescript.cpp
|
C++
|
gpl3
| 2,588
|
#include "VBO.hpp"
#include <Graphics\OpenGLTools.hpp>
namespace zzz{
VBO::VBO() {
VBO_=0;
nelements_=0;
binded=false;
}
VBO::~VBO() {
if (binded)
Unbind();
if (VBO_!=0)
glDeleteBuffers(1,&VBO_);
}
bool VBO::Create(const void *data,int numOfElement,VBODescript &vbodesc,GLenum usage/*=GL_STATIC_DRAW*/) {
vector<VBODescript> tmp(1,vbodesc);
return Create(data,numOfElement,tmp,usage);
}
bool VBO::Create(const void *data,int numOfElement,vector<VBODescript> &vbodesc,GLenum usage/*=GL_STATIC_DRAW*/) {
if (VBO_==0)
glGenBuffers(1,&VBO_);
glBindBuffer(GL_ARRAY_BUFFER,VBO_);
if (ProcessVBODescript(vbodesc)==false)
return false;
glBufferData(GL_ARRAY_BUFFER,elementsize_*numOfElement,data,usage);
glBindBuffer(GL_ARRAY_BUFFER,0);
nelements_=numOfElement;
return true;
}
bool VBO::CreateEmpty(int numOfElement,VBODescript &vbodesc,GLenum usage) {
vector<VBODescript> tmp(1,vbodesc);
return CreateEmpty(numOfElement,tmp,usage);
}
bool VBO::CreateEmpty(int numOfElement,vector<VBODescript> &vbodesc,GLenum usage) {
if (VBO_==0)
glGenBuffers(1,&VBO_);
glBindBuffer(GL_ARRAY_BUFFER,VBO_);
if (ProcessVBODescript(vbodesc)==false)
return false;
glBufferData(GL_ARRAY_BUFFER,elementsize_*numOfElement,NULL,usage);
glBindBuffer(GL_ARRAY_BUFFER,0);
return true;
}
bool VBO::Bind() {
if (VBO_==0)
return false;
glBindBuffer(GL_ARRAY_BUFFER,VBO_);
CHECK_GL_ERROR();
int len=vbodesc_.size();
for (int i=0; i<len; i++) {
switch(vbodesc_[i].ArrayType) {
case GL_VERTEX_ARRAY:
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(vbodesc_[i].Size,vbodesc_[i].Type,0,offset_[i]);
CHECK_GL_ERROR();
break;
case GL_NORMAL_ARRAY:
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(vbodesc_[i].Type,0,offset_[i]);
CHECK_GL_ERROR();
break;
case GL_COLOR_ARRAY:
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(vbodesc_[i].Size,vbodesc_[i].Type,0,offset_[i]);
CHECK_GL_ERROR();
break;
case GL_INDEX_ARRAY:
glEnableClientState(GL_INDEX_ARRAY);
glIndexPointer(vbodesc_[i].Type,0,offset_[i]);
CHECK_GL_ERROR();
break;
case GL_TEXTURE_COORD_ARRAY:
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(vbodesc_[i].Size,vbodesc_[i].Type,0,offset_[i]);
CHECK_GL_ERROR();
break;
case GL_EDGE_FLAG_ARRAY:
glEnableClientState(GL_EDGE_FLAG_ARRAY);
glEdgeFlagPointer(0,offset_[i]);
CHECK_GL_ERROR();
break;
case 0:
glEnableVertexAttribArray(vbodesc_[i].Loc);
glVertexAttribPointer(vbodesc_[i].Loc,vbodesc_[i].Size,vbodesc_[i].Type,0,0,offset_[i]);
CHECK_GL_ERROR();
break;
default:
printf("UNKNOWN ArrayType: %d\n",vbodesc_[i].ArrayType);
return false;
}
}
glBindBuffer(GL_ARRAY_BUFFER,0);
CHECK_GL_ERROR();
binded=true;
return true;
}
bool VBO::Unbind() {
if (VBO_==0)
return false;
if (binded==false)
return false;
int len=vbodesc_.size();
for (int i=0; i<len; i++) {
switch(vbodesc_[i].ArrayType)
{
case GL_VERTEX_ARRAY:
glDisableClientState(GL_VERTEX_ARRAY);
break;
case GL_NORMAL_ARRAY:
glDisableClientState(GL_NORMAL_ARRAY);
break;
case GL_COLOR_ARRAY:
glDisableClientState(GL_COLOR_ARRAY);
break;
case GL_INDEX_ARRAY:
glDisableClientState(GL_INDEX_ARRAY);
break;
case GL_TEXTURE_COORD_ARRAY:
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
break;
case GL_EDGE_FLAG_ARRAY:
glDisableClientState(GL_EDGE_FLAG_ARRAY);
break;
case 0:
glDisableVertexAttribArray(vbodesc_[i].Loc);
break;
default:
printf("UNKNOWN ArrayType: %d\n",vbodesc_[i].ArrayType);
return false;
}
}
binded=false;
return true;
}
bool VBO::ProcessVBODescript(vector<VBODescript> &vbodesc) {
int len=vbodesc.size();
zint64 offset=0;
offset_.clear();
for (int i=0; i<len; i++)
{
offset_.push_back((GLvoid*)offset);
int typesize=vbodesc[i].GetElementSize();
offset+=typesize;
}
vbodesc_=vbodesc;
elementsize_=offset;
return true;
}
bool VBO::SetAttrbuiteLoc(zuint n,GLint loc) {
if (vbodesc_.size()<=n)
return false;
if (vbodesc_[n].ArrayType!=0)
return false;
vbodesc_[n].Loc=loc;
return true;
}
int VBO::GetElementNumber() {
return nelements_;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/VBO/VBO.cpp
|
C++
|
gpl3
| 4,438
|
#include "PBOHelper.hpp"
namespace zzz{
bool zzz::PBOHelper::FBOToVBO(int x,int y,int width, int height,GLenum from, VBO &to)
{
glReadBuffer(from);
glBindBuffer(GL_PIXEL_PACK_BUFFER_EXT, to.VBO_);
GLenum format=0,type;
if (to.vbodesc_[0].Size==1) format=GL_RED;
else if (to.vbodesc_[0].Size==2) return false;
else if (to.vbodesc_[0].Size==3) format=GL_RGB;
else if (to.vbodesc_[0].Size==4) format=GL_RGBA;
type=to.vbodesc_[0].Type;
glReadPixels(x,y,width,height,format,type,0);
glReadBuffer(GL_NONE);
glBindBuffer(GL_PIXEL_PACK_BUFFER_EXT,0);
return true;
}
bool PBOHelper::FBOToVBO(int x,int y,int width,int height,GLenum format,GLenum from, VBO &to)
{
glReadBuffer(from);
glBindBuffer(GL_PIXEL_PACK_BUFFER_EXT, to.VBO_);
GLenum type;
type=to.vbodesc_[0].Type;
glReadPixels(x,y,width,height,format,type,0);
glReadBuffer(GL_NONE);
glBindBuffer(GL_PIXEL_PACK_BUFFER_EXT,0);
return true;
}
bool PBOHelper::FBOToVBO(int x,int y,int width,int height,GLenum format,GLenum type, GLenum from, VBO &to)
{
glReadBuffer(from);
glBindBuffer(GL_PIXEL_PACK_BUFFER_EXT, to.VBO_);
glReadPixels(x,y,width,height,format,type,0);
glReadBuffer(GL_NONE);
glBindBuffer(GL_PIXEL_PACK_BUFFER_EXT,0);
return true;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/VBO/PBOHelper.cpp
|
C++
|
gpl3
| 1,288
|
#pragma once
#include <zGraphicsConfig.hpp>
#include <common.hpp>
#include "VBODescript.hpp"
#include <Utility/Uncopyable.hpp>
namespace zzz{
class ZGRAPHICS_CLASS VBO : public Uncopyable {
public:
VBO();
~VBO();
bool CreateEmpty(int numOfElement,VBODescript &vbodesc,GLenum usage);
bool CreateEmpty(int numOfElement,vector<VBODescript> &vbodesc,GLenum usage);
bool Create(const void *data,int numOfElement,VBODescript &vbodesc,GLenum usage=GL_STATIC_DRAW); //single data buffer
bool Create(const void *data,int numOfElement,vector<VBODescript> &vbodesc,GLenum usage=GL_STATIC_DRAW); //multiple data buffer
bool SetAttrbuiteLoc(zuint n,GLint loc);
bool Bind();
bool Unbind();
int GetElementNumber();
GLuint VBO_;
private:
bool binded;
bool ProcessVBODescript(vector<VBODescript> &vbodesc);
int nelements_;
GLsizeiptr elementsize_;
vector<VBODescript> vbodesc_;
vector<GLvoid *> offset_;
friend class PBOHelper;
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/VBO/VBO.hpp
|
C++
|
gpl3
| 955
|
#pragma once
#include <zGraphicsConfig.hpp>
#include <common.hpp>
#include "VBODescript.hpp"
#include <Utility/Uncopyable.hpp>
namespace zzz{
class ZGRAPHICS_CLASS ElementVBO : public Uncopyable {
public:
ElementVBO();
~ElementVBO();
bool Create(void *data,int numOfElement,VBODescript &vbodesc,GLenum usage=GL_STATIC_DRAW);
bool Bind();
bool Unbind();
GLuint VBO_;
private:
bool binded;
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/VBO/ElementVBO.hpp
|
C++
|
gpl3
| 409
|
#include "ElementVBO.hpp"
namespace zzz{
ElementVBO::ElementVBO()
{
VBO_=0;
binded=false;
}
ElementVBO::~ElementVBO()
{
if (binded)
Unbind();
if (VBO_!=0)
glDeleteBuffers(1,&VBO_);
}
bool ElementVBO::Create(void *data,int numOfElement,VBODescript &vbodesc,GLenum usage/*=GL_STATIC_DRAW*/)
{
if (VBO_==0)
glGenBuffers(1,&VBO_);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,VBO_);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,vbodesc.GetElementSize()*numOfElement,data,usage);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
return true;
}
bool ElementVBO::Bind()
{
if (VBO_==0)
return false;
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,VBO_);
binded=true;
return true;
}
bool ElementVBO::Unbind()
{
if (VBO_==0)
return false;
if (binded==false)
return false;
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
binded=false;
return true;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/VBO/ElementVBO.cpp
|
C++
|
gpl3
| 864
|
#pragma once
#include <zs.hpp>
#include "zOpenGLParser.hpp"
#include "zKeyMapParser.hpp"
#include "../Renderer/ArcBallRenderer.hpp"
namespace zzz{
class zRenderScript : public zScript
{
public:
zRenderScript();
void Init(ArcBallRenderer *renderer);
void OnChar( unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags );
ArcBallRenderer *m_renderer;
private:
void setConst();
void setParser();
void setObject();
zOpenGLParser *m_glParser;
zKeyMapParser *m_kmParser;
map<char,string> m_keymap;
friend zKeyMapParser;
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zRenderScript.hpp
|
C++
|
gpl3
| 573
|
#include <common.hpp>
#include "zOpenGLParser.hpp"
#include "../Resource/Shader/ShaderSpecify.hpp"
namespace zzz{
bool zzz::zOpenGLParser::Parse( const string &cmd1, int &id )
{
string cmd=ToLow_copy(cmd1);
if (cmd=="glenable") id=GLENABLE;
else if (cmd=="gldisable") id=GLDISABLE;
else if (cmd=="glclear") id=GLCLEAR;
else if (cmd=="glmatrixmode") id=GLMATRIXMODE;
else if (cmd=="glpushmatrix") id=GLPUSHMATRIX;
else if (cmd=="glpopmatrix") id=GLPOPMATRIX;
else if (cmd=="glloadidentity") id=GLLOADIDENTITY;
else if (cmd=="glviewport") id=GLVIEWPORT;
else if (cmd=="gltranslate") id=GLTRANSLATE;
else if (cmd=="glrotate") id=GLROTATE;
else if (cmd=="glpolygonmode") id=GLPOLYGONMODE;
else if (cmd=="gldepthfunc") id=GLDEPTHFUNC;
else if (cmd=="glcheckerror") id=GLCHECKERROR;
else if (cmd=="glcleardepth") id=GLCLEARDEPTH;
else if (cmd=="glclearcolor") id=GLCLEARCOLOR;
else if (cmd=="glbegin") id=GLBEGIN;
else if (cmd=="glend") id=GLEND;
else if (cmd=="glvertex") id=GLVERTEX;
else if (cmd=="glcolor") id=GLCOLOR;
else if (cmd=="glnormal") id=GLNORMAL;
else if (cmd=="gltexcoord") id=GLTEXCOORD;
else if (cmd=="placeobj") id=PLACEOBJ;
else if (cmd=="placeenv") id=PLACEENV;
else if (cmd=="gldrawbuffer") id=GLDRAWBUFFER;
else if (cmd=="drawcoordinate") id=DRAWCOORDINATE;
else if (cmd=="drawtriangle") id=DRAWTRIANGLE;
else if (cmd=="drawtexture") id=DRAWTEXTURE;
else return false;
return true;
}
bool zzz::zOpenGLParser::Do( int id, const vector<zParam*> ¶ms, zParam *ret )
{
double *d0,*d1,*d2,*d3;
int i0,i1,i2,i3;
switch(id)
{
case GLENABLE:
if (params.size()!=1) return false;
d0=zparam_cast<double*>(params[0]);
i0=(int)(*d0);
glEnable(i0);
break;
case GLDISABLE:
if (params.size()!=1) return false;
d0=zparam_cast<double*>(params[0]);
i0=(int)(*d0);
glDisable(i0);
break;
case GLCLEAR:
if (params.size()==0)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
else
{
int x=0;
for (zuint i=0;i<params.size();i++)
{
d0=zparam_cast<double*>(params[i]);
i0=(int)(*d0);
x=x|i0;
}
glClear(x);
}
break;
case GLMATRIXMODE:
if (params.size()!=1) return false;
d0=zparam_cast<double*>(params[0]);
i0=(int)(*d0);
glMatrixMode(i0);
break;
case GLPUSHMATRIX:
if (!params.empty()) return false;
glPushMatrix();
break;
case GLPOPMATRIX:
if (!params.empty()) return false;
glPopMatrix();
break;
case GLLOADIDENTITY:
if (!params.empty()) return false;
glLoadIdentity();
break;
case GLVIEWPORT:
if (params.size()!=4) return false;
d0=zparam_cast<double*>(params[0]);
i0=(int)(*d0);
d1=zparam_cast<double*>(params[1]);
i1=(int)(*d1);
d2=zparam_cast<double*>(params[2]);
i2=(int)(*d2);
d3=zparam_cast<double*>(params[3]);
i3=(int)(*d3);
glViewport(i0,i1,i2,i3);
break;
case GLTRANSLATE:
if (params.size()!=3) return false;
d0=zparam_cast<double*>(params[0]);
d1=zparam_cast<double*>(params[1]);
d2=zparam_cast<double*>(params[2]);
glTranslated(*d0,*d1,*d2);
break;
case GLROTATE:
if (params.size()!=4) return false;
d0=zparam_cast<double*>(params[0]);
d1=zparam_cast<double*>(params[1]);
d2=zparam_cast<double*>(params[2]);
d3=zparam_cast<double*>(params[3]);
glRotated(*d0,*d1,*d2,*d3);
break;
case GLPOLYGONMODE:
if (params.size()!=2) return false;
d0=zparam_cast<double*>(params[0]);
i0=(int)(*d0);
d1=zparam_cast<double*>(params[1]);
i1=(int)(*d1);
glPolygonMode(i0,i1);
break;
case GLDEPTHFUNC:
if (params.size()!=1) return false;
d0=zparam_cast<double*>(params[0]);
i0=(int)(*d0);
glDepthFunc(i0);
break;
case GLCHECKERROR:
if (params.size()>1) return false;
{
if (!params.empty())
{
d0=zparam_cast<double*>(params[0]);
i0=(int)(*d0);
}
cerr<<"CHECK OPENGL ERROR:";
GLenum glErr = glGetError();
if (glErr==GL_NO_ERROR)
if (!params.empty())
cerr<<"CHECK OPENGL ERROR "<<i0<<": NO ERROR\n";
else
cerr<<"CHECK OPENGL ERROR : NO ERROR\n";
else
if (!params.empty())
cerr<<"CHECK OPENGL ERROR :"<<i0<<"\n";
else
cerr<<"CHECK OPENGL ERROR :\n";
while (glErr != GL_NO_ERROR)
{
cerr << "GL Error #" << glErr << "(" ;
const GLubyte *x=gluErrorString(glErr);
if ( x != NULL) cerr<< x;
cerr << ")\n";
glErr = glGetError();
}
}
break;
case GLCLEARDEPTH:
if (params.size()!=1) return false;
d0=zparam_cast<double*>(params[0]);
glClearDepth(*d0);
break;
case GLCLEARCOLOR:
if (params.size()!=4) return false;
d0=zparam_cast<double*>(params[0]);
d1=zparam_cast<double*>(params[1]);
d2=zparam_cast<double*>(params[2]);
d3=zparam_cast<double*>(params[3]);
glClearColor(*d0,*d1,*d2,*d3);
break;
case GLBEGIN:
if (params.size()!=1) return false;
d0=zparam_cast<double*>(params[0]);
i0=(int)(*d0);
glBegin(i0);
break;
case GLEND:
if (!params.empty()) return false;
glEnd();
break;
case GLCOLOR:
if (params.size()==3)
{
d0=zparam_cast<double*>(params[0]);
d1=zparam_cast<double*>(params[1]);
d2=zparam_cast<double*>(params[2]);
glColor3d(*d0,*d1,*d2);
}
else if (params.size()==4)
{
d0=zparam_cast<double*>(params[0]);
d1=zparam_cast<double*>(params[1]);
d2=zparam_cast<double*>(params[2]);
d3=zparam_cast<double*>(params[3]);
glColor4d(*d0,*d1,*d2,*d3);
}
else return false;
break;
case GLVERTEX:
if (params.size()==2)
{
d0=zparam_cast<double*>(params[0]);
d1=zparam_cast<double*>(params[1]);
glVertex2d(*d0,*d1);
}
else if (params.size()==3)
{
d0=zparam_cast<double*>(params[0]);
d1=zparam_cast<double*>(params[1]);
d2=zparam_cast<double*>(params[2]);
glVertex3d(*d0,*d1,*d2);
}
else if (params.size()==4)
{
d0=zparam_cast<double*>(params[0]);
d1=zparam_cast<double*>(params[1]);
d2=zparam_cast<double*>(params[2]);
d3=zparam_cast<double*>(params[3]);
glVertex4d(*d0,*d1,*d2,*d3);
}
else return false;
break;
case GLNORMAL:
if (params.size()!=3) return false;
d0=zparam_cast<double*>(params[0]);
d1=zparam_cast<double*>(params[1]);
d2=zparam_cast<double*>(params[2]);
glNormal3d(*d0,*d1,*d2);
break;
case GLTEXCOORD:
if (params.size()==2)
{
d0=zparam_cast<double*>(params[0]);
d1=zparam_cast<double*>(params[1]);
glTexCoord2d(*d0,*d1);
}
else if (params.size()==3)
{
d0=zparam_cast<double*>(params[0]);
d1=zparam_cast<double*>(params[1]);
d2=zparam_cast<double*>(params[2]);
glTexCoord3d(*d0,*d1,*d2);
}
else if (params.size()==4)
{
d0=zparam_cast<double*>(params[0]);
d1=zparam_cast<double*>(params[1]);
d2=zparam_cast<double*>(params[2]);
d3=zparam_cast<double*>(params[3]);
glTexCoord4d(*d0,*d1,*d2,*d3);
}
else return false;
break;
case GLDRAWBUFFER:
if (params.size()!=1) return false;
d0=zparam_cast<double>(params[0]);
i0=(int)(*d0);
glDrawBuffer(i0);
break;
case PLACEOBJ:
glLoadIdentity();
m_renderer->camera_.ApplyGL();
m_renderer->m_pCurObjArcBall->ApplyGL();
break;
case PLACEENV:
glLoadIdentity();
m_renderer->camera_.ApplyGL();
m_renderer->m_pCurEnvArcBall->ApplyGL();
break;
case DRAWCOORDINATE:
if (params.size()!=1) return false;
d0=zparam_cast<double>(params[0]);
ColorShader.Begin();
glBegin(GL_LINES);
glColor4d(1.0,0.0,0.0,1.0);glVertex3d(0,0,0);glVertex3d(*d0,0,0);
glColor4d(0.0,1.0,0.0,1.0);glVertex3d(0,0,0);glVertex3d(0,*d0,0);
glColor4d(0.0,0.0,1.0,1.0);glVertex3d(0,0,0);glVertex3d(0,0,*d0);
glEnd();
ColorShader.End();
break;
case DRAWTRIANGLE:
if (params.size()!=1) return false;
d0=zparam_cast<double>(params[0]);
ColorShader.Begin();
glBegin(GL_TRIANGLES);
glColor3d(1.0,0.0,0.0); glVertex3d( 0.0, *d0, 0.0);
glColor3d(0.0,1.0,0.0); glVertex3d(-*d0,-*d0, 0.0);
glColor3d(0.0,0.0,1.0); glVertex3d( *d0,-*d0, 0.0);
glEnd();
ColorShader.End();
break;
case DRAWTEXTURE:
if (params.size()!=1) return false;
d0=zparam_cast<double>(params[0]);
TextureShader.Begin();
TextureShader.SetUniform1i("tex",0);
glBegin(GL_QUADS);
glTexCoord2d(0,0); glVertex3d(-*d0,*d0,0);
glTexCoord2d(0,1); glVertex3d(-*d0,-*d0,0);
glTexCoord2d(1,1); glVertex3d(*d0,-*d0,0);
glTexCoord2d(1,0); glVertex3d(*d0,*d0,0);
glEnd();
TextureShader.End();
break;
default:
return false;
}
return true;
}
void zOpenGLParser::Init( zScript *zs )
{
zs->SetVariable("GL_DEPTH_BUFFER_BIT",GL_DEPTH_BUFFER_BIT);
zs->SetVariable("GL_COLOR_BUFFER_BIT",GL_COLOR_BUFFER_BIT);
zs->SetVariable("GL_STENCIL_BUFFER_BIT",GL_STENCIL_BUFFER_BIT);
zs->SetVariable("GL_DEPTH_TEST",GL_DEPTH_TEST);
zs->SetVariable("GL_PROJECTION",GL_PROJECTION);
zs->SetVariable("GL_MODELVIEW",GL_MODELVIEW);
zs->SetVariable("GL_TEXTURE0",GL_TEXTURE0);
zs->SetVariable("GL_TEXTURE1",GL_TEXTURE1);
zs->SetVariable("GL_TEXTURE2",GL_TEXTURE2);
zs->SetVariable("GL_TEXTURE3",GL_TEXTURE3);
zs->SetVariable("GL_TEXTURE4",GL_TEXTURE4);
zs->SetVariable("GL_TEXTURE5",GL_TEXTURE5);
zs->SetVariable("GL_TEXTURE6",GL_TEXTURE6);
zs->SetVariable("GL_TEXTURE7",GL_TEXTURE7);
zs->SetVariable("GL_TEXTURE8",GL_TEXTURE8);
zs->SetVariable("GL_TEXTURE9",GL_TEXTURE9);
zs->SetVariable("GL_TEXTURE10",GL_TEXTURE10);
zs->SetVariable("GL_TEXTURE11",GL_TEXTURE11);
zs->SetVariable("GL_TEXTURE12",GL_TEXTURE12);
zs->SetVariable("GL_TEXTURE13",GL_TEXTURE13);
zs->SetVariable("GL_TEXTURE14",GL_TEXTURE14);
zs->SetVariable("GL_TEXTURE15",GL_TEXTURE15);
zs->SetVariable("GL_TEXTURE16",GL_TEXTURE16);
zs->SetVariable("GL_TEXTURE17",GL_TEXTURE17);
zs->SetVariable("GL_TEXTURE18",GL_TEXTURE18);
zs->SetVariable("GL_TEXTURE19",GL_TEXTURE19);
zs->SetVariable("GL_TEXTURE20",GL_TEXTURE20);
zs->SetVariable("GL_TEXTURE21",GL_TEXTURE21);
zs->SetVariable("GL_TEXTURE22",GL_TEXTURE22);
zs->SetVariable("GL_TEXTURE23",GL_TEXTURE23);
zs->SetVariable("GL_TEXTURE24",GL_TEXTURE24);
zs->SetVariable("GL_TEXTURE25",GL_TEXTURE25);
zs->SetVariable("GL_TEXTURE26",GL_TEXTURE26);
zs->SetVariable("GL_TEXTURE27",GL_TEXTURE27);
zs->SetVariable("GL_TEXTURE28",GL_TEXTURE28);
zs->SetVariable("GL_TEXTURE29",GL_TEXTURE29);
zs->SetVariable("GL_TEXTURE30",GL_TEXTURE30);
zs->SetVariable("GL_TEXTURE31",GL_TEXTURE31);
zs->SetVariable("GL_LIGHT0",GL_LIGHT0);
zs->SetVariable("GL_LIGHT1",GL_LIGHT1);
zs->SetVariable("GL_LIGHT2",GL_LIGHT2);
zs->SetVariable("GL_LIGHT3",GL_LIGHT3);
zs->SetVariable("GL_LIGHT4",GL_LIGHT4);
zs->SetVariable("GL_LIGHT5",GL_LIGHT5);
zs->SetVariable("GL_LIGHT6",GL_LIGHT6);
zs->SetVariable("GL_LIGHT7",GL_LIGHT7);
zs->SetVariable("GL_LIGHTING",GL_LIGHTING);
zs->SetVariable("GL_MULTISAMPLE",GL_MULTISAMPLE);
zs->SetVariable("GL_COLOR_ATTACHMENT0_EXT",GL_COLOR_ATTACHMENT0_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT1_EXT",GL_COLOR_ATTACHMENT1_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT2_EXT",GL_COLOR_ATTACHMENT2_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT3_EXT",GL_COLOR_ATTACHMENT3_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT4_EXT",GL_COLOR_ATTACHMENT4_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT5_EXT",GL_COLOR_ATTACHMENT5_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT6_EXT",GL_COLOR_ATTACHMENT6_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT7_EXT",GL_COLOR_ATTACHMENT7_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT8_EXT",GL_COLOR_ATTACHMENT8_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT9_EXT",GL_COLOR_ATTACHMENT9_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT10_EXT",GL_COLOR_ATTACHMENT10_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT11_EXT",GL_COLOR_ATTACHMENT11_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT12_EXT",GL_COLOR_ATTACHMENT12_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT13_EXT",GL_COLOR_ATTACHMENT13_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT14_EXT",GL_COLOR_ATTACHMENT14_EXT);
zs->SetVariable("GL_COLOR_ATTACHMENT15_EXT",GL_COLOR_ATTACHMENT15_EXT);
zs->SetVariable("GL_DEPTH_ATTACHMENT_EXT",GL_DEPTH_ATTACHMENT_EXT);
zs->SetVariable("GL_STENCIL_ATTACHMENT_EXT",GL_STENCIL_ATTACHMENT_EXT);
zs->SetVariable("GL_FRONT",GL_FRONT);
zs->SetVariable("GL_BACK",GL_BACK);
zs->SetVariable("GL_FRONT_AND_BACK",GL_FRONT_AND_BACK);
zs->SetVariable("GL_POINT",GL_POINT);
zs->SetVariable("GL_LINE",GL_LINE);
zs->SetVariable("GL_FILL",GL_FILL);
zs->SetVariable("GL_NEVER",GL_NEVER);
zs->SetVariable("GL_LESS",GL_LESS);
zs->SetVariable("GL_LEQUAL",GL_LEQUAL);
zs->SetVariable("GL_EQUAL",GL_EQUAL);
zs->SetVariable("GL_GREATER",GL_GREATER);
zs->SetVariable("GL_NOTEQUAL",GL_NOTEQUAL);
zs->SetVariable("GL_GEQUAL",GL_GEQUAL);
zs->SetVariable("GL_ALWAYS",GL_ALWAYS);
zs->SetVariable("GL_POINTS",GL_POINTS);
zs->SetVariable("GL_LINES",GL_LINES);
zs->SetVariable("GL_LINE_LOOP",GL_LINE_LOOP);
zs->SetVariable("GL_LINE_STRIP",GL_LINE_STRIP);
zs->SetVariable("GL_TRIANGLES",GL_TRIANGLES);
zs->SetVariable("GL_TRIANGLE_STRIP",GL_TRIANGLE_STRIP);
zs->SetVariable("GL_TRIANGLE_FAN",GL_TRIANGLE_FAN);
zs->SetVariable("GL_QUADS",GL_QUADS);
zs->SetVariable("GL_QUAD_STRIP",GL_QUAD_STRIP);
zs->SetVariable("GL_POLYGON",GL_POLYGON);
}
void zOpenGLParser::SetRenderer( ArcBallRenderer *renderer )
{
m_renderer=renderer;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zOpenGLParser.cpp
|
C++
|
gpl3
| 14,193
|
#pragma once
#include <zs.hpp>
#include "../Resource/Texture/Texture2D.hpp"
namespace zzz{
typedef zObject<Texture2D> zObjectTexture2D;
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zObjectTexture2D.hpp
|
C++
|
gpl3
| 145
|
#pragma once
#include <zs.hpp>
#include "../Resource/Texture/TextureCube.hpp"
namespace zzz{
typedef zObject<TextureCube> zObjectTextureCube;
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zObjectTextureCube.hpp
|
C++
|
gpl3
| 150
|
#pragma once
namespace zzz{
class zObjectTextureHelper
{
public:
static int TextureInt( const string &str )
{
string str1;
if (str[0]=='g' && str[1]=='l' && str[2]=='_') str1.assign(str.begin()+3,str.end());
else str1=str;
//internal
if (str1=="alpha") return GL_ALPHA;
if (str1=="alpha4") return GL_ALPHA4;
if (str1=="alpha8") return GL_ALPHA8;
if (str1=="alpha12") return GL_ALPHA12;
if (str1=="alpha16") return GL_ALPHA16;
if (str1=="luminance") return GL_LUMINANCE;
if (str1=="luminance4") return GL_LUMINANCE4;
if (str1=="luminance8") return GL_LUMINANCE8;
if (str1=="luminance12") return GL_LUMINANCE12;
if (str1=="luminance12") return GL_LUMINANCE16;
if (str1=="luminance_alpha") return GL_LUMINANCE_ALPHA;
if (str1=="luminance4_alpha4") return GL_LUMINANCE4_ALPHA4;
if (str1=="luminance6_alpha2") return GL_LUMINANCE6_ALPHA2;
if (str1=="luminance8_alpha8") return GL_LUMINANCE8_ALPHA8;
if (str1=="luminance12_alpha4") return GL_LUMINANCE12_ALPHA4;
if (str1=="luminance12_alpha12") return GL_LUMINANCE12_ALPHA12;
if (str1=="luminance16_alpha16") return GL_LUMINANCE16_ALPHA16;
if (str1=="intensity") return GL_INTENSITY;
if (str1=="intensity4") return GL_INTENSITY4;
if (str1=="intensity8") return GL_INTENSITY8;
if (str1=="intensity12") return GL_INTENSITY12;
if (str1=="intensity16") return GL_INTENSITY16;
if (str1=="r3_g3_b2") return GL_R3_G3_B2;
if (str1=="rgb") return GL_RGB;
if (str1=="rgb4") return GL_RGB4;
if (str1=="rgb5") return GL_RGB5;
if (str1=="rgb8") return GL_RGB8;
if (str1=="rgb10") return GL_RGB10;
if (str1=="rgb12") return GL_RGB12;
if (str1=="rgb16") return GL_RGB16;
if (str1=="rgba") return GL_RGBA;
if (str1=="rgba2") return GL_RGBA2;
if (str1=="rgba4") return GL_RGBA4;
if (str1=="rgb5_a1") return GL_RGB5_A1;
if (str1=="rgba8") return GL_RGBA8;
if (str1=="rgb10_a2") return GL_RGB10_A2;
if (str1=="rgba12") return GL_RGBA12;
if (str1=="rgba16") return GL_RGBA16;
if (str1=="rgba32f") return GL_RGBA32F_ARB;
if (str1=="rgb32f") return GL_RGB32F_ARB;
if (str1=="alpha32f") return GL_ALPHA32F_ARB;
if (str1=="intensity32f") return GL_INTENSITY32F_ARB;
if (str1=="luminance32f") return GL_LUMINANCE32F_ARB;
if (str1=="luminance_alpha32f") return GL_LUMINANCE_ALPHA32F_ARB;
if (str1=="rgba16f") return GL_RGBA16F_ARB;
if (str1=="rgb16f") return GL_RGB16F_ARB;
if (str1=="alpha16f") return GL_ALPHA16F_ARB;
if (str1=="intensity16f") return GL_INTENSITY16F_ARB;
if (str1=="luminance16f") return GL_LUMINANCE16F_ARB;
if (str1=="luminance_alpha16f") return GL_LUMINANCE_ALPHA16F_ARB;
if (str1=="depth_component") return GL_DEPTH_COMPONENT;
if (str1=="depth_component16") return GL_DEPTH_COMPONENT16;
if (str1=="depth_component24") return GL_DEPTH_COMPONENT24;
if (str1=="depth_component32") return GL_DEPTH_COMPONENT32;
//format
if (str1=="color_index") return GL_COLOR_INDEX;
if (str1=="red") return GL_RED;
if (str1=="blue") return GL_BLUE;
if (str1=="green") return GL_GREEN;
if (str1=="bgr") return GL_BGR;
if (str1=="bgra") return GL_BGRA;
//type
if (str1=="double") return GL_DOUBLE;
if (str1=="float") return GL_FLOAT;
if (str1=="unsigned_byte") return GL_UNSIGNED_BYTE;
if (str1=="byte") return GL_BYTE;
if (str1=="bitmap") return GL_BITMAP;
if (str1=="unsigned_short") return GL_UNSIGNED_SHORT;
if (str1=="short") return GL_SHORT;
if (str1=="unsigned_int") return GL_UNSIGNED_INT;
if (str1=="int") return GL_INT;
return 0;
}
static bool TextureConst(const string &str, int &ret)
{
ret=TextureInt(str);
if (ret==0) return false;
else return true;
}
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zObjectTextureHelper.hpp
|
C++
|
gpl3
| 3,821
|
#include "zObjectTexture2D.hpp"
#include "zObjectTextureHelper.hpp"
namespace zzz{
bool zObjectTexture2D::LoadFromMemory(istringstream &iss, const string &path)
{
Texture2D *t=(Texture2D*)m_obj;
string tmp;
int tmpi;
while(true)
{
iss>>tmp;
if (iss.fail()) break;
ToLow(tmp);
if (tmp=="f" || tmp=="file")
{
iss>>tmp;
tmp=PathFile(path,tmp);
t->Create(tmp.c_str());
}
else if (tmp=="s" || tmp=="size")
{
float width,height;
iss>>width>>height;
t->ChangeSize(width,height);
}
else if (tmp=="i" || tmp=="iformat" || tmp=="internalformat")
{
iss>>tmp;
if (zObjectTextureHelper::TextureConst(tmp,tmpi)) t->ChangeInternalFormat(tmpi);
else printf("UNKNOWN CONSTANT: %s\n",tmp.c_str());
}
else
{
printf("UNKNOWN PARAMETER: %s\n",tmp.c_str());
return false;
}
}
return true;
}
bool zObjectTexture2D::Do(const string &cmd1, const vector<zParam*> ¶m, zParam *ret)
{
Texture2D *obj=(Texture2D*)m_obj;
string cmd=ToLow_copy(cmd1);
if (cmd=="bind")
{
double *d0=zparam_cast<double*>(param[0]);
int i0=(int)(*d0);
obj->Bind(GL_TEXTURE0+i0);
}
else if (cmd=="disable")
{
double *d0=zparam_cast<double*>(param[0]);
int i0=(int)(*d0);
obj->Disable(GL_TEXTURE0+i0);
}
else if (cmd=="disableall")
obj->DisableAll();
else if (cmd=="changesize")
{
double *d0=zparam_cast<double*>(param[0]);
double *d1=zparam_cast<double*>(param[1]);
obj->ChangeSize(*d0,*d1);
}
else return false;
return true;
}
bool zObjectTexture2D::IsTrue()
{
return true;
}
string zObjectTexture2D::ToString()
{
return string("Texture2D");
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zObjectTexture2D.cpp
|
C++
|
gpl3
| 1,793
|
#pragma once
#include <zs.hpp>
#include "../Resource/Shader/Shader.hpp"
namespace zzz{
class ShaderLoader
{
public:
static bool LoadShaderFile(const char* vertexFile, const char* fragmentFile,Shader *shader);
static bool LoadShaderMemory(const char* vertexMem,const char* fragmentMem,Shader *shader);
};
typedef zObject<Shader> zObjectShader;
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zObjectShader.hpp
|
C++
|
gpl3
| 365
|
#include "zKeyMapParser.hpp"
#include "zRenderScript.hpp"
namespace zzz{
bool zKeyMapParser::Parse( const string &cmd, int &id )
{
string cmd1=ToLow_copy(cmd);
if (cmd1=="keymap")
{
id=0;
return true;
}
return false;
}
bool zKeyMapParser::Do( int id, const vector<zParam*> ¶ms, zParam *ret )
{
if (id==0)
{
if (params.size()!=2) return false;
string *str=zparam_cast<string*>(params[0]);
if (str==0) return false;
if (params[1]->m_func.empty()) return false;
m_zrs->m_keymap[str->at(0)]=params[1]->m_func;
return true;
}
return false;
}
void zKeyMapParser::SetZRS( zRenderScript *zrs )
{
m_zrs=zrs;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zKeyMapParser.cpp
|
C++
|
gpl3
| 702
|
#include "zObjectShader.hpp"
#include "zRenderScript.hpp"
namespace zzz{
bool ShaderLoader::LoadShaderFile( const char* vertexFile, const char* fragmentFile, Shader *o)
{
bool ret=o->LoadVertexFile(vertexFile) && o->LoadFragmentFile(fragmentFile) && o->Link();
return ret;
}
bool ShaderLoader::LoadShaderMemory( const char* vertexMem, const char* fragmentMem, Shader *o)
{
bool ret=o->LoadVertexMemory(vertexMem) && o->LoadFragmentMemory(fragmentMem) && o->Link();
return ret;
}
bool zObjectShader::LoadFromMemory(istringstream &iss, const string &path)
{
Shader *shader=(Shader*)m_obj;
shader->Clear();
string FragmentShaderFilename="",VertexShaderFilename="";
string buf;
while(true)
{
iss>>buf;
if (iss.fail()) break;
ToLow(buf);
if (buf=="v" || buf=="vert" || buf=="vertfile" || buf=="vertfilename")
{
iss>>buf;
VertexShaderFilename=PathFile(path,buf);
}
else if (buf=="f" || buf=="frag" || buf=="fragfile" || buf=="fragfilename")
{
iss>>buf;
FragmentShaderFilename=PathFile(path,buf);
}
else if (buf=="f1" || buf=="float1")
{
UniformParam tmp;
tmp.type=UniformParam::F1;
iss>>tmp.name;
iss>>tmp.f1;
shader->UniformParamList.push_back(tmp);
}
else if (buf=="f2" || buf=="float2")
{
UniformParam tmp;
tmp.type=UniformParam::F2;
iss>>tmp.name;
iss>>tmp.f2[0]>>tmp.f2[1];
shader->UniformParamList.push_back(tmp);
}
else if (buf=="f3" || buf=="float3")
{
UniformParam tmp;
tmp.type=UniformParam::F3;
iss>>tmp.name;
iss>>tmp.f3[0]>>tmp.f3[1]>>tmp.f3[2];
shader->UniformParamList.push_back(tmp);
}
else if (buf=="f4" || buf=="float4")
{
UniformParam tmp;
tmp.type=UniformParam::F4;
iss>>tmp.name;
iss>>tmp.f4[0]>>tmp.f4[1]>>tmp.f4[2]>>tmp.f4[3];
shader->UniformParamList.push_back(tmp);
}
else if (buf=="i1" || buf=="int1")
{
UniformParam tmp;
tmp.type=UniformParam::I1;
iss>>tmp.name;
iss>>tmp.i1;
shader->UniformParamList.push_back(tmp);
}
else if (buf=="i2" || buf=="int2")
{
UniformParam tmp;
tmp.type=UniformParam::I2;
iss>>tmp.name;
iss>>tmp.i2[0]>>tmp.i2[1];
shader->UniformParamList.push_back(tmp);
}
else if (buf=="i3" || buf=="int3")
{
UniformParam tmp;
tmp.type=UniformParam::I3;
iss>>tmp.name;
iss>>tmp.i3[0]>>tmp.i3[1]>>tmp.i3[2];
shader->UniformParamList.push_back(tmp);
}
else if (buf=="i4" || buf=="int4")
{
UniformParam tmp;
tmp.type=UniformParam::I4;
iss>>tmp.name;
iss>>tmp.i4[0]>>tmp.i4[1]>>tmp.i4[2]>>tmp.i4[3];
shader->UniformParamList.push_back(tmp);
}
else if (buf=="m2" || buf=="mat2" || buf=="matrix2" || buf=="mat2x2" || buf=="matrix2x2")
{
UniformParam tmp;
tmp.type=UniformParam::M2;
iss>>tmp.name;
iss>>tmp.m2[0]>>tmp.m2[1]>>\
tmp.m2[2]>>tmp.m2[3];
shader->UniformParamList.push_back(tmp);
}
else if (buf=="m3" || buf=="mat3" || buf=="matrix3" || buf=="mat3x3" || buf=="matrix3x3")
{
UniformParam tmp;
tmp.type=UniformParam::M3;
iss>>tmp.name;
iss>>tmp.m3[0]>>tmp.m3[1]>>tmp.m3[2]>>\
tmp.m3[3]>>tmp.m3[4]>>tmp.m3[5]>>\
tmp.m3[6]>>tmp.m3[7]>>tmp.m3[8];
shader->UniformParamList.push_back(tmp);
}
else if (buf=="m4" || buf=="mat4" || buf=="matrix4" || buf=="mat4x4" || buf=="matrix4x4")
{
UniformParam tmp;
tmp.type=UniformParam::M4;
iss>>tmp.name;
iss>>tmp.m4[0]>>tmp.m4[1]>>tmp.m4[2]>>tmp.m4[3]>>\
tmp.m4[4]>>tmp.m4[5]>>tmp.m4[6]>>tmp.m4[7]>>\
tmp.m4[8]>>tmp.m4[9]>>tmp.m4[10]>>tmp.m4[11]>>\
tmp.m4[12]>>tmp.m4[13]>>tmp.m4[14]>>tmp.m4[15];
shader->UniformParamList.push_back(tmp);
}
else if (buf=="objrot" || buf=="objrotate" || buf=="objrotmat" || buf=="objrotatematrix")
{
UniformParam tmp;
tmp.type=UniformParam::OBJROT;
iss>>tmp.name;
shader->UniformParamList.push_back(tmp);
}
else if (buf=="objrottrans" || buf=="objrotatetranspose" || buf=="objrottransmat" || buf=="objrotatetransposematrix")
{
UniformParam tmp;
tmp.type=UniformParam::OBJROTTRANS;
iss>>tmp.name;
shader->UniformParamList.push_back(tmp);
}
else if (buf=="envrot" || buf=="envrotate" || buf=="envrotmat" || buf=="envrotatematrix")
{
UniformParam tmp;
tmp.type=UniformParam::ENVROT;
iss>>tmp.name;
shader->UniformParamList.push_back(tmp);
}
else if (buf=="envrottrans" || buf=="envrotatetranspose" || buf=="envrottransmat" || buf=="envrotatetransposematrix")
{
UniformParam tmp;
tmp.type=UniformParam::ENVROTTRANS;
iss>>tmp.name;
shader->UniformParamList.push_back(tmp);
}
else
{
printf("UNKNOWN PARAMETER: %s\n",buf.c_str());
return false;
}
}
return ShaderLoader::LoadShaderFile(VertexShaderFilename.c_str(),FragmentShaderFilename.c_str(),shader);
}
bool zObjectShader::Do(const string &cmd1, const vector<zParam*> ¶m, zParam *ret)
{
Shader *obj=(Shader*)m_obj;
zRenderScript *zrs=(zRenderScript*)m_zs;
string cmd=ToLow_copy(cmd1);
if (cmd=="begin")
{
obj->Begin();
obj->SetUniforms(zrs->m_renderer);
}
else if (cmd=="end")
obj->End();
else if (cmd=="setuniforms")
obj->SetUniforms(zrs->m_renderer);
else if (cmd=="changeuniform1i")
{
string *str=zparam_cast<string*>(param[0]);
if (!str) return false;
double *d0=zparam_cast<double*>(param[1]);
if (!d0) return false;
obj->ChangeUniform(*str,(int)(*d0));
}
else if (cmd=="changeuniform1f")
{
string *str=zparam_cast<string*>(param[0]);
if (!str) return false;
double *d0=zparam_cast<double*>(param[1]);
if (!d0) return false;
obj->ChangeUniform(*str,(float)(*d0));
}
else return false;
return true;
}
bool zObjectShader::IsTrue()
{
return true;
}
string zObjectShader::ToString()
{
return string("Shader");
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zObjectShader.cpp
|
C++
|
gpl3
| 6,346
|
#pragma once
//#include <zs.hpp>
namespace zzz{
class zRenderScript;
class zKeyMapParser : public zExtParser
{
public:
bool Parse(const string &cmd, int &id);
bool Do(int id, const vector<zParam*> ¶ms, zParam *ret);
void SetZRS(zRenderScript *zrs);
private:
zRenderScript *m_zrs;
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zKeyMapParser.hpp
|
C++
|
gpl3
| 311
|
#include "zRenderScript.hpp"
#include "zObjectTexture2D.hpp"
#include "zObjectTextureCube.hpp"
#include "zObjectShader.hpp"
#include "zObjectLight.hpp"
//#include "zObjectMesh.hpp"
#include "zObjectFBO.hpp"
namespace zzz{
zRenderScript::zRenderScript()
{
}
void zRenderScript::setConst()
{
}
void zRenderScript::setParser()
{
m_glParser=new zOpenGLParser;
m_glParser->SetRenderer(m_renderer);
AddParser(m_glParser);
m_kmParser=new zKeyMapParser;
m_kmParser->SetZRS(this);
AddParser(m_kmParser);
}
void zRenderScript::setObject()
{
AddObjectTemplate("Texture2D",new zObjectTexture2D);
AddObjectTemplate("TextureCube",new zObjectTextureCube);
AddObjectTemplate("Shader",new zObjectShader);
AddObjectTemplate("Light",new zObjectLight);
// AddObjectTemplate("Mesh",new zObjectMesh);
AddObjectTemplate("FBO",new zObjectFBO);
}
void zRenderScript::Init( ArcBallRenderer *renderer )
{
m_renderer=renderer;
setConst();
setParser();
setObject();
}
void zRenderScript::OnChar( unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags )
{
map<char,string>::iterator mcsi=m_keymap.find(nChar);
if (mcsi!=m_keymap.end())
{
zParam ret;
DoFunction(mcsi->second,&ret);
}
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zRenderScript.cpp
|
C++
|
gpl3
| 1,272
|
#pragma once
#include <zs.hpp>
#include "../Renderer/ArcBallRenderer.hpp"
namespace zzz{
class zOpenGLParser : public zExtParser
{
public:
enum {GLENABLE,GLDISABLE,GLCLEAR,GLMATRIXMODE,GLPUSHMATRIX,GLPOPMATRIX,GLLOADIDENTITY,GLVIEWPORT,
GLTRANSLATE,GLROTATE,GLPOLYGONMODE,GLDEPTHFUNC,GLCHECKERROR,GLCLEARDEPTH,GLCLEARCOLOR,//OPENGLBASE
GLBEGIN,GLEND,GLVERTEX,GLCOLOR,GLNORMAL,GLTEXCOORD,//OPENGL Draw
PLACEOBJ,PLACEENV,GLDRAWBUFFER,
DRAWCOORDINATE,DRAWTRIANGLE,DRAWTEXTURE
};
bool Parse(const string &cmd, int &id);
bool Do(int id, const vector<zParam*> ¶ms, zParam *ret);
void Init(zScript *zs);
void SetRenderer(ArcBallRenderer *renderer);
private:
ArcBallRenderer *m_renderer;
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zOpenGLParser.hpp
|
C++
|
gpl3
| 740
|
#pragma once
#include <zs.hpp>
#include "../Resource/Mesh/ObjMesh.hpp"
namespace zzz{
typedef zObject<ObjMesh> zObjectMesh;
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zObjectMesh.hpp
|
C++
|
gpl3
| 132
|
#pragma once
#include <zs.hpp>
#include "../FBO/FBO.hpp"
namespace zzz{
typedef zObject<FBO> zObjectFBO;
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zObjectFBO.hpp
|
C++
|
gpl3
| 115
|
#include "zObjectMesh.hpp"
namespace zzz{
bool zObjectMesh::LoadFromMemory(istringstream &iss, const string &path)
{
ObjMesh *o=(ObjMesh*)m_obj;
float trans[3],rot[4],scaleto;
string tmp,filename;
bool normalize=true,createvbo=true,calnormal=false,translate=false,rotate=false,scale=false;
while(true)
{
iss>>tmp;
if (iss.fail()) break;
ToLow(tmp);
if (tmp=="f" || tmp=="file" || tmp=="filename")
{
iss>>tmp;
filename=PathFile(path,tmp);
}
else if (tmp=="e" || tmp=="emi" || tmp=="emission" || tmp=="ems")
{
iss>>o->m_mat_emi[0]>>o->m_mat_emi[1]>>o->m_mat_emi[2]>>o->m_mat_emi[3];
}
else if (tmp=="a" || tmp=="amb" || tmp=="ambient" || tmp=="abt")
{
iss>>o->m_mat_amb[0]>>o->m_mat_amb[1]>>o->m_mat_amb[2]>>o->m_mat_amb[3];
}
else if (tmp=="d" || tmp=="dif" || tmp=="diffuse" || tmp=="dfs")
{
iss>>o->m_mat_dif[0]>>o->m_mat_dif[1]>>o->m_mat_dif[2]>>o->m_mat_dif[3];
}
else if (tmp=="s" || tmp=="spe" || tmp=="specular" || tmp=="spc")
{
iss>>o->m_mat_spe[0]>>o->m_mat_spe[1]>>o->m_mat_spe[2]>>o->m_mat_spe[3];
}
else if (tmp=="i" || tmp=="shi" || tmp=="shininess" || tmp=="shn")
{
iss>>o->m_mat_shi;
}
else if (tmp=="normalize")
{
iss>>tmp;
ToLow(tmp);
if (tmp=="true" || tmp=="t" || tmp=="1") normalize=true;
else if (tmp=="false" || tmp=="f" || tmp=="0") normalize=false;
else
{
printf("UNKNOWN PARAMETER: %s\n",tmp.c_str());
return false;
}
}
else if (tmp=="createvbo")
{
iss>>tmp;
ToLow(tmp);
if (tmp=="true" || tmp=="t" || tmp=="1") createvbo=true;
else if (tmp=="false" || tmp=="f" || tmp=="0") createvbo=false;
else
{
printf("UNKNOWN PARAMETER: %s\n",tmp.c_str());
return false;
}
}
else if (tmp=="calnormal")
{
iss>>tmp;
ToLow(tmp);
if (tmp=="true" || tmp=="t" || tmp=="1") calnormal=true;
else if (tmp=="false" || tmp=="f" || tmp=="0") calnormal=false;
else
{
printf("UNKNOWN PARAMETER: %s\n",tmp.c_str());
return false;
}
}
else if (tmp=="translate" || tmp=="t")
{
iss>>trans[0]>>trans[1]>>trans[2];
translate=true;
}
else if (tmp=="rotate" || tmp=="r")
{
iss>>rot[0]>>rot[1]>>rot[2]>>rot[3];
rotate=true;
}
else if (tmp=="scale")
{
iss>>scaleto;
scale=true;
}
else
{
printf("UNKNOWN PARAMETER: %s\n",tmp.c_str());
return false;
}
}
printf("Load obj file: %s\n",filename.c_str());
if (!o->LoadFromFile(filename.c_str()))
{
printf("ERROR: Load Obj: %s\n",filename.c_str());
return false;
}
if (normalize) o->Normalize();
if (scale) o->Scale(scaleto);
if (rotate) o->Rotate(rot[0],rot[1],rot[2],rot[3]);
if (translate) o->Translate(trans[0],trans[1],trans[2]);
if (createvbo) o->CreateVBO();
if (calnormal) o->CalNormal();
return true;
}
bool zObjectMesh::Do(const string &cmd1, const vector<zParam*> ¶m, zParam *ret)
{
ObjMesh *obj=(ObjMesh*)m_obj;
string cmd=ToLow_copy(cmd1);
if (cmd=="draw")
obj->Draw();
else if (cmd=="drawvbo")
obj->DrawVBO();
else if (cmd=="drawelement")
obj->DrawElement();
else if (cmd=="scale")
{
double *d0=zparam_cast<double>(param[0]);
obj->Scale(*d0);
}
else if (cmd=="translate")
{
double *d0=zparam_cast<double>(param[0]);
double *d1=zparam_cast<double>(param[1]);
double *d2=zparam_cast<double>(param[2]);
obj->Translate(*d0,*d1,*d2);
}
else if (cmd=="rotate")
{
double *d0=zparam_cast<double>(param[0]);
double *d1=zparam_cast<double>(param[1]);
double *d2=zparam_cast<double>(param[2]);
double *d3=zparam_cast<double>(param[3]);
obj->Rotate(*d0,*d1,*d2,*d3);
}
else return false;
return true;
}
bool zObjectMesh::IsTrue()
{
return true;
}
string zObjectMesh::ToString()
{
return string("Texture2D");
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zObjectMesh.cpp
|
C++
|
gpl3
| 4,180
|
#include "zObjectLight.hpp"
#include "../Resource/Shader/ShaderSpecify.hpp"
namespace zzz{
bool zObjectLight::LoadFromMemory(istringstream &iss, const string &path)
{
Light *l=(Light*)m_obj;
string tmp;
while(true)
{
iss>>tmp;
if (iss.fail()) break;
ToLow(tmp);
if (tmp=="p" || tmp=="pos" || tmp=="position" || tmp=="pst")
{
iss>>l->m_pos[0]>>l->m_pos[1]>>l->m_pos[2]>>l->m_pos[3];
memcpy(l->m_oripos,l->m_pos,sizeof(float)*4);
}
else if (tmp=="a" || tmp=="amb" || tmp=="ambient" || tmp=="abt")
{
iss>>l->m_amb[0]>>l->m_amb[1]>>l->m_amb[2]>>l->m_amb[3];
}
else if (tmp=="d" || tmp=="dif" || tmp=="diffuse" || tmp=="dfs")
{
iss>>l->m_dif[0]>>l->m_dif[1]>>l->m_dif[2]>>l->m_dif[3];
}
else if (tmp=="s" || tmp=="spe" || tmp=="specular" || tmp=="spc")
{
iss>>l->m_spe[0]>>l->m_spe[1]>>l->m_spe[2]>>l->m_spe[3];
}
else if (tmp=="l" || tmp=="lig" || tmp=="light" || tmp=="lit")
{
int x;
iss>>x;
if (x==0) l->m_mylight=GL_LIGHT0;
else if (x==1) l->m_mylight=GL_LIGHT1;
else if (x==2) l->m_mylight=GL_LIGHT2;
else if (x==3) l->m_mylight=GL_LIGHT3;
else if (x==4) l->m_mylight=GL_LIGHT4;
else if (x==5) l->m_mylight=GL_LIGHT5;
else if (x==6) l->m_mylight=GL_LIGHT6;
else if (x==7) l->m_mylight=GL_LIGHT7;
}
else
{
printf("UNKNOWN PARAMETER: %s\n",tmp.c_str());
return false;
}
}
l->m_inited=true;
return true;
}
bool zObjectLight::Do(const string &cmd1, const vector<zParam*> ¶m, zParam *ret)
{
Light *obj=(Light*)m_obj;
string cmd=ToLow_copy(cmd1);
if (cmd=="enable")
{
double *d0=zparam_cast<double*>(param[0]);
int i0=(int)(*d0);
obj->Enable(GL_LIGHT0+i0);
}
else if (cmd=="disable")
{
if (param.empty())
obj->Disable();
else
{
double *d0=zparam_cast<double*>(param[0]);
int i0=(int)(*d0);
obj->Disable(GL_LIGHT0+i0);
}
}
else if (cmd=="disableall")
{
obj->DisableAll();
}
else if (cmd=="drawline")
{
ColorShader.Begin();
obj->DrawLine();
ColorShader.End();
}
else return false;
return true;
}
bool zObjectLight::IsTrue()
{
return true;
}
string zObjectLight::ToString()
{
return string("Texture2D");
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zObjectLight.cpp
|
C++
|
gpl3
| 2,409
|
#include "zObjectFBO.hpp"
#include "zObjectTexture2D.hpp"
namespace zzz{
bool zObjectFBO::LoadFromMemory(istringstream &iss, const string &path)
{
return true;
}
bool zObjectFBO::Do(const string &cmd1, const vector<zParam*> ¶m, zParam *ret)
{
FBO *obj=(FBO*)m_obj;
string cmd=ToLow_copy(cmd1);
if (cmd=="bind")
{
obj->Bind();
}
else if (cmd=="attach")
{
if (param.size()!=2) return false;
else
{
Texture2D *tex=zparam_obj_cast<Texture2D*>(param[0]);
double *d0=zparam_cast<double*>(param[1]);
int i0=(int)(*d0);
obj->AttachTexture(GL_TEXTURE_2D,tex->GetID(),i0);
}
}
else if (cmd=="disable")
{
obj->Disable();
}
else if (cmd=="isvalid")
{
obj->IsValid();
}
else return false;
return true;
}
bool zObjectFBO::IsTrue()
{
return true;
}
string zObjectFBO::ToString()
{
return string("FBO");
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zObjectFBO.cpp
|
C++
|
gpl3
| 938
|
#pragma once
#include <zs.hpp>
#include "../Resource/Light/Light.hpp"
namespace zzz{
typedef zObject<Light> zObjectLight;
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zObjectLight.hpp
|
C++
|
gpl3
| 130
|
#include "zObjectTextureCube.hpp"
#include "zObjectTextureHelper.hpp"
#include "../Resource/Shader/ShaderSpecify.hpp"
namespace zzz{
bool zObjectTextureCube::LoadFromMemory(istringstream &iss, const string &path)
{
TextureCube *t=(TextureCube*)m_obj;
string tmp;
int tmpi;
while(true)
{
iss>>tmp;
if (iss.fail()) break;
ToLow(tmp);
if (tmp=="f" || tmp=="file")
{
iss>>tmp;
tmp=PathFile(path,tmp);
t->Create(tmp.c_str());
}
else if (tmp=="files")
{
string posx,posy,posz,negx,negy,negz;
iss>>posx;
posx=PathFile(path,posx);
iss>>negx;
negx=PathFile(path,negx);
iss>>posy;
posy=PathFile(path,posy);
iss>>negy;
negy=PathFile(path,negy);
iss>>posz;
posz=PathFile(path,posz);
iss>>negz;
negz=PathFile(path,negz);
t->Create(posx.c_str(),negx.c_str(),posy.c_str(),negy.c_str(),posz.c_str(),negz.c_str());
}
else if (tmp=="s" || tmp=="size")
{
float width,height;
iss>>width>>height;
t->ChangeSize(width,height);
}
else if (tmp=="c" || tmp=="cubesize")
{
float size;
iss>>size;
t->ChangeSize(size);
}
else if (tmp=="i" || tmp=="internalformat")
{
iss>>tmp;
if (zObjectTextureHelper::TextureConst(tmp,tmpi)) t->ChangeInternalFormat(tmpi);
else printf("UNKNOWN CONSTANT: %s\n",tmp.c_str());
}
else
{
printf("UNKNOWN PARAMETER: %s\n",tmp.c_str());
return false;
}
}
return true;
}
bool zObjectTextureCube::Do(const string &cmd1, const vector<zParam*> ¶m, zParam *ret)
{
TextureCube *obj=(TextureCube*)m_obj;
string cmd=ToLow_copy(cmd1);
if (cmd=="bind")
{
if (param.size()!=1) return false;
double *d0=zparam_cast<double*>(param[0]);
int i0=(int)(*d0);
obj->Bind(GL_TEXTURE0+i0);
}
else if (cmd=="disable")
{
if (param.size()!=1) return false;
double *d0=zparam_cast<double*>(param[0]);
int i0=(int)(*d0);
obj->Disable(GL_TEXTURE0+i0);
}
else if (cmd=="disableall")
obj->DisableAll();
else if (cmd=="changesize")
{
if (param.size()!=1 && param.size()!=2) return false;
double *d0=zparam_cast<double*>(param[0]);
if (param.size()==2)
{
double *d1=zparam_cast<double*>(param[1]);
obj->ChangeSize(*d0,*d1);
}
else
obj->ChangeSize(*d0,*d0);
}
else if (cmd=="drawcubemap")
{
if (param.size()!=1) return false;
double *d0=zparam_cast<double*>(param[0]);
CubemapShader.Begin();
obj->DrawCubemap(*d0);
CubemapShader.End();
}
else return false;
return true;
}
bool zObjectTextureCube::IsTrue()
{
return true;
}
string zObjectTextureCube::ToString()
{
return string("Texture2D");
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zRenderScript/zObjectTextureCube.cpp
|
C++
|
gpl3
| 2,892
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "../Graphics/ArcBall.hpp"
#include "GraphicsGUI.hpp"
namespace zzz {
class ZGRAPHICS_CLASS ArcBallGUI : public ArcBall, public GraphicsGUI<Renderer>
{
public:
bool OnMouseMove(unsigned int nFlags,int x,int y);
bool OnLButtonDown(unsigned int nFlags,int x,int y);
bool OnLButtonUp(unsigned int nFlags,int x,int y) {return true;}
void OnSize(unsigned int nType, int cx, int cy);
};
} // namespace zzz
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsGUI/ArcBallGUI.hpp
|
C++
|
gpl3
| 475
|
#include "CameraGUI.hpp"
#include "../Renderer/Renderer.hpp"
namespace zzz {
CameraGUI::CameraGUI() {
SetPosition(0, 0, 2);
}
bool CameraGUI::OnMouseWheel(unsigned int nFlags, int zDelta, int x,int y) {
int nstep=zDelta;
if (nstep<0) {
nstep=-nstep;
if (orthoMode_) {
for (int i=0; i<nstep; i++) orthoScale_*=1.03f;
SetPerspective(width_, height_);
} else {
for (int i=0; i<nstep; i++) Position_[2]*=1.03f;
}
} else {
if (orthoMode_) {
for (int i=0; i<nstep; i++) orthoScale_/=1.03f;
SetPerspective(width_, height_);
} else {
for (int i=0; i<nstep; i++) Position_[2]/=1.03f;
}
}
return true;
}
bool CameraGUI::OnMButtonDown(unsigned int nFlags,int x,int y) {
renderer_->GetContext()->OwnMouse(true);
lastX_ = x;
lastY_ = y;
return true;
}
bool CameraGUI::OnRButtonDown(unsigned int nFlags,int x,int y)
{
renderer_->GetContext()->OwnMouse(true);
lastX_ = x;
lastY_ = y;
return true;
}
bool CameraGUI::OnMouseMove(unsigned int nFlags,int x,int y)
{
if (CheckBit(nFlags, ZZZFLAG_MMOUSE)) {
if (!orthoMode_) {
MoveUpwards(0.003*Position_[2]*(y-lastY_));
MoveLeftwards(0.003*Position_[2]*(x-lastX_));
} else {
MoveUpwards(0.003*orthoScale_*(y-lastY_));
MoveLeftwards(0.003*orthoScale_*(x-lastX_));
}
lastX_=x;
lastY_=y;
return true;
} else if (CheckBit(nFlags, ZZZFLAG_RMOUSE)) {
int step = y - lastY_;
if (step > 0)
for (int i=0; i<step; i++) Position_[2]*=1.003f;
else {
step = -step;
for (int i=0; i<step; i++) Position_[2]/=1.003f;
}
lastX_=x;
lastY_=y;
return true;
} else
return false;
}
void CameraGUI::OnSize(unsigned int nType, int cx, int cy)
{
if (cy <= 0) return;
SetPerspective(cx,cy);
}
} // namespace zzz
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsGUI/CameraGUI.cpp
|
C++
|
gpl3
| 1,900
|
#pragma once
#include <zGraphicsConfig.hpp>
#include <zGraphicsConfig.hpp>
#include "GraphicsGUI.hpp"
#ifdef ZZZ_LIB_ANTTWEAKBAR
#include <AntTweakBar.h>
namespace zzz{
class Renderer;
class ZGRAPHICS_CLASS AntTweakBarGUI : public GraphicsGUI<Renderer>
{
public:
AntTweakBarGUI();
virtual bool Terminate();
//true: handled by GUI, false: not handled by GUI
virtual bool OnMouseMove(unsigned int nFlags,int x,int y);
virtual bool OnLButtonDown(unsigned int nFlags,int x,int y);
virtual bool OnLButtonUp(unsigned int nFlags,int x,int y);
virtual bool OnRButtonDown(unsigned int nFlags,int x,int y);
virtual bool OnRButtonUp(unsigned int nFlags,int x,int y);
virtual bool OnMButtonDown(unsigned int nFlags,int x,int y);
virtual bool OnMButtonUp(unsigned int nFlags,int x,int y);
virtual bool OnMouseWheel(unsigned int nFlags, int zDelta, int x,int y);
virtual bool OnKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
virtual void Draw();
virtual void OnSize(unsigned int nType, int cx, int cy);
private:
int ZZZKeyToTwKey(unsigned int nChar);
int ZZZFlagToTwModifier(unsigned int nFlags);
};
}
#define MAKE_TW_CALL(c,f) void TW_CALL Call##f(void *clientData) {reinterpret_cast<c*>(clientData)->f();}
#define MAKE_TW_SET(c,f,t) void TW_CALL Call##f(const void *x, void *clientData) {reinterpret_cast<c*>(clientData)->f(reinterpret_cast<const t*>(x));}
#define MAKE_TW_GET(c,f,t) void TW_CALL Call##f(void *x, void *clientData) {reinterpret_cast<c*>(clientData)->f(reinterpret_cast<t*>(x));}
#endif
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsGUI/AntTweakBarGUI.hpp
|
C++
|
gpl3
| 1,600
|
#include "AntTweakBarGUI.hpp"
#include "../Renderer/Renderer.hpp"
#ifdef ZZZ_LIB_ANTTWEAKBAR
namespace zzz{
bool AntTweakBarGUI::Terminate()
{
return TwTerminate()!=0;
}
bool AntTweakBarGUI::OnMouseMove(unsigned int nFlags,int x,int y)
{
bool ret=(TwMouseMotion(x,y)!=0);
if (ret) renderer_->Redraw();
return ret;
}
bool AntTweakBarGUI::OnLButtonDown(unsigned int nFlags,int x,int y)
{
bool ret=(TwMouseButton(TW_MOUSE_PRESSED,TW_MOUSE_LEFT)!=0);
if (ret) renderer_->Redraw();
return ret;
}
bool AntTweakBarGUI::OnLButtonUp(unsigned int nFlags,int x,int y)
{
bool ret=(TwMouseButton(TW_MOUSE_RELEASED,TW_MOUSE_LEFT)!=0);
if (ret) renderer_->Redraw();
return ret;
}
bool AntTweakBarGUI::OnRButtonDown(unsigned int nFlags,int x,int y)
{
bool ret=(TwMouseButton(TW_MOUSE_PRESSED,TW_MOUSE_RIGHT)!=0);
if (ret) renderer_->Redraw();
return ret;
}
bool AntTweakBarGUI::OnRButtonUp(unsigned int nFlags,int x,int y)
{
bool ret=(TwMouseButton(TW_MOUSE_RELEASED,TW_MOUSE_RIGHT)!=0);
if (ret) renderer_->Redraw();
return ret;
}
bool AntTweakBarGUI::OnMButtonDown(unsigned int nFlags,int x,int y)
{
bool ret=(TwMouseButton(TW_MOUSE_PRESSED,TW_MOUSE_MIDDLE)!=0);
if (ret) renderer_->Redraw();
return ret;
}
bool AntTweakBarGUI::OnMButtonUp(unsigned int nFlags,int x,int y)
{
bool ret=(TwMouseButton(TW_MOUSE_RELEASED,TW_MOUSE_MIDDLE)!=0);
if (ret) renderer_->Redraw();
return ret;
}
bool AntTweakBarGUI::OnMouseWheel(unsigned int nFlags, int zDelta, int x,int y)
{
bool ret=(TwMouseWheel(zDelta)!=0);
if (ret) renderer_->Redraw();
return ret;
}
bool AntTweakBarGUI::OnKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags)
{
bool ret=(TwKeyPressed(ZZZKeyToTwKey(nChar), ZZZFlagToTwModifier(nFlags))!=0);
if (ret) renderer_->Redraw();
return ret;
}
void AntTweakBarGUI::OnSize(unsigned int nType, int cx, int cy)
{
int res=TwWindowSize(cx,cy);
}
void AntTweakBarGUI::Draw()
{
int res=TwDraw();
}
AntTweakBarGUI::AntTweakBarGUI()
{
if (!TwInit(TW_OPENGL, NULL))
{
ZLOG(ZERROR)<<"AntTweakBar initialization failed: "<<TwGetLastError()<<endl;
}
}
int AntTweakBarGUI::ZZZKeyToTwKey(unsigned int nChar)
{
switch(nChar) {
case ZZZKEY_BACK: return TW_KEY_BACKSPACE;
case ZZZKEY_TAB: return TW_KEY_TAB;
case ZZZKEY_RETURN: return TW_KEY_RETURN;
case ZZZKEY_PAUSE: return TW_KEY_PAUSE;
case ZZZKEY_ESC: return TW_KEY_ESCAPE;
case ZZZKEY_SPACE: return TW_KEY_SPACE;
case ZZZKEY_DELETE: return TW_KEY_DELETE;
case ZZZKEY_UP: return TW_KEY_UP;
case ZZZKEY_DOWN: return TW_KEY_DOWN;
case ZZZKEY_RIGHT: return TW_KEY_RIGHT;
case ZZZKEY_LEFT: return TW_KEY_LEFT;
case ZZZKEY_INSERT: return TW_KEY_INSERT;
case ZZZKEY_HOME: return TW_KEY_HOME;
case ZZZKEY_END: return TW_KEY_END;
case ZZZKEY_PAGEUP: return TW_KEY_PAGE_UP;
case ZZZKEY_PAGEDOWN: return TW_KEY_PAGE_DOWN;
case ZZZKEY_F1: return TW_KEY_F1;
case ZZZKEY_F2: return TW_KEY_F2;
case ZZZKEY_F3: return TW_KEY_F3;
case ZZZKEY_F4: return TW_KEY_F4;
case ZZZKEY_F5: return TW_KEY_F5;
case ZZZKEY_F6: return TW_KEY_F6;
case ZZZKEY_F7: return TW_KEY_F7;
case ZZZKEY_F8: return TW_KEY_F8;
case ZZZKEY_F9: return TW_KEY_F9;
case ZZZKEY_F10: return TW_KEY_F10;
case ZZZKEY_F11: return TW_KEY_F11;
case ZZZKEY_F12: return TW_KEY_F12;
case ZZZKEY_F13: return TW_KEY_F13;
case ZZZKEY_F14: return TW_KEY_F14;
case ZZZKEY_F15: return TW_KEY_F15;
default: return nChar;
}
}
int AntTweakBarGUI::ZZZFlagToTwModifier(unsigned int nFlags)
{
int x = TW_KMOD_NONE;
if (CheckBit(nFlags, ZZZFLAG_SHIFT))
SetBit(x, TW_KMOD_SHIFT);
if (CheckBit(nFlags, ZZZFLAG_CTRL))
SetBit(x, TW_KMOD_CTRL);
if (CheckBit(nFlags, ZZZFLAG_ALT))
SetBit(x, TW_KMOD_ALT);
return x;
}
}
#endif
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsGUI/AntTweakBarGUI.cpp
|
C++
|
gpl3
| 3,908
|
#include "ArcBallGUI.hpp"
#include "../Renderer/Renderer.hpp"
namespace zzz {
bool ArcBallGUI::OnMouseMove(unsigned int nFlags,int x,int y)
{
if (CheckBit(nFlags, ZZZFLAG_LMOUSE)) {
Rotate(x,y);
return true;
}
return false;
}
bool ArcBallGUI::OnLButtonDown(unsigned int nFlags,int x,int y)
{
renderer_->GetContext()->OwnMouse(true);
SetOldPos(x, y);
return true;
}
void ArcBallGUI::OnSize(unsigned int nType, int cx, int cy)
{
if (cy > 0) {
SetWindowSize(cx,cy);
}
}
} // namespace zzz
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsGUI/ArcBallGUI.cpp
|
C++
|
gpl3
| 545
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "CameraGUI.hpp"
#include <Utility\Timer.hpp>
namespace zzz {
class ZGRAPHICS_CLASS MovingCameraGUI : public CameraGUI
{
public:
MovingCameraGUI();
bool OnLButtonDown(unsigned int nFlags,int x,int y);
bool OnMouseMove(unsigned int nFlags,int x,int y);
bool OnMouseWheel(unsigned int nFlags, int zDelta, int x,int y);
bool OnMButtonDown(unsigned int nFlags,int x,int y);
bool OnMButtonUp(unsigned int nFlags,int x,int y);
bool OnChar(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
double moving_speed_;
private:
void UpdateSpeed();
int last_x_, last_y_;
double current_speed_;
Timer timer_;
const double accelerate_time_;
};
} // namespace zzz
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsGUI/MovingCameraGUI.hpp
|
C++
|
gpl3
| 765
|
#pragma once
namespace zzz{
template<typename T>
class GraphicsGUI
{
public:
//true: succeed, false: failed
bool Init(T *renderer)
{
renderer_=renderer;
return InitData();
}
virtual bool Terminate(){return true;}
virtual bool InitData(){return true;}
//true: handled by GUI, false: not handled by GUI
virtual bool OnMouseMove(unsigned int nFlags,int x,int y){return false;}
virtual bool OnLButtonDown(unsigned int nFlags,int x,int y){return false;}
virtual bool OnLButtonUp(unsigned int nFlags,int x,int y){return false;}
virtual bool OnRButtonDown(unsigned int nFlags,int x,int y){return false;}
virtual bool OnRButtonUp(unsigned int nFlags,int x,int y){return false;}
virtual bool OnMButtonDown(unsigned int nFlags,int x,int y){return false;}
virtual bool OnMButtonUp(unsigned int nFlags,int x,int y){return false;}
virtual bool OnMouseWheel(unsigned int nFlags, int zDelta, int x,int y){return false;}
virtual bool OnChar(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags){return false;}
virtual bool OnKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags){return false;}
virtual bool OnKeyUp(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags){return false;}
virtual void Draw(){};
virtual void OnSize(unsigned int nType, int cx, int cy){}
protected:
T *renderer_;
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsGUI/GraphicsGUI.hpp
|
C++
|
gpl3
| 1,408
|
#include "MovingCameraGUI.hpp"
#include "../Renderer/Renderer.hpp"
namespace zzz {
MovingCameraGUI::MovingCameraGUI()
:moving_speed_(1), accelerate_time_(2.0) {}
bool MovingCameraGUI::OnLButtonDown(unsigned int nFlags,int x,int y) {
renderer_->GetContext()->OwnMouse(true);
last_x_ = x;
last_y_ = y;
return true;
}
bool MovingCameraGUI::OnMouseMove(unsigned int nFlags,int x,int y) {
if (CheckBit(nFlags, ZZZFLAG_LMOUSE)) {
ChangeYaw(0.01*(x - last_x_));
ChangePitch(0.01*(y - last_y_));
last_x_ = x;
last_y_ = y;
return true;
}
return false;
}
bool MovingCameraGUI::OnMouseWheel(unsigned int nFlags, int zDelta, int x,int y) {
int nstep=zDelta;
int i;
if (nstep<0) {
nstep=-nstep;
for (i=0; i<nstep; i++) MoveForwards(moving_speed_);
} else {
for (i=0; i<nstep; i++) MoveForwards(-moving_speed_);
}
return true;
}
bool MovingCameraGUI::OnMButtonDown(unsigned int nFlags,int x,int y) {
return false; // just override CameraGUI
}
bool MovingCameraGUI::OnMButtonUp(unsigned int nFlags,int x,int y) {
return false; // just override CameraGUI
}
bool MovingCameraGUI::OnChar(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags) {
switch(nChar)
{
case ZZZKEY_w:
UpdateSpeed();
MoveForwards(current_speed_);
return true;
case ZZZKEY_s:
UpdateSpeed();
MoveForwards(-current_speed_);
return true;
case ZZZKEY_a:
UpdateSpeed();
MoveLeftwards(current_speed_);
return true;
case ZZZKEY_d:
UpdateSpeed();
MoveLeftwards(-current_speed_);
return true;
case ZZZKEY_q:
UpdateSpeed();
MoveUpwards(current_speed_);
return true;
case ZZZKEY_e:
UpdateSpeed();
MoveUpwards(-current_speed_);
return true;
case ZZZKEY_MINUS:
moving_speed_ *= 0.8;
return true;
case ZZZKEY_EQUAL:
moving_speed_ /= 0.8;
return true;
}
return false;
}
void MovingCameraGUI::UpdateSpeed() {
double elapsed = timer_.Elapsed();
// If just started, change speed to 1/20 moving_speed_;
if (elapsed > 0.2) {
current_speed_ = moving_speed_ / 20.0;
timer_.Restart();
return;
} else {
// Accelerate from 0 to moving_speed_ in 2 secs.
if (current_speed_ != moving_speed_) {
current_speed_ += current_speed_ /accelerate_time_ * elapsed;
if (current_speed_ > moving_speed_) current_speed_ = moving_speed_;
}
timer_.Restart();
}
}
} // namespace zzz
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsGUI/MovingCameraGUI.cpp
|
C++
|
gpl3
| 2,540
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "../Graphics/Camera.hpp"
#include "GraphicsGUI.hpp"
namespace zzz {
class ZGRAPHICS_CLASS CameraGUI : public Camera, public GraphicsGUI<Renderer>
{
public:
CameraGUI();
bool OnMButtonDown(unsigned int nFlags,int x,int y);
bool OnRButtonDown(unsigned int nFlags,int x,int y);
bool OnMouseMove(unsigned int nFlags,int x,int y);
bool OnMouseWheel(unsigned int nFlags, int zDelta, int x,int y);
void OnSize(unsigned int nType, int cx, int cy);
private:
bool middleButton_;
bool rightButton_;
int lastX_, lastY_;
};
} // namespace zzz
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsGUI/CameraGUI.hpp
|
C++
|
gpl3
| 624
|
#pragma once
#include <Math/Vector4.hpp>
#include <Math/Vector3.hpp>
#include <Math/Vector2.hpp>
#include <Math/Matrix4x4.hpp>
#include <Math/Matrix3x3.hpp>
#include <Math/Matrix2x2.hpp>
#include <Graphics/Rotation.hpp>
namespace zzz{
// Get a D-dimensinal rotation matrix Mat, so that:
// Mat * from = to.
// There are unlimited such rotation matrix, since each vector only provide one constraints.
// There are D-3 DoF left. (since rotation matrix itself has 1 constraint)
// This process is just to find any one of them.
template<int D>
inline Matrix<D,D,double> GetRotationBetweenVectors(const Vector<D,double> &from, const Vector<D,double> &to)
{
Matrix<D,D,double> rot;
//actually this is not needed, algorithm can handle this
//just to make it faster
double dotlen=FastDot(from,to);
if (Abs(dotlen-1)<EPSILON)
{
rot.Identical();
return rot;
}
if (Abs(dotlen+1)<EPSILON)
{
rot.Identical();
return -rot;
}
Matrix<D,D,double> e,alpha,beta;
e.Identical();
for (int i=0; i<D; i++) if (from[i]!=0)
{
e.Row(i)=from;
if (i!=0) Swap(e.Row(0),e.Row(i));
break;
}
GramSchmidt<double>::Process(e,alpha);
e.Identical();
for (int i=0; i<D; i++) if (to[i]!=0)
{
e.Row(i)=to;
if (i!=0) Swap(e.Row(0),e.Row(i));
break;
}
GramSchmidt<double>::Process(e,beta);
for (int r=0; r<D; r++) for (int c=0; c<D; c++)
rot(r,c)=FastDot(alpha.Row(r),beta.Row(c));
rot=alpha.Inverted()*rot*alpha;
return rot;
}
template<>
inline Matrix<3,3,double> GetRotationBetweenVectors(const Vector<3,double> &from, const Vector<3,double> &to)
{
double costheta = FastDot(from, to);
if (Within(1-TINY_EPSILON, Abs(costheta), 1+TINY_EPSILON)) {
Vector3d axis = from.RandomPerpendicularUnitVec();
Rotationd rot(Quaterniond(axis, SafeACos(costheta)));
return rot;
}
Rotation<double> rot(from.Cross(to),SafeACos(FastDot(from,to)));
return rot;
}
template<>
inline Matrix<2,2,double> GetRotationBetweenVectors(const Vector<2,double> &from, const Vector<2,double> &to)
{
Vector3d from3(from,0),to3(to,0);
Matrix<3,3,double> mat=GetRotationBetweenVectors(from3,to3);
Matrix<2,2,double> ret(mat(0,0),mat(0,1),mat(1,0),mat(1,1));
return ret;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsAlgo/RotationMatrix.hpp
|
C++
|
gpl3
| 2,313
|
// Original from Marching Cubes Example Program
// by Cory Bloyd (corysama@yahoo.com)
// For a description of the algorithm go to
// http://astronomy.swin.edu.au/pbourke/modelling/polygonise/
#pragma once
#include <zGraphicsConfig.hpp>
#include <Math/Array.hpp>
#include <Math/Vector3.hpp>
#include "../Graphics/AABB.hpp"
#include "../Resource/Mesh/SimpleMesh.hpp"
namespace zzz{
class ZGRAPHICS_CLASS MarchingCubes {
public:
MarchingCubes();
void SetSampler(float isoValue, float &sampler(const Vector3f &, const vector<Vector3f> &)=NULL);
void SetCubeSize(float cubesize);
void Polygonize(const vector<Vector3f> &points, const AABB<3,float> &aabb, SimpleMesh &mesh);
void Polygonize(const Array<3,float> &cubevalues, const Vector3f &ori, SimpleMesh &mesh);
void Polygonize2(const vector<Vector3f> &points, const AABB<3,float> &aabb, SimpleMesh &mesh);
void Polygonize2(const Array<3,float> &cubevalues, const Vector3f &ori, SimpleMesh &mesh);
private:
float isoValue_, cubeSize_;
float (*sampler_)(const Vector3f &, const vector<Vector3f> &);
float getOffset(float fValue1, float fValue2, float fValueDesired) const;
void SampleArray(const vector<Vector3f> &points, const AABB<3,float> &aabb, Array<3,float> &cubevalues);
void MarchTetrahedron(const Vector<4,Vector3f> &pasTetrahedronPosition, const Vector4f &pafTetrahedronValue, SimpleMesh &mesh);
static int TetrahedronEdgeFlags[16];
static int TetrahedronTriangles[16][7];
static int CubeEdgeFlags[256];
static int TriangleConnectionTable[256][16];
static const Vector3ui VertexOffset[8];
static const int EdgeConnection[12][2];
static const Vector3i EdgeDirection[12];
static const int TetrahedronEdgeConnection[6][2];
static const int TetrahedronsInACube[6][4];
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsAlgo/MarchingCubes.hpp
|
C++
|
gpl3
| 1,821
|
#include "Delaunay.hpp"
#include "../Graphics/AABB.hpp"
#include <Utility\TextProgressBar.hpp>
namespace zzz {
typedef DelaunayVertexSet::iterator vIterator;
typedef DelaunayVertexSet::const_iterator cvIterator;
typedef DelaunayTriangleSet::iterator tIterator;
typedef DelaunayTriangleSet::const_iterator ctIterator;
typedef DelaunayEdgeSet::iterator edgeIterator;
typedef DelaunayEdgeSet::const_iterator cedgeIterator;
void DelaunayTriangle::SetCircumCircle()
{
Vector2f p0 = at(0)->first;
Vector2f p1 = at(1)->first;
Vector2f p2 = at(2)->first;
float y10 = p1[1] - p0[1];
float y21 = p2[1] - p1[1];
bool b21zero = y21 > -EPSILON && y21 < EPSILON;
if (y10 > -EPSILON && y10 < EPSILON) {
if (b21zero) { // All three vertices are on one horizontal line.
if (p1[0] > p0[0]) {
if (p2[0] > p1[0]) p1[0] = p2[0];
} else {
if (p2[0] < p0[0]) p0[0] = p2[0];
}
Center_[0] = (p0[0] + p1[0]) * 0.5f;
Center_[1] = p0[1];
} else { // Vertices_[0] and Vertices_[1] are on one horizontal line.
float m1 = - (p2[0] - p1[0]) / y21;
float mx1 = (p1[0] + p2[0]) * 0.5f;
float my1 = (p1[1] + p2[1]) * 0.5f;
Center_[0] = (p0[0] + p1[0]) * 0.5f;
Center_[1] = m1 * (Center_[0] - mx1) + my1;
}
} else if (b21zero) { // Vertices_[1] and Vertices_[2] are on one horizontal line.
float m0 = - (p1[0] - p0[0]) / y10;
float mx0 = (p0[0] + p1[0]) * .5F;
float my0 = (p0[1] + p1[1]) * .5F;
Center_[0] = (p1[0] + p2[0]) * .5F;
Center_[1] = m0 * (Center_[0] - mx0) + my0;
} else { // 'Common' cases, no multiple vertices are on one horizontal line.
float m0 = - (p1[0] - p0[0]) / y10;
float m1 = - (p2[0] - p1[0]) / y21;
float mx0 = (p0[0] + p1[0]) * .5F;
float my0 = (p0[1] + p1[1]) * .5F;
float mx1 = (p1[0] + p2[0]) * .5F;
float my1 = (p1[1] + p2[1]) * .5F;
Center_[0] = (m0 * mx0 - m1 * mx1 + my1 - my0) / (m0 - m1);
Center_[1] = m0 * (Center_[0] - mx0) + my0;
}
Vector2f dp = p0 - Center_;
R2_ = dp.LenSqr(); // the radius of the circumcircle, squared
R_ = Sqrt(R2_); // the proper radius
// Version 1.1: make R2_ slightly higher to ensure that all edges
// of co-circular vertices will be caught.
// Note that this is a compromise. In fact, the algorithm isn't really
// suited for very many co-circular vertices.
R2_ *= 1.000001f;
}
// Function object to check whether a DelaunayTriangle has one of the vertices in SuperTriangle.
// operator() returns true if it does.
class VertexInSuperTriangle
{
public:
VertexInSuperTriangle(const DelaunayVertex SuperTriangle[3]) : pSuperTriangle_(SuperTriangle) {}
bool operator()(const DelaunayTriangle& tri) const {
for (int i = 0; i < 3; i++) {
const DelaunayVertex * p = tri[i];
if (p == pSuperTriangle_ || p == pSuperTriangle_+1 || p == pSuperTriangle_+2)
return true;
}
return false;
}
protected:
const DelaunayVertex *pSuperTriangle_;
};
// Function object to check whether a DelaunayTriangle is 'completed', i.e. doesn't need to be checked
// again in the algorithm, i.e. it won't be changed anymore.
// Therefore it can be removed from the workset.
// A DelaunayTriangle is completed if the circumcircle is completely to the left of the current Vector2f.
// If a DelaunayTriangle is completed, it will be inserted in the output set, unless one or more of it's vertices
// belong to the 'super DelaunayTriangle'.
class CompleteTriangle {
public:
CompleteTriangle(cvIterator itVertex, DelaunayTriangleSet& output, const DelaunayVertex SuperTriangle[3])
: itVertex_(itVertex), Output_(output), pSuperTriangle_(SuperTriangle) {
}
bool operator()(const DelaunayTriangle& tri) const {
bool b = tri.IsLeftOf(itVertex_);
if (b) {
VertexInSuperTriangle thv(pSuperTriangle_);
if (! thv(tri)) Output_.push_back(tri);
}
return b;
}
protected:
DelaunayVertexSet::const_iterator itVertex_;
DelaunayTriangleSet& Output_;
const DelaunayVertex* pSuperTriangle_;
};
// Function object to check whether Vector2f is in circumcircle of DelaunayTriangle.
// operator() returns true if it does.
// The edges of a 'hot' DelaunayTriangle are stored in the edgeSet edges.
class VertexInCircumCircle {
public:
VertexInCircumCircle(cvIterator itVertex, DelaunayEdgeSet& edges)
: itVertex_(itVertex), Edges_(edges) {
}
bool operator()(const DelaunayTriangle& tri) const {
bool b = tri.CCEncompasses(itVertex_);
if (b) {
HandleEdge(tri[0], tri[1]);
HandleEdge(tri[1], tri[2]);
HandleEdge(tri[2], tri[0]);
}
return b;
}
protected:
void HandleEdge(const DelaunayVertex * p0, const DelaunayVertex * p1) const {
const DelaunayVertex *pVertex0;
const DelaunayVertex *pVertex1;
// Create a normalized DelaunayEdge, in which the smallest Vector2f comes first.
if (p0->first < p1->first) {
pVertex0 = p0;
pVertex1 = p1;
} else {
pVertex0 = p1;
pVertex1 = p0;
}
DelaunayEdge e(pVertex0, pVertex1);
// Check if this DelaunayEdge is already in the buffer
edgeIterator found = Edges_.find(e);
if (found == Edges_.end()) Edges_.insert(e); // no, it isn't, so insert
else Edges_.erase(found); // yes, it is, so erase it to eliminate double edges
}
cvIterator itVertex_;
DelaunayEdgeSet& Edges_;
};
void Delaunay::Triangulate(const vector<Vector2f>& vertices, vector<Vector3i>& output)
{
DelaunayVertexSet vset;
vset.reserve(vertices.size());
for (zuint i=0; i<vertices.size(); i++) {
vset.push_back(make_pair(vertices[i],i));
}
sort(vset.begin(), vset.end());
DelaunayTriangleSet tset;
DoTriangulate(vset, tset);
output.clear();
output.reserve(tset.size());
for (DelaunayTriangleSet::iterator ti=tset.begin();ti!=tset.end();ti++) {
output.push_back(Vector3i(ti->at(0)->second, ti->at(1)->second, ti->at(2)->second));
}
}
void Delaunay::DoTriangulate(const DelaunayVertexSet& vertices, DelaunayTriangleSet& output)
{
if (vertices.size() < 3) return; // nothing to handle
AABB<2, float> aabb;
for (DelaunayVertexSet::const_iterator di=vertices.begin(); di!=vertices.end(); di++)
aabb+=di->first;
float xMin = aabb.Min()[0];
float yMin = aabb.Min()[1];
float xMax = aabb.Max()[0];
float yMax = aabb.Max()[1];
float dx = xMax - xMin;
float dy = yMax - yMin;
// Make the bounding box slightly bigger, just to feel safe.
float ddx = dx * 0.01F;
float ddy = dy * 0.01F;
xMin -= ddx;
xMax += ddx;
dx += 2 * ddx;
yMin -= ddy;
yMax += ddy;
dy += 2 * ddy;
// Create a 'super DelaunayTriangle', encompassing all the vertices. We choose an equilateral DelaunayTriangle with horizontal base.
// We could have made the 'super DelaunayTriangle' simply very big. However, the algorithm is quite sensitive to
// rounding errors, so it's better to make the 'super DelaunayTriangle' just big enough, like we do here.
DelaunayVertex vSuper[3];
vSuper[0].first = Vector2f(xMin - dy * C_SQRT3 / 3.0F, yMin); // Simple highschool geometry, believe me.
vSuper[1].first = Vector2f(xMax + dy * C_SQRT3 / 3.0F, yMin);
vSuper[2].first = Vector2f((xMin + xMax) * 0.5F, yMax + dx * C_SQRT3 * 0.5F);
DelaunayTriangleSet workset;
workset.reserve(vertices.size());
workset.push_back(DelaunayTriangle(vSuper, vSuper+1, vSuper+2));
TextProgressBar bar("Delaunay Triangulating");
bar.SetMaximum(vertices.size()-1);
bar.SetMinimum(0);
bar.Start();
for (DelaunayVertexSet::const_iterator itVertex = vertices.begin(); itVertex != vertices.end(); itVertex++)
{
bar.DeltaUpdate();
// First, remove all 'completed' triangles from the workset.
// A DelaunayTriangle is 'completed' if its circumcircle is entirely to the left of the current Vector2f.
// Vertices are sorted in x-direction (the set container does this automagically).
// Unless they are part of the 'super DelaunayTriangle', copy the 'completed' triangles to the output.
// The algorithm also works without this step, but it is an important optimalization for bigger numbers of vertices.
// It makes the algorithm about five times faster for 2000 vertices, and for 10000 vertices,
// it's thirty times faster. For smaller numbers, the difference is negligible.
tIterator itEnd = remove_if(workset.begin(), workset.end(), CompleteTriangle(itVertex, output, vSuper));
DelaunayEdgeSet edges;
// A DelaunayTriangle is 'hot' if the current Vector2f v is inside the circumcircle.
// Remove all hot triangles, but keep their edges.
itEnd = remove_if(workset.begin(), itEnd, VertexInCircumCircle(itVertex, edges));
workset.erase(itEnd, workset.end()); // remove_if doesn't actually remove; we have to do this explicitly.
// Create new triangles from the edges and the current Vector2f.
for (edgeIterator it = edges.begin(); it != edges.end(); it++)
workset.push_back(DelaunayTriangle((*it)[0], (*it)[1], & (* itVertex)));
// sort(workset.begin(), workset.end());
}
bar.End();
// Finally, remove all the triangles belonging to the 'super DelaunayTriangle' and move the remaining
// triangles tot the output; remove_copy_if lets us do that in one go.
tIterator where = output.begin();
remove_copy_if(workset.begin(), workset.end(), inserter(output, where), VertexInSuperTriangle(vSuper));
}
void Delaunay::TrianglesToEdges(const DelaunayTriangleSet& triangles, DelaunayEdgeSet& edges)
{
for (ctIterator it = triangles.begin(); it != triangles.end(); ++it)
{
HandleEdge((*it)[0], (*it)[1], edges);
HandleEdge((*it)[1], (*it)[2], edges);
HandleEdge((*it)[2], (*it)[0], edges);
}
}
void Delaunay::HandleEdge(const DelaunayVertex * p0, const DelaunayVertex * p1, DelaunayEdgeSet& edges)
{
const DelaunayVertex * pV0(NULL);
const DelaunayVertex * pV1(NULL);
if (p0->first < p1->first) {
pV0 = p0;
pV1 = p1;
} else {
pV0 = p1;
pV1 = p0;
}
// Insert a normalized DelaunayEdge. If it's already in edges, insertion will fail,
// thus leaving only unique edges.
edges.insert(DelaunayEdge(pV0, pV1));
}
}; // namespace zzz
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsAlgo/Delaunay.cpp
|
C++
|
gpl3
| 10,466
|
#pragma once
#include "../Resource/Mesh/SimpleMesh.hpp"
#include "../Graphics/GeometryHelper.hpp"
namespace zzz{
template<int LEVEL>
class TrackOnSphere
{
public:
TrackOnSphere()
{
for (int i=0; i<LEVEL; i++)
GeometryHelper::CreateSphere(sphere_[i],i);
}
int Track(const Vector3f &dir, vector<int> &tri)
{
tri.clear();
int pos=-1;
//get first one
Vector2f bary,bary2;
for (zuint i=0; i<sphere_[0].faces_.size(); i++)
if (ptInTri(dir,0,i,bary)) pos=i;
assert(pos!=-1);
tri.push_back(pos);
for (int level=1;level<LEVEL;level++)
{
int f0=pos;
int f1=f0*3+sphere_[level-1].faces_.size();
int f2=f0*3+1+sphere_[level-1].faces_.size();
int f3=f0*3+2+sphere_[level-1].faces_.size();
pos=-1;
if (ptInTri(dir,level,f0,bary)) {pos=f0;bary2=bary;}
else if (ptInTri(dir,level,f1,bary)) {pos=f1;bary2=bary;}
else if (ptInTri(dir,level,f2,bary)) {pos=f2;bary2=bary;}
else if (ptInTri(dir,level,f3,bary)) {pos=f3;bary2=bary;}
assert(pos!=-1);
tri.push_back(pos);
}
float uv=Clamp(1.0f-bary[0]-bary[1],0.0f,1.0f);
if (bary[0]>uv && bary[0]>bary[1]) return sphere_[LEVEL-1].faces_[pos][1];
else if (bary[1]>bary[0] && bary[1]>uv) return sphere_[LEVEL-1].faces_[pos][2];
return sphere_[LEVEL-1].faces_[pos][0];
}
private:
bool ptInTri(const Vector3f &dir, int level, int face, Vector2f &bary)
{
float dist;
return GeometryHelper::RayInTriangle(\
sphere_[level].vertices_[sphere_[level].faces_[face][0]],\
sphere_[level].vertices_[sphere_[level].faces_[face][1]],\
sphere_[level].vertices_[sphere_[level].faces_[face][2]],\
Vector3f(0,0,0),dir,dist,bary) && dist>0;
}
SimpleMesh sphere_[LEVEL];
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsAlgo/TrackOnSphere.hpp
|
C++
|
gpl3
| 1,842
|
#include "MarchingCubes.hpp"
#include <Utility/Tools.hpp>
namespace zzz{
//Sampler1 finds the distance of (fX, fY, fZ) from three moving points
float Sampler1(const Vector3f &p, const vector<Vector3f> &points)
{
double fResult = 0.0;
for (zuint i=0; i<points.size(); i++)
fResult+=1.0f/(p-points[i]).LenSqr();
return fResult;
}
//Sampler2 finds the distance of (fX, fY, fZ) from three moving lines
float Sampler2(const Vector3f &p, const vector<Vector3f> &points)
{
double fResult = 0.0;
for (zuint i=0; i<points.size(); i++)
{
Vector3f dif = p - points[i];
dif[2]=0;
fResult += 0.5/dif.LenSqr();
}
return fResult;
}
MarchingCubes::MarchingCubes()
:sampler_(Sampler1),isoValue_(48.0f),cubeSize_(1)
{}
void MarchingCubes::SetSampler(float isoValue, float &sampler(const Vector3f &, const vector<Vector3f> &))
{
isoValue_=isoValue;
if (sampler!=NULL) sampler_=Sampler1;
else sampler_=Sampler1;
}
void MarchingCubes::SetCubeSize(float cubesize)
{
cubeSize_=cubesize;
}
void MarchingCubes::SampleArray(const vector<Vector3f> &points, const AABB<3,float> &aabb, Array<3,float> &cubevalues)
{
zuint countX=ceil(aabb.Diff(0)/cubeSize_)+1;
zuint countY=ceil(aabb.Diff(1)/cubeSize_)+1;
zuint countZ=ceil(aabb.Diff(2)/cubeSize_)+1;
cubevalues.SetSize(Vector3ui(countX,countY,countZ));
for (zuint x=0; x<countX; x++) for (zuint y=0; y<countY; y++) for (zuint z=0; z<countZ; z++)
{
Vector3f curZero(x*cubeSize_,y*cubeSize_,z*cubeSize_);
curZero+=aabb.Min();
cubevalues(Vector3ui(x,y,z))=sampler_(curZero, points);
}
}
void MarchingCubes::Polygonize(const vector<Vector3f> &points, const AABB<3,float> &aabb, SimpleMesh &mesh)
{
Array<3,float> cubevalues;
SampleArray(points,aabb,cubevalues);
Polygonize(cubevalues,aabb.Min(),mesh);
}
void MarchingCubes::Polygonize(const Array<3,float> &cubevalues, const Vector3f &ori, SimpleMesh &mesh)
{
mesh.Clear();
zuint countX=cubevalues.Size(0)-1;
zuint countY=cubevalues.Size(1)-1;
zuint countZ=cubevalues.Size(2)-1;
for (zuint x=0; x<countX; x++) for (zuint y=0; y<countY; y++) for (zuint z=0; z<countZ; z++)
{
Vector3ui curCoord(x,y,z);
//Make a local copy of the values at the cube's corners
float cubeValue[8];
for(int i=0; i<8; i++)
cubeValue[i]=cubevalues(curCoord+VertexOffset[i]);
//Find which vertices are inside of the surface and which are outside
int iFlagIndex = 0;
for(int i = 0; i < 8; i++)
if(cubeValue[i] <= isoValue_) SetBit(iFlagIndex,1<<i);
//Find which edges are intersected by the surface
int iFlags = CubeEdgeFlags[iFlagIndex];
//If the cube is entirely inside or outside of the surface, then there will be no intersections
if(iFlags == 0) continue;
//Find the point of intersection of the surface with each edge
//Then find the normal to the surface at those points
Vector3f EdgeVertex[12];
for(int i = 0; i < 12; i++)
{
//if there is an intersection on this edge
if(iFlags & (1<<i))
{
float offset = getOffset(cubeValue[EdgeConnection[i][0]], cubeValue[EdgeConnection[i][1]], isoValue_);
EdgeVertex[i] = ori+Vector3f(curCoord)*cubeSize_ + (Vector3f(VertexOffset[ EdgeConnection[i][0] ]) + Vector3f(EdgeDirection[i]) * offset) * cubeSize_;
}
}
//Draw the triangles that were found. There can be up to five per cube
for(int i = 0; i < 5; i++)
{
if(TriangleConnectionTable[iFlagIndex][3*i] < 0) break;
SimpleMesh::Triangle tri;
for(int j = 0; j < 3; j++)
tri[j]=EdgeVertex[TriangleConnectionTable[iFlagIndex][3*i+j]];
mesh.triangles_.push_back(tri);
}
}
}
//getOffset finds the approximate point of intersection of the surface
// between two points with the values fValue1 and fValue2
float MarchingCubes::getOffset(float fValue1, float fValue2, float fValueDesired) const
{
float fDelta = fValue2 - fValue1;
if(fDelta == 0.0f) return 0.5f;
return (fValueDesired - fValue1)/fDelta;
}
//MarchTetrahedron performs the Marching Tetrahedrons algorithm on a single tetrahedron
void MarchingCubes::MarchTetrahedron(const Vector<4,Vector3f> &TetrahedronPosition, const Vector4f &TetrahedronValue, SimpleMesh &mesh)
{
//Find which vertices are inside of the surface and which are outside
int iFlagIndex=0;
for(int i = 0; i < 4; i++)
if(TetrahedronValue[i] <= isoValue_) iFlagIndex |= 1<<i;
//Find which edges are intersected by the surface
int iFlags = TetrahedronEdgeFlags[iFlagIndex];
//If the tetrahedron is entirely inside or outside of the surface, then there will be no intersections
if(iFlags == 0) return;
//Find the point of intersection of the surface with each edge
// Then find the normal to the surface at those points
Vector3f EdgeVertex[6];
Vector3f EdgeNorm[6];
for(int i = 0; i < 6; i++)
{
//if there is an intersection on this edge
if(iFlags & (1<<i))
{
int iVert0 = TetrahedronEdgeConnection[i][0];
int iVert1 = TetrahedronEdgeConnection[i][1];
float offset = getOffset(TetrahedronValue[iVert0], TetrahedronValue[iVert1], isoValue_);
float fInvOffset = 1.0 - offset;
EdgeVertex[i][0] = fInvOffset*TetrahedronPosition[iVert0][0] + offset*TetrahedronPosition[iVert1][0];
EdgeVertex[i][1] = fInvOffset*TetrahedronPosition[iVert0][1] + offset*TetrahedronPosition[iVert1][1];
EdgeVertex[i][2] = fInvOffset*TetrahedronPosition[iVert0][2] + offset*TetrahedronPosition[iVert1][2];
}
}
//Draw the triangles that were found. There can be up to 2 per tetrahedron
for(int i = 0; i < 2; i++)
{
if(TetrahedronTriangles[iFlagIndex][3*i] < 0) break;
SimpleMesh::Triangle tri;
for(int j = 0; j < 3; j++)
{
tri[j]=EdgeVertex[TetrahedronTriangles[iFlagIndex][3*i+j]];
}
mesh.triangles_.push_back(tri);
}
}
void MarchingCubes::Polygonize2(const vector<Vector3f> &points, const AABB<3,float> &aabb, SimpleMesh &mesh)
{
Array<3,float> cubevalues;
SampleArray(points,aabb,cubevalues);
Polygonize2(cubevalues,aabb.Min(),mesh);
}
//vMarchCube2 performs the Marching Tetrahedrons algorithm on a single cube by making six calls to MarchTetrahedron
void MarchingCubes::Polygonize2(const Array<3,float> &cubevalues, const Vector3f &ori, SimpleMesh &mesh)
{
mesh.Clear();
zuint countX=cubevalues.Size(0)-1;
zuint countY=cubevalues.Size(1)-1;
zuint countZ=cubevalues.Size(2)-1;
for (zuint x=0; x<countX; x++) for (zuint y=0; y<countY; y++) for (zuint z=0; z<countZ; z++)
{
Vector3ui curCoord(x,y,z);
//Make a local copy of the cube's corner positions
Vector3f CubePosition[8];
for(int i = 0; i < 8; i++)
CubePosition[i] = ori+Vector3f(curCoord+VertexOffset[i])*cubeSize_;
//Make a local copy of the cube's corner values
float cubeValue[8];
for(int i = 0; i < 8; i++)
cubeValue[i] = cubevalues(curCoord+VertexOffset[i]);
Vector<4,Vector3f> asTetrahedronPosition;
Vector4f afTetrahedronValue;
for(int iTetrahedron = 0; iTetrahedron < 6; iTetrahedron++)
{
for(int i = 0; i < 4; i++)
{
int iVertexInACube = TetrahedronsInACube[iTetrahedron][i];
asTetrahedronPosition[i] = CubePosition[iVertexInACube];
afTetrahedronValue[i] = cubeValue[iVertexInACube];
}
MarchTetrahedron(asTetrahedronPosition, afTetrahedronValue,mesh);
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
const Vector3ui MarchingCubes::VertexOffset[8] =
{
Vector3ui(0, 0, 0),Vector3ui(1, 0, 0),Vector3ui(1, 1, 0),Vector3ui(0, 1, 0),
Vector3ui(0, 0, 1),Vector3ui(1, 0, 1),Vector3ui(1, 1, 1),Vector3ui(0, 1, 1)
};
//EdgeConnection lists the index of the endpoint vertices for each of the 12 edges of the cube
const int MarchingCubes::EdgeConnection[12][2] =
{
{0,1}, {1,2}, {2,3}, {3,0},
{4,5}, {5,6}, {6,7}, {7,4},
{0,4}, {1,5}, {2,6}, {3,7}
};
//EdgeDirection lists the direction vector (vertex1-vertex0) for each edge in the cube
const Vector3i MarchingCubes::EdgeDirection[12] =
{
Vector3i(1, 0, 0),Vector3i(0, 1, 0),Vector3i(-1, 0, 0),Vector3i(0, -1, 0),
Vector3i(1, 0, 0),Vector3i(0, 1, 0),Vector3i(-1, 0, 0),Vector3i(0, -1, 0),
Vector3i(0, 0, 1),Vector3i(0, 0, 1),Vector3i(0, 0, 1),Vector3i(0, 0, 1)
};
//TetrahedronEdgeConnection lists the index of the endpoint vertices for each of the 6 edges of the tetrahedron
const int MarchingCubes::TetrahedronEdgeConnection[6][2] =
{
{0,1}, {1,2}, {2,0}, {0,3}, {1,3}, {2,3}
};
//TetrahedronEdgeConnection lists the index of verticies from a cube
// that made up each of the six tetrahedrons within the cube
const int MarchingCubes::TetrahedronsInACube[6][4] =
{
{0,5,1,6},
{0,1,2,6},
{0,2,3,6},
{0,3,7,6},
{0,7,4,6},
{0,4,5,6},
};
// For any edge, if one vertex is inside of the surface and the other is outside of the surface
// then the edge intersects the surface
// For each of the 4 vertices of the tetrahedron can be two possible states : either inside or outside of the surface
// For any tetrahedron the are 2^4=16 possible sets of vertex states
// This table lists the edges intersected by the surface for all 16 possible vertex states
// There are 6 edges. For each entry in the table, if edge #n is intersected, then bit #n is set to 1
int MarchingCubes::TetrahedronEdgeFlags[16]=
{
0x00, 0x0d, 0x13, 0x1e, 0x26, 0x2b, 0x35, 0x38, 0x38, 0x35, 0x2b, 0x26, 0x1e, 0x13, 0x0d, 0x00,
};
// For each of the possible vertex states listed in TetrahedronEdgeFlags there is a specific triangulation
// of the edge intersection points. TetrahedronTriangles lists all of them in the form of
// 0-2 edge triples with the list terminated by the invalid value -1.
//
// I generated this table by hand
int MarchingCubes::TetrahedronTriangles[16][7] =
{
{-1, -1, -1, -1, -1, -1, -1},
{ 0, 3, 2, -1, -1, -1, -1},
{ 0, 1, 4, -1, -1, -1, -1},
{ 1, 4, 2, 2, 4, 3, -1},
{ 1, 2, 5, -1, -1, -1, -1},
{ 0, 3, 5, 0, 5, 1, -1},
{ 0, 2, 5, 0, 5, 4, -1},
{ 5, 4, 3, -1, -1, -1, -1},
{ 3, 4, 5, -1, -1, -1, -1},
{ 4, 5, 0, 5, 2, 0, -1},
{ 1, 5, 0, 5, 3, 0, -1},
{ 5, 2, 1, -1, -1, -1, -1},
{ 3, 4, 2, 2, 4, 1, -1},
{ 4, 1, 0, -1, -1, -1, -1},
{ 2, 3, 0, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1},
};
// For any edge, if one vertex is inside of the surface and the other is outside of the surface
// then the edge intersects the surface
// For each of the 8 vertices of the cube can be two possible states : either inside or outside of the surface
// For any cube the are 2^8=256 possible sets of vertex states
// This table lists the edges intersected by the surface for all 256 possible vertex states
// There are 12 edges. For each entry in the table, if edge #n is intersected, then bit #n is set to 1
int MarchingCubes::CubeEdgeFlags[256]=
{
0x000, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
0x190, 0x099, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
0x230, 0x339, 0x033, 0x13a, 0x636, 0x73f, 0x435, 0x53c, 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
0x3a0, 0x2a9, 0x1a3, 0x0aa, 0x7a6, 0x6af, 0x5a5, 0x4ac, 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
0x460, 0x569, 0x663, 0x76a, 0x066, 0x16f, 0x265, 0x36c, 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0x0ff, 0x3f5, 0x2fc, 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x055, 0x15c, 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0x0cc, 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, 0x0cc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 0x15c, 0x055, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, 0x2fc, 0x3f5, 0x0ff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, 0x36c, 0x265, 0x16f, 0x066, 0x76a, 0x663, 0x569, 0x460,
0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, 0x4ac, 0x5a5, 0x6af, 0x7a6, 0x0aa, 0x1a3, 0x2a9, 0x3a0,
0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x033, 0x339, 0x230,
0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x099, 0x190,
0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x000
};
// For each of the possible vertex states listed in CubeEdgeFlags there is a specific triangulation
// of the edge intersection points. TriangleConnectionTable lists all of them in the form of
// 0-5 edge triples with the list terminated by the invalid value -1.
// For example: TriangleConnectionTable[3] list the 2 triangles formed when corner[0]
// and corner[1] are inside of the surface, but the rest of the cube is not.
//
// I found this table in an example program someone wrote long ago. It was probably generated by hand
int MarchingCubes::TriangleConnectionTable[256][16] =
{
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1},
{3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1},
{3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1},
{3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1},
{9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
{2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1},
{8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
{4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1},
{3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1},
{1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1},
{4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1},
{4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
{5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1},
{2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1},
{9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
{0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
{2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1},
{10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1},
{5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1},
{5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1},
{9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1},
{1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1},
{10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1},
{8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1},
{2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1},
{7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1},
{2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1},
{11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1},
{5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1},
{11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1},
{11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1},
{9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1},
{2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1},
{6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1},
{3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1},
{6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
{10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1},
{6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1},
{8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1},
{7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1},
{3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1},
{0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1},
{9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1},
{8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1},
{5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1},
{0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1},
{6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1},
{10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1},
{10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1},
{8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1},
{1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1},
{0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1},
{10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1},
{3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1},
{6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1},
{9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1},
{8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1},
{3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1},
{6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1},
{0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1},
{10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1},
{10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1},
{2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1},
{7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1},
{7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1},
{2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1},
{1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1},
{11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1},
{8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1},
{0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1},
{7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
{10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
{2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
{6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1},
{7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1},
{2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1},
{10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1},
{10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1},
{0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1},
{7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1},
{6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1},
{8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1},
{9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1},
{6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1},
{4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1},
{10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1},
{8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1},
{0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1},
{1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1},
{8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1},
{10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1},
{4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1},
{10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
{11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1},
{9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
{6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1},
{7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1},
{3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1},
{7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1},
{3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1},
{6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1},
{9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1},
{1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1},
{4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1},
{7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1},
{6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1},
{3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1},
{0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1},
{6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1},
{0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1},
{11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1},
{6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1},
{5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1},
{9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1},
{1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1},
{1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1},
{10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1},
{0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1},
{5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1},
{10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1},
{11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1},
{9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1},
{7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1},
{2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1},
{8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1},
{9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1},
{9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1},
{1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1},
{9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1},
{5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1},
{0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1},
{10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1},
{2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1},
{0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1},
{0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1},
{9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1},
{5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1},
{3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1},
{5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1},
{8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1},
{0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1},
{9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1},
{1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1},
{3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1},
{4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1},
{9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1},
{11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1},
{11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1},
{2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1},
{9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1},
{3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1},
{1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1},
{4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1},
{3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1},
{0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1},
{1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsAlgo/MarchingCubes.cpp
|
C++
|
gpl3
| 28,735
|
#pragma once
#include <zGraphicsConfig.hpp>
#include <common.hpp>
#include <Math/Vector3.hpp>
#include <Math/Vector2.hpp>
namespace zzz {
typedef pair<Vector2f,int> DelaunayVertex;
typedef vector<DelaunayVertex> DelaunayVertexSet;
///////////////////
// DelaunayTriangle
class ZGRAPHICS_CLASS DelaunayTriangle : public Vector<3, const DelaunayVertex*> {
public:
DelaunayTriangle(const DelaunayTriangle& tri)
: Center_(tri.Center_), R_(tri.R_), R2_(tri.R2_), Vector<3, const DelaunayVertex*>(tri) {
}
DelaunayTriangle(const DelaunayVertex *p0, const DelaunayVertex *p1, const DelaunayVertex *p2)
:Vector<3, const DelaunayVertex*>(p0, p1, p2) {
SetCircumCircle();
}
using Vector<3,const DelaunayVertex*>::operator[];
bool operator<(const DelaunayTriangle& tri) const {
return Center_ < tri.Center_;
}
bool IsLeftOf(DelaunayVertexSet::const_iterator itVertex) const {
// returns true if * itVertex is to the right of the DelaunayTriangle's circumcircle
return itVertex->first.x() > (Center_.x() + R_);
}
bool CCEncompasses(DelaunayVertexSet::const_iterator itVertex) const {
// Returns true if * itVertex is in the DelaunayTriangle's circumcircle.
// A Vector2f exactly on the circle is also considered to be in the circle.
// First check boundary box.
Vector2f dist = itVertex->first - Center_; // the distance between v and the circle center
float dist2 = dist.LenSqr(); // squared
return dist2 <= R2_; // compare with squared radius
}
protected:
Vector2f Center_; // center of circumcircle
float R_; // radius of circumcircle
float R2_; // radius of circumcircle, squared
void SetCircumCircle();
};
typedef vector<DelaunayTriangle> DelaunayTriangleSet;
///////////////////
// DelaunayEdge
typedef Vector<2, const DelaunayVertex*> DelaunayEdge;
typedef set<DelaunayEdge> DelaunayEdgeSet;
///////////////////
// Delaunay
class ZGRAPHICS_CLASS Delaunay {
public:
void Triangulate(const vector<Vector2f>& vertices, vector<Vector3i>& output);
private:
// Calculate the Delaunay triangulation for the given set of vertices.
void DoTriangulate(const DelaunayVertexSet& vertices, DelaunayTriangleSet& output);
// Put the edges of the triangles in an edgeSet, eliminating double edges.
// This comes in useful for drawing the triangulation.
void TrianglesToEdges(const DelaunayTriangleSet& triangles, DelaunayEdgeSet& edges);
protected:
void HandleEdge(const DelaunayVertex * p0, const DelaunayVertex * p1, DelaunayEdgeSet& edges);
};
}; // namespace zzz
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/GraphicsAlgo/Delaunay.hpp
|
C++
|
gpl3
| 2,666
|
#pragma once
#include "zGraphicsConfig.hpp"
#include "Graphics/Graphics.hpp"
#include "Context/GLUTContext.hpp"
#include "Context/Qt4Context.hpp"
#include "Context/SFMLContext.hpp"
#include "Context/SingleViewContext.hpp"
#include "Renderer/ArcBallRenderer.hpp"
#include "Renderer/CameraRenderer.hpp"
#include "Renderer/ControlRenderer.hpp"
#include "Renderer/MultiObjEnvRenderer.hpp"
#include "Renderer/OneImageRenderer.hpp"
#include "Renderer/OneObjEnvRenderer.hpp"
#include "Renderer/OneObjRenderer.hpp"
#include "Renderer/Renderer.hpp"
#include "Renderer/SwitchRenderer.hpp"
#include "Renderer/Vis2DRenderer.hpp"
#include "Renderer/RendererHelper.hpp"
#include "Graphics/AABB.hpp"
#include "Graphics/ArcBall.hpp"
#include "Graphics/BoundingBox3.hpp"
#include "Graphics/Color.hpp"
#include "Graphics/ColorDefine.hpp"
#include "Graphics/Coordinate.hpp"
#include "Graphics/CubeMap.hpp"
#include "Graphics/GeometryHelper.hpp"
#include "Graphics/GraphicsElement.hpp"
#include "Graphics/GraphicsHelper.hpp"
#include "Graphics/HeightMap.hpp"
#include "Graphics/Quaternion.hpp"
#include "Graphics/RayTransform.hpp"
#include "Graphics/Rotation.hpp"
#include "Graphics/Transformation.hpp"
#include "Graphics/Translation.hpp"
#include "Graphics/SH/SHCoeff.hpp"
//#include "Graphics/SH/SHCoeff4f_SSE.hpp"
//#include "Graphics/SH/SHRotationMatrix.hpp"
#include "Graphics/Haar/HaarCoeffCubemap.hpp"
#include "Graphics/Haar/HaarCoeffCubemap4Triple.hpp"
#include "Graphics/Haar/HaarCubemapTriple.hpp"
//#include "Graphics/TransformMatrix/HaarSHTransformMatrix.hpp"
#include "GraphicsGUI/AntTweakBarGUI.hpp"
#include "GraphicsGUI/ArcBallGUI.hpp"
#include "GraphicsGUI/CameraGUI.hpp"
#include "GraphicsGUI/MovingCameraGUI.hpp"
#include "Resource/Script/LightScript.hpp"
#include "Resource/Script/ObjectScript.hpp"
#include "Resource/Script/ShaderScript.hpp"
#include "Resource/Script/TextureScript.hpp"
#include "FBO/FBO.hpp"
#include "FBO/RenderBuffer.hpp"
#include "VBO/PBOHelper.hpp"
#include "VBO/VBO.hpp"
#include "Resource/Light/Light.hpp"
#include "Resource/Mesh/Material.hpp"
#include "Resource/Mesh/Mesh.hpp"
#include "Resource/Mesh/MeshIO/IOObjectMesh.hpp"
#include "Resource/Mesh/MeshIO/MeshIO.hpp"
#include "Resource/Mesh/PolygonMesh.hpp"
#include "Resource/Mesh/SimpleMesh.hpp"
#include "Resource/Shader/Shader.hpp"
#include "Resource/Shader/ShaderSpecify.hpp"
#include "Resource/Texture/Texture1D.hpp"
#include "Resource/Texture/Texture2D.hpp"
#include "Resource/Texture/Texture2DIOObject.hpp"
#include "Resource/Texture/TextureCube.hpp"
#include "Resource/Texture/TextureSpecify.hpp"
#include "GraphicsAlgo/Delaunay.hpp"
#include "GraphicsAlgo/MarchingCubes.hpp"
#include "GraphicsAlgo/RotationMatrix.hpp"
#include "GraphicsAlgo/TrackOnSphere.hpp"
#include "RayTracer/RT_KdTree.hpp"
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/zGraphics.hpp
|
C++
|
gpl3
| 2,880
|
#pragma once
#include "../zGraphicsConfig.hpp"
#ifdef ZZZ_LIB_OPENGL
// Glew need to be included before gl.
#define GLEW_STATIC
#include <glew.h>
// OpenGL
#ifdef ZZZ_OS_WIN
#include <Windows.h>
#endif
#include <GL/gl.h>
#include <GL/glu.h>
#endif // ZZZ_LIB_OPENGL
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/Graphics.hpp
|
C++
|
gpl3
| 292
|
#include "CubeMap.hpp"
namespace zzz{
map<zuint,CubemapPosList*> Cubemapbase::PosListMap;
const CubemapPosList& Cubemapbase::GetPosList(zuint n)
{
map<zuint,CubemapPosList*>::iterator muci=PosListMap.find(n);
if (muci==PosListMap.end())
{
CubemapPosList *newposlist=new CubemapPosList;
newposlist->reserve(6*n*n);
const float allarea=4.0/n/n;
const float halfn=n/2.0;
for (zuint i=0; i<6; i++) for (zuint j=0; j<n; j++) for (zuint k=0; k<n; k++)
{
CubemapPos newpos;
newpos.direction=CartesianDirCoordf(CubeCoord((CUBEFACE)i,k,j,n)); //should be i,k,j , so that it is correspond to ToIndex() order
//the must-be-correct way is newposlist[CubeCoord((CUBEFACE)i,j,k,n).ToIndex()].direction=CartesianDirCoordf(CubeCoord((CUBEFACE)i,j,k,n))
//however this must be quicker
float rsquare=1+
(halfn-j-0.5)*(halfn-j-0.5)/halfn/halfn+
(halfn-k-0.5)*(halfn-k-0.5)/halfn/halfn;
float costheta=1.0/sqrt(rsquare);
float omiga=allarea*costheta/rsquare;
newpos.solidangle=omiga;
newposlist->push_back(newpos);
}
PosListMap[n]=newposlist;
return *newposlist;
}
return *(muci->second);
}
map<Cubemapbase::SHBaseCubemapDesc,Cubemap<float>*> Cubemapbase::SHBaseCubemap;
const Cubemap<float>& Cubemapbase::GetSHBaseCubemap(int l,int m,int size)
{
SHBaseCubemapDesc x;
x[0]=l; x[1]=m; x[2]=size;
map<SHBaseCubemapDesc,Cubemap<float>*>::iterator msi=SHBaseCubemap.find(x);
if (msi==SHBaseCubemap.end())
{
Cubemapf *newcube=new Cubemapf(size);
const CubemapPosList &poslist=GetPosList(size);
int len=size*size*6;
for (int i=0; i<len; i++)
{
SphericalCoordf sc(poslist[i].direction);
newcube->v[i]=SHBase(l,m,sc.theta,sc.phi)*poslist[i].solidangle;
}
SHBaseCubemap[x]=newcube;
return *newcube;
}
return *(msi->second);
}
const Cubemap<float>* Cubemapbase::GetSHBaseCubemapPointer(int l,int m,int size)
{
SHBaseCubemapDesc x;
x[0]=l; x[1]=m; x[2]=size;
map<SHBaseCubemapDesc,Cubemap<float>*>::iterator msi=SHBaseCubemap.find(x);
if (msi==SHBaseCubemap.end())
{
Cubemapf *newcube=new Cubemapf(size);
const CubemapPosList &poslist=GetPosList(size);
int len=size*size*6;
for (int i=0; i<len; i++)
{
SphericalCoordf sc(poslist[i].direction);
newcube->v[i]=SHBase(l,m,sc.theta,sc.phi)*poslist[i].solidangle;
}
SHBaseCubemap[x]=newcube;
return newcube;
}
return msi->second;
}
float Cubemapbase::SHBase(int l,int m,float theta,float phi)
{
const float sqrt2 = sqrt(2.0);
if(m==0) return K(l,0)*P(l,m,cos(theta));
else if(m>0) return sqrt2*K(l,m)*cos(m*phi)*P(l,m,cos(theta));
else return sqrt2*K(l,-m)*sin(-m*phi)*P(l,-m,cos(theta));
}
float Cubemapbase::K(int l,int m)
{
float temp = ((2.0*l+1.0)*Factorial(l-m)) / (4.0*PI*Factorial(l+m));
return sqrt(temp);
}
float Cubemapbase::P(int l,int m,float x)
{
float pmm = 1.0;
if(m>0) {
float somx2 = sqrt((1.0-x)*(1.0+x));
float fact = 1.0;
for(int i=1; i<=m; i++) {
pmm *= (-fact) * somx2;
fact += 2.0;
}
}
if(l==m) return pmm;
float pmmp1 = x * (2.0*m+1.0) * pmm;
if(l==m+1) return pmmp1;
float pll = 0.0;
for(int ll=m+2; ll<=l; ++ll) {
pll = ((2.0*ll-1.0)*x*pmmp1-(ll+m-1.0)*pmm) / (ll-m);
pmm = pmmp1;
pmmp1 = pll;
}
return pll;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/CubeMap.cpp
|
C++
|
gpl3
| 3,551
|
#pragma once
#include <zGraphicsConfig.hpp>
#include <Math/Vector3.hpp>
#include "Graphics.hpp"
#include <Image/Image.hpp>
#include "AABB.hpp"
#include "Color.hpp"
namespace zzz{
class ZGRAPHICS_CLASS GraphicsHelper {
public:
inline void DrawLine(const Vector3d &p1, const Vector3d &p2) const
{
glBegin(GL_LINES);
glVertex3dv(p1.Data());
glVertex3dv(p2.Data());
glEnd();
}
inline void DrawTriangle(const Vector3d &p1, const Vector3d &p2, const Vector3d &p3) const
{
glBegin(GL_TRIANGLES);
glNormal3dv(p1.Data());
glVertex3dv(p1.Data());
glNormal3dv(p2.Data());
glVertex3dv(p2.Data());
glNormal3dv(p3.Data());
glVertex3dv(p3.Data());
glEnd();
}
void DrawPlane(const Vector3d &point, const Vector3d &normal, double size) const;
void DrawGrid(const Vector3d &point, const Vector3d &normal, double size, double interval) const;
void DrawCoord(const Vector3d &point, double length=10, int linewidth=4);
void DrawSphere(const double r, const int levels) const;
void DrawImage(const Image<Vector3f> &img)const{glDrawPixels(img.Cols(),img.Rows(),GL_RGB,GL_FLOAT,img.Data());}
void DrawImage(const Image<Vector4f> &img)const{glDrawPixels(img.Cols(),img.Rows(),GL_RGBA,GL_FLOAT,img.Data());}
void DrawImage(const Image<Vector3uc> &img)const{glDrawPixels(img.Cols(),img.Rows(),GL_RGB,GL_UNSIGNED_BYTE,img.Data());}
void DrawImage(const Image<Vector4uc> &img)const{glDrawPixels(img.Cols(),img.Rows(),GL_RGBA,GL_UNSIGNED_BYTE,img.Data());}
void DrawImage(const Image<zuchar> &img)const{glDrawPixels(img.Cols(),img.Rows(),GL_LUMINANCE,GL_UNSIGNED_BYTE,img.Data());}
void DrawImage(const Image<float> &img)const{glDrawPixels(img.Cols(),img.Rows(),GL_LUMINANCE,GL_FLOAT,img.Data());}
void DrawAABB(const AABB<3,float> &aabb, const Colorf& color, float width=1.0f) const;
private:
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/GraphicsHelper.hpp
|
C++
|
gpl3
| 1,899
|
#pragma once
#include <zGraphicsConfig.hpp>
#include "Color.hpp"
namespace zzz {
class ZGRAPHICS_CLASS ColorDefine {
public:
static const Colorf aliceBlue;
static const Colorf antiqueWhite;
static const Colorf antiqueWhite1;
static const Colorf antiqueWhite2;
static const Colorf antiqueWhite3;
static const Colorf antiqueWhite4;
static const Colorf aquamarine;
static const Colorf aquamarine1;
static const Colorf aquamarine2;
static const Colorf aquamarine3;
static const Colorf aquamarine4;
static const Colorf azure;
static const Colorf azure1;
static const Colorf azure2;
static const Colorf azure3;
static const Colorf azure4;
static const Colorf beige;
static const Colorf bisque;
static const Colorf bisque1;
static const Colorf bisque2;
static const Colorf bisque3;
static const Colorf bisque4;
static const Colorf black;
static const Colorf blanchedAlmond;
static const Colorf blue;
static const Colorf blue1;
static const Colorf blue2;
static const Colorf blue3;
static const Colorf blue4;
static const Colorf blueViolet;
static const Colorf brown;
static const Colorf brown1;
static const Colorf brown2;
static const Colorf brown3;
static const Colorf brown4;
static const Colorf burlywood;
static const Colorf burlywood1;
static const Colorf burlywood2;
static const Colorf burlywood3;
static const Colorf burlywood4;
static const Colorf cadetBlue;
static const Colorf cadetBlue1;
static const Colorf cadetBlue2;
static const Colorf cadetBlue3;
static const Colorf cadetBlue4;
static const Colorf chartreuse;
static const Colorf chartreuse1;
static const Colorf chartreuse2;
static const Colorf chartreuse3;
static const Colorf chartreuse4;
static const Colorf chocolate;
static const Colorf chocolate1;
static const Colorf chocolate2;
static const Colorf chocolate3;
static const Colorf chocolate4;
static const Colorf coral;
static const Colorf coral1;
static const Colorf coral2;
static const Colorf coral3;
static const Colorf coral4;
static const Colorf cornflowerBlue;
static const Colorf cornsilk;
static const Colorf cornsilk1;
static const Colorf cornsilk2;
static const Colorf cornsilk3;
static const Colorf cornsilk4;
static const Colorf cyan;
static const Colorf cyan1;
static const Colorf cyan2;
static const Colorf cyan3;
static const Colorf cyan4;
static const Colorf darkBlue;
static const Colorf darkCyan;
static const Colorf darkGoldenrod;
static const Colorf darkGoldenrod1;
static const Colorf darkGoldenrod2;
static const Colorf darkGoldenrod3;
static const Colorf darkGoldenrod4;
static const Colorf darkGray;
static const Colorf darkGreen;
static const Colorf darkGrey;
static const Colorf darkKhaki;
static const Colorf darkMagenta;
static const Colorf darkOliveGreen;
static const Colorf darkOliveGreen1;
static const Colorf darkOliveGreen2;
static const Colorf darkOliveGreen3;
static const Colorf darkOliveGreen4;
static const Colorf darkOrange;
static const Colorf darkOrange1;
static const Colorf darkOrange2;
static const Colorf darkOrange3;
static const Colorf darkOrange4;
static const Colorf darkOrchid;
static const Colorf darkOrchid1;
static const Colorf darkOrchid2;
static const Colorf darkOrchid3;
static const Colorf darkOrchid4;
static const Colorf darkRed;
static const Colorf darkSalmon;
static const Colorf darkSeaGreen;
static const Colorf darkSeaGreen1;
static const Colorf darkSeaGreen2;
static const Colorf darkSeaGreen3;
static const Colorf darkSeaGreen4;
static const Colorf darkSlateBlue;
static const Colorf darkSlateGray;
static const Colorf darkSlateGray1;
static const Colorf darkSlateGray2;
static const Colorf darkSlateGray3;
static const Colorf darkSlateGray4;
static const Colorf darkSlateGrey;
static const Colorf darkTurquoise;
static const Colorf darkViolet;
static const Colorf deepPink;
static const Colorf deepPink1;
static const Colorf deepPink2;
static const Colorf deepPink3;
static const Colorf deepPink4;
static const Colorf deepSkyBlue;
static const Colorf deepSkyBlue1;
static const Colorf deepSkyBlue2;
static const Colorf deepSkyBlue3;
static const Colorf deepSkyBlue4;
static const Colorf dimGray;
static const Colorf dimGrey;
static const Colorf dodgerBlue;
static const Colorf dodgerBlue1;
static const Colorf dodgerBlue2;
static const Colorf dodgerBlue3;
static const Colorf dodgerBlue4;
static const Colorf firebrick;
static const Colorf firebrick1;
static const Colorf firebrick2;
static const Colorf firebrick3;
static const Colorf firebrick4;
static const Colorf floralWhite;
static const Colorf forestGreen;
static const Colorf gainsboro;
static const Colorf ghostWhite;
static const Colorf gold;
static const Colorf gold1;
static const Colorf gold2;
static const Colorf gold3;
static const Colorf gold4;
static const Colorf goldenrod;
static const Colorf goldenrod1;
static const Colorf goldenrod2;
static const Colorf goldenrod3;
static const Colorf goldenrod4;
static const Colorf gray;
static const Colorf gray0;
static const Colorf gray1;
static const Colorf gray10;
static const Colorf gray100;
static const Colorf gray11;
static const Colorf gray12;
static const Colorf gray13;
static const Colorf gray14;
static const Colorf gray15;
static const Colorf gray16;
static const Colorf gray17;
static const Colorf gray18;
static const Colorf gray19;
static const Colorf gray2;
static const Colorf gray20;
static const Colorf gray21;
static const Colorf gray22;
static const Colorf gray23;
static const Colorf gray24;
static const Colorf gray25;
static const Colorf gray26;
static const Colorf gray27;
static const Colorf gray28;
static const Colorf gray29;
static const Colorf gray3;
static const Colorf gray30;
static const Colorf gray31;
static const Colorf gray32;
static const Colorf gray33;
static const Colorf gray34;
static const Colorf gray35;
static const Colorf gray36;
static const Colorf gray37;
static const Colorf gray38;
static const Colorf gray39;
static const Colorf gray4;
static const Colorf gray40;
static const Colorf gray41;
static const Colorf gray42;
static const Colorf gray43;
static const Colorf gray44;
static const Colorf gray45;
static const Colorf gray46;
static const Colorf gray47;
static const Colorf gray48;
static const Colorf gray49;
static const Colorf gray5;
static const Colorf gray50;
static const Colorf gray51;
static const Colorf gray52;
static const Colorf gray53;
static const Colorf gray54;
static const Colorf gray55;
static const Colorf gray56;
static const Colorf gray57;
static const Colorf gray58;
static const Colorf gray59;
static const Colorf gray6;
static const Colorf gray60;
static const Colorf gray61;
static const Colorf gray62;
static const Colorf gray63;
static const Colorf gray64;
static const Colorf gray65;
static const Colorf gray66;
static const Colorf gray67;
static const Colorf gray68;
static const Colorf gray69;
static const Colorf gray7;
static const Colorf gray70;
static const Colorf gray71;
static const Colorf gray72;
static const Colorf gray73;
static const Colorf gray74;
static const Colorf gray75;
static const Colorf gray76;
static const Colorf gray77;
static const Colorf gray78;
static const Colorf gray79;
static const Colorf gray8;
static const Colorf gray80;
static const Colorf gray81;
static const Colorf gray82;
static const Colorf gray83;
static const Colorf gray84;
static const Colorf gray85;
static const Colorf gray86;
static const Colorf gray87;
static const Colorf gray88;
static const Colorf gray89;
static const Colorf gray9;
static const Colorf gray90;
static const Colorf gray91;
static const Colorf gray92;
static const Colorf gray93;
static const Colorf gray94;
static const Colorf gray95;
static const Colorf gray96;
static const Colorf gray97;
static const Colorf gray98;
static const Colorf gray99;
static const Colorf green;
static const Colorf green1;
static const Colorf green2;
static const Colorf green3;
static const Colorf green4;
static const Colorf greenYellow;
static const Colorf grey;
static const Colorf grey0;
static const Colorf grey1;
static const Colorf grey10;
static const Colorf grey100;
static const Colorf grey11;
static const Colorf grey12;
static const Colorf grey13;
static const Colorf grey14;
static const Colorf grey15;
static const Colorf grey16;
static const Colorf grey17;
static const Colorf grey18;
static const Colorf grey19;
static const Colorf grey2;
static const Colorf grey20;
static const Colorf grey21;
static const Colorf grey22;
static const Colorf grey23;
static const Colorf grey24;
static const Colorf grey25;
static const Colorf grey26;
static const Colorf grey27;
static const Colorf grey28;
static const Colorf grey29;
static const Colorf grey3;
static const Colorf grey30;
static const Colorf grey31;
static const Colorf grey32;
static const Colorf grey33;
static const Colorf grey34;
static const Colorf grey35;
static const Colorf grey36;
static const Colorf grey37;
static const Colorf grey38;
static const Colorf grey39;
static const Colorf grey4;
static const Colorf grey40;
static const Colorf grey41;
static const Colorf grey42;
static const Colorf grey43;
static const Colorf grey44;
static const Colorf grey45;
static const Colorf grey46;
static const Colorf grey47;
static const Colorf grey48;
static const Colorf grey49;
static const Colorf grey5;
static const Colorf grey50;
static const Colorf grey51;
static const Colorf grey52;
static const Colorf grey53;
static const Colorf grey54;
static const Colorf grey55;
static const Colorf grey56;
static const Colorf grey57;
static const Colorf grey58;
static const Colorf grey59;
static const Colorf grey6;
static const Colorf grey60;
static const Colorf grey61;
static const Colorf grey62;
static const Colorf grey63;
static const Colorf grey64;
static const Colorf grey65;
static const Colorf grey66;
static const Colorf grey67;
static const Colorf grey68;
static const Colorf grey69;
static const Colorf grey7;
static const Colorf grey70;
static const Colorf grey71;
static const Colorf grey72;
static const Colorf grey73;
static const Colorf grey74;
static const Colorf grey75;
static const Colorf grey76;
static const Colorf grey77;
static const Colorf grey78;
static const Colorf grey79;
static const Colorf grey8;
static const Colorf grey80;
static const Colorf grey81;
static const Colorf grey82;
static const Colorf grey83;
static const Colorf grey84;
static const Colorf grey85;
static const Colorf grey86;
static const Colorf grey87;
static const Colorf grey88;
static const Colorf grey89;
static const Colorf grey9;
static const Colorf grey90;
static const Colorf grey91;
static const Colorf grey92;
static const Colorf grey93;
static const Colorf grey94;
static const Colorf grey95;
static const Colorf grey96;
static const Colorf grey97;
static const Colorf grey98;
static const Colorf grey99;
static const Colorf honeydew;
static const Colorf honeydew1;
static const Colorf honeydew2;
static const Colorf honeydew3;
static const Colorf honeydew4;
static const Colorf hotPink;
static const Colorf hotPink1;
static const Colorf hotPink2;
static const Colorf hotPink3;
static const Colorf hotPink4;
static const Colorf indianRed;
static const Colorf indianRed1;
static const Colorf indianRed2;
static const Colorf indianRed3;
static const Colorf indianRed4;
static const Colorf ivory;
static const Colorf ivory1;
static const Colorf ivory2;
static const Colorf ivory3;
static const Colorf ivory4;
static const Colorf khaki;
static const Colorf khaki1;
static const Colorf khaki2;
static const Colorf khaki3;
static const Colorf khaki4;
static const Colorf lavender;
static const Colorf lavenderBlush;
static const Colorf lavenderBlush1;
static const Colorf lavenderBlush2;
static const Colorf lavenderBlush3;
static const Colorf lavenderBlush4;
static const Colorf lawnGreen;
static const Colorf lemonChiffon;
static const Colorf lemonChiffon1;
static const Colorf lemonChiffon2;
static const Colorf lemonChiffon3;
static const Colorf lemonChiffon4;
static const Colorf lightBlue;
static const Colorf lightBlue1;
static const Colorf lightBlue2;
static const Colorf lightBlue3;
static const Colorf lightBlue4;
static const Colorf lightCoral;
static const Colorf lightCyan;
static const Colorf lightCyan1;
static const Colorf lightCyan2;
static const Colorf lightCyan3;
static const Colorf lightCyan4;
static const Colorf lightGoldenrod;
static const Colorf lightGoldenrod1;
static const Colorf lightGoldenrod2;
static const Colorf lightGoldenrod3;
static const Colorf lightGoldenrod4;
static const Colorf lightGoldenrodYellow;
static const Colorf lightGray;
static const Colorf lightGreen;
static const Colorf lightGrey;
static const Colorf lightPink;
static const Colorf lightPink1;
static const Colorf lightPink2;
static const Colorf lightPink3;
static const Colorf lightPink4;
static const Colorf lightSalmon;
static const Colorf lightSalmon1;
static const Colorf lightSalmon2;
static const Colorf lightSalmon3;
static const Colorf lightSalmon4;
static const Colorf lightSeaGreen;
static const Colorf lightSkyBlue;
static const Colorf lightSkyBlue1;
static const Colorf lightSkyBlue2;
static const Colorf lightSkyBlue3;
static const Colorf lightSkyBlue4;
static const Colorf lightSlateBlue;
static const Colorf lightSlateGray;
static const Colorf lightSlateGrey;
static const Colorf lightSteelBlue;
static const Colorf lightSteelBlue1;
static const Colorf lightSteelBlue2;
static const Colorf lightSteelBlue3;
static const Colorf lightSteelBlue4;
static const Colorf lightYellow;
static const Colorf lightYellow1;
static const Colorf lightYellow2;
static const Colorf lightYellow3;
static const Colorf lightYellow4;
static const Colorf limeGreen;
static const Colorf linen;
static const Colorf magenta;
static const Colorf magenta1;
static const Colorf magenta2;
static const Colorf magenta3;
static const Colorf magenta4;
static const Colorf maroon;
static const Colorf maroon1;
static const Colorf maroon2;
static const Colorf maroon3;
static const Colorf maroon4;
static const Colorf mediumAquamarine;
static const Colorf mediumBlue;
static const Colorf mediumOrchid;
static const Colorf mediumOrchid1;
static const Colorf mediumOrchid2;
static const Colorf mediumOrchid3;
static const Colorf mediumOrchid4;
static const Colorf mediumPurple;
static const Colorf mediumPurple1;
static const Colorf mediumPurple2;
static const Colorf mediumPurple3;
static const Colorf mediumPurple4;
static const Colorf mediumSeaGreen;
static const Colorf mediumSlateBlue;
static const Colorf mediumSpringGreen;
static const Colorf mediumTurquoise;
static const Colorf mediumVioletRed;
static const Colorf midnightBlue;
static const Colorf mintCream;
static const Colorf mistyRose;
static const Colorf mistyRose1;
static const Colorf mistyRose2;
static const Colorf mistyRose3;
static const Colorf mistyRose4;
static const Colorf moccasin;
static const Colorf navajoWhite;
static const Colorf navajoWhite1;
static const Colorf navajoWhite2;
static const Colorf navajoWhite3;
static const Colorf navajoWhite4;
static const Colorf navy;
static const Colorf navyBlue;
static const Colorf oldLace;
static const Colorf oliveDrab;
static const Colorf oliveDrab1;
static const Colorf oliveDrab2;
static const Colorf oliveDrab3;
static const Colorf oliveDrab4;
static const Colorf orange;
static const Colorf orange1;
static const Colorf orange2;
static const Colorf orange3;
static const Colorf orange4;
static const Colorf orangeRed;
static const Colorf orangeRed1;
static const Colorf orangeRed2;
static const Colorf orangeRed3;
static const Colorf orangeRed4;
static const Colorf orchid;
static const Colorf orchid1;
static const Colorf orchid2;
static const Colorf orchid3;
static const Colorf orchid4;
static const Colorf paleGoldenrod;
static const Colorf paleGreen;
static const Colorf paleGreen1;
static const Colorf paleGreen2;
static const Colorf paleGreen3;
static const Colorf paleGreen4;
static const Colorf paleTurquoise;
static const Colorf paleTurquoise1;
static const Colorf paleTurquoise2;
static const Colorf paleTurquoise3;
static const Colorf paleTurquoise4;
static const Colorf paleVioletRed;
static const Colorf paleVioletRed1;
static const Colorf paleVioletRed2;
static const Colorf paleVioletRed3;
static const Colorf paleVioletRed4;
static const Colorf papayaWhip;
static const Colorf peachPuff;
static const Colorf peachPuff1;
static const Colorf peachPuff2;
static const Colorf peachPuff3;
static const Colorf peachPuff4;
static const Colorf peru;
static const Colorf pink;
static const Colorf pink1;
static const Colorf pink2;
static const Colorf pink3;
static const Colorf pink4;
static const Colorf plum;
static const Colorf plum1;
static const Colorf plum2;
static const Colorf plum3;
static const Colorf plum4;
static const Colorf powderBlue;
static const Colorf purple;
static const Colorf purple1;
static const Colorf purple2;
static const Colorf purple3;
static const Colorf purple4;
static const Colorf red;
static const Colorf red1;
static const Colorf red2;
static const Colorf red3;
static const Colorf red4;
static const Colorf rosyBrown;
static const Colorf rosyBrown1;
static const Colorf rosyBrown2;
static const Colorf rosyBrown3;
static const Colorf rosyBrown4;
static const Colorf royalBlue;
static const Colorf royalBlue1;
static const Colorf royalBlue2;
static const Colorf royalBlue3;
static const Colorf royalBlue4;
static const Colorf saddleBrown;
static const Colorf salmon;
static const Colorf salmon1;
static const Colorf salmon2;
static const Colorf salmon3;
static const Colorf salmon4;
static const Colorf sandyBrown;
static const Colorf seaGreen;
static const Colorf seaGreen1;
static const Colorf seaGreen2;
static const Colorf seaGreen3;
static const Colorf seaGreen4;
static const Colorf seashell;
static const Colorf seashell1;
static const Colorf seashell2;
static const Colorf seashell3;
static const Colorf seashell4;
static const Colorf sienna;
static const Colorf sienna1;
static const Colorf sienna2;
static const Colorf sienna3;
static const Colorf sienna4;
static const Colorf skyBlue;
static const Colorf skyBlue1;
static const Colorf skyBlue2;
static const Colorf skyBlue3;
static const Colorf skyBlue4;
static const Colorf slateBlue;
static const Colorf slateBlue1;
static const Colorf slateBlue2;
static const Colorf slateBlue3;
static const Colorf slateBlue4;
static const Colorf slateGray;
static const Colorf slateGray1;
static const Colorf slateGray2;
static const Colorf slateGray3;
static const Colorf slateGray4;
static const Colorf slateGrey;
static const Colorf snow;
static const Colorf snow1;
static const Colorf snow2;
static const Colorf snow3;
static const Colorf snow4;
static const Colorf springGreen;
static const Colorf springGreen1;
static const Colorf springGreen2;
static const Colorf springGreen3;
static const Colorf springGreen4;
static const Colorf steelBlue;
static const Colorf steelBlue1;
static const Colorf steelBlue2;
static const Colorf steelBlue3;
static const Colorf steelBlue4;
static const Colorf tan1;
static const Colorf tan2;
static const Colorf tan3;
static const Colorf tan4;
static const Colorf thistle;
static const Colorf thistle1;
static const Colorf thistle2;
static const Colorf thistle3;
static const Colorf thistle4;
static const Colorf tomato;
static const Colorf tomato1;
static const Colorf tomato2;
static const Colorf tomato3;
static const Colorf tomato4;
static const Colorf turquoise;
static const Colorf turquoise1;
static const Colorf turquoise2;
static const Colorf turquoise3;
static const Colorf turquoise4;
static const Colorf violet;
static const Colorf violetRed;
static const Colorf violetRed1;
static const Colorf violetRed2;
static const Colorf violetRed3;
static const Colorf violetRed4;
static const Colorf wheat;
static const Colorf wheat1;
static const Colorf wheat2;
static const Colorf wheat3;
static const Colorf wheat4;
static const Colorf white;
static const Colorf whiteSmoke;
static const Colorf yellow;
static const Colorf yellow1;
static const Colorf yellow2;
static const Colorf yellow3;
static const Colorf yellow4;
static const Colorf yellowGreen;
static const int Size;
static const char *Name[];
static const Color<float> *Value[];
static const int DistinctSize;
static const char *DistinctName[];
static const Color<float> *DistinctValue[];
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/ColorDefine.hpp
|
C++
|
gpl3
| 22,212
|
#pragma once
#include "HaarCoeffCubemap.hpp"
namespace zzz{
template < int CUBEFACEN,class T1=float,typename T2=unsigned short > class HaarCoeffCubemap4TripleFull;
struct _s
{
short l; //:8; //256
short i; //:12; //4096
short j; //:12; //4096
};
enum _m{M01,M10,M11};
//////////////////////////////////////////////////////////////////////////
#define _SPARSENEW
template < int CUBEFACEN,class T1=float,typename T2=unsigned short >
class HaarCoeffCubemap4TripleSparse
{
public:
typedef T1 VALUE_TYPE;
typedef T2 INDEX_TYPE;
VALUE_TYPE Scale[6];
struct _coeff
{
Vector<3,VALUE_TYPE> value;
INDEX_TYPE index;
bool operator<(const _coeff &c)const {return index<c.index;}
}*Coeff;
int Size;
const int LEVELN;
static const int FACEDATASIZE=(CUBEFACEN*CUBEFACEN-1)/3;
static const int DATASIZE=FACEDATASIZE*6;
VALUE_TYPE EMPTYPSUM;
#ifdef SPARSENEW
INDEX_TYPE IndexToLocal[DATASIZE];
#endif
VALUE_TYPE *psum;
bool psumanege_;
const Vector<3,VALUE_TYPE> zerovalue;
HaarCoeffCubemap4TripleSparse()
:zerovalue(0),LEVELN(Log2(CUBEFACEN)),psumanege_(false)
{
Size=0;
memset(Scale,0,sizeof(VALUE_TYPE)*6);
memset(&EMPTYPSUM,1,sizeof(T1));
#ifdef SPARSENEW
memset(IndexToLocal,0,sizeof(INDEX_TYPE)*DATASIZE);
#endif
Coeff=NULL;
psum=NULL;
psumanege_=false;
}
~HaarCoeffCubemap4TripleSparse()
{
delete[] Coeff;
if (psumanege_)
delete[] psum;
}
inline void operator*=(const VALUE_TYPE &x)
{
for (int i=0; i<Size; i++)
Coeff[i].value*=x;
for (int i=0; i<6; i++)
Scale[i]*=x;
}
inline void operator+=(const HaarCoeffCubemap4TripleSparse<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &h)
{
for(int i=0; i<6; i++)
Scale[i]+=h.Scale[i];
#ifdef SPARSENEW
_coeff *newdata=new _coeff[Size+h.Size];
memcpy(newdata,Coeff,sizeof(_coeff)*Size);
memcpy(newdata+Size,h.Coeff,sizeof(_coeff)*h.Size);
delete[] Coeff;
Coeff=newdata;
Size+=h.Size;
memset(IndexToLocal,0,sizeof(INDEX_TYPE)*DATASIZE);
for (int i=0; i<Size; i++)
{
int index=Coeff[i].index;
if (IndexToLocal[index]==0) IndexToLocal[index]=i;
else
{
Coeff[IndexToLocal[i]].value+=Coeff[i].value;
Coeff[i].value.v[0]=EMPTYPSUM;
}
}
#else
_coeff* tmp=new _coeff[Size+h.Size];
memset(tmp,0,sizeof(_coeff)*(Size+h.Size));
_coeff *c1=Coeff,*c2=h.Coeff,*c1end=Coeff+Size,*c2end=h.Coeff+h.Size;
if (c1==NULL)
{
*this=h;
return;
}
int cur=0;
while(c1!=c1end && c2!=c2end)
{
if (c1->value==0){c1++;continue;}
if (c2->value==0){c2++;continue;}
if (c1->index<c2->index)
{
tmp[cur]=(*c1);
cur++;
c1++;
}
else if (c1->index>c2->index)
{
tmp[cur]=(*c2);
cur++;
c2++;
}
else
{
tmp[cur].index=c1->index; ;
tmp[cur].value=c1->value+c2->value;
cur++;
c1++;
c2++;
}
}
while (c1!=c1end)
{
if (c1->value==0){c1++;continue;}
tmp[cur]=(*c1);
cur++;
c1++;
}
while (c2!=c2end)
{
if (c2->value==0){c2++;continue;}
tmp[cur]=(*c2);
cur++;
c2++;
}
Size=cur;
delete[] Coeff;
Coeff=tmp;
#endif
}
inline void operator=(const HaarCoeffCubemap4TripleSparse<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &h)
{
memcpy(Scale,h.Scale,sizeof(VALUE_TYPE)*6);
if (Size!=h.Size)
{
delete[] Coeff;
Size=h.Size;
if (Size!=0)
{
Coeff=new _coeff[Size];
memcpy(Coeff,h.Coeff,sizeof(_coeff)*Size);
}
else Coeff=NULL;
}
else
memcpy(Coeff,h.Coeff,sizeof(_coeff)*Size);
PrepareIndexToLocal();
if (psum!=NULL)
memset(psum,1,sizeof(VALUE_TYPE)*DATASIZE);
}
const Vector<3,VALUE_TYPE> & operator[](INDEX_TYPE n) const
{
if (Coeff==NULL)
return zerovalue;
_coeff c;
c.index=n;
const _coeff *pos=lower_bound(Coeff,Coeff+Size,c);
if (pos->index==n) return pos->value;
else return zerovalue;
}
const Vector<3,VALUE_TYPE> *Find(INDEX_TYPE n)
{
if (Coeff==NULL)
return NULL;
#ifdef SPARSENEW
int pos=IndexToLocal[n];
if (pos==0) return NULL;
else return &(Coeff[pos].value);
#else
_coeff c;
c.index=n;
const _coeff *pos=lower_bound(Coeff,Coeff+Size,c);
if (pos->index==n) return &(pos->value);
else return NULL;
#endif
}
inline void PrepareIndexToLocal()
{
#ifdef SPARSENEW
memset(IndexToLocal,0,sizeof(INDEX_TYPE)*DATASIZE);
for(int i=0; i<Size; i++)
IndexToLocal[Coeff[i].index]=i;
#endif
}
inline void Clear()
{
delete[] Coeff;
Coeff=NULL;
Size=0;
memset(Scale,0,sizeof(VALUE_TYPE)*6);
if (psum!=NULL)
memset(psum,1,sizeof(VALUE_TYPE)*DATASIZE);
}
inline void Zero()
{
Clear();
}
inline void ResetPsum()
{
if (psum!=NULL)
memset(psum,1,sizeof(VALUE_TYPE)*DATASIZE);
}
inline void Create(int n)
{
if (n==Size) return;
Clear();
Coeff=new _coeff[n];
memset(Coeff,0,sizeof(_coeff)*n);
Size=n;
}
VALUE_TYPE Dot(const HaarCoeffCubemap4TripleSparse<CUBEFACEN,T1,T2> &c)const
{
VALUE_TYPE ret=Scale[0]*c.Scale[0]+Scale[1]*c.Scale[1]+Scale[2]*c.Scale[2]+Scale[3]*c.Scale[3]+Scale[4]*c.Scale[4]+Scale[5]*c.Scale[5];
if (c.Size==0) return ret;
_coeff *cur1=Coeff,*cur2=c.Coeff,*end1=cur1+Size,*end2=cur2+c.Size;
for (;cur1!=end1;cur1++)
{
#ifdef SPARSENEW
if (cur1->value.v[0]=EMPTYPSUM) continue;
int index=cur1->index;
int pos2=c.IndexToLocal[index];
if (pos2==0) continue;
ret+=cur1->value.Dot(c.Coeff[pos2].value);
#else
while(cur2!=end2 && cur1->index > cur2->index) cur2++;
if (cur2==end2) break;
if (cur1->index==cur2->index)
ret+=cur1->value.Dot(cur2->value);
#endif
}
return ret;
}
VALUE_TYPE Dot(const HaarCoeffCubemap4TripleFull<CUBEFACEN,T1,T2> &c)const
{
VALUE_TYPE ret=Scale[0]*c.Scale[0]+Scale[1]*c.Scale[1]+Scale[2]*c.Scale[2]+Scale[3]*c.Scale[3]+Scale[4]*c.Scale[4]+Scale[5]*c.Scale[5];
for (int cur1=0;cur1<Size;cur1++)
{
ret+=Coeff[cur1].value.Dot(c.Square[Coeff[cur1].index]);
}
return ret;
}
void SaveToCubemap(Cubemap<VALUE_TYPE> &c)
{
const HaarCoeffCubemap4TripleFull<CUBEFACEN,INDEX_TYPE,INDEX_TYPE> &indextable=HaarCoeffCubemap4TripleFull<CUBEFACEN>::GetCubemapIndexTable();
c.Zero();
c.ChangeSize(CUBEFACEN);
for(int sideIdx = 0; sideIdx < 6; ++sideIdx)
{
c.v[indextable.Scale[sideIdx]]=Scale[sideIdx];
}
for (int i=0; i<Size; i++)
{
c.v[indextable.Square[Coeff[i].index].v[0]]=Coeff[i].value.v[0];
c.v[indextable.Square[Coeff[i].index].v[1]]=Coeff[i].value.v[1];
c.v[indextable.Square[Coeff[i].index].v[2]]=Coeff[i].value.v[2];
}
}
friend ostream& operator<<(ostream &o, HaarCoeffCubemap4TripleSparse<CUBEFACEN,T1,T2> &me)
{
me.SaveToFileA(o);
return o;
}
friend istream& operator>>(istream &i, HaarCoeffCubemap4TripleSparse<CUBEFACEN,T1,T2> &me)
{
me.LoadFromFileA(i);
return i;
}
void SaveToFileA(ostream &fo)
{
fo<<Scale[0]<<' '<<Scale[1]<<' '<<Scale[2]<<' '<<Scale[3]<<' '<<Scale[4]<<' '<<Scale[5]<<endl;
fo<<Size<<endl;
for(int i=0; i<Size; i++)
{
fo<<Coeff[i].value<<' ';
fo<<Coeff[i].index<<' ';
}
fo<<endl;
}
void LoadFromFileA(istream &fi)
{
Clear();
fi>>Scale[0]>>Scale[1]>>Scale[2]>>Scale[3]>>Scale[4]>>Scale[5];
fi>>Size;
Coeff=new _coeff[Size];
for(int i=0; i<Size; i++)
{
fi>>Coeff[i].value;
fi>>Coeff[i].index;
}
PrepareIndexToLocal();
}
void LoadFromFileA(FILE *fp)
{
printf("LoadFromFileA(FILE *fp) must be specilized to use!\n");
}
void SaveToFileB(FILE *fp)
{
fwrite(Scale,sizeof(VALUE_TYPE),6,fp);
fwrite(&Size,sizeof(Size),1,fp);
fwrite(Coeff,sizeof(_coeff),Size,fp);
}
void LoadFromFileB(FILE *fp)
{
Clear();
fread(Scale,sizeof(VALUE_TYPE),6,fp);
fread(&Size,sizeof(Size),1,fp);
Coeff=new _coeff[Size];
fread(Coeff,sizeof(_coeff),Size,fp);
PrepareIndexToLocal();
}
};
void HaarCoeffCubemap4TripleSparse<32,float,unsigned short>::LoadFromFileA(FILE *fp)
{
Clear();
fscanf(fp,"%f %f %f %f %f %f",Scale,Scale+1,Scale+2,Scale+3,Scale+4,Scale+5);
fscanf(fp,"%d",&Size);
Coeff=new _coeff[Size];
for(int i=0; i<Size; i++)
{
fscanf(fp,"%f %f %f",&(Coeff[i].value[0]),&(Coeff[i].value[1]),&(Coeff[i].value[2]));
fscanf(fp,"%hd",&(Coeff[i].index));
}
}
//////////////////////////////////////////////////////////////////////////
template < int CUBEFACEN, int KEEPNUM, class T1=float,typename T2=unsigned short >
class HaarCoeffCubemap4TripleSparseStatic
{
public:
typedef T1 VALUE_TYPE;
typedef T2 INDEX_TYPE;
VALUE_TYPE Scale[6];
struct _coeff
{
Vector<3,VALUE_TYPE> value;
INDEX_TYPE index;
bool operator<(const _coeff &c)const {return index<c.index;}
}Coeff[KEEPNUM];
static const int Size=KEEPNUM;
const int LEVELN;
static const int FACEDATASIZE=(CUBEFACEN*CUBEFACEN-1)/3;
static const int DATASIZE=FACEDATASIZE*6;
T1 EMPTYPSUM;
VALUE_TYPE *psum;
bool psumanege_;
const Vector<3,VALUE_TYPE> zerovalue;
HaarCoeffCubemap4TripleSparseStatic()
:zerovalue(0),LEVELN(Log2(CUBEFACEN)),psumanege_(false)
{
memset(Scale,0,sizeof(VALUE_TYPE)*6);
memset(&EMPTYPSUM,1,sizeof(T1));
memset(Coeff,0,sizeof(_coeff)*KEEPNUM);
for (int i=0; i<KEEPNUM; i++) Coeff[i].index=i;
psumanege_=false;
psum=NULL;
}
~HaarCoeffCubemap4TripleSparseStatic()
{
if (psumanege_)
delete[] psum;
}
inline void operator*=(const VALUE_TYPE &x)
{
for (int i=0; i<KEEPNUM; i++)
Coeff[i].value*=x;
for (int i=0; i<6; i++)
Scale[i]*=x;
}
inline void operator/=(const VALUE_TYPE &x)
{
for (int i=0; i<KEEPNUM; i++)
Coeff[i].value/=x;
for (int i=0; i<6; i++)
Scale[i]/=x;
}
struct _sortnode{VALUE_TYPE sum;INDEX_TYPE index;int pos;};
struct _SumGreater{bool operator()(const _sortnode &x,const _sortnode &y){return x.sum>y.sum;}};
struct _IndexLess{bool operator()(const _sortnode &x,const _sortnode &y){return x.index<y.index;}};
inline void operator+=(const HaarCoeffCubemap4TripleSparseStatic<CUBEFACEN,KEEPNUM,VALUE_TYPE,INDEX_TYPE> &h)
{
Vector<3,VALUE_TYPE> tmp[KEEPNUM*2];
_sortnode tmp2[KEEPNUM*2];
int cur=0,cur2=0;
for (int cur1=0;cur1<KEEPNUM;cur1++)
{
while (cur2<KEEPNUM && Coeff[cur1].index>h.Coeff[cur2].index)
{
tmp2[cur].index=h.Coeff[cur2].index;
tmp2[cur].pos=cur;
tmp[cur]=h.Coeff[cur2].value;
tmp2[cur].sum=tmp[cur].AbsMax();
cur++;cur2++;
}
if (cur2<KEEPNUM && Coeff[cur1].index==h.Coeff[cur2].index)
{
tmp2[cur].index=Coeff[cur1].index;
tmp2[cur].pos=cur;
tmp[cur]=h.Coeff[cur2].value+Coeff[cur1].value;
tmp2[cur].sum=tmp[cur].AbsMax();
cur++;cur2++;
continue;
}
if ((cur2>=KEEPNUM) || (cur2<KEEPNUM && Coeff[cur1].index<h.Coeff[cur2].index))
{
tmp2[cur].index=Coeff[cur1].index;
tmp2[cur].pos=cur;
tmp[cur]=Coeff[cur1].value;
tmp2[cur].sum=tmp[cur].AbsMax();
cur++;
continue;
}
}
while (cur2<KEEPNUM)
{
tmp2[cur].index=h.Coeff[cur2].index;
tmp2[cur].pos=cur;
tmp[cur]=h.Coeff[cur2].value;
tmp2[cur].sum=tmp[cur].AbsMax();
cur++;cur2++;
}
nth_element(tmp2,tmp2+KEEPNUM,tmp2+cur,_SumGreater());
sort(tmp2,tmp2+KEEPNUM,_IndexLess());
for (int i=0; i<KEEPNUM; i++)
{
Coeff[i].value=tmp[tmp2[i].pos];
Coeff[i].index=tmp2[i].index;
}
for(int i=0; i<6; i++)
Scale[i]+=h.Scale[i];
}
inline const HaarCoeffCubemap4TripleSparseStatic<CUBEFACEN,KEEPNUM,VALUE_TYPE,INDEX_TYPE>& operator=(const HaarCoeffCubemap4TripleSparseStatic<CUBEFACEN,KEEPNUM,VALUE_TYPE,INDEX_TYPE> &h)
{
Zero();
memcpy(Scale,h.Scale,sizeof(VALUE_TYPE)*6);
memcpy(Coeff,h.Coeff,sizeof(_coeff)*KEEPNUM);
return *this;
}
inline const HaarCoeffCubemap4TripleSparseStatic<CUBEFACEN,KEEPNUM,VALUE_TYPE,INDEX_TYPE>& operator=(const HaarCoeffCubemap4TripleSparse<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &h)
{
Zero();
memcpy(Scale,h.Scale,sizeof(VALUE_TYPE)*6);
if (h.Size==KEEPNUM)
memcpy(Coeff,h.Coeff,sizeof(_coeff)*KEEPNUM);
else if (h.Size>KEEPNUM)
{
_sortnode *tmp2=new _sortnode[h.Size];
for (int i=0; i<h.Size; i++)
{
tmp2[i].index=h.Coeff[i].index;
tmp2[i].pos=i;
tmp2[i].sum=h.Coeff[i].value.AbsMax();
}
nth_element(tmp2,tmp2+KEEPNUM,tmp2+h.Size,_SumGreater());
sort(tmp2,tmp2+KEEPNUM,_IndexLess());
for (int i=0; i<KEEPNUM; i++)
{
Coeff[i].value=h.Coeff[tmp2[i].pos].value;
Coeff[i].value=tmp2[i].index;
}
}
else
{
memcpy(Coeff,h.Coeff,sizeof(_coeff)*h.Size);
for (int cur=Coeff[h.Size-1].index,i=h.Size; i<KEEPNUM; i++)
Coeff[i].index=cur++;
}
return *this;
}
const Vector<3,VALUE_TYPE> & operator[](INDEX_TYPE n) const
{
_coeff c;
c.index=n;
const _coeff *pos=lower_bound(Coeff,Coeff+KEEPNUM,c);
if (pos->index==n) return pos->value;
else return zerovalue;
}
_coeff *Find(INDEX_TYPE n)
{
_coeff c;
c.index=n;
_coeff *pos=lower_bound(Coeff,Coeff+KEEPNUM,c);
if (pos->index==n) return pos;
else return NULL;
}
inline void Zero()
{
memset(Scale,0,sizeof(VALUE_TYPE)*6);
memset(Coeff,0,sizeof(_coeff)*KEEPNUM);
for (int i=0; i<KEEPNUM; i++) Coeff[i].index=i;
if (psum!=NULL)
memset(psum,1,sizeof(VALUE_TYPE)*DATASIZE);
}
inline void ResetPsum()
{
if (psum!=NULL)
memset(psum,1,sizeof(VALUE_TYPE)*DATASIZE);
}
template <int KEEPNUM2>
VALUE_TYPE Dot(const HaarCoeffCubemap4TripleSparseStatic<CUBEFACEN,KEEPNUM2,T1,T2> &c)const
{
VALUE_TYPE ret=Scale[0]*c.Scale[0]+Scale[1]*c.Scale[1]+Scale[2]*c.Scale[2]+Scale[3]*c.Scale[3]+Scale[4]*c.Scale[4]+Scale[5]*c.Scale[5];
if (c.Size==0) return ret;
int cur2=0;
for (int cur1=0;cur1<KEEPNUM;cur1++)
{
while(cur2<KEEPNUM2 && Coeff[cur1].index>c.Coeff[cur2].index) cur2++;
if (cur2==KEEPNUM2) break;
if (Coeff[cur1].index==c.Coeff[cur2].index)
ret+=Coeff[cur1].value.Dot(c.Coeff[cur2].value);
}
return ret;
}
VALUE_TYPE Dot(const HaarCoeffCubemap4TripleFull<CUBEFACEN,T1,T2> &c)const
{
VALUE_TYPE ret=Scale[0]*c.Scale[0]+Scale[1]*c.Scale[1]+Scale[2]*c.Scale[2]+Scale[3]*c.Scale[3]+Scale[4]*c.Scale[4]+Scale[5]*c.Scale[5];
for (int cur1=0;cur1<KEEPNUM;cur1++)
{
ret+=Coeff[cur1].value.Dot(c.Square[Coeff[cur1].index]);
}
return ret;
}
void SaveToCubemap(Cubemap<VALUE_TYPE> &c)
{
const HaarCoeffCubemap4TripleFull<CUBEFACEN,INDEX_TYPE,INDEX_TYPE> &indextable=HaarCoeffCubemap4TripleFull<CUBEFACEN>::GetCubemapIndexTable();
c.Zero();
c.ChangeSize(CUBEFACEN);
for(int sideIdx = 0; sideIdx < 6; ++sideIdx)
{
c.v[indextable.Scale[sideIdx]]=Scale[sideIdx];
}
for (int i=0; i<KEEPNUM; i++)
{
c.v[indextable.Square[Coeff[i].index].v[0]]=Coeff[i].value.v[0];
c.v[indextable.Square[Coeff[i].index].v[1]]=Coeff[i].value.v[1];
c.v[indextable.Square[Coeff[i].index].v[2]]=Coeff[i].value.v[2];
}
}
friend ostream& operator<<(ostream &o, HaarCoeffCubemap4TripleSparseStatic<CUBEFACEN,KEEPNUM,T1,T2> &me)
{
me.SaveToFileA(o);
return o;
}
friend istream& operator>>(istream &i, HaarCoeffCubemap4TripleSparseStatic<CUBEFACEN,KEEPNUM,T1,T2> &me)
{
me.LoadFromFileA(i);
return i;
}
void SaveToFileA(ostream &fo)
{
fo<<Scale[0]<<' '<<Scale[1]<<' '<<Scale[2]<<' '<<Scale[3]<<' '<<Scale[4]<<' '<<Scale[5]<<endl;
fo<<Size<<endl;
for(int i=0; i<KEEPNUM; i++)
{
fo<<Coeff[i].value<<' ';
fo<<Coeff[i].index<<' ';
}
fo<<endl;
}
void LoadFromFileA(istream &fi)
{
Clear();
fi>>Scale[0]>>Scale[1]>>Scale[2]>>Scale[3]>>Scale[4]>>Scale[5];
int size;
fi>>size;
if (size!=KEEPNUM)
{
printf("HaarCoeffCubemap4TripleSparseStatic LoadFromFileA ERROR!\n");
return;
}
Coeff=new _coeff[Size];
for(int i=0; i<KEEPNUM; i++)
{
fi>>Coeff[i].value;
fi>>Coeff[i].index;
}
}
void LoadFromFileA(FILE *fp)
{
printf("LoadFromFileA(FILE *fp) must be specilized to use!\n");
}
void SaveToFileB(FILE *fp)
{
fwrite(Scale,sizeof(VALUE_TYPE),6,fp);
fwrite(&Size,sizeof(Size),1,fp);
fwrite(Coeff,sizeof(_coeff),KEEPNUM,fp);
}
void LoadFromFileB(FILE *fp)
{
Clear();
fread(Scale,sizeof(VALUE_TYPE),6,fp);
fread(&Size,sizeof(Size),1,fp);
if (size!=KEEPNUM)
{
printf("HaarCoeffCubemap4TripleSparseStatic LoadFromFileA ERROR!\n");
return;
}
fread(Coeff,sizeof(_coeff),KEEPNUM,fp);
}
};
//////////////////////////////////////////////////////////////////////////
template < int CUBEFACEN,class T1,typename T2 >
class HaarCoeffCubemap4TripleFull
{
public:
typedef T1 VALUE_TYPE;
typedef T2 INDEX_TYPE;
const int LEVELN;
static const int FACEDATASIZE=(CUBEFACEN*CUBEFACEN-1)/3;
static const int DATASIZE=FACEDATASIZE*6;
T1 EMPTYPSUM;
VALUE_TYPE Scale[6];
Vector<3,VALUE_TYPE> Square[DATASIZE];
T1 psum[DATASIZE];
HaarCoeffCubemap4TripleFull()
:LEVELN(Log2(CUBEFACEN))
{
memset(&EMPTYPSUM,1,sizeof(EMPTYPSUM));
// Zero();
}
inline Vector<3,VALUE_TYPE> & operator[](INDEX_TYPE n)
{
return Square[n];
}
inline const Vector<3,VALUE_TYPE> & operator[](INDEX_TYPE n) const
{
return Square[n];
}
inline void Zero()
{
memset(Square,0,sizeof(Vector<3,VALUE_TYPE>)*DATASIZE);
memset(psum,1,sizeof(T1)*DATASIZE);
memset(Scale,0,sizeof(VALUE_TYPE)*6);
}
inline void ResetPsum()
{
memset(psum,1,sizeof(T1)*DATASIZE);
}
inline void operator=(const HaarCoeffCubemap4TripleFull<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &f)
{
memcpy(Scale,f.Scale,sizeof(VALUE_TYPE)*6);
memcpy(Square,f.Square,sizeof(Vector<3,VALUE_TYPE>)*DATASIZE);
}
inline void operator+=(const HaarCoeffCubemap4TripleFull<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &f)
{
for (int i=0; i<6; i++)
Scale[i]+=f.Scale[i];
for (int i=0; i<DATASIZE; i++)
Square[i]+=f.Square[i];
}
INDEX_TYPE SToPos(_s s,_m m,int face)
{
switch (m)
{
case M01:
return face*CUBEFACEN*CUBEFACEN+CUBEFACEN*s.j+(1<<s.l)+s.i;
case M10:
return face*CUBEFACEN*CUBEFACEN+CUBEFACEN*((1<<s.l)+s.j)+s.i;
case M11:
return face*CUBEFACEN*CUBEFACEN+CUBEFACEN*((1<<s.l)+s.j)+(1<<s.l)+s.i;
}
return 0;
}
void LoadFromCubemap(const Cubemap<VALUE_TYPE> &c)
{
Vector<3,VALUE_TYPE> *pSquare = Square;
VALUE_TYPE* pScale = Scale;
VALUE_TYPE* Coef=c.v;
for(int sideIdx = 0; sideIdx < 6; ++sideIdx)
{
*pScale++ = *(Coef + sideIdx * CUBEFACEN * CUBEFACEN);
for(int level = 0; level < LEVELN; ++level)
for(int iIdx = 0; iIdx < (1<<level); ++iIdx)
for(int jIdx = 0; jIdx < (1<<level); ++jIdx)
{
//res * row + col
//M01. col: 2^l +i, row: j
pSquare->v[0] = *(Coef + sideIdx*CUBEFACEN*CUBEFACEN + CUBEFACEN * jIdx + (1<<level) + iIdx);
//M10. col: i, row: 2^l+j
pSquare->v[1] = *(Coef + sideIdx*CUBEFACEN*CUBEFACEN + CUBEFACEN * ((1<<level) + jIdx) + iIdx);
//M11. col: 2^l+i, row: 2^l+j
pSquare->v[2] = *(Coef + sideIdx*CUBEFACEN*CUBEFACEN + CUBEFACEN * ((1<<level) + jIdx) + (1<<level) + iIdx);
++pSquare;
}
}
memset(psum,1,sizeof(T1)*DATASIZE);
}
void SaveToCubemap(Cubemap<VALUE_TYPE> &c)
{
Vector<3,VALUE_TYPE> *pSquare = Square;
VALUE_TYPE* pScale = Scale;
VALUE_TYPE* Coef=c.v;
for(int sideIdx = 0; sideIdx < 6; ++sideIdx)
{
*(Coef + sideIdx * CUBEFACEN * CUBEFACEN) = *pScale++ ;
for(int level = 0; level < LEVELN; ++level)
for(int iIdx = 0; iIdx < (1<<level); ++iIdx)
for(int jIdx = 0; jIdx < (1<<level); ++jIdx)
{
//res * row + col
//M01. col: 2^l +i, row: j
*(Coef + sideIdx*CUBEFACEN*CUBEFACEN + CUBEFACEN * jIdx + (1<<level) + iIdx) = pSquare->x;
//M10. col: i, row: 2^l+j
*(Coef + sideIdx*CUBEFACEN*CUBEFACEN + CUBEFACEN * ((1<<level) + jIdx) + iIdx) = pSquare->y;
//M11. col: 2^l+i, row: 2^l+j
*(Coef + sideIdx*CUBEFACEN*CUBEFACEN + CUBEFACEN * ((1<<level) + jIdx) + (1<<level) + iIdx) = pSquare->z;
++pSquare;
}
}
}
static const HaarCoeffCubemap4TripleFull<CUBEFACEN,INDEX_TYPE,INDEX_TYPE> &GetCubemapIndexTable()
{
static bool init=false;
static HaarCoeffCubemap4TripleFull<CUBEFACEN,INDEX_TYPE,INDEX_TYPE> indextable;
if (init==false)
{
Vector<3,INDEX_TYPE> *pSquare = indextable.Square;
INDEX_TYPE* pScale = indextable.Scale;
for(int sideIdx = 0; sideIdx < 6; ++sideIdx)
{
*pScale++ = sideIdx * CUBEFACEN * CUBEFACEN;
for(int level = 0; level < indextable.LEVELN; ++level) for(int iIdx = 0; iIdx < (1<<level); ++iIdx) for(int jIdx = 0; jIdx < (1<<level); ++jIdx)
{
pSquare->v[0] = sideIdx*CUBEFACEN*CUBEFACEN + CUBEFACEN * jIdx + (1<<level) + iIdx;
pSquare->v[1] = sideIdx*CUBEFACEN*CUBEFACEN + CUBEFACEN * ((1<<level) + jIdx) + iIdx;
pSquare->v[2] = sideIdx*CUBEFACEN*CUBEFACEN + CUBEFACEN * ((1<<level) + jIdx) + (1<<level) + iIdx;
++pSquare;
}
}
init=true;
}
return indextable;
}
struct _sortnode{VALUE_TYPE first;INDEX_TYPE second;};
struct _Greater{bool operator()(const _sortnode &a,const _sortnode &b){return a.first>b.first;};};
struct _idxLess{bool operator()(const _sortnode &a,const _sortnode &b){return a.second<b.second;};};
void KeepBigElement(int keepNum, HaarCoeffCubemap4TripleSparse<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &BigElement, bool bAreaWeighted=false)
{
const int sideNum = FACEDATASIZE;
_sortnode CoefFabAndIdx[FACEDATASIZE*6];
if(bAreaWeighted)
{
for(int i = 0; i < sideNum*6; ++i)
{
Vector<3,VALUE_TYPE> weightedCoef = Square[i] / float(1 << Log2((i % sideNum) / CUBEFACEN));
CoefFabAndIdx[i].first = weightedCoef.AbsMax();
CoefFabAndIdx[i].second = i;
}
}
else
{
for(short int i = 0; i < (short int)sideNum*6; ++i)
{
CoefFabAndIdx[i].first = Square[i].AbsMax();
CoefFabAndIdx[i].second = i;
}
}
//now CoefFabAndIdx are all >0
nth_element(CoefFabAndIdx, CoefFabAndIdx + keepNum, CoefFabAndIdx+FACEDATASIZE*6, _Greater());
#ifdef SPARSENEW
#else
sort(CoefFabAndIdx, CoefFabAndIdx + keepNum, _idxLess());
#endif
//bigCoefs and corresponding indices in the same position in coefIndices
BigElement.Create(keepNum);
for (int i = 0; i < keepNum; ++i)
{
BigElement.Coeff[i].value = Square[CoefFabAndIdx[i].second];
BigElement.Coeff[i].index = CoefFabAndIdx[i].second;
}
memcpy(BigElement.Scale,Scale,sizeof(VALUE_TYPE)*6);
BigElement.PrepareIndexToLocal();
}
void KeepBigElement(float keepRatio, HaarCoeffCubemap4TripleSparse<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &BigElement, bool bAreaWeighted=false)
{
const int sideNum = FACEDATASIZE;
_sortnode CoefFabAndIdx[FACEDATASIZE*6];
VALUE_TYPE ori_energe=0,keep_energe,scale_energe=0;
for (int i=0; i<6; i++)
scale_energe+=Scale[i]*Scale[i];
ori_energe=scale_energe;
if(bAreaWeighted)
{
for(INDEX_TYPE i = 0; i < sideNum*6; ++i)
{
Vector<3,VALUE_TYPE> weightedCoef = Square[i] / float(1 << Log2((i % sideNum) / CUBEFACEN));
CoefFabAndIdx[i].first = weightedCoef.AbsMax();
CoefFabAndIdx[i].second = i;
ori_energe+=CoefFabAndIdx[i].first*CoefFabAndIdx[i].first;
}
}
else
{
for(INDEX_TYPE i = 0; i < sideNum*6; ++i)
{
CoefFabAndIdx[i].first = Square[i].AbsMax();
CoefFabAndIdx[i].second = i;
ori_energe+=CoefFabAndIdx[i].first*CoefFabAndIdx[i].first;
}
}
keep_energe=ori_energe*keepRatio;
sort(CoefFabAndIdx, CoefFabAndIdx+FACEDATASIZE*6, _Greater());
VALUE_TYPE got_energe=scale_energe;
int keepNum=0;
for(INDEX_TYPE i = 0; i < sideNum*6; ++i)
{
got_energe+=CoefFabAndIdx[i].first*CoefFabAndIdx[i].first;
if (got_energe>=keep_energe)
{
keepNum=i+1;
break;
}
}
#ifdef SPARSENEW
#else
sort(CoefFabAndIdx, CoefFabAndIdx + keepNum, _idxLess());
#endif
//bigCoefs and corresponding indices in the same position in coefIndices
BigElement.Create(keepNum);
for (int i = 0; i < keepNum; ++i)
{
BigElement.Coeff[i].value = Square[CoefFabAndIdx[i].second];
BigElement.Coeff[i].index = CoefFabAndIdx[i].second;
}
memcpy(BigElement.Scale,Scale,sizeof(VALUE_TYPE)*6);
BigElement.PrepareIndexToLocal();
}
template <int KEEPNUM>
void KeepBigElement(HaarCoeffCubemap4TripleSparseStatic<CUBEFACEN,KEEPNUM,VALUE_TYPE,INDEX_TYPE> &BigElement, bool bAreaWeighted=false)
{
const int sideNum = FACEDATASIZE;
vector<pair<VALUE_TYPE, INDEX_TYPE> > CoefFabAndIdx(sideNum * 6);
if(bAreaWeighted)
{
for(short int i = 0; i < (short int)sideNum*6; ++i)
{
Vector<3,VALUE_TYPE> weightedCoef = Square[i] / float(1 << Log2((i % sideNum) / CUBEFACEN));
CoefFabAndIdx[i] = pair<VALUE_TYPE, INDEX_TYPE>(weightedCoef.absmax(), i);
}
}
else
{
for(short int i = 0; i < (short int)sideNum*6; ++i)
{
CoefFabAndIdx[i] = pair<VALUE_TYPE, INDEX_TYPE>(Square[i].absmax(), i);
}
}
//now CoefFabAndIdx are all >0
nth_element(CoefFabAndIdx.begin(), CoefFabAndIdx.begin() + KEEPNUM, CoefFabAndIdx.end(), _Greater()); //cut off: first keepNum element is biggest
sort(CoefFabAndIdx.begin(), CoefFabAndIdx.begin() + KEEPNUM, _idxLess()); //for real-time 3p indexing, sort into s/l/i/j/m increasing order. Refer to Ng04
//bigCoefs and corresponding indices in the same position in coefIndices
for (int i = 0; i < KEEPNUM; ++i)
{
BigElement.Coeff[i].value = Square[CoefFabAndIdx[i].second];
BigElement.Coeff[i].index = CoefFabAndIdx[i].second;
}
for (int i=0; i<6; i++)
BigElement.Scale[i]=Scale[i];
}
void LoadFromSparse(HaarCoeffCubemap4TripleSparse<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &BigElement)
{
Zero();
for (int i=0; i<6; i++)
Scale[i]=BigElement.Scale[i];
for (int i=0; i<BigElement.Size; i++)
{
#ifdef SPARSENEW
if (BigElement.Coeff[i].value.v[0]==EMPTYPSUM) continue;
#endif
Square[BigElement.Coeff[i].index]=BigElement.Coeff[i].value;
}
}
VALUE_TYPE Dot(const HaarCoeffCubemap4TripleFull<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &c) const
{
VALUE_TYPE ret=Scale[0]*c.Scale[0]+Scale[1]*c.Scale[1]+Scale[2]*c.Scale[2]+Scale[3]*c.Scale[3]+Scale[4]*c.Scale[4]+Scale[5]*c.Scale[5];
for (int i=0; i<DATASIZE; i++)
ret+=Square[i].Dot(c.Square[i]);
return ret;
}
VALUE_TYPE Dot(const HaarCoeffCubemap4TripleSparse<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &c) const
{
VALUE_TYPE ret=Scale[0]*c.Scale[0]+Scale[1]*c.Scale[1]+Scale[2]*c.Scale[2]+Scale[3]*c.Scale[3]+Scale[4]*c.Scale[4]+Scale[5]*c.Scale[5];
for (int i=0; i<c.Size; i++)
ret+=Square[c.Coeff[i].index].Dot(c.Coeff[i].value);
return ret;
}
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/Haar/HaarCoeffCubemap4Triple.hpp
|
C++
|
gpl3
| 28,699
|
#pragma once
#include "HaarCoeff1D.hpp"
namespace zzz{
template <typename T1, typename T2>
struct HaarCoeff2D;
template <typename T1, typename T2>
struct HaarCoeff2DScale;
template <typename T1,typename T2>
class HaarCoeff2D
{
typedef T1 Index_Type;
typedef T2 Value_Type;
struct _coeffrow{
Index_Type index;
HaarCoeff1D<T1,T2> rowCoeff;
}*Coeff;
size_t Size;
HaarCoeff2D()
{
Coeff=0;
Size=0;
}
~HaarCoeff2D()
{
delete[] Coeff;
}
void Clear()
{
delete[] Coeff;
Coeff=0;
Size=0;
}
HaarCoeff2D(const HaarCoeff2D<T1,T2> &c)
{
*this=c;
}
const HaarCoeff2D& operator=(const HaarCoeff2D<T1,T2> &c)
{
Clear();
Size=c.Size;
Coeff=new _coeffrow[c.Size];
for (int i=0; i<Size; i++)
{
Coeff[i].index=c.Coeff[i].index;
Coeff[i].rowCoeff=c.Coeff[i].rowCoeff;
}
return *this;
}
void LoadFromData(Value_Type *data, Index_Type size, Value_Type threshold=0) //load a size * size matrix data
{
Clear();
int len=0;
for (Index_Type i=0; i<size; i++)
{
Value_Type *curdata=data+i*size;
for (Index_Type j=0; j<size; j++)
{
if (abs(curdata[j])>0)
{
len++;
break;
}
}
}
Size=len;
Coeff=new _coeffrow[len];
Index_Type cur=0;
for (Index_Type i=0; i<size; i++)
{
Value_Type *curdata=data+i*size;
Coeff[cur].rowCoeff.LoadFromData(curdata,size,threshold);
if (Coeff[cur].rowCoeff.Size!=0)
{
Coeff[cur].index=i;
cur++;
}
}
}
void SaveToData(Value_Type *data, Index_Type size)
{
int cur=0;
for (int i=0; i<size; i++)
{
if (cur<Size && Coeff[cur].index==i)
{
Coeff[cur].rowCoeff.SaveToData(data+i*size,size);
cur++;
}
else
memset(data+i*size,0,sizeof(Value_Type)*size);
}
}
inline Value_Type Dot(const HaarCoeff2D<T1,T2> &c)
{
Value_Type ret=0;
int cur1=0,cur2=0;
for (cur1=0;cur1<Size;cur1++)
{
while(cur2<c.Size && Coeff[cur1].index>c.Coeff[cur2].index) cur2++;
if (Coeff[cur1].index==c.Coeff[cur2].index) ret+=Coeff[cur1].rowCoeff.Dot(c.Coeff[cur2].rowCoeff);
}
return ret;
}
inline Value_Type Dot(const HaarCoeff2DScale<T1,T2> &c)
{
Value_Type ret=0;
int cur1=0,cur2=0;
for (cur1=0;cur1<Size;cur1++)
{
while(cur2<c.Size && Coeff[cur1].index>c.Coeff[cur2].index) cur2++;
if (Coeff[cur1].index==c.Coeff[cur2].index) ret+=Coeff[cur1].rowCoeff.Dot(c.Coeff[cur2].rowCoeff);
}
return ret;
}
};
template <typename T1,typename T2>
class HaarCoeff2DScale
{
typedef T1 Index_Type;
typedef T2 Value_Type;
struct _coeffrow{
Index_Type index;
HaarCoeff1DScale<T1,T2> rowCoeff;
}*Coeff;
size_t Size;
HaarCoeff2DScale()
{
Coeff=0;
Size=0;
}
~HaarCoeff2DScale()
{
delete[] Coeff;
}
void Clear()
{
delete[] Coeff;
Coeff=0;
Size=0;
}
HaarCoeff2DScale(const HaarCoeff2DScale<T1,T2> &c)
{
*this=c;
}
const HaarCoeff2DScale& operator=(const HaarCoeff2DScale<T1,T2> &c)
{
Clear();
Size=c.Size;
Coeff=new _coeffrow[c.Size];
for (int i=0; i<Size; i++)
{
Coeff[i].index=c.Coeff[i].index;
Coeff[i].rowCoeff=c.Coeff[i].rowCoeff;
}
return *this;
}
void LoadFromData(Value_Type *data, Index_Type size, Value_Type threshold=0) //load a size * size matrix data
{
Clear();
int len=0;
for (Index_Type i=0; i<size; i++)
{
Value_Type *curdata=data+i*size;
for (Index_Type j=0; j<size; j++)
{
if (abs(curdata[j])>0)
{
len++;
break;
}
}
}
Size=len;
Coeff=new _coeffrow[len];
Index_Type cur=0;
for (Index_Type i=0; i<size; i++)
{
Value_Type *curdata=data+i*size;
Coeff[cur].rowCoeff.LoadFromData(curdata,size,threshold);
if (Coeff[cur].rowCoeff.Size!=0)
{
Coeff[cur].index=i;
cur++;
}
}
}
void SaveToData(Value_Type *data, Index_Type size)
{
int cur=0;
for (int i=0; i<size; i++)
{
if (cur<Size && Coeff[cur].index==i)
{
Coeff[cur].rowCoeff.SaveToData(data+i*size,size);
cur++;
}
else
memset(data+i*size,0,sizeof(Value_Type)*size);
}
}
inline Value_Type Dot(const HaarCoeff2D<T1,T2> &c)
{
Value_Type ret=0;
int cur1=0,cur2=0;
for (cur1=0;cur1<Size;cur1++)
{
while(cur2<c.Size && Coeff[cur1].index>c.Coeff[cur2].index) cur2++;
if (Coeff[cur1].index==c.Coeff[cur2].index) ret+=Coeff[cur1].rowCoeff.Dot(c.Coeff[cur2].rowCoeff);
}
return ret;
}
inline Value_Type Dot(const HaarCoeff2DScale<T1,T2> &c)
{
Value_Type ret=0;
int cur1=0,cur2=0;
for (cur1=0;cur1<Size;cur1++)
{
while(cur2<c.Size && Coeff[cur1].index>c.Coeff[cur2].index) cur2++;
if (Coeff[cur1].index==c.Coeff[cur2].index) ret+=Coeff[cur1].rowCoeff.Dot(c.Coeff[cur2].rowCoeff);
}
return ret;
}
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/Haar/HaarCoeff2D.hpp
|
C++
|
gpl3
| 5,292
|
#pragma once
namespace zzz{
template <typename T1, typename T2, size_t N>
struct HaarCoeff
{
typedef T1 Index_Type;
typedef T2 Value_Type;
struct _coeff{
Index_Type index;
Value_Type value;
}Coeff[N];
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/Haar/HaarCoeff.hpp
|
C++
|
gpl3
| 235
|
#pragma once
//#include "../../common.hpp"
#include "../CubeMap.hpp"
namespace zzz{
//no scale, no index compression
template <class T1, typename T2, int CUBEFACEN>
struct HaarCoeffCubemap
{
typedef T1 VALUE_TYPE;
typedef T2 INDEX_TYPE;
struct _coeff
{
T2 index;
T1 value;
}*Coeff;
public:
HaarCoeffCubemap()
{
Coeff=NULL;
}
~HaarCoeffCubemap()
{
Clear();
}
inline void Clear()
{
delete[] Coeff;
Coeff=NULL;
}
void LoadFromCubemap(const Cubemap<VALUE_TYPE> &c, int KeepNumber, bool AreaWeighted=true, bool bSortByCoef=false, bool bSortByIdx=false)
{
Clear();
Coeff=new _coeff[KeepNumber];
_coeff *oricoeff=new _coeff[c.datasize];
VALUE_TYPE *v=c.v;
if (AreaWeighted)
{
for (int i=0; i<c.datasize; i++)
{
oricoeff[i].index=i;
oricoeff[i].value=v[i];
}
}
}
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/Haar/HaarCoeffCubemap.hpp
|
C++
|
gpl3
| 928
|
#pragma once
namespace zzz{
template <typename T1, typename T2>
struct HaarCoeff1D;
template <typename T1, typename T2>
struct HaarCoeff1DScale;
template <typename T1, typename T2>
struct HaarCoeff1D
{
typedef T1 Index_Type;
typedef T2 Value_Type;
struct _coeff{
Index_Type index;
Value_Type value;
}*Coeff;
size_t Size;
HaarCoeff1D()
{
Coeff=0;
Size=0;
}
~HaarCoeff1D()
{
delete[] Coeff;
}
void Clear()
{
delete[] Coeff;
Coeff=0;
Size=0;
}
HaarCoeff1D(const HaarCoeff1D<T1,T2> &c)
{
*this=c;
}
const HaarCoeff1D& operator=(const HaarCoeff1D<T1,T2> &c)
{
Clear();
Size=c.Size;
Coeff=new _coeff[c.Size];
memcpy(Coeff,c.Coeff,sizeof(_coeff)*Size);
return *this;
}
void LoadFromData(Value_Type *data, Index_Type size, Value_Type threshold=0)
{
Clear();
int len=0;
for (Index_Type i=0; i<size; i++)
if (abs(data[i])>threshold) len++;
Size=len;
Coeff=new _coeff[len];
Index_Type cur=0;
for (Index_Type i=0; i<size; i++)
if (abs(data[i])>threshold)
{
Coeff[i].index=cur;
Coeff[i].value=data[i];
cur++;
}
}
void SaveToData(Value_Type *data, Index_Type size)
{
memset(data,0,sizeof(Value_Type)*size);
for (int i=0; i<Size; i++)
data[Coeff[i].index]=Coeff[i].value;
}
inline Value_Type Dot(const HaarCoeff1D<T1,T2> &c)
{
Value_Type ret=0;
int cur1=0,cur2=0;
for (cur1=0;cur1<Size;cur1++)
{
while(cur2<c.Size && Coeff[cur1].index>c.Coeff[cur2].index) cur2++;
if (Coeff[cur1].index==c.Coeff[cur2].index) ret+=Coeff[cur1].value*c.Coeff[cur2].value;
}
return ret;
}
inline Value_Type Dot(const HaarCoeff1DScale<T1,T2> &c)
{
Value_Type ret=0;
int cur1=0,cur2=0;
for (cur1=0;cur1<Size;cur1++)
{
while(cur2<c.Size && Coeff[cur1].index>c.Coeff[cur2].index) cur2++;
if (Coeff[cur1].index==c.Coeff[cur2].index) ret+=Coeff[cur1].value*c.Coeff[cur2].value;
}
return ret*c.Scale;
}
};
template <typename T1, typename T2>
struct HaarCoeff1DScale
{
typedef T1 Index_Type;
typedef T2 Value_Type;
struct _coeff{
Index_Type index;
Value_Type value;
}*Coeff;
size_t Size;
float Scale;
HaarCoeff1D()
{
Coeff=0;
Size=0;
Scale=1.0f;
}
~HaarCoeff1D()
{
delete[] Coeff;
}
void Clear()
{
delete[] Coeff;
Coeff=0;
Size=0;
Scale=1.0f;
}
HaarCoeff1D(const HaarCoeff1DScale<T1,T2> &c)
{
*this=c;
}
const HaarCoeff1D& operator=(const HaarCoeff1DScale<T1,T2> &c)
{
Clear();
Size=c.Size;
Scale=c.Scale;
Coeff=new _coeff[c.Size];
memcpy(Coeff,c.Coeff,sizeof(_coeff)*Size);
return *this;
}
template <typename T>
void LoadFromData(T *data, Index_Type size, T threshold=0)
{
Clear();
int len=0;
T minvalue=numeric_limits<T>::max(),maxvalue=numeric_limits<T>::min();
for (Index_Type i=0; i<size; i++)
{
if (abs(data[i])>threshold)
{
len++;
if (minvalue>data[i]) minvalue=data[i];
if (maxvalue<data[i]) maxvalue=data[i];
}
}
maxvalue=(abs(minvalue)<abs(maxvalue))?abs(maxvalue):abs(minvalue);
Scale=(float)maxvalue/(float)numeric_limits<Value_Type>::max();
Size=len;
Coeff=new _coeff[len];
Index_Type cur=0;
for (Index_Type i=0; i<size; i++)
if (abs(data[i])>threshold)
{
Coeff[i].index=cur;
Coeff[i].value=(Value_Type)(data[i]/Scale);
cur++;
}
}
void SaveToData(Value_Type *data, Index_Type size)
{
memset(data,0,sizeof(Value_Type)*size);
for (int i=0; i<Size; i++)
data[Coeff[i].index]=Coeff[i].value*Scale;
}
inline Value_Type Dot(const HaarCoeff1D<T1,T2> &c)
{
float ret=0;
int cur1=0,cur2=0;
for (cur1=0;cur1<Size;cur1++)
{
while(cur2<c.Size && Coeff[cur1].index>c.Coeff[cur2].index) cur2++;
if (Coeff[cur1].index==c.Coeff[cur2].index) ret+=Coeff[cur1].value*c.Coeff[cur2].value;
}
return ret*Scale;
}
inline Value_Type Dot(const HaarCoeff1DScale<T1,T2> &c)
{
float ret=0;
int cur1=0,cur2=0;
for (cur1=0;cur1<Size;cur1++)
{
while(cur2<c.Size && Coeff[cur1].index>c.Coeff[cur2].index) cur2++;
if (Coeff[cur1].index==c.Coeff[cur2].index) ret+=Coeff[cur1].value*c.Coeff[cur2].value;
}
return ret*Scale*c.Scale;
}
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/Haar/HaarCoeff1D.hpp
|
C++
|
gpl3
| 4,606
|
#pragma once
#include "Coordinate.hpp"
#include "../Resource/Texture/TextureCube.hpp"
#include "../Resource/Texture/Texture2D.hpp"
#include "SH/SHCoeff.hpp"
//#include "SH/SHCoeff4f_SSE.hpp"
#include <Math/Array.hpp>
namespace zzz{
template <typename T>class Cubemap;
struct CubemapPos
{
CartesianDirCoordf direction;
float solidangle;
};
typedef vector<CubemapPos> CubemapPosList;
class Cubemapbase
{
public:
static const CubemapPosList& GetPosList(zuint n);
static const Cubemap<float>& GetSHBaseCubemap(int l,int m,int size);
static const Cubemap<float>* GetSHBaseCubemapPointer(int l,int m,int size);
private:
static map<zuint,CubemapPosList*> PosListMap;
private:
//SH Projection Helper
typedef Vector<3,int> SHBaseCubemapDesc;
static map<SHBaseCubemapDesc,Cubemap<float>*> SHBaseCubemap;
static float SHBase(int l,int m,float theta,float phi);
static float K(int l,int m);
static float P(int l,int m,float x);
};
template <typename T>
class Cubemap : public Cubemapbase
{
public:
Cubemap()
{
cubesize=0;
facesize=0;
datasize=0;
v=NULL;
}
Cubemap(int n)
{
cubesize=n;
facesize=n*n;
datasize=facesize*6;
v=new T[cubesize*cubesize*6];
}
Cubemap(const Cubemap<T> &cube)
{
v=0;
*this=cube;
}
~Cubemap()
{
Clear();
}
void Dump()
{
for (zuint i=0; i<datasize; i++)
{
if (i%facesize==0) zout<<"-------------------------------------------------\n";
if (i%cubesize==0) zout<<"| ";
zout<<v[i]<<' ';
if (i%cubesize==cubesize-1) zout<<"|\n";
}
}
const Cubemap& operator=(const Cubemap<T> &cube)
{
ChangeSize(cube.cubesize);
memcpy(v,cube.v,sizeof(T)*datasize);
return *this;
}
void ChangeSize(int n)
{
if (n==cubesize) return;
Clear();
cubesize=n;
facesize=n*n;
datasize=facesize*6;
v=new T[datasize];
}
void Clear()
{
delete[] v;
v=0;
cubesize=0;
facesize=0;
datasize=0;
}
void Zero(const T x=0)
{
for (zuint i=0; i<datasize; i++) v[i]=x;
}
inline T& At(const CubeCoord &c)
{
return v[c.ToIndex()];
}
template <typename T1>
inline T Get(const CubeCoordNormalized<T1> &c) const
{
float ratioX,ratioY;
CubeCoord basePos=c.GetBaseCubeCoord(cubesize,ratioX,ratioY);
T ret=0;
CubeCoord pos=basePos;
pos.Standardize();
ret+=v[pos.ToIndex()]*(1-ratioX)*(1-ratioY);
basePos.x++;
pos=basePos;
pos.Standardize();
ret+=v[pos.ToIndex()]*1*(1-ratioY);
basePos.x--;basePos.y++;
pos=basePos;
pos.Standardize();
ret+=v[pos.ToIndex()]*(1-ratioX)*ratioY;
basePos.x++;
pos=basePos;
pos.Standardize();
ret+=v[pos.ToIndex()]*ratioX*ratioY;
return ret;
}
inline void Set(const CubeCoordNormalized<T> &c,const T value,bool plus=false)
{
float ratioX,ratioY;
CubeCoord basePos=c.GetBaseCubeCoord(cubesize,ratioX,ratioY);
T ret=0;
basePos.Standardize();
if (plus) v[basePos.ToIndex()]+=value/(4*(1-ratioX)*(1-ratioY));
else v[basePos.ToIndex()]=value/(4*(1-ratioX)*(1-ratioY));
basePos.x++;
basePos.Standardize();
if (plus) v[basePos.ToIndex()]+=value/(4*1*(1-ratioY));
else v[basePos.ToIndex()]=value/(4*1*(1-ratioY));
basePos.x--;basePos.y++;
basePos.Standardize();
if (plus) v[basePos.ToIndex()]+=value/(4*(1-ratioX)*ratioY);
else v[basePos.ToIndex()]=value/(4*(1-ratioX)*ratioY);
basePos.x++;
basePos.Standardize();
if (plus) v[basePos.ToIndex()]+=value/(4*ratioX*ratioY);
else v[basePos.ToIndex()]=value/(4*ratioX*ratioY);
return ret;
}
inline T& operator[](zuint n)
{
return v[n];
}
inline const T& operator[](zuint n) const
{
return v[n];
}
template <typename T1>
float Dot(const Cubemap<T1> &c) const
{
T ret=0;
for (int i=0; i<datasize; i++)
ret+=v[i]*c[i];
return ret;
}
bool LoadFromPfm(const string &filename)
{
printf("LoadFromPfm: Must be specialized to use\n");
return false;
}
bool SaveToPfm(const string &filename)
{
printf("SaveToPfm: Must be specialized to use\n");
return false;
}
void LoadFromTextureCube(TextureCube &t, int channel=0)
{
printf("LoadFromTextureCube: Must be specialized to use\n");
}
void LoadFromTexture2Ds(Texture2D *t, int channel=0)
{
printf("LoadFromTexture2Ds: Must be specialized to use\n");
}
void ProjectToHaar()
{
Haar2D(v,cubesize);
Haar2D(v+1*facesize,cubesize);
Haar2D(v+2*facesize,cubesize);
Haar2D(v+3*facesize,cubesize);
Haar2D(v+4*facesize,cubesize);
Haar2D(v+5*facesize,cubesize);
}
void LoadFromHaar()
{
AntiHaar2D(v,cubesize);
AntiHaar2D(v+1*facesize,cubesize);
AntiHaar2D(v+2*facesize,cubesize);
AntiHaar2D(v+3*facesize,cubesize);
AntiHaar2D(v+4*facesize,cubesize);
AntiHaar2D(v+5*facesize,cubesize);
}
void SingleLoadFromHaar(zuint dir)
{
memset(v,0,sizeof(T)*datasize);
zuint face=dir/(facesize);
dir=dir%(facesize);
memcpy(v+facesize*face,SingleLoadFromHaarFace(dir),sizeof(T)*facesize);
}
T *SingleLoadFromHaarFace(zuint dir)
{
static T **pre=NULL;
static int precubesize=0;
if (pre==NULL || precubesize!=cubesize)
{
zout<<"SingleLoadFromHaarPrecompute!\n";
if (pre!=NULL)
for(zuint i=0; i<facesize; i++)
delete[] pre[i];
delete[] pre;
precubesize=cubesize;
pre=new T*[facesize];
for (zuint i=0; i<facesize; i++)
{
pre[i]=new T[facesize];
memset(pre[i],0,sizeof(T)*facesize);
pre[i][i]=1;
AntiHaar2D(pre[i],cubesize);
}
}
return pre[dir];
}
template <int N,typename T1>
void SingleProjectToSH(int pos, T value, SHCoeff<N,T1> &sh)
{
int cur=0;
for (int l=0; l<N; l++) for (int m=-l; m<=l; m++)
{
const Cubemap<float> &shbase=Cubemapbase::GetSHBaseCubemap(l,m,cubesize);
sh[cur]=value*shbase[pos];
cur++;
}
}
template <int N,typename T1>
void ProjectToSH(SHCoeff<N,T1> &sh)
{
int cur=0;
for (int l=0; l<N; l++) for (int m=-l; m<=l; m++)
{
const Cubemap<float> &shbase=GetSHBaseCubemap(l,m,cubesize);
T1 res=0;
for (zuint i=0; i<datasize; i++)
res+=v[i]*shbase[i];
sh[cur]=res;
cur++;
}
return;
}
/*
void ProjectToSH(SHCoeff4f_SSE &sh)
{
int cur=0;
for (int l=0; l<4; l++) for (int m=-l; m<=l; m++)
{
const Cubemapf &shbase=GetSHBaseCubemap(l,m,cubesize);
float res=0;
for (zuint i=0; i<datasize; i++)
res+=v[i]*shbase[i];
sh[cur]=res;
cur++;
}
return;
}
*/
template <int N,typename T1>
void LoadFromSH(SHCoeff<N,T1> &sh)
{
Zero();
int cur=0;
for (int l=0; l<N; l++) for (int m=-l; m<=l; m++)
{
if (sh[cur]!=T1(0))
{
const Cubemap<float> &shbase=GetSHBaseCubemap(l,m,cubesize);
for (zuint i=0; i<datasize; i++)
v[i]+=sh[cur]*shbase[i];
}
cur++;
}
}
T *v;
zuint cubesize, facesize, datasize;
private:
//Haar Wavelet Projection Helper
static void Haar1D(T *vec,int n)
{
int w=n;
T *vecp = new T[n];
memset(vecp,0,sizeof(int)*n);
const float sqrt2=sqrt(2.0);
while(w>1)
{
w/=2;
for(int i=0; i<w; i++)
{
vecp[i] = (vec[2*i] + vec[2*i+1])/sqrt2;
vecp[i+w] = (vec[2*i] - vec[2*i+1])/sqrt2;
}
memcpy(vec,vecp,sizeof(T)*w*2);
}
delete[] vecp;
}
static void Haar2D(T *vec,int n)
{//2d haar on a nxn map
int height=n;
while(height>1)
{
for (int i=0; i<height; i++)
Haar2Dhelper1(vec+n*i,height);
for (int i=0; i<height; i++)
Haar2Dhelper2(vec+i,height,n);
height/=2;
}
}
static void Haar2Dhelper1(T *vec,int n)
{//one step horizontal haar
T *vecp=new T[n];
const float sqrt2=sqrt(2.0);
const int w=n/2;
int x=0;
for (int i=0; i<w; i++)
{
vecp[i]=(vec[x]+vec[x+1])/sqrt2;
vecp[i+w]=(vec[x]-vec[x+1])/sqrt2;
x+=2;
}
memcpy(vec,vecp,sizeof(T)*n);
delete[] vecp;
}
static void Haar2Dhelper2(T *vec,int n,int span)
{//one step vertical haar
T *vecp=new T[n];
const float sqrt2=sqrt(2.0);
const int w=n/2;
int x=0;
for (int i=0; i<w; i++)
{
vecp[i] = (vec[x]+vec[x+span])/sqrt2;
vecp[i+w] = (vec[x]-vec[x+span])/sqrt2;
x += 2*span;
}
x=0;
for (int i=0; i<n; i++)
{
vec[x]=vecp[i];
x+=span;
}
delete[] vecp;
}
static void AntiHaar1D(T *vec, int n)
{
int w=1;
T *vecp = new T[n];
memset(vecp,0,sizeof(int)*n);
const float sqrt2over2=sqrt(2.0)/2.0f;
while(w<n)
{
for(int i=0; i<w; i++)
{
vecp[2*i]=(vec[i]+vec[i+w])*sqrt2over2;
vecp[2*i+1]=(vec[i]-vec[i+w])*sqrt2over2;
}
memcpy(vec,vecp,sizeof(T)*w*2);
w*=2;
}
delete[] vecp;
}
static void AntiHaar2D(T *vec,int n)
{//Anti 2d haar on a nxn map
int height=2;
while(height<=n)
{
for (int i=0; i<height; i++)
AntiHaar2Dhelper2(vec+i,height,n);
for (int i=0; i<height; i++)
AntiHaar2Dhelper1(vec+n*i,height);
height*=2;
}
}
static void AntiHaar2Dhelper1(T *vec,int n)
{//one step horizontal anti-haar
T *vecp=new T[n];
const float sqrt2over2=sqrt(2.0)/2.0f;
const int w=n/2;
int x=0;
for (int i=0; i<w; i++)
{
vecp[x]=(vec[i]+vec[i+w])*sqrt2over2;
vecp[x+1]=(vec[i]-vec[i+w])*sqrt2over2;
x+=2;
}
memcpy(vec,vecp,sizeof(T)*n);
delete[] vecp;
}
static void AntiHaar2Dhelper2(T *vec,int n,int span)
{//one step vertical anti-haar
T *vecp=new T[n];
const float sqrt2over2=sqrt(2.0)/2.0f;
const int w=span*n/2;
int x=0;
for (int i=0; i<n; i+=2)
{
vecp[i]=(vec[x]+vec[x+w])*sqrt2over2;
vecp[i+1]=(vec[x]-vec[x+w])*sqrt2over2;
x+=span;
}
x=0;
for (int i=0; i<n; i++)
{
vec[x]=vecp[i];
x+=span;
}
delete[] vecp;
}
};
typedef Cubemap<float> Cubemapf;
typedef Cubemap<Vector3f> Cubemap3f;
template<>
bool Cubemap<Vector3f>::LoadFromPfm(const string &filename)
{
FILE *fp;
fp=fopen(filename.c_str(), "r");
if (fp==NULL)
return false;
char s[1000];
s[0]=0;
int width,height;
int headerlen=0;
if (fscanf(fp,"%[^\x0a]\x0a",s)!=1)
{
fclose(fp);
return false;
}
if ((strlen(s)<2)||(s[0]!='P')||(s[1]!='f'&&s[1]!='F'))
{
fclose(fp);
return false;
}
headerlen+=(int)strlen(s)+1;
if (fscanf(fp,"%[^\x0a]\x0a",s)!=1)
{
fclose(fp);
return false;
}
if (sscanf(s,"%d %d",&width,&height)!=2)
{
fclose(fp);
return false;
}
if (width%3!=0||height%4!=0||(((width/3)&(width/3-1))!=0)||(((height/4)&(height/4-1))!=0)||width/3!=height/4)
{
fclose(fp);
return false;
}
headerlen+=(int)strlen(s)+1;
if (fscanf(fp,"%[^\x0a]\x0a",s)!=1)
{
fclose(fp);
return false;
}
headerlen+=(int)strlen(s)+1;
fclose(fp);
fp=fopen(filename.c_str(), "rb");
float *data;
data=new float[width*height*3];
if (fseek(fp,headerlen,SEEK_SET)!=0) return false;
int ii=(int)fread((void *)data,1,width*height*3*(int)sizeof(float),fp);
if (ii!=width*height*3*(int)sizeof(float))
{
delete[] data;
data=0;
fclose(fp);
return false;
}
fclose(fp);
cubesize=width/3;
ChangeSize(cubesize);
for (zuint i=0; i<cubesize; i++) for (zuint j=0; j<cubesize; j++)
{
CubeCoord c(POSX,j,i,cubesize);
v[c.ToIndex()]=Vector3f(data+((cubesize*3-1-i)*width+cubesize*3-1-j)*3);
}
for (zuint i=0; i<cubesize; i++) for (zuint j=0; j<cubesize; j++)
{
CubeCoord c(NEGX,j,i,cubesize);
v[c.ToIndex()]=Vector3f(data+((cubesize*3-1-i)*width+cubesize-1-j)*3);
}
for (zuint i=0; i<cubesize; i++) for (zuint j=0; j<cubesize; j++)
{
CubeCoord c(POSY,j,i,cubesize);
v[c.ToIndex()]=Vector3f(data+((cubesize*3+i)*width+cubesize+j)*3);
}
for (zuint i=0; i<cubesize; i++) for (zuint j=0; j<cubesize; j++)
{
CubeCoord c(NEGY,j,i,cubesize);
v[c.ToIndex()]=Vector3f(data+((cubesize*1+i)*width+cubesize+j)*3);
}
for (zuint i=0; i<cubesize; i++) for (zuint j=0; j<cubesize; j++)
{
CubeCoord c(POSZ,j,i,cubesize);
v[c.ToIndex()]=Vector3f(data+((cubesize*0+i)*width+cubesize+j)*3);
}
for (zuint i=0; i<cubesize; i++) for (zuint j=0; j<cubesize; j++)
{
CubeCoord c(NEGZ,j,i,cubesize);
v[c.ToIndex()]=Vector3f(data+((cubesize*3-1-i)*width+cubesize*2-1-j)*3);
}
delete[] data;
return true;
}
template<>
bool Cubemap<Vector3f>::SaveToPfm(const string &filename)
{
char s1[1000];
FILE *fp=fopen(filename.c_str(), "wb");
if (fp==NULL) return false;
sprintf(s1,"PF\x0a%d %d\x0a-1.000000\x0a",cubesize*3,cubesize*4);
fwrite(s1,1,strlen(s1),fp);
int width=cubesize*3;
int height=cubesize*4;
float *data;
data=new float[width*height*3];
memset(data,0,sizeof(float)*width*height*3);
for (zuint i=0; i<cubesize; i++) for (zuint j=0; j<cubesize; j++)
{
CubeCoord c(POSX,j,i,cubesize);
memcpy(data+((cubesize*3-1-i)*width+cubesize*3-1-j)*3,v[c.ToIndex()].Data(),sizeof(float)*3);
}
for (zuint i=0; i<cubesize; i++) for (zuint j=0; j<cubesize; j++)
{
CubeCoord c(NEGX,j,i,cubesize);
memcpy(data+((cubesize*3-1-i)*width+cubesize-1-j)*3,v[c.ToIndex()].Data(),sizeof(float)*3);
}
for (zuint i=0; i<cubesize; i++) for (zuint j=0; j<cubesize; j++)
{
CubeCoord c(POSY,j,i,cubesize);
memcpy(data+((cubesize*3+i)*width+cubesize+j)*3,v[c.ToIndex()].Data(),sizeof(float)*3);
}
for (zuint i=0; i<cubesize; i++) for (zuint j=0; j<cubesize; j++)
{
CubeCoord c(NEGY,j,i,cubesize);
memcpy(data+((cubesize*1+i)*width+cubesize+j)*3,v[c.ToIndex()].Data(),sizeof(float)*3);
}
for (zuint i=0; i<cubesize; i++) for (zuint j=0; j<cubesize; j++)
{
CubeCoord c(POSZ,j,i,cubesize);
memcpy(data+((cubesize*0+i)*width+cubesize+j)*3,v[c.ToIndex()].Data(),sizeof(float)*3);
}
for (zuint i=0; i<cubesize; i++) for (zuint j=0; j<cubesize; j++)
{
CubeCoord c(NEGZ,j,i,cubesize);
memcpy(data+((cubesize*3-1-i)*width+cubesize*2-1-j)*3,v[c.ToIndex()].Data(),sizeof(float)*3);
}
fwrite(data,1,width*height*3*sizeof(float),fp);
fclose(fp);
delete[] data;
return true;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/CubeMap.hpp
|
C++
|
gpl3
| 16,076
|
#pragma warning(disable:4309)
const int fontwidth=8,fontheight=12;
const char fontmap[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,192,192,192,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,192,0,0,192,0,0,192,192,0,192,0,192,0,192,0,192,0,192,192,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,192,192,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,0,0,192,0,0,192,0,0,192,0,192,0,192,0,192,192,192,0,192,192,0,192,192,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,192,192,192,192,0,0,0,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,192,192,192,192,0,0,0,192,192,0,192,192,192,192,192,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,0,0,0,0,192,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,192,192,0,0,0,0,192,192,0,0,0,0,192,0,0,0,192,192,0,0,0,192,192,192,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,0,192,0,0,0,0,0,0,0,\
0,192,192,192,192,192,0,0,192,192,192,192,192,192,0,0,192,192,192,192,192,192,0,0,0,192,192,192,192,0,0,0,0,0,0,192,192,192,192,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,\
0,192,192,192,192,192,0,0,192,192,0,0,192,192,0,0,192,192,192,192,192,192,0,0,0,0,192,192,192,192,0,0,192,192,192,192,192,0,0,0,192,192,192,192,192,192,192,0,192,192,192,192,0,0,0,0,0,0,192,192,192,192,192,0,192,192,0,0,192,192,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,192,192,192,0,0,192,192,0,192,192,192,192,192,192,192,0,192,192,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,0,192,192,192,0,0,0,\
192,192,192,192,0,0,0,0,0,0,0,0,192,192,0,0,192,192,192,0,0,192,192,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,192,192,0,0,0,192,192,192,192,192,192,192,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,192,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,192,192,192,0,192,192,0,192,192,0,192,192,192,0,0,0,192,192,192,192,0,0,0,0,192,192,192,0,192,192,0,0,192,192,192,192,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,192,192,0,0,192,192,192,0,0,192,192,0,0,192,192,192,192,192,192,0,192,192,0,0,192,192,0,0,192,192,192,0,0,192,192,0,0,192,192,192,192,192,192,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,0,192,192,192,192,0,0,0,\
0,192,192,192,192,192,0,0,0,192,192,192,192,192,0,0,192,192,192,192,0,0,0,0,0,192,192,192,192,0,0,0,0,0,192,192,192,0,0,0,0,192,192,192,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,0,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,192,192,192,192,0,0,0,0,0,192,192,192,0,0,0,0,0,192,192,0,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,192,192,192,192,0,0,0,0,192,192,192,0,192,192,0,0,192,192,192,192,0,0,0,0,192,192,192,0,192,192,0,0,192,192,192,0,192,192,0,0,192,192,192,0,192,192,0,0,192,192,192,0,192,192,0,0,192,192,192,192,0,0,0,0,192,192,192,192,192,0,0,0,192,192,192,192,192,0,0,0,192,192,192,192,192,0,0,0,192,192,192,192,192,192,0,0,192,192,192,192,192,192,0,0,192,192,192,192,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,\
192,192,192,192,192,192,0,0,192,192,192,0,192,192,192,192,192,192,0,192,192,192,192,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,0,192,192,0,0,192,192,192,0,192,192,0,0,0,0,0,192,192,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,192,192,192,192,192,192,192,0,0,0,192,192,0,0,0,0,192,0,0,0,0,192,192,0,0,192,192,192,0,0,0,0,\
0,192,192,192,0,192,192,0,0,192,192,192,192,192,192,0,0,192,192,192,192,0,0,0,0,192,192,192,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,192,192,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,192,192,0,0,192,192,0,0,\
0,0,192,0,0,192,0,0,192,0,192,0,192,0,192,0,0,192,192,0,192,192,0,192,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,\
0,192,192,192,0,192,192,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,192,192,0,192,192,192,192,192,192,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,192,192,0,0,0,0,192,192,192,0,192,192,192,192,192,192,0,0,0,192,192,192,192,0,0,0,192,192,192,0,192,192,192,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,192,192,0,0,192,192,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,\
192,192,192,0,0,192,192,192,192,192,0,192,192,0,192,192,192,192,192,192,192,192,192,192,0,0,192,192,192,0,0,0,0,0,0,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,192,192,0,0,0,0,192,192,0,0,192,192,192,192,192,192,192,0,0,0,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,0,0,0,0,192,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,192,192,0,0,192,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,0,192,192,0,0,0,0,0,0,\
192,192,0,0,0,192,192,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,192,0,0,0,0,0,192,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,\
192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,0,0,0,192,192,0,0,0,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,\
0,192,192,0,0,0,0,0,0,192,192,192,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,192,192,0,0,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,0,192,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,192,192,0,192,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,\
0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,192,192,0,0,0,0,192,192,0,192,192,0,0,0,192,192,0,192,192,0,0,0,0,192,192,192,192,0,0,192,192,0,0,0,192,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,0,\
192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,\
192,192,0,0,0,192,0,0,192,192,0,192,192,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,0,0,0,192,192,0,192,192,192,0,192,192,0,0,0,\
192,192,0,0,192,192,0,0,0,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,0,0,0,0,192,192,0,192,0,192,192,0,0,192,192,0,192,192,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,\
0,192,0,0,192,0,0,192,0,192,0,192,0,192,0,192,192,0,192,192,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,\
192,192,0,192,192,192,192,0,192,192,192,192,192,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,192,192,0,0,192,192,0,0,0,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,\
192,192,192,192,192,192,0,0,192,192,192,192,192,192,0,0,192,192,192,192,192,192,0,0,192,192,192,192,192,192,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,\
0,192,192,0,0,192,192,192,0,192,192,192,192,192,192,0,192,192,192,0,0,192,192,192,0,192,192,192,192,192,0,0,0,0,192,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,192,192,0,0,0,0,0,0,0,0,0,192,192,192,0,0,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,192,192,0,0,192,192,192,192,0,0,192,192,192,192,192,192,192,0,0,192,192,192,192,192,192,0,0,0,0,192,192,0,0,0,0,192,192,192,192,192,192,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,192,192,192,192,192,192,192,0,0,0,192,0,0,192,0,0,0,192,192,192,192,192,0,0,0,0,192,192,192,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,0,0,0,0,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,\
192,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,192,192,192,0,0,0,0,0,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,\
192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,192,0,192,192,0,0,0,192,192,0,\
0,192,192,0,0,0,0,0,192,192,0,192,192,192,192,0,0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,192,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,0,0,0,0,0,192,192,0,0,0,192,192,0,192,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,\
0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,0,192,192,0,0,0,192,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,\
192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,192,192,0,0,192,192,192,192,192,192,0,0,\
192,192,0,0,0,0,0,0,192,192,0,192,192,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,192,192,192,192,0,0,192,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,\
192,192,0,0,192,192,0,0,0,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,192,192,0,192,192,0,192,192,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,192,192,\
192,0,0,192,0,0,192,0,192,0,192,0,192,0,192,0,192,192,0,192,192,0,192,192,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,192,192,192,0,0,0,192,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,192,0,0,192,192,0,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,192,192,192,192,192,0,0,0,0,0,0,192,192,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,192,192,192,0,192,192,0,0,192,192,0,0,192,192,192,192,192,192,192,0,192,192,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,192,192,192,0,192,192,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,192,192,192,192,192,192,192,192,192,192,192,\
0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,0,0,0,192,192,192,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,\
192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,192,0,0,192,192,192,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,0,0,0,0,0,192,192,0,0,0,0,192,192,0,192,192,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,\
0,192,192,0,0,0,192,192,192,192,192,0,0,192,192,192,192,192,0,0,0,0,192,192,192,192,192,192,192,192,192,0,0,192,192,192,192,192,0,0,192,192,192,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,192,192,192,192,0,0,0,0,0,192,192,192,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,192,192,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,192,192,192,0,0,0,0,192,192,192,0,0,0,\
0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,\
192,192,192,192,0,192,192,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,192,192,192,192,192,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,\
192,192,0,192,192,192,192,0,192,192,192,192,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,0,0,0,192,192,0,0,192,0,0,192,192,0,0,192,192,192,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,0,192,0,192,192,0,0,0,192,192,0,192,192,0,192,192,192,192,0,192,192,0,0,0,192,192,0,\
0,192,192,0,0,0,0,0,192,192,0,0,192,192,192,0,0,192,192,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,0,192,192,0,0,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,192,192,192,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,192,192,192,192,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,0,0,0,0,0,0,192,192,0,0,0,192,192,0,192,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,\
0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,0,192,192,192,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,0,192,192,0,0,0,192,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,\
192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,192,192,192,192,0,0,0,192,192,192,192,192,0,0,0,192,192,192,192,192,0,0,0,192,192,192,192,192,0,0,0,192,192,192,192,192,0,0,192,192,0,0,0,0,0,0,192,192,192,192,192,192,0,0,192,192,192,192,192,192,0,0,192,192,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,\
192,192,192,192,192,0,0,0,0,192,192,192,192,192,192,192,192,192,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,192,0,0,192,192,192,192,0,0,0,0,192,192,0,0,0,\
0,192,192,192,192,192,0,0,0,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,192,192,0,192,192,192,192,192,192,192,0,192,192,192,192,192,192,192,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,192,0,0,192,192,0,192,192,192,192,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,192,192,\
0,0,192,0,0,192,0,0,0,192,0,192,0,192,0,192,0,192,192,0,192,192,0,192,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,\
192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,0,192,192,192,192,192,192,0,192,192,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,\
0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,\
0,192,192,0,0,0,192,192,192,192,192,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,192,192,192,192,192,192,192,0,192,192,192,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,192,192,192,192,192,192,0,192,192,192,192,192,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,192,192,0,192,192,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,192,192,192,0,192,192,192,192,192,192,192,0,192,192,0,0,0,0,0,0,192,192,192,192,192,192,192,192,0,0,192,192,192,0,0,0,0,192,192,192,192,192,0,0,\
0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,192,192,0,0,0,192,192,192,192,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,192,0,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,192,192,192,192,192,192,0,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,\
192,192,0,192,0,192,192,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,192,192,192,0,0,0,192,192,192,192,192,0,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,0,0,0,\
192,192,0,192,192,192,192,0,192,192,0,0,192,192,0,0,0,192,192,192,192,192,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,192,192,192,0,0,0,192,192,192,192,192,0,0,192,192,0,0,0,0,0,0,192,192,192,192,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,0,0,0,0,192,192,0,0,0,0,0,192,192,0,192,0,192,192,0,192,192,192,192,192,192,192,0,192,192,0,0,0,192,192,0,\
0,192,192,192,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,192,192,192,0,0,0,192,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,0,192,192,192,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,0,0,0,0,0,192,192,0,0,0,192,192,0,192,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,\
0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,192,0,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,0,192,192,0,0,192,192,0,192,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,0,192,192,0,0,\
192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,\
192,192,0,0,0,0,0,0,0,0,0,192,192,0,192,192,192,192,192,192,192,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,192,192,192,192,0,0,192,192,192,192,192,192,0,0,192,0,0,0,192,0,0,0,0,0,0,192,192,0,0,0,\
0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,192,192,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,192,192,192,192,0,0,192,192,192,192,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,192,192,192,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,\
0,192,0,0,192,0,0,192,192,0,192,0,192,0,192,0,192,0,192,192,0,192,192,0,0,0,0,192,192,0,0,0,192,192,192,192,192,0,0,0,0,0,0,192,192,0,0,0,192,192,192,0,0,192,192,0,192,192,192,192,192,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,192,192,192,192,192,192,192,0,0,0,0,192,192,0,0,0,192,192,192,192,192,0,0,0,\
0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,192,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,0,192,192,192,192,192,192,192,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,192,192,192,192,192,192,192,192,0,0,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,192,0,0,0,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,\
192,192,0,192,192,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,192,192,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,192,192,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,192,192,0,192,192,192,192,0,192,0,192,192,0,192,192,192,192,192,192,0,0,192,192,0,0,192,192,0,0,\
192,192,192,192,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,192,192,192,0,0,0,0,0,192,192,0,0,0,0,192,0,0,0,192,0,0,0,192,192,0,192,192,0,0,0,192,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,\
0,192,192,0,0,0,192,192,0,192,192,192,192,192,192,0,192,192,0,192,192,0,192,192,192,192,192,192,192,192,192,0,192,192,192,192,192,192,192,0,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,192,192,192,192,0,0,0,0,0,192,192,192,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,192,192,0,192,192,0,192,192,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,192,0,0,0,0,192,192,192,192,192,0,0,\
0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,192,0,0,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,\
192,192,0,192,192,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,0,192,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,192,0,0,0,0,0,192,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,\
192,192,0,192,192,192,192,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,0,0,0,192,192,0,0,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,192,192,192,192,192,0,192,192,192,192,0,192,192,0,192,192,0,0,0,192,192,0,\
0,192,192,0,0,192,192,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,192,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,192,0,0,0,192,192,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,192,0,192,192,0,0,192,192,0,192,192,0,0,0,192,192,192,192,0,0,0,0,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,192,192,192,192,192,192,0,0,192,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,\
192,192,0,192,192,192,0,0,0,192,192,192,0,192,192,0,192,192,192,0,192,192,0,0,0,192,192,192,192,0,0,0,192,192,192,192,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,192,192,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,0,\
192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,192,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,\
192,192,0,0,0,192,0,0,192,192,192,192,192,192,192,0,192,192,0,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,0,192,192,192,192,0,0,0,192,192,192,192,0,0,0,0,0,192,192,192,192,192,192,0,\
0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,192,192,192,0,0,0,192,192,192,0,0,192,192,0,0,192,192,192,192,192,192,0,0,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,192,192,0,0,192,192,0,0,\
192,0,0,192,0,0,192,0,0,192,0,192,0,192,0,192,192,192,0,192,192,0,192,192,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,192,192,192,192,192,0,0,0,192,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,192,192,192,192,192,0,192,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,192,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,192,0,192,192,192,192,192,192,192,192,192,192,0,0,192,192,192,192,192,192,192,192,192,192,192,0,192,192,0,0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,0,0,192,192,192,192,192,192,192,192,192,192,192,\
0,192,192,0,0,192,192,0,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,192,192,192,0,0,0,192,192,192,192,192,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,192,192,192,192,192,192,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,\
0,192,192,192,0,192,192,0,192,192,0,192,192,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,0,0,0,0,192,192,192,192,192,192,0,0,192,192,0,0,192,192,0,192,192,0,192,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,192,192,0,0,0,192,192,0,192,192,0,192,192,192,192,0,192,192,192,192,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,\
0,0,0,0,0,0,0,0,192,192,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,192,192,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,\
0,192,192,192,192,192,192,192,192,192,0,192,192,0,192,192,192,192,192,192,192,192,192,192,192,192,192,0,192,192,192,0,0,192,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,192,192,0,0,0,0,0,0,0,0,0,192,192,192,0,0,192,192,192,192,192,192,0,0,192,192,0,0,192,192,0,192,192,0,192,192,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,0,0,192,192,192,192,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,192,0,0,0,0,0,192,0,0,0,0,192,192,192,192,192,192,192,0,\
0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,192,192,0,0,192,192,0,192,192,192,192,192,192,192,0,192,192,0,0,0,0,0,0,192,192,0,0,0,192,0,0,192,192,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,\
192,192,0,0,192,192,192,0,192,192,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,192,0,0,0,0,0,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,\
192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,192,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,192,192,192,192,192,0,192,192,192,0,0,192,192,0,192,192,0,0,0,192,192,0,\
0,192,192,0,0,192,192,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,192,0,0,0,0,192,0,0,0,0,\
192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,192,192,0,0,0,\
192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,192,192,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,192,0,0,0,192,0,0,0,0,0,0,192,192,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,192,0,0,192,0,0,192,0,192,0,192,0,192,0,0,192,192,0,192,192,0,192,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,\
0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,\
0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,192,192,0,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,192,0,192,192,0,0,192,192,192,192,192,0,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,\
0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,192,192,0,192,192,0,192,192,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,192,192,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,\
0,192,192,0,0,0,192,192,0,0,0,192,192,0,0,0,192,192,192,192,192,192,192,192,0,192,0,0,0,192,0,0,0,0,192,192,192,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,192,192,0,192,192,0,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,192,192,192,192,192,192,192,0,\
0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,0,0,0,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,\
192,192,0,0,0,192,192,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,192,192,192,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,\
192,192,0,0,0,192,192,0,0,192,192,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,0,0,0,192,192,0,0,0,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,192,192,192,0,192,192,192,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,\
0,192,192,0,0,192,192,0,0,192,192,0,192,192,0,0,0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,192,0,192,192,0,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,192,0,0,0,192,192,0,0,0,0,192,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,0,0,0,0,0,0,0,0,0,0,\
0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,192,192,0,192,192,0,192,0,0,0,0,0,0,0,0,0,\
192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,192,192,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,192,192,0,192,192,0,0,0,192,192,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,\
0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,192,0,0,0,192,0,0,0,0,0,0,192,192,0,0,0,\
0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,192,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,192,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,192,0,0,192,0,0,192,0,192,0,192,0,192,0,192,192,0,192,192,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,\
0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,\
0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,192,192,192,192,0,0,0,\
192,192,192,192,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,192,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,0,192,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,192,192,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,\
0,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,192,192,192,192,192,0,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,192,192,192,192,192,0,0,0,0,0,192,0,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,192,192,0,0,192,192,192,192,192,192,0,0,0,0,192,192,192,0,0,0,192,192,192,192,192,192,192,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,192,192,0,0,0,\
0,192,192,192,192,192,0,0,0,0,192,192,0,0,0,0,192,192,192,192,192,192,0,0,0,0,192,192,192,192,0,0,192,192,192,192,192,0,0,0,192,192,192,192,192,192,192,0,192,192,192,192,192,192,192,0,0,0,192,192,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,192,192,0,0,0,0,0,0,192,192,192,192,0,192,192,192,0,0,192,192,0,192,192,192,192,0,0,0,0,192,192,0,0,0,192,192,0,192,192,0,0,0,192,192,0,0,0,192,192,192,0,0,0,\
192,192,192,192,192,192,0,0,0,0,192,192,192,0,0,0,192,192,192,192,192,192,0,0,0,192,192,192,192,0,0,0,192,192,192,192,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,192,192,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,192,192,192,192,192,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,\
0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,192,192,0,0,192,192,192,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,0,0,0,0,192,192,0,0,0,192,192,192,0,0,0,0,0,0,192,192,192,0,0,192,192,0,0,0,0,0,0,0,0,\
0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,0,192,192,0,0,0,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,0,192,192,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,0,192,192,0,192,192,0,0,0,0,192,192,192,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,\
0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,0,0,192,192,192,192,0,0,0,192,192,0,0,192,192,0,0,0,192,192,0,0,0,0,0,0,192,192,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,192,192,0,0,192,192,0,192,192,0,0,192,192,0,0,192,0,0,0,192,0,0,0,0,0,0,192,192,0,192,192,\
0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,192,0,192,192,0,192,192,0,192,192,192,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,192,0,0,192,192,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
192,0,0,192,0,0,192,0,192,0,192,0,192,0,192,0,192,192,0,192,192,0,192,192,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,\
0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,\
0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,192,192,192,192,192,192,0,0,192,192,192,192,192,192,192,0,192,192,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,0,0,0,192,192,192,192,0,0,0,0,192,192,192,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,0,192,192,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,\
0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,0,0,192,192,0,0,192,192,0,0,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,0,\
0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,192,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,192,0,0,192,0,0,0,192,0,192,0,192,0,192,0,192,192,0,192,192,0,192,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,192,192,0,0,192,192,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,\
0,192,192,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,192,192,0,0,0,0,192,192,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,0,0,0,0,0,0,0,0,192,192,192,192,192,192,192,192,192,192,192,192,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
};
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/BMPFontData.hpp
|
C++
|
gpl3
| 64,051
|
#include "ColorDefine.hpp"
namespace zzz{
const Colorf ColorDefine::aliceBlue (0.94118,0.97255,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#F0F8FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::antiqueWhite (0.98039,0.92157,0.84314); /// \htmlonly <table><tr><td width="300" bgcolor="#FAEBD7"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::antiqueWhite1 (1.00000,0.93725,0.85882); /// \htmlonly <table><tr><td width="300" bgcolor="#FFEFDB"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::antiqueWhite2 (0.93333,0.87451,0.80000); /// \htmlonly <table><tr><td width="300" bgcolor="#EEDFCC"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::antiqueWhite3 (0.80392,0.75294,0.69020); /// \htmlonly <table><tr><td width="300" bgcolor="#CDC0B0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::antiqueWhite4 (0.54510,0.51373,0.47059); /// \htmlonly <table><tr><td width="300" bgcolor="#8B8378"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::aquamarine (0.49804,1.00000,0.83137); /// \htmlonly <table><tr><td width="300" bgcolor="#7FFFD4"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::aquamarine1 (0.49804,1.00000,0.83137); /// \htmlonly <table><tr><td width="300" bgcolor="#7FFFD4"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::aquamarine2 (0.46275,0.93333,0.77647); /// \htmlonly <table><tr><td width="300" bgcolor="#76EEC6"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::aquamarine3 (0.40000,0.80392,0.66667); /// \htmlonly <table><tr><td width="300" bgcolor="#66CDAA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::aquamarine4 (0.27059,0.54510,0.45490); /// \htmlonly <table><tr><td width="300" bgcolor="#458B74"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::azure (0.94118,1.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#F0FFFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::azure1 (0.94118,1.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#F0FFFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::azure2 (0.87843,0.93333,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#E0EEEE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::azure3 (0.75686,0.80392,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#C1CDCD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::azure4 (0.51373,0.54510,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#838B8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::beige (0.96078,0.96078,0.86275); /// \htmlonly <table><tr><td width="300" bgcolor="#F5F5DC"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::bisque (1.00000,0.89412,0.76863); /// \htmlonly <table><tr><td width="300" bgcolor="#FFE4C4"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::bisque1 (1.00000,0.89412,0.76863); /// \htmlonly <table><tr><td width="300" bgcolor="#FFE4C4"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::bisque2 (0.93333,0.83529,0.71765); /// \htmlonly <table><tr><td width="300" bgcolor="#EED5B7"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::bisque3 (0.80392,0.71765,0.61961); /// \htmlonly <table><tr><td width="300" bgcolor="#CDB79E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::bisque4 (0.54510,0.49020,0.41961); /// \htmlonly <table><tr><td width="300" bgcolor="#8B7D6B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::black (0.00000,0.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#000000"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::blanchedAlmond (1.00000,0.92157,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#FFEBCD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::blue (0.00000,0.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#0000FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::blue1 (0.00000,0.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#0000FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::blue2 (0.00000,0.00000,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#0000EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::blue3 (0.00000,0.00000,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#0000CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::blue4 (0.00000,0.00000,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#00008B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::blueViolet (0.54118,0.16863,0.88627); /// \htmlonly <table><tr><td width="300" bgcolor="#8A2BE2"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::brown (0.64706,0.16471,0.16471); /// \htmlonly <table><tr><td width="300" bgcolor="#A52A2A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::brown1 (1.00000,0.25098,0.25098); /// \htmlonly <table><tr><td width="300" bgcolor="#FF4040"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::brown2 (0.93333,0.23137,0.23137); /// \htmlonly <table><tr><td width="300" bgcolor="#EE3B3B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::brown3 (0.80392,0.20000,0.20000); /// \htmlonly <table><tr><td width="300" bgcolor="#CD3333"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::brown4 (0.54510,0.13725,0.13725); /// \htmlonly <table><tr><td width="300" bgcolor="#8B2323"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::burlywood (0.87059,0.72157,0.52941); /// \htmlonly <table><tr><td width="300" bgcolor="#DEB887"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::burlywood1 (1.00000,0.82745,0.60784); /// \htmlonly <table><tr><td width="300" bgcolor="#FFD39B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::burlywood2 (0.93333,0.77255,0.56863); /// \htmlonly <table><tr><td width="300" bgcolor="#EEC591"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::burlywood3 (0.80392,0.66667,0.49020); /// \htmlonly <table><tr><td width="300" bgcolor="#CDAA7D"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::burlywood4 (0.54510,0.45098,0.33333); /// \htmlonly <table><tr><td width="300" bgcolor="#8B7355"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cadetBlue (0.37255,0.61961,0.62745); /// \htmlonly <table><tr><td width="300" bgcolor="#5F9EA0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cadetBlue1 (0.59608,0.96078,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#98F5FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cadetBlue2 (0.55686,0.89804,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#8EE5EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cadetBlue3 (0.47843,0.77255,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#7AC5CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cadetBlue4 (0.32549,0.52549,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#53868B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::chartreuse (0.49804,1.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#7FFF00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::chartreuse1 (0.49804,1.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#7FFF00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::chartreuse2 (0.46275,0.93333,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#76EE00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::chartreuse3 (0.40000,0.80392,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#66CD00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::chartreuse4 (0.27059,0.54510,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#458B00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::chocolate (0.82353,0.41176,0.11765); /// \htmlonly <table><tr><td width="300" bgcolor="#D2691E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::chocolate1 (1.00000,0.49804,0.14118); /// \htmlonly <table><tr><td width="300" bgcolor="#FF7F24"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::chocolate2 (0.93333,0.46275,0.12941); /// \htmlonly <table><tr><td width="300" bgcolor="#EE7621"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::chocolate3 (0.80392,0.40000,0.11373); /// \htmlonly <table><tr><td width="300" bgcolor="#CD661D"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::chocolate4 (0.54510,0.27059,0.07451); /// \htmlonly <table><tr><td width="300" bgcolor="#8B4513"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::coral (1.00000,0.49804,0.31373); /// \htmlonly <table><tr><td width="300" bgcolor="#FF7F50"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::coral1 (1.00000,0.44706,0.33725); /// \htmlonly <table><tr><td width="300" bgcolor="#FF7256"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::coral2 (0.93333,0.41569,0.31373); /// \htmlonly <table><tr><td width="300" bgcolor="#EE6A50"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::coral3 (0.80392,0.35686,0.27059); /// \htmlonly <table><tr><td width="300" bgcolor="#CD5B45"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::coral4 (0.54510,0.24314,0.18431); /// \htmlonly <table><tr><td width="300" bgcolor="#8B3E2F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cornflowerBlue (0.39216,0.58431,0.92941); /// \htmlonly <table><tr><td width="300" bgcolor="#6495ED"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cornsilk (1.00000,0.97255,0.86275); /// \htmlonly <table><tr><td width="300" bgcolor="#FFF8DC"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cornsilk1 (1.00000,0.97255,0.86275); /// \htmlonly <table><tr><td width="300" bgcolor="#FFF8DC"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cornsilk2 (0.93333,0.90980,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#EEE8CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cornsilk3 (0.80392,0.78431,0.69412); /// \htmlonly <table><tr><td width="300" bgcolor="#CDC8B1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cornsilk4 (0.54510,0.53333,0.47059); /// \htmlonly <table><tr><td width="300" bgcolor="#8B8878"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cyan (0.00000,1.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#00FFFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cyan1 (0.00000,1.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#00FFFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cyan2 (0.00000,0.93333,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#00EEEE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cyan3 (0.00000,0.80392,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#00CDCD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::cyan4 (0.00000,0.54510,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#008B8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkBlue (0.00000,0.00000,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#00008B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkCyan (0.00000,0.54510,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#008B8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkGoldenrod (0.72157,0.52549,0.04314); /// \htmlonly <table><tr><td width="300" bgcolor="#B8860B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkGoldenrod1 (1.00000,0.72549,0.05882); /// \htmlonly <table><tr><td width="300" bgcolor="#FFB90F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkGoldenrod2 (0.93333,0.67843,0.05490); /// \htmlonly <table><tr><td width="300" bgcolor="#EEAD0E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkGoldenrod3 (0.80392,0.58431,0.04706); /// \htmlonly <table><tr><td width="300" bgcolor="#CD950C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkGoldenrod4 (0.54510,0.39608,0.03137); /// \htmlonly <table><tr><td width="300" bgcolor="#8B6508"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkGray (0.66275,0.66275,0.66275); /// \htmlonly <table><tr><td width="300" bgcolor="#A9A9A9"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkGreen (0.00000,0.39216,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#006400"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkGrey (0.66275,0.66275,0.66275); /// \htmlonly <table><tr><td width="300" bgcolor="#A9A9A9"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkKhaki (0.74118,0.71765,0.41961); /// \htmlonly <table><tr><td width="300" bgcolor="#BDB76B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkMagenta (0.54510,0.00000,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#8B008B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOliveGreen (0.33333,0.41961,0.18431); /// \htmlonly <table><tr><td width="300" bgcolor="#556B2F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOliveGreen1 (0.79216,1.00000,0.43922); /// \htmlonly <table><tr><td width="300" bgcolor="#CAFF70"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOliveGreen2 (0.73725,0.93333,0.40784); /// \htmlonly <table><tr><td width="300" bgcolor="#BCEE68"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOliveGreen3 (0.63529,0.80392,0.35294); /// \htmlonly <table><tr><td width="300" bgcolor="#A2CD5A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOliveGreen4 (0.43137,0.54510,0.23922); /// \htmlonly <table><tr><td width="300" bgcolor="#6E8B3D"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOrange (1.00000,0.54902,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FF8C00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOrange1 (1.00000,0.49804,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FF7F00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOrange2 (0.93333,0.46275,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#EE7600"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOrange3 (0.80392,0.40000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#CD6600"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOrange4 (0.54510,0.27059,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#8B4500"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOrchid (0.60000,0.19608,0.80000); /// \htmlonly <table><tr><td width="300" bgcolor="#9932CC"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOrchid1 (0.74902,0.24314,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#BF3EFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOrchid2 (0.69804,0.22745,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#B23AEE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOrchid3 (0.60392,0.19608,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#9A32CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkOrchid4 (0.40784,0.13333,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#68228B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkRed (0.54510,0.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#8B0000"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkSalmon (0.91373,0.58824,0.47843); /// \htmlonly <table><tr><td width="300" bgcolor="#E9967A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkSeaGreen (0.56078,0.73725,0.56078); /// \htmlonly <table><tr><td width="300" bgcolor="#8FBC8F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkSeaGreen1 (0.75686,1.00000,0.75686); /// \htmlonly <table><tr><td width="300" bgcolor="#C1FFC1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkSeaGreen2 (0.70588,0.93333,0.70588); /// \htmlonly <table><tr><td width="300" bgcolor="#B4EEB4"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkSeaGreen3 (0.60784,0.80392,0.60784); /// \htmlonly <table><tr><td width="300" bgcolor="#9BCD9B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkSeaGreen4 (0.41176,0.54510,0.41176); /// \htmlonly <table><tr><td width="300" bgcolor="#698B69"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkSlateBlue (0.28235,0.23922,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#483D8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkSlateGray (0.18431,0.30980,0.30980); /// \htmlonly <table><tr><td width="300" bgcolor="#2F4F4F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkSlateGray1 (0.59216,1.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#97FFFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkSlateGray2 (0.55294,0.93333,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#8DEEEE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkSlateGray3 (0.47451,0.80392,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#79CDCD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkSlateGray4 (0.32157,0.54510,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#528B8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkSlateGrey (0.18431,0.30980,0.30980); /// \htmlonly <table><tr><td width="300" bgcolor="#2F4F4F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkTurquoise (0.00000,0.80784,0.81961); /// \htmlonly <table><tr><td width="300" bgcolor="#00CED1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::darkViolet (0.58039,0.00000,0.82745); /// \htmlonly <table><tr><td width="300" bgcolor="#9400D3"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::deepPink (1.00000,0.07843,0.57647); /// \htmlonly <table><tr><td width="300" bgcolor="#FF1493"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::deepPink1 (1.00000,0.07843,0.57647); /// \htmlonly <table><tr><td width="300" bgcolor="#FF1493"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::deepPink2 (0.93333,0.07059,0.53725); /// \htmlonly <table><tr><td width="300" bgcolor="#EE1289"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::deepPink3 (0.80392,0.06275,0.46275); /// \htmlonly <table><tr><td width="300" bgcolor="#CD1076"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::deepPink4 (0.54510,0.03922,0.31373); /// \htmlonly <table><tr><td width="300" bgcolor="#8B0A50"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::deepSkyBlue (0.00000,0.74902,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#00BFFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::deepSkyBlue1 (0.00000,0.74902,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#00BFFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::deepSkyBlue2 (0.00000,0.69804,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#00B2EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::deepSkyBlue3 (0.00000,0.60392,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#009ACD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::deepSkyBlue4 (0.00000,0.40784,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#00688B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::dimGray (0.41176,0.41176,0.41176); /// \htmlonly <table><tr><td width="300" bgcolor="#696969"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::dimGrey (0.41176,0.41176,0.41176); /// \htmlonly <table><tr><td width="300" bgcolor="#696969"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::dodgerBlue (0.11765,0.56471,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#1E90FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::dodgerBlue1 (0.11765,0.56471,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#1E90FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::dodgerBlue2 (0.10980,0.52549,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#1C86EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::dodgerBlue3 (0.09412,0.45490,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#1874CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::dodgerBlue4 (0.06275,0.30588,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#104E8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::firebrick (0.69804,0.13333,0.13333); /// \htmlonly <table><tr><td width="300" bgcolor="#B22222"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::firebrick1 (1.00000,0.18824,0.18824); /// \htmlonly <table><tr><td width="300" bgcolor="#FF3030"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::firebrick2 (0.93333,0.17255,0.17255); /// \htmlonly <table><tr><td width="300" bgcolor="#EE2C2C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::firebrick3 (0.80392,0.14902,0.14902); /// \htmlonly <table><tr><td width="300" bgcolor="#CD2626"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::firebrick4 (0.54510,0.10196,0.10196); /// \htmlonly <table><tr><td width="300" bgcolor="#8B1A1A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::floralWhite (1.00000,0.98039,0.94118); /// \htmlonly <table><tr><td width="300" bgcolor="#FFFAF0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::forestGreen (0.13333,0.54510,0.13333); /// \htmlonly <table><tr><td width="300" bgcolor="#228B22"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gainsboro (0.86275,0.86275,0.86275); /// \htmlonly <table><tr><td width="300" bgcolor="#DCDCDC"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::ghostWhite (0.97255,0.97255,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#F8F8FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gold (1.00000,0.84314,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FFD700"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gold1 (1.00000,0.84314,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FFD700"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gold2 (0.93333,0.78824,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#EEC900"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gold3 (0.80392,0.67843,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#CDAD00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gold4 (0.54510,0.45882,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#8B7500"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::goldenrod (0.85490,0.64706,0.12549); /// \htmlonly <table><tr><td width="300" bgcolor="#DAA520"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::goldenrod1 (1.00000,0.75686,0.14510); /// \htmlonly <table><tr><td width="300" bgcolor="#FFC125"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::goldenrod2 (0.93333,0.70588,0.13333); /// \htmlonly <table><tr><td width="300" bgcolor="#EEB422"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::goldenrod3 (0.80392,0.60784,0.11373); /// \htmlonly <table><tr><td width="300" bgcolor="#CD9B1D"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::goldenrod4 (0.54510,0.41176,0.07843); /// \htmlonly <table><tr><td width="300" bgcolor="#8B6914"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray (0.74510,0.74510,0.74510); /// \htmlonly <table><tr><td width="300" bgcolor="#BEBEBE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray0 (0.00000,0.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#000000"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray1 (0.01176,0.01176,0.01176); /// \htmlonly <table><tr><td width="300" bgcolor="#030303"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray10 (0.10196,0.10196,0.10196); /// \htmlonly <table><tr><td width="300" bgcolor="#1A1A1A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray100 (1.00000,1.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FFFFFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray11 (0.10980,0.10980,0.10980); /// \htmlonly <table><tr><td width="300" bgcolor="#1C1C1C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray12 (0.12157,0.12157,0.12157); /// \htmlonly <table><tr><td width="300" bgcolor="#1F1F1F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray13 (0.12941,0.12941,0.12941); /// \htmlonly <table><tr><td width="300" bgcolor="#212121"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray14 (0.14118,0.14118,0.14118); /// \htmlonly <table><tr><td width="300" bgcolor="#242424"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray15 (0.14902,0.14902,0.14902); /// \htmlonly <table><tr><td width="300" bgcolor="#262626"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray16 (0.16078,0.16078,0.16078); /// \htmlonly <table><tr><td width="300" bgcolor="#292929"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray17 (0.16863,0.16863,0.16863); /// \htmlonly <table><tr><td width="300" bgcolor="#2B2B2B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray18 (0.18039,0.18039,0.18039); /// \htmlonly <table><tr><td width="300" bgcolor="#2E2E2E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray19 (0.18824,0.18824,0.18824); /// \htmlonly <table><tr><td width="300" bgcolor="#303030"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray2 (0.01961,0.01961,0.01961); /// \htmlonly <table><tr><td width="300" bgcolor="#050505"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray20 (0.20000,0.20000,0.20000); /// \htmlonly <table><tr><td width="300" bgcolor="#333333"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray21 (0.21176,0.21176,0.21176); /// \htmlonly <table><tr><td width="300" bgcolor="#363636"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray22 (0.21961,0.21961,0.21961); /// \htmlonly <table><tr><td width="300" bgcolor="#383838"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray23 (0.23137,0.23137,0.23137); /// \htmlonly <table><tr><td width="300" bgcolor="#3B3B3B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray24 (0.23922,0.23922,0.23922); /// \htmlonly <table><tr><td width="300" bgcolor="#3D3D3D"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray25 (0.25098,0.25098,0.25098); /// \htmlonly <table><tr><td width="300" bgcolor="#404040"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray26 (0.25882,0.25882,0.25882); /// \htmlonly <table><tr><td width="300" bgcolor="#424242"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray27 (0.27059,0.27059,0.27059); /// \htmlonly <table><tr><td width="300" bgcolor="#454545"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray28 (0.27843,0.27843,0.27843); /// \htmlonly <table><tr><td width="300" bgcolor="#474747"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray29 (0.29020,0.29020,0.29020); /// \htmlonly <table><tr><td width="300" bgcolor="#4A4A4A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray3 (0.03137,0.03137,0.03137); /// \htmlonly <table><tr><td width="300" bgcolor="#080808"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray30 (0.30196,0.30196,0.30196); /// \htmlonly <table><tr><td width="300" bgcolor="#4D4D4D"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray31 (0.30980,0.30980,0.30980); /// \htmlonly <table><tr><td width="300" bgcolor="#4F4F4F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray32 (0.32157,0.32157,0.32157); /// \htmlonly <table><tr><td width="300" bgcolor="#525252"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray33 (0.32941,0.32941,0.32941); /// \htmlonly <table><tr><td width="300" bgcolor="#545454"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray34 (0.34118,0.34118,0.34118); /// \htmlonly <table><tr><td width="300" bgcolor="#575757"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray35 (0.34902,0.34902,0.34902); /// \htmlonly <table><tr><td width="300" bgcolor="#595959"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray36 (0.36078,0.36078,0.36078); /// \htmlonly <table><tr><td width="300" bgcolor="#5C5C5C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray37 (0.36863,0.36863,0.36863); /// \htmlonly <table><tr><td width="300" bgcolor="#5E5E5E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray38 (0.38039,0.38039,0.38039); /// \htmlonly <table><tr><td width="300" bgcolor="#616161"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray39 (0.38824,0.38824,0.38824); /// \htmlonly <table><tr><td width="300" bgcolor="#636363"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray4 (0.03922,0.03922,0.03922); /// \htmlonly <table><tr><td width="300" bgcolor="#0A0A0A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray40 (0.40000,0.40000,0.40000); /// \htmlonly <table><tr><td width="300" bgcolor="#666666"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray41 (0.41176,0.41176,0.41176); /// \htmlonly <table><tr><td width="300" bgcolor="#696969"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray42 (0.41961,0.41961,0.41961); /// \htmlonly <table><tr><td width="300" bgcolor="#6B6B6B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray43 (0.43137,0.43137,0.43137); /// \htmlonly <table><tr><td width="300" bgcolor="#6E6E6E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray44 (0.43922,0.43922,0.43922); /// \htmlonly <table><tr><td width="300" bgcolor="#707070"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray45 (0.45098,0.45098,0.45098); /// \htmlonly <table><tr><td width="300" bgcolor="#737373"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray46 (0.45882,0.45882,0.45882); /// \htmlonly <table><tr><td width="300" bgcolor="#757575"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray47 (0.47059,0.47059,0.47059); /// \htmlonly <table><tr><td width="300" bgcolor="#787878"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray48 (0.47843,0.47843,0.47843); /// \htmlonly <table><tr><td width="300" bgcolor="#7A7A7A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray49 (0.49020,0.49020,0.49020); /// \htmlonly <table><tr><td width="300" bgcolor="#7D7D7D"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray5 (0.05098,0.05098,0.05098); /// \htmlonly <table><tr><td width="300" bgcolor="#0D0D0D"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray50 (0.49804,0.49804,0.49804); /// \htmlonly <table><tr><td width="300" bgcolor="#7F7F7F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray51 (0.50980,0.50980,0.50980); /// \htmlonly <table><tr><td width="300" bgcolor="#828282"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray52 (0.52157,0.52157,0.52157); /// \htmlonly <table><tr><td width="300" bgcolor="#858585"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray53 (0.52941,0.52941,0.52941); /// \htmlonly <table><tr><td width="300" bgcolor="#878787"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray54 (0.54118,0.54118,0.54118); /// \htmlonly <table><tr><td width="300" bgcolor="#8A8A8A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray55 (0.54902,0.54902,0.54902); /// \htmlonly <table><tr><td width="300" bgcolor="#8C8C8C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray56 (0.56078,0.56078,0.56078); /// \htmlonly <table><tr><td width="300" bgcolor="#8F8F8F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray57 (0.56863,0.56863,0.56863); /// \htmlonly <table><tr><td width="300" bgcolor="#919191"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray58 (0.58039,0.58039,0.58039); /// \htmlonly <table><tr><td width="300" bgcolor="#949494"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray59 (0.58824,0.58824,0.58824); /// \htmlonly <table><tr><td width="300" bgcolor="#969696"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray6 (0.05882,0.05882,0.05882); /// \htmlonly <table><tr><td width="300" bgcolor="#0F0F0F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray60 (0.60000,0.60000,0.60000); /// \htmlonly <table><tr><td width="300" bgcolor="#999999"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray61 (0.61176,0.61176,0.61176); /// \htmlonly <table><tr><td width="300" bgcolor="#9C9C9C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray62 (0.61961,0.61961,0.61961); /// \htmlonly <table><tr><td width="300" bgcolor="#9E9E9E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray63 (0.63137,0.63137,0.63137); /// \htmlonly <table><tr><td width="300" bgcolor="#A1A1A1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray64 (0.63922,0.63922,0.63922); /// \htmlonly <table><tr><td width="300" bgcolor="#A3A3A3"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray65 (0.65098,0.65098,0.65098); /// \htmlonly <table><tr><td width="300" bgcolor="#A6A6A6"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray66 (0.65882,0.65882,0.65882); /// \htmlonly <table><tr><td width="300" bgcolor="#A8A8A8"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray67 (0.67059,0.67059,0.67059); /// \htmlonly <table><tr><td width="300" bgcolor="#ABABAB"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray68 (0.67843,0.67843,0.67843); /// \htmlonly <table><tr><td width="300" bgcolor="#ADADAD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray69 (0.69020,0.69020,0.69020); /// \htmlonly <table><tr><td width="300" bgcolor="#B0B0B0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray7 (0.07059,0.07059,0.07059); /// \htmlonly <table><tr><td width="300" bgcolor="#121212"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray70 (0.70196,0.70196,0.70196); /// \htmlonly <table><tr><td width="300" bgcolor="#B3B3B3"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray71 (0.70980,0.70980,0.70980); /// \htmlonly <table><tr><td width="300" bgcolor="#B5B5B5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray72 (0.72157,0.72157,0.72157); /// \htmlonly <table><tr><td width="300" bgcolor="#B8B8B8"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray73 (0.72941,0.72941,0.72941); /// \htmlonly <table><tr><td width="300" bgcolor="#BABABA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray74 (0.74118,0.74118,0.74118); /// \htmlonly <table><tr><td width="300" bgcolor="#BDBDBD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray75 (0.74902,0.74902,0.74902); /// \htmlonly <table><tr><td width="300" bgcolor="#BFBFBF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray76 (0.76078,0.76078,0.76078); /// \htmlonly <table><tr><td width="300" bgcolor="#C2C2C2"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray77 (0.76863,0.76863,0.76863); /// \htmlonly <table><tr><td width="300" bgcolor="#C4C4C4"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray78 (0.78039,0.78039,0.78039); /// \htmlonly <table><tr><td width="300" bgcolor="#C7C7C7"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray79 (0.78824,0.78824,0.78824); /// \htmlonly <table><tr><td width="300" bgcolor="#C9C9C9"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray8 (0.07843,0.07843,0.07843); /// \htmlonly <table><tr><td width="300" bgcolor="#141414"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray80 (0.80000,0.80000,0.80000); /// \htmlonly <table><tr><td width="300" bgcolor="#CCCCCC"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray81 (0.81176,0.81176,0.81176); /// \htmlonly <table><tr><td width="300" bgcolor="#CFCFCF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray82 (0.81961,0.81961,0.81961); /// \htmlonly <table><tr><td width="300" bgcolor="#D1D1D1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray83 (0.83137,0.83137,0.83137); /// \htmlonly <table><tr><td width="300" bgcolor="#D4D4D4"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray84 (0.83922,0.83922,0.83922); /// \htmlonly <table><tr><td width="300" bgcolor="#D6D6D6"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray85 (0.85098,0.85098,0.85098); /// \htmlonly <table><tr><td width="300" bgcolor="#D9D9D9"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray86 (0.85882,0.85882,0.85882); /// \htmlonly <table><tr><td width="300" bgcolor="#DBDBDB"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray87 (0.87059,0.87059,0.87059); /// \htmlonly <table><tr><td width="300" bgcolor="#DEDEDE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray88 (0.87843,0.87843,0.87843); /// \htmlonly <table><tr><td width="300" bgcolor="#E0E0E0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray89 (0.89020,0.89020,0.89020); /// \htmlonly <table><tr><td width="300" bgcolor="#E3E3E3"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray9 (0.09020,0.09020,0.09020); /// \htmlonly <table><tr><td width="300" bgcolor="#171717"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray90 (0.89804,0.89804,0.89804); /// \htmlonly <table><tr><td width="300" bgcolor="#E5E5E5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray91 (0.90980,0.90980,0.90980); /// \htmlonly <table><tr><td width="300" bgcolor="#E8E8E8"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray92 (0.92157,0.92157,0.92157); /// \htmlonly <table><tr><td width="300" bgcolor="#EBEBEB"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray93 (0.92941,0.92941,0.92941); /// \htmlonly <table><tr><td width="300" bgcolor="#EDEDED"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray94 (0.94118,0.94118,0.94118); /// \htmlonly <table><tr><td width="300" bgcolor="#F0F0F0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray95 (0.94902,0.94902,0.94902); /// \htmlonly <table><tr><td width="300" bgcolor="#F2F2F2"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray96 (0.96078,0.96078,0.96078); /// \htmlonly <table><tr><td width="300" bgcolor="#F5F5F5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray97 (0.96863,0.96863,0.96863); /// \htmlonly <table><tr><td width="300" bgcolor="#F7F7F7"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray98 (0.98039,0.98039,0.98039); /// \htmlonly <table><tr><td width="300" bgcolor="#FAFAFA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::gray99 (0.98824,0.98824,0.98824); /// \htmlonly <table><tr><td width="300" bgcolor="#FCFCFC"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::green (0.00000,1.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#00FF00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::green1 (0.00000,1.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#00FF00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::green2 (0.00000,0.93333,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#00EE00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::green3 (0.00000,0.80392,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#00CD00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::green4 (0.00000,0.54510,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#008B00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::greenYellow (0.67843,1.00000,0.18431); /// \htmlonly <table><tr><td width="300" bgcolor="#ADFF2F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey (0.74510,0.74510,0.74510); /// \htmlonly <table><tr><td width="300" bgcolor="#BEBEBE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey0 (0.00000,0.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#000000"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey1 (0.01176,0.01176,0.01176); /// \htmlonly <table><tr><td width="300" bgcolor="#030303"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey10 (0.10196,0.10196,0.10196); /// \htmlonly <table><tr><td width="300" bgcolor="#1A1A1A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey100 (1.00000,1.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FFFFFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey11 (0.10980,0.10980,0.10980); /// \htmlonly <table><tr><td width="300" bgcolor="#1C1C1C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey12 (0.12157,0.12157,0.12157); /// \htmlonly <table><tr><td width="300" bgcolor="#1F1F1F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey13 (0.12941,0.12941,0.12941); /// \htmlonly <table><tr><td width="300" bgcolor="#212121"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey14 (0.14118,0.14118,0.14118); /// \htmlonly <table><tr><td width="300" bgcolor="#242424"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey15 (0.14902,0.14902,0.14902); /// \htmlonly <table><tr><td width="300" bgcolor="#262626"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey16 (0.16078,0.16078,0.16078); /// \htmlonly <table><tr><td width="300" bgcolor="#292929"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey17 (0.16863,0.16863,0.16863); /// \htmlonly <table><tr><td width="300" bgcolor="#2B2B2B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey18 (0.18039,0.18039,0.18039); /// \htmlonly <table><tr><td width="300" bgcolor="#2E2E2E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey19 (0.18824,0.18824,0.18824); /// \htmlonly <table><tr><td width="300" bgcolor="#303030"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey2 (0.01961,0.01961,0.01961); /// \htmlonly <table><tr><td width="300" bgcolor="#050505"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey20 (0.20000,0.20000,0.20000); /// \htmlonly <table><tr><td width="300" bgcolor="#333333"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey21 (0.21176,0.21176,0.21176); /// \htmlonly <table><tr><td width="300" bgcolor="#363636"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey22 (0.21961,0.21961,0.21961); /// \htmlonly <table><tr><td width="300" bgcolor="#383838"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey23 (0.23137,0.23137,0.23137); /// \htmlonly <table><tr><td width="300" bgcolor="#3B3B3B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey24 (0.23922,0.23922,0.23922); /// \htmlonly <table><tr><td width="300" bgcolor="#3D3D3D"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey25 (0.25098,0.25098,0.25098); /// \htmlonly <table><tr><td width="300" bgcolor="#404040"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey26 (0.25882,0.25882,0.25882); /// \htmlonly <table><tr><td width="300" bgcolor="#424242"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey27 (0.27059,0.27059,0.27059); /// \htmlonly <table><tr><td width="300" bgcolor="#454545"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey28 (0.27843,0.27843,0.27843); /// \htmlonly <table><tr><td width="300" bgcolor="#474747"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey29 (0.29020,0.29020,0.29020); /// \htmlonly <table><tr><td width="300" bgcolor="#4A4A4A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey3 (0.03137,0.03137,0.03137); /// \htmlonly <table><tr><td width="300" bgcolor="#080808"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey30 (0.30196,0.30196,0.30196); /// \htmlonly <table><tr><td width="300" bgcolor="#4D4D4D"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey31 (0.30980,0.30980,0.30980); /// \htmlonly <table><tr><td width="300" bgcolor="#4F4F4F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey32 (0.32157,0.32157,0.32157); /// \htmlonly <table><tr><td width="300" bgcolor="#525252"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey33 (0.32941,0.32941,0.32941); /// \htmlonly <table><tr><td width="300" bgcolor="#545454"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey34 (0.34118,0.34118,0.34118); /// \htmlonly <table><tr><td width="300" bgcolor="#575757"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey35 (0.34902,0.34902,0.34902); /// \htmlonly <table><tr><td width="300" bgcolor="#595959"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey36 (0.36078,0.36078,0.36078); /// \htmlonly <table><tr><td width="300" bgcolor="#5C5C5C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey37 (0.36863,0.36863,0.36863); /// \htmlonly <table><tr><td width="300" bgcolor="#5E5E5E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey38 (0.38039,0.38039,0.38039); /// \htmlonly <table><tr><td width="300" bgcolor="#616161"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey39 (0.38824,0.38824,0.38824); /// \htmlonly <table><tr><td width="300" bgcolor="#636363"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey4 (0.03922,0.03922,0.03922); /// \htmlonly <table><tr><td width="300" bgcolor="#0A0A0A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey40 (0.40000,0.40000,0.40000); /// \htmlonly <table><tr><td width="300" bgcolor="#666666"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey41 (0.41176,0.41176,0.41176); /// \htmlonly <table><tr><td width="300" bgcolor="#696969"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey42 (0.41961,0.41961,0.41961); /// \htmlonly <table><tr><td width="300" bgcolor="#6B6B6B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey43 (0.43137,0.43137,0.43137); /// \htmlonly <table><tr><td width="300" bgcolor="#6E6E6E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey44 (0.43922,0.43922,0.43922); /// \htmlonly <table><tr><td width="300" bgcolor="#707070"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey45 (0.45098,0.45098,0.45098); /// \htmlonly <table><tr><td width="300" bgcolor="#737373"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey46 (0.45882,0.45882,0.45882); /// \htmlonly <table><tr><td width="300" bgcolor="#757575"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey47 (0.47059,0.47059,0.47059); /// \htmlonly <table><tr><td width="300" bgcolor="#787878"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey48 (0.47843,0.47843,0.47843); /// \htmlonly <table><tr><td width="300" bgcolor="#7A7A7A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey49 (0.49020,0.49020,0.49020); /// \htmlonly <table><tr><td width="300" bgcolor="#7D7D7D"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey5 (0.05098,0.05098,0.05098); /// \htmlonly <table><tr><td width="300" bgcolor="#0D0D0D"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey50 (0.49804,0.49804,0.49804); /// \htmlonly <table><tr><td width="300" bgcolor="#7F7F7F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey51 (0.50980,0.50980,0.50980); /// \htmlonly <table><tr><td width="300" bgcolor="#828282"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey52 (0.52157,0.52157,0.52157); /// \htmlonly <table><tr><td width="300" bgcolor="#858585"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey53 (0.52941,0.52941,0.52941); /// \htmlonly <table><tr><td width="300" bgcolor="#878787"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey54 (0.54118,0.54118,0.54118); /// \htmlonly <table><tr><td width="300" bgcolor="#8A8A8A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey55 (0.54902,0.54902,0.54902); /// \htmlonly <table><tr><td width="300" bgcolor="#8C8C8C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey56 (0.56078,0.56078,0.56078); /// \htmlonly <table><tr><td width="300" bgcolor="#8F8F8F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey57 (0.56863,0.56863,0.56863); /// \htmlonly <table><tr><td width="300" bgcolor="#919191"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey58 (0.58039,0.58039,0.58039); /// \htmlonly <table><tr><td width="300" bgcolor="#949494"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey59 (0.58824,0.58824,0.58824); /// \htmlonly <table><tr><td width="300" bgcolor="#969696"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey6 (0.05882,0.05882,0.05882); /// \htmlonly <table><tr><td width="300" bgcolor="#0F0F0F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey60 (0.60000,0.60000,0.60000); /// \htmlonly <table><tr><td width="300" bgcolor="#999999"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey61 (0.61176,0.61176,0.61176); /// \htmlonly <table><tr><td width="300" bgcolor="#9C9C9C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey62 (0.61961,0.61961,0.61961); /// \htmlonly <table><tr><td width="300" bgcolor="#9E9E9E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey63 (0.63137,0.63137,0.63137); /// \htmlonly <table><tr><td width="300" bgcolor="#A1A1A1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey64 (0.63922,0.63922,0.63922); /// \htmlonly <table><tr><td width="300" bgcolor="#A3A3A3"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey65 (0.65098,0.65098,0.65098); /// \htmlonly <table><tr><td width="300" bgcolor="#A6A6A6"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey66 (0.65882,0.65882,0.65882); /// \htmlonly <table><tr><td width="300" bgcolor="#A8A8A8"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey67 (0.67059,0.67059,0.67059); /// \htmlonly <table><tr><td width="300" bgcolor="#ABABAB"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey68 (0.67843,0.67843,0.67843); /// \htmlonly <table><tr><td width="300" bgcolor="#ADADAD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey69 (0.69020,0.69020,0.69020); /// \htmlonly <table><tr><td width="300" bgcolor="#B0B0B0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey7 (0.07059,0.07059,0.07059); /// \htmlonly <table><tr><td width="300" bgcolor="#121212"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey70 (0.70196,0.70196,0.70196); /// \htmlonly <table><tr><td width="300" bgcolor="#B3B3B3"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey71 (0.70980,0.70980,0.70980); /// \htmlonly <table><tr><td width="300" bgcolor="#B5B5B5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey72 (0.72157,0.72157,0.72157); /// \htmlonly <table><tr><td width="300" bgcolor="#B8B8B8"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey73 (0.72941,0.72941,0.72941); /// \htmlonly <table><tr><td width="300" bgcolor="#BABABA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey74 (0.74118,0.74118,0.74118); /// \htmlonly <table><tr><td width="300" bgcolor="#BDBDBD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey75 (0.74902,0.74902,0.74902); /// \htmlonly <table><tr><td width="300" bgcolor="#BFBFBF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey76 (0.76078,0.76078,0.76078); /// \htmlonly <table><tr><td width="300" bgcolor="#C2C2C2"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey77 (0.76863,0.76863,0.76863); /// \htmlonly <table><tr><td width="300" bgcolor="#C4C4C4"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey78 (0.78039,0.78039,0.78039); /// \htmlonly <table><tr><td width="300" bgcolor="#C7C7C7"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey79 (0.78824,0.78824,0.78824); /// \htmlonly <table><tr><td width="300" bgcolor="#C9C9C9"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey8 (0.07843,0.07843,0.07843); /// \htmlonly <table><tr><td width="300" bgcolor="#141414"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey80 (0.80000,0.80000,0.80000); /// \htmlonly <table><tr><td width="300" bgcolor="#CCCCCC"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey81 (0.81176,0.81176,0.81176); /// \htmlonly <table><tr><td width="300" bgcolor="#CFCFCF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey82 (0.81961,0.81961,0.81961); /// \htmlonly <table><tr><td width="300" bgcolor="#D1D1D1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey83 (0.83137,0.83137,0.83137); /// \htmlonly <table><tr><td width="300" bgcolor="#D4D4D4"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey84 (0.83922,0.83922,0.83922); /// \htmlonly <table><tr><td width="300" bgcolor="#D6D6D6"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey85 (0.85098,0.85098,0.85098); /// \htmlonly <table><tr><td width="300" bgcolor="#D9D9D9"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey86 (0.85882,0.85882,0.85882); /// \htmlonly <table><tr><td width="300" bgcolor="#DBDBDB"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey87 (0.87059,0.87059,0.87059); /// \htmlonly <table><tr><td width="300" bgcolor="#DEDEDE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey88 (0.87843,0.87843,0.87843); /// \htmlonly <table><tr><td width="300" bgcolor="#E0E0E0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey89 (0.89020,0.89020,0.89020); /// \htmlonly <table><tr><td width="300" bgcolor="#E3E3E3"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey9 (0.09020,0.09020,0.09020); /// \htmlonly <table><tr><td width="300" bgcolor="#171717"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey90 (0.89804,0.89804,0.89804); /// \htmlonly <table><tr><td width="300" bgcolor="#E5E5E5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey91 (0.90980,0.90980,0.90980); /// \htmlonly <table><tr><td width="300" bgcolor="#E8E8E8"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey92 (0.92157,0.92157,0.92157); /// \htmlonly <table><tr><td width="300" bgcolor="#EBEBEB"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey93 (0.92941,0.92941,0.92941); /// \htmlonly <table><tr><td width="300" bgcolor="#EDEDED"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey94 (0.94118,0.94118,0.94118); /// \htmlonly <table><tr><td width="300" bgcolor="#F0F0F0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey95 (0.94902,0.94902,0.94902); /// \htmlonly <table><tr><td width="300" bgcolor="#F2F2F2"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey96 (0.96078,0.96078,0.96078); /// \htmlonly <table><tr><td width="300" bgcolor="#F5F5F5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey97 (0.96863,0.96863,0.96863); /// \htmlonly <table><tr><td width="300" bgcolor="#F7F7F7"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey98 (0.98039,0.98039,0.98039); /// \htmlonly <table><tr><td width="300" bgcolor="#FAFAFA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::grey99 (0.98824,0.98824,0.98824); /// \htmlonly <table><tr><td width="300" bgcolor="#FCFCFC"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::honeydew (0.94118,1.00000,0.94118); /// \htmlonly <table><tr><td width="300" bgcolor="#F0FFF0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::honeydew1 (0.94118,1.00000,0.94118); /// \htmlonly <table><tr><td width="300" bgcolor="#F0FFF0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::honeydew2 (0.87843,0.93333,0.87843); /// \htmlonly <table><tr><td width="300" bgcolor="#E0EEE0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::honeydew3 (0.75686,0.80392,0.75686); /// \htmlonly <table><tr><td width="300" bgcolor="#C1CDC1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::honeydew4 (0.51373,0.54510,0.51373); /// \htmlonly <table><tr><td width="300" bgcolor="#838B83"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::hotPink (1.00000,0.41176,0.70588); /// \htmlonly <table><tr><td width="300" bgcolor="#FF69B4"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::hotPink1 (1.00000,0.43137,0.70588); /// \htmlonly <table><tr><td width="300" bgcolor="#FF6EB4"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::hotPink2 (0.93333,0.41569,0.65490); /// \htmlonly <table><tr><td width="300" bgcolor="#EE6AA7"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::hotPink3 (0.80392,0.37647,0.56471); /// \htmlonly <table><tr><td width="300" bgcolor="#CD6090"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::hotPink4 (0.54510,0.22745,0.38431); /// \htmlonly <table><tr><td width="300" bgcolor="#8B3A62"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::indianRed (0.80392,0.36078,0.36078); /// \htmlonly <table><tr><td width="300" bgcolor="#CD5C5C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::indianRed1 (1.00000,0.41569,0.41569); /// \htmlonly <table><tr><td width="300" bgcolor="#FF6A6A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::indianRed2 (0.93333,0.38824,0.38824); /// \htmlonly <table><tr><td width="300" bgcolor="#EE6363"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::indianRed3 (0.80392,0.33333,0.33333); /// \htmlonly <table><tr><td width="300" bgcolor="#CD5555"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::indianRed4 (0.54510,0.22745,0.22745); /// \htmlonly <table><tr><td width="300" bgcolor="#8B3A3A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::ivory (1.00000,1.00000,0.94118); /// \htmlonly <table><tr><td width="300" bgcolor="#FFFFF0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::ivory1 (1.00000,1.00000,0.94118); /// \htmlonly <table><tr><td width="300" bgcolor="#FFFFF0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::ivory2 (0.93333,0.93333,0.87843); /// \htmlonly <table><tr><td width="300" bgcolor="#EEEEE0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::ivory3 (0.80392,0.80392,0.75686); /// \htmlonly <table><tr><td width="300" bgcolor="#CDCDC1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::ivory4 (0.54510,0.54510,0.51373); /// \htmlonly <table><tr><td width="300" bgcolor="#8B8B83"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::khaki (0.94118,0.90196,0.54902); /// \htmlonly <table><tr><td width="300" bgcolor="#F0E68C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::khaki1 (1.00000,0.96471,0.56078); /// \htmlonly <table><tr><td width="300" bgcolor="#FFF68F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::khaki2 (0.93333,0.90196,0.52157); /// \htmlonly <table><tr><td width="300" bgcolor="#EEE685"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::khaki3 (0.80392,0.77647,0.45098); /// \htmlonly <table><tr><td width="300" bgcolor="#CDC673"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::khaki4 (0.54510,0.52549,0.30588); /// \htmlonly <table><tr><td width="300" bgcolor="#8B864E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lavender (0.90196,0.90196,0.98039); /// \htmlonly <table><tr><td width="300" bgcolor="#E6E6FA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lavenderBlush (1.00000,0.94118,0.96078); /// \htmlonly <table><tr><td width="300" bgcolor="#FFF0F5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lavenderBlush1 (1.00000,0.94118,0.96078); /// \htmlonly <table><tr><td width="300" bgcolor="#FFF0F5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lavenderBlush2 (0.93333,0.87843,0.89804); /// \htmlonly <table><tr><td width="300" bgcolor="#EEE0E5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lavenderBlush3 (0.80392,0.75686,0.77255); /// \htmlonly <table><tr><td width="300" bgcolor="#CDC1C5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lavenderBlush4 (0.54510,0.51373,0.52549); /// \htmlonly <table><tr><td width="300" bgcolor="#8B8386"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lawnGreen (0.48627,0.98824,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#7CFC00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lemonChiffon (1.00000,0.98039,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#FFFACD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lemonChiffon1 (1.00000,0.98039,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#FFFACD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lemonChiffon2 (0.93333,0.91373,0.74902); /// \htmlonly <table><tr><td width="300" bgcolor="#EEE9BF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lemonChiffon3 (0.80392,0.78824,0.64706); /// \htmlonly <table><tr><td width="300" bgcolor="#CDC9A5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lemonChiffon4 (0.54510,0.53725,0.43922); /// \htmlonly <table><tr><td width="300" bgcolor="#8B8970"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightBlue (0.67843,0.84706,0.90196); /// \htmlonly <table><tr><td width="300" bgcolor="#ADD8E6"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightBlue1 (0.74902,0.93725,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#BFEFFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightBlue2 (0.69804,0.87451,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#B2DFEE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightBlue3 (0.60392,0.75294,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#9AC0CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightBlue4 (0.40784,0.51373,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#68838B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightCoral (0.94118,0.50196,0.50196); /// \htmlonly <table><tr><td width="300" bgcolor="#F08080"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightCyan (0.87843,1.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#E0FFFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightCyan1 (0.87843,1.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#E0FFFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightCyan2 (0.81961,0.93333,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#D1EEEE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightCyan3 (0.70588,0.80392,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#B4CDCD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightCyan4 (0.47843,0.54510,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#7A8B8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightGoldenrod (0.93333,0.86667,0.50980); /// \htmlonly <table><tr><td width="300" bgcolor="#EEDD82"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightGoldenrod1 (1.00000,0.92549,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#FFEC8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightGoldenrod2 (0.93333,0.86275,0.50980); /// \htmlonly <table><tr><td width="300" bgcolor="#EEDC82"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightGoldenrod3 (0.80392,0.74510,0.43922); /// \htmlonly <table><tr><td width="300" bgcolor="#CDBE70"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightGoldenrod4 (0.54510,0.50588,0.29804); /// \htmlonly <table><tr><td width="300" bgcolor="#8B814C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightGoldenrodYellow(0.98039,0.98039,0.82353); /// \htmlonly <table><tr><td width="300" bgcolor="#FAFAD2"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightGray (0.82745,0.82745,0.82745); /// \htmlonly <table><tr><td width="300" bgcolor="#D3D3D3"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightGreen (0.56471,0.93333,0.56471); /// \htmlonly <table><tr><td width="300" bgcolor="#90EE90"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightGrey (0.82745,0.82745,0.82745); /// \htmlonly <table><tr><td width="300" bgcolor="#D3D3D3"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightPink (1.00000,0.71373,0.75686); /// \htmlonly <table><tr><td width="300" bgcolor="#FFB6C1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightPink1 (1.00000,0.68235,0.72549); /// \htmlonly <table><tr><td width="300" bgcolor="#FFAEB9"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightPink2 (0.93333,0.63529,0.67843); /// \htmlonly <table><tr><td width="300" bgcolor="#EEA2AD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightPink3 (0.80392,0.54902,0.58431); /// \htmlonly <table><tr><td width="300" bgcolor="#CD8C95"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightPink4 (0.54510,0.37255,0.39608); /// \htmlonly <table><tr><td width="300" bgcolor="#8B5F65"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSalmon (1.00000,0.62745,0.47843); /// \htmlonly <table><tr><td width="300" bgcolor="#FFA07A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSalmon1 (1.00000,0.62745,0.47843); /// \htmlonly <table><tr><td width="300" bgcolor="#FFA07A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSalmon2 (0.93333,0.58431,0.44706); /// \htmlonly <table><tr><td width="300" bgcolor="#EE9572"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSalmon3 (0.80392,0.50588,0.38431); /// \htmlonly <table><tr><td width="300" bgcolor="#CD8162"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSalmon4 (0.54510,0.34118,0.25882); /// \htmlonly <table><tr><td width="300" bgcolor="#8B5742"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSeaGreen (0.12549,0.69804,0.66667); /// \htmlonly <table><tr><td width="300" bgcolor="#20B2AA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSkyBlue (0.52941,0.80784,0.98039); /// \htmlonly <table><tr><td width="300" bgcolor="#87CEFA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSkyBlue1 (0.69020,0.88627,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#B0E2FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSkyBlue2 (0.64314,0.82745,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#A4D3EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSkyBlue3 (0.55294,0.71373,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#8DB6CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSkyBlue4 (0.37647,0.48235,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#607B8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSlateBlue (0.51765,0.43922,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#8470FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSlateGray (0.46667,0.53333,0.60000); /// \htmlonly <table><tr><td width="300" bgcolor="#778899"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSlateGrey (0.46667,0.53333,0.60000); /// \htmlonly <table><tr><td width="300" bgcolor="#778899"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSteelBlue (0.69020,0.76863,0.87059); /// \htmlonly <table><tr><td width="300" bgcolor="#B0C4DE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSteelBlue1 (0.79216,0.88235,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#CAE1FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSteelBlue2 (0.73725,0.82353,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#BCD2EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSteelBlue3 (0.63529,0.70980,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#A2B5CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightSteelBlue4 (0.43137,0.48235,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#6E7B8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightYellow (1.00000,1.00000,0.87843); /// \htmlonly <table><tr><td width="300" bgcolor="#FFFFE0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightYellow1 (1.00000,1.00000,0.87843); /// \htmlonly <table><tr><td width="300" bgcolor="#FFFFE0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightYellow2 (0.93333,0.93333,0.81961); /// \htmlonly <table><tr><td width="300" bgcolor="#EEEED1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightYellow3 (0.80392,0.80392,0.70588); /// \htmlonly <table><tr><td width="300" bgcolor="#CDCDB4"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::lightYellow4 (0.54510,0.54510,0.47843); /// \htmlonly <table><tr><td width="300" bgcolor="#8B8B7A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::limeGreen (0.19608,0.80392,0.19608); /// \htmlonly <table><tr><td width="300" bgcolor="#32CD32"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::linen (0.98039,0.94118,0.90196); /// \htmlonly <table><tr><td width="300" bgcolor="#FAF0E6"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::magenta (1.00000,0.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FF00FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::magenta1 (1.00000,0.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FF00FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::magenta2 (0.93333,0.00000,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#EE00EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::magenta3 (0.80392,0.00000,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#CD00CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::magenta4 (0.54510,0.00000,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#8B008B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::maroon (0.69020,0.18824,0.37647); /// \htmlonly <table><tr><td width="300" bgcolor="#B03060"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::maroon1 (1.00000,0.20392,0.70196); /// \htmlonly <table><tr><td width="300" bgcolor="#FF34B3"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::maroon2 (0.93333,0.18824,0.65490); /// \htmlonly <table><tr><td width="300" bgcolor="#EE30A7"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::maroon3 (0.80392,0.16078,0.56471); /// \htmlonly <table><tr><td width="300" bgcolor="#CD2990"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::maroon4 (0.54510,0.10980,0.38431); /// \htmlonly <table><tr><td width="300" bgcolor="#8B1C62"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumAquamarine (0.40000,0.80392,0.66667); /// \htmlonly <table><tr><td width="300" bgcolor="#66CDAA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumBlue (0.00000,0.00000,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#0000CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumOrchid (0.72941,0.33333,0.82745); /// \htmlonly <table><tr><td width="300" bgcolor="#BA55D3"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumOrchid1 (0.87843,0.40000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#E066FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumOrchid2 (0.81961,0.37255,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#D15FEE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumOrchid3 (0.70588,0.32157,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#B452CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumOrchid4 (0.47843,0.21569,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#7A378B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumPurple (0.57647,0.43922,0.85882); /// \htmlonly <table><tr><td width="300" bgcolor="#9370DB"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumPurple1 (0.67059,0.50980,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#AB82FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumPurple2 (0.62353,0.47451,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#9F79EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumPurple3 (0.53725,0.40784,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#8968CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumPurple4 (0.36471,0.27843,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#5D478B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumSeaGreen (0.23529,0.70196,0.44314); /// \htmlonly <table><tr><td width="300" bgcolor="#3CB371"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumSlateBlue (0.48235,0.40784,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#7B68EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumSpringGreen (0.00000,0.98039,0.60392); /// \htmlonly <table><tr><td width="300" bgcolor="#00FA9A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumTurquoise (0.28235,0.81961,0.80000); /// \htmlonly <table><tr><td width="300" bgcolor="#48D1CC"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mediumVioletRed (0.78039,0.08235,0.52157); /// \htmlonly <table><tr><td width="300" bgcolor="#C71585"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::midnightBlue (0.09804,0.09804,0.43922); /// \htmlonly <table><tr><td width="300" bgcolor="#191970"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mintCream (0.96078,1.00000,0.98039); /// \htmlonly <table><tr><td width="300" bgcolor="#F5FFFA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mistyRose (1.00000,0.89412,0.88235); /// \htmlonly <table><tr><td width="300" bgcolor="#FFE4E1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mistyRose1 (1.00000,0.89412,0.88235); /// \htmlonly <table><tr><td width="300" bgcolor="#FFE4E1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mistyRose2 (0.93333,0.83529,0.82353); /// \htmlonly <table><tr><td width="300" bgcolor="#EED5D2"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mistyRose3 (0.80392,0.71765,0.70980); /// \htmlonly <table><tr><td width="300" bgcolor="#CDB7B5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::mistyRose4 (0.54510,0.49020,0.48235); /// \htmlonly <table><tr><td width="300" bgcolor="#8B7D7B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::moccasin (1.00000,0.89412,0.70980); /// \htmlonly <table><tr><td width="300" bgcolor="#FFE4B5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::navajoWhite (1.00000,0.87059,0.67843); /// \htmlonly <table><tr><td width="300" bgcolor="#FFDEAD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::navajoWhite1 (1.00000,0.87059,0.67843); /// \htmlonly <table><tr><td width="300" bgcolor="#FFDEAD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::navajoWhite2 (0.93333,0.81176,0.63137); /// \htmlonly <table><tr><td width="300" bgcolor="#EECFA1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::navajoWhite3 (0.80392,0.70196,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#CDB38B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::navajoWhite4 (0.54510,0.47451,0.36863); /// \htmlonly <table><tr><td width="300" bgcolor="#8B795E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::navy (0.00000,0.00000,0.50196); /// \htmlonly <table><tr><td width="300" bgcolor="#000080"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::navyBlue (0.00000,0.00000,0.50196); /// \htmlonly <table><tr><td width="300" bgcolor="#000080"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::oldLace (0.99216,0.96078,0.90196); /// \htmlonly <table><tr><td width="300" bgcolor="#FDF5E6"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::oliveDrab (0.41961,0.55686,0.13725); /// \htmlonly <table><tr><td width="300" bgcolor="#6B8E23"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::oliveDrab1 (0.75294,1.00000,0.24314); /// \htmlonly <table><tr><td width="300" bgcolor="#C0FF3E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::oliveDrab2 (0.70196,0.93333,0.22745); /// \htmlonly <table><tr><td width="300" bgcolor="#B3EE3A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::oliveDrab3 (0.60392,0.80392,0.19608); /// \htmlonly <table><tr><td width="300" bgcolor="#9ACD32"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::oliveDrab4 (0.41176,0.54510,0.13333); /// \htmlonly <table><tr><td width="300" bgcolor="#698B22"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orange (1.00000,0.64706,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FFA500"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orange1 (1.00000,0.64706,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FFA500"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orange2 (0.93333,0.60392,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#EE9A00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orange3 (0.80392,0.52157,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#CD8500"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orange4 (0.54510,0.35294,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#8B5A00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orangeRed (1.00000,0.27059,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FF4500"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orangeRed1 (1.00000,0.27059,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FF4500"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orangeRed2 (0.93333,0.25098,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#EE4000"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orangeRed3 (0.80392,0.21569,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#CD3700"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orangeRed4 (0.54510,0.14510,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#8B2500"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orchid (0.85490,0.43922,0.83922); /// \htmlonly <table><tr><td width="300" bgcolor="#DA70D6"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orchid1 (1.00000,0.51373,0.98039); /// \htmlonly <table><tr><td width="300" bgcolor="#FF83FA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orchid2 (0.93333,0.47843,0.91373); /// \htmlonly <table><tr><td width="300" bgcolor="#EE7AE9"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orchid3 (0.80392,0.41176,0.78824); /// \htmlonly <table><tr><td width="300" bgcolor="#CD69C9"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::orchid4 (0.54510,0.27843,0.53725); /// \htmlonly <table><tr><td width="300" bgcolor="#8B4789"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleGoldenrod (0.93333,0.90980,0.66667); /// \htmlonly <table><tr><td width="300" bgcolor="#EEE8AA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleGreen (0.59608,0.98431,0.59608); /// \htmlonly <table><tr><td width="300" bgcolor="#98FB98"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleGreen1 (0.60392,1.00000,0.60392); /// \htmlonly <table><tr><td width="300" bgcolor="#9AFF9A"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleGreen2 (0.56471,0.93333,0.56471); /// \htmlonly <table><tr><td width="300" bgcolor="#90EE90"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleGreen3 (0.48627,0.80392,0.48627); /// \htmlonly <table><tr><td width="300" bgcolor="#7CCD7C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleGreen4 (0.32941,0.54510,0.32941); /// \htmlonly <table><tr><td width="300" bgcolor="#548B54"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleTurquoise (0.68627,0.93333,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#AFEEEE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleTurquoise1 (0.73333,1.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#BBFFFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleTurquoise2 (0.68235,0.93333,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#AEEEEE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleTurquoise3 (0.58824,0.80392,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#96CDCD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleTurquoise4 (0.40000,0.54510,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#668B8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleVioletRed (0.85882,0.43922,0.57647); /// \htmlonly <table><tr><td width="300" bgcolor="#DB7093"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleVioletRed1 (1.00000,0.50980,0.67059); /// \htmlonly <table><tr><td width="300" bgcolor="#FF82AB"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleVioletRed2 (0.93333,0.47451,0.62353); /// \htmlonly <table><tr><td width="300" bgcolor="#EE799F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleVioletRed3 (0.80392,0.40784,0.53725); /// \htmlonly <table><tr><td width="300" bgcolor="#CD6889"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::paleVioletRed4 (0.54510,0.27843,0.36471); /// \htmlonly <table><tr><td width="300" bgcolor="#8B475D"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::papayaWhip (1.00000,0.93725,0.83529); /// \htmlonly <table><tr><td width="300" bgcolor="#FFEFD5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::peachPuff (1.00000,0.85490,0.72549); /// \htmlonly <table><tr><td width="300" bgcolor="#FFDAB9"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::peachPuff1 (1.00000,0.85490,0.72549); /// \htmlonly <table><tr><td width="300" bgcolor="#FFDAB9"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::peachPuff2 (0.93333,0.79608,0.67843); /// \htmlonly <table><tr><td width="300" bgcolor="#EECBAD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::peachPuff3 (0.80392,0.68627,0.58431); /// \htmlonly <table><tr><td width="300" bgcolor="#CDAF95"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::peachPuff4 (0.54510,0.46667,0.39608); /// \htmlonly <table><tr><td width="300" bgcolor="#8B7765"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::peru (0.80392,0.52157,0.24706); /// \htmlonly <table><tr><td width="300" bgcolor="#CD853F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::pink (1.00000,0.75294,0.79608); /// \htmlonly <table><tr><td width="300" bgcolor="#FFC0CB"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::pink1 (1.00000,0.70980,0.77255); /// \htmlonly <table><tr><td width="300" bgcolor="#FFB5C5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::pink2 (0.93333,0.66275,0.72157); /// \htmlonly <table><tr><td width="300" bgcolor="#EEA9B8"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::pink3 (0.80392,0.56863,0.61961); /// \htmlonly <table><tr><td width="300" bgcolor="#CD919E"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::pink4 (0.54510,0.38824,0.42353); /// \htmlonly <table><tr><td width="300" bgcolor="#8B636C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::plum (0.86667,0.62745,0.86667); /// \htmlonly <table><tr><td width="300" bgcolor="#DDA0DD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::plum1 (1.00000,0.73333,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FFBBFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::plum2 (0.93333,0.68235,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#EEAEEE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::plum3 (0.80392,0.58824,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#CD96CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::plum4 (0.54510,0.40000,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#8B668B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::powderBlue (0.69020,0.87843,0.90196); /// \htmlonly <table><tr><td width="300" bgcolor="#B0E0E6"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::purple (0.62745,0.12549,0.94118); /// \htmlonly <table><tr><td width="300" bgcolor="#A020F0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::purple1 (0.60784,0.18824,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#9B30FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::purple2 (0.56863,0.17255,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#912CEE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::purple3 (0.49020,0.14902,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#7D26CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::purple4 (0.33333,0.10196,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#551A8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::red (1.00000,0.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FF0000"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::red1 (1.00000,0.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FF0000"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::red2 (0.93333,0.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#EE0000"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::red3 (0.80392,0.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#CD0000"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::red4 (0.54510,0.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#8B0000"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::rosyBrown (0.73725,0.56078,0.56078); /// \htmlonly <table><tr><td width="300" bgcolor="#BC8F8F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::rosyBrown1 (1.00000,0.75686,0.75686); /// \htmlonly <table><tr><td width="300" bgcolor="#FFC1C1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::rosyBrown2 (0.93333,0.70588,0.70588); /// \htmlonly <table><tr><td width="300" bgcolor="#EEB4B4"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::rosyBrown3 (0.80392,0.60784,0.60784); /// \htmlonly <table><tr><td width="300" bgcolor="#CD9B9B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::rosyBrown4 (0.54510,0.41176,0.41176); /// \htmlonly <table><tr><td width="300" bgcolor="#8B6969"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::royalBlue (0.25490,0.41176,0.88235); /// \htmlonly <table><tr><td width="300" bgcolor="#4169E1"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::royalBlue1 (0.28235,0.46275,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#4876FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::royalBlue2 (0.26275,0.43137,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#436EEE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::royalBlue3 (0.22745,0.37255,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#3A5FCD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::royalBlue4 (0.15294,0.25098,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#27408B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::saddleBrown (0.54510,0.27059,0.07451); /// \htmlonly <table><tr><td width="300" bgcolor="#8B4513"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::salmon (0.98039,0.50196,0.44706); /// \htmlonly <table><tr><td width="300" bgcolor="#FA8072"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::salmon1 (1.00000,0.54902,0.41176); /// \htmlonly <table><tr><td width="300" bgcolor="#FF8C69"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::salmon2 (0.93333,0.50980,0.38431); /// \htmlonly <table><tr><td width="300" bgcolor="#EE8262"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::salmon3 (0.80392,0.43922,0.32941); /// \htmlonly <table><tr><td width="300" bgcolor="#CD7054"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::salmon4 (0.54510,0.29804,0.22353); /// \htmlonly <table><tr><td width="300" bgcolor="#8B4C39"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::sandyBrown (0.95686,0.64314,0.37647); /// \htmlonly <table><tr><td width="300" bgcolor="#F4A460"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::seaGreen (0.18039,0.54510,0.34118); /// \htmlonly <table><tr><td width="300" bgcolor="#2E8B57"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::seaGreen1 (0.32941,1.00000,0.62353); /// \htmlonly <table><tr><td width="300" bgcolor="#54FF9F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::seaGreen2 (0.30588,0.93333,0.58039); /// \htmlonly <table><tr><td width="300" bgcolor="#4EEE94"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::seaGreen3 (0.26275,0.80392,0.50196); /// \htmlonly <table><tr><td width="300" bgcolor="#43CD80"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::seaGreen4 (0.18039,0.54510,0.34118); /// \htmlonly <table><tr><td width="300" bgcolor="#2E8B57"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::seashell (1.00000,0.96078,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#FFF5EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::seashell1 (1.00000,0.96078,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#FFF5EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::seashell2 (0.93333,0.89804,0.87059); /// \htmlonly <table><tr><td width="300" bgcolor="#EEE5DE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::seashell3 (0.80392,0.77255,0.74902); /// \htmlonly <table><tr><td width="300" bgcolor="#CDC5BF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::seashell4 (0.54510,0.52549,0.50980); /// \htmlonly <table><tr><td width="300" bgcolor="#8B8682"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::sienna (0.62745,0.32157,0.17647); /// \htmlonly <table><tr><td width="300" bgcolor="#A0522D"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::sienna1 (1.00000,0.50980,0.27843); /// \htmlonly <table><tr><td width="300" bgcolor="#FF8247"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::sienna2 (0.93333,0.47451,0.25882); /// \htmlonly <table><tr><td width="300" bgcolor="#EE7942"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::sienna3 (0.80392,0.40784,0.22353); /// \htmlonly <table><tr><td width="300" bgcolor="#CD6839"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::sienna4 (0.54510,0.27843,0.14902); /// \htmlonly <table><tr><td width="300" bgcolor="#8B4726"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::skyBlue (0.52941,0.80784,0.92157); /// \htmlonly <table><tr><td width="300" bgcolor="#87CEEB"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::skyBlue1 (0.52941,0.80784,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#87CEFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::skyBlue2 (0.49412,0.75294,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#7EC0EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::skyBlue3 (0.42353,0.65098,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#6CA6CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::skyBlue4 (0.29020,0.43922,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#4A708B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::slateBlue (0.41569,0.35294,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#6A5ACD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::slateBlue1 (0.51373,0.43529,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#836FFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::slateBlue2 (0.47843,0.40392,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#7A67EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::slateBlue3 (0.41176,0.34902,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#6959CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::slateBlue4 (0.27843,0.23529,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#473C8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::slateGray (0.43922,0.50196,0.56471); /// \htmlonly <table><tr><td width="300" bgcolor="#708090"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::slateGray1 (0.77647,0.88627,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#C6E2FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::slateGray2 (0.72549,0.82745,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#B9D3EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::slateGray3 (0.62353,0.71373,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#9FB6CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::slateGray4 (0.42353,0.48235,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#6C7B8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::slateGrey (0.43922,0.50196,0.56471); /// \htmlonly <table><tr><td width="300" bgcolor="#708090"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::snow (1.00000,0.98039,0.98039); /// \htmlonly <table><tr><td width="300" bgcolor="#FFFAFA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::snow1 (1.00000,0.98039,0.98039); /// \htmlonly <table><tr><td width="300" bgcolor="#FFFAFA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::snow2 (0.93333,0.91373,0.91373); /// \htmlonly <table><tr><td width="300" bgcolor="#EEE9E9"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::snow3 (0.80392,0.78824,0.78824); /// \htmlonly <table><tr><td width="300" bgcolor="#CDC9C9"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::snow4 (0.54510,0.53725,0.53725); /// \htmlonly <table><tr><td width="300" bgcolor="#8B8989"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::springGreen (0.00000,1.00000,0.49804); /// \htmlonly <table><tr><td width="300" bgcolor="#00FF7F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::springGreen1 (0.00000,1.00000,0.49804); /// \htmlonly <table><tr><td width="300" bgcolor="#00FF7F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::springGreen2 (0.00000,0.93333,0.46275); /// \htmlonly <table><tr><td width="300" bgcolor="#00EE76"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::springGreen3 (0.00000,0.80392,0.40000); /// \htmlonly <table><tr><td width="300" bgcolor="#00CD66"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::springGreen4 (0.00000,0.54510,0.27059); /// \htmlonly <table><tr><td width="300" bgcolor="#008B45"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::steelBlue (0.27451,0.50980,0.70588); /// \htmlonly <table><tr><td width="300" bgcolor="#4682B4"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::steelBlue1 (0.38824,0.72157,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#63B8FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::steelBlue2 (0.36078,0.67451,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#5CACEE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::steelBlue3 (0.30980,0.58039,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#4F94CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::steelBlue4 (0.21176,0.39216,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#36648B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::tan1 (1.00000,0.64706,0.30980); /// \htmlonly <table><tr><td width="300" bgcolor="#FFA54F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::tan2 (0.93333,0.60392,0.28627); /// \htmlonly <table><tr><td width="300" bgcolor="#EE9A49"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::tan3 (0.80392,0.52157,0.24706); /// \htmlonly <table><tr><td width="300" bgcolor="#CD853F"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::tan4 (0.54510,0.35294,0.16863); /// \htmlonly <table><tr><td width="300" bgcolor="#8B5A2B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::thistle (0.84706,0.74902,0.84706); /// \htmlonly <table><tr><td width="300" bgcolor="#D8BFD8"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::thistle1 (1.00000,0.88235,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FFE1FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::thistle2 (0.93333,0.82353,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#EED2EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::thistle3 (0.80392,0.70980,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#CDB5CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::thistle4 (0.54510,0.48235,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#8B7B8B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::tomato (1.00000,0.38824,0.27843); /// \htmlonly <table><tr><td width="300" bgcolor="#FF6347"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::tomato1 (1.00000,0.38824,0.27843); /// \htmlonly <table><tr><td width="300" bgcolor="#FF6347"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::tomato2 (0.93333,0.36078,0.25882); /// \htmlonly <table><tr><td width="300" bgcolor="#EE5C42"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::tomato3 (0.80392,0.30980,0.22353); /// \htmlonly <table><tr><td width="300" bgcolor="#CD4F39"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::tomato4 (0.54510,0.21176,0.14902); /// \htmlonly <table><tr><td width="300" bgcolor="#8B3626"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::turquoise (0.25098,0.87843,0.81569); /// \htmlonly <table><tr><td width="300" bgcolor="#40E0D0"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::turquoise1 (0.00000,0.96078,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#00F5FF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::turquoise2 (0.00000,0.89804,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#00E5EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::turquoise3 (0.00000,0.77255,0.80392); /// \htmlonly <table><tr><td width="300" bgcolor="#00C5CD"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::turquoise4 (0.00000,0.52549,0.54510); /// \htmlonly <table><tr><td width="300" bgcolor="#00868B"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::violet (0.93333,0.50980,0.93333); /// \htmlonly <table><tr><td width="300" bgcolor="#EE82EE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::violetRed (0.81569,0.12549,0.56471); /// \htmlonly <table><tr><td width="300" bgcolor="#D02090"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::violetRed1 (1.00000,0.24314,0.58824); /// \htmlonly <table><tr><td width="300" bgcolor="#FF3E96"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::violetRed2 (0.93333,0.22745,0.54902); /// \htmlonly <table><tr><td width="300" bgcolor="#EE3A8C"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::violetRed3 (0.80392,0.19608,0.47059); /// \htmlonly <table><tr><td width="300" bgcolor="#CD3278"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::violetRed4 (0.54510,0.13333,0.32157); /// \htmlonly <table><tr><td width="300" bgcolor="#8B2252"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::wheat (0.96078,0.87059,0.70196); /// \htmlonly <table><tr><td width="300" bgcolor="#F5DEB3"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::wheat1 (1.00000,0.90588,0.72941); /// \htmlonly <table><tr><td width="300" bgcolor="#FFE7BA"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::wheat2 (0.93333,0.84706,0.68235); /// \htmlonly <table><tr><td width="300" bgcolor="#EED8AE"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::wheat3 (0.80392,0.72941,0.58824); /// \htmlonly <table><tr><td width="300" bgcolor="#CDBA96"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::wheat4 (0.54510,0.49412,0.40000); /// \htmlonly <table><tr><td width="300" bgcolor="#8B7E66"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::white (1.00000,1.00000,1.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FFFFFF"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::whiteSmoke (0.96078,0.96078,0.96078); /// \htmlonly <table><tr><td width="300" bgcolor="#F5F5F5"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::yellow (1.00000,1.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FFFF00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::yellow1 (1.00000,1.00000,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#FFFF00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::yellow2 (0.93333,0.93333,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#EEEE00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::yellow3 (0.80392,0.80392,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#CDCD00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::yellow4 (0.54510,0.54510,0.00000); /// \htmlonly <table><tr><td width="300" bgcolor="#8B8B00"> </td></tr></table> \endhtmlonly
const Colorf ColorDefine::yellowGreen (0.60392,0.80392,0.19608); /// \htmlonly <table><tr><td width="300" bgcolor="#9ACD32"> </td></tr></table> \endhtmlonly
const char *ColorDefine::Name[] =
{
"aliceBlue",
"antiqueWhite",
"antiqueWhite1",
"antiqueWhite2",
"antiqueWhite3",
"antiqueWhite4",
"aquamarine",
"aquamarine1",
"aquamarine2",
"aquamarine3",
"aquamarine4",
"azure",
"azure1",
"azure2",
"azure3",
"azure4",
"beige",
"bisque",
"bisque1",
"bisque2",
"bisque3",
"bisque4",
"black",
"blanchedAlmond",
"blue",
"blue1",
"blue2",
"blue3",
"blue4",
"blueViolet",
"brown",
"brown1",
"brown2",
"brown3",
"brown4",
"burlywood",
"burlywood1",
"burlywood2",
"burlywood3",
"burlywood4",
"cadetBlue",
"cadetBlue1",
"cadetBlue2",
"cadetBlue3",
"cadetBlue4",
"chartreuse",
"chartreuse1",
"chartreuse2",
"chartreuse3",
"chartreuse4",
"chocolate",
"chocolate1",
"chocolate2",
"chocolate3",
"chocolate4",
"coral",
"coral1",
"coral2",
"coral3",
"coral4",
"cornflowerBlue",
"cornsilk",
"cornsilk1",
"cornsilk2",
"cornsilk3",
"cornsilk4",
"cyan",
"cyan1",
"cyan2",
"cyan3",
"cyan4",
"darkBlue",
"darkCyan",
"darkGoldenrod",
"darkGoldenrod1",
"darkGoldenrod2",
"darkGoldenrod3",
"darkGoldenrod4",
"darkGray",
"darkGreen",
"darkGrey",
"darkKhaki",
"darkMagenta",
"darkOliveGreen",
"darkOliveGreen1",
"darkOliveGreen2",
"darkOliveGreen3",
"darkOliveGreen4",
"darkOrange",
"darkOrange1",
"darkOrange2",
"darkOrange3",
"darkOrange4",
"darkOrchid",
"darkOrchid1",
"darkOrchid2",
"darkOrchid3",
"darkOrchid4",
"darkRed",
"darkSalmon",
"darkSeaGreen",
"darkSeaGreen1",
"darkSeaGreen2",
"darkSeaGreen3",
"darkSeaGreen4",
"darkSlateBlue",
"darkSlateGray",
"darkSlateGray1",
"darkSlateGray2",
"darkSlateGray3",
"darkSlateGray4",
"darkSlateGrey",
"darkTurquoise",
"darkViolet",
"deepPink",
"deepPink1",
"deepPink2",
"deepPink3",
"deepPink4",
"deepSkyBlue",
"deepSkyBlue1",
"deepSkyBlue2",
"deepSkyBlue3",
"deepSkyBlue4",
"dimGray",
"dimGrey",
"dodgerBlue",
"dodgerBlue1",
"dodgerBlue2",
"dodgerBlue3",
"dodgerBlue4",
"firebrick",
"firebrick1",
"firebrick2",
"firebrick3",
"firebrick4",
"floralWhite",
"forestGreen",
"gainsboro",
"ghostWhite",
"gold",
"gold1",
"gold2",
"gold3",
"gold4",
"goldenrod",
"goldenrod1",
"goldenrod2",
"goldenrod3",
"goldenrod4",
"gray",
"gray0",
"gray1",
"gray10",
"gray100",
"gray11",
"gray12",
"gray13",
"gray14",
"gray15",
"gray16",
"gray17",
"gray18",
"gray19",
"gray2",
"gray20",
"gray21",
"gray22",
"gray23",
"gray24",
"gray25",
"gray26",
"gray27",
"gray28",
"gray29",
"gray3",
"gray30",
"gray31",
"gray32",
"gray33",
"gray34",
"gray35",
"gray36",
"gray37",
"gray38",
"gray39",
"gray4",
"gray40",
"gray41",
"gray42",
"gray43",
"gray44",
"gray45",
"gray46",
"gray47",
"gray48",
"gray49",
"gray5",
"gray50",
"gray51",
"gray52",
"gray53",
"gray54",
"gray55",
"gray56",
"gray57",
"gray58",
"gray59",
"gray6",
"gray60",
"gray61",
"gray62",
"gray63",
"gray64",
"gray65",
"gray66",
"gray67",
"gray68",
"gray69",
"gray7",
"gray70",
"gray71",
"gray72",
"gray73",
"gray74",
"gray75",
"gray76",
"gray77",
"gray78",
"gray79",
"gray8",
"gray80",
"gray81",
"gray82",
"gray83",
"gray84",
"gray85",
"gray86",
"gray87",
"gray88",
"gray89",
"gray9",
"gray90",
"gray91",
"gray92",
"gray93",
"gray94",
"gray95",
"gray96",
"gray97",
"gray98",
"gray99",
"green",
"green1",
"green2",
"green3",
"green4",
"greenYellow",
"grey",
"grey0",
"grey1",
"grey10",
"grey100",
"grey11",
"grey12",
"grey13",
"grey14",
"grey15",
"grey16",
"grey17",
"grey18",
"grey19",
"grey2",
"grey20",
"grey21",
"grey22",
"grey23",
"grey24",
"grey25",
"grey26",
"grey27",
"grey28",
"grey29",
"grey3",
"grey30",
"grey31",
"grey32",
"grey33",
"grey34",
"grey35",
"grey36",
"grey37",
"grey38",
"grey39",
"grey4",
"grey40",
"grey41",
"grey42",
"grey43",
"grey44",
"grey45",
"grey46",
"grey47",
"grey48",
"grey49",
"grey5",
"grey50",
"grey51",
"grey52",
"grey53",
"grey54",
"grey55",
"grey56",
"grey57",
"grey58",
"grey59",
"grey6",
"grey60",
"grey61",
"grey62",
"grey63",
"grey64",
"grey65",
"grey66",
"grey67",
"grey68",
"grey69",
"grey7",
"grey70",
"grey71",
"grey72",
"grey73",
"grey74",
"grey75",
"grey76",
"grey77",
"grey78",
"grey79",
"grey8",
"grey80",
"grey81",
"grey82",
"grey83",
"grey84",
"grey85",
"grey86",
"grey87",
"grey88",
"grey89",
"grey9",
"grey90",
"grey91",
"grey92",
"grey93",
"grey94",
"grey95",
"grey96",
"grey97",
"grey98",
"grey99",
"honeydew",
"honeydew1",
"honeydew2",
"honeydew3",
"honeydew4",
"hotPink",
"hotPink1",
"hotPink2",
"hotPink3",
"hotPink4",
"indianRed",
"indianRed1",
"indianRed2",
"indianRed3",
"indianRed4",
"ivory",
"ivory1",
"ivory2",
"ivory3",
"ivory4",
"khaki",
"khaki1",
"khaki2",
"khaki3",
"khaki4",
"lavender",
"lavenderBlush",
"lavenderBlush1",
"lavenderBlush2",
"lavenderBlush3",
"lavenderBlush4",
"lawnGreen",
"lemonChiffon",
"lemonChiffon1",
"lemonChiffon2",
"lemonChiffon3",
"lemonChiffon4",
"lightBlue",
"lightBlue1",
"lightBlue2",
"lightBlue3",
"lightBlue4",
"lightCoral",
"lightCyan",
"lightCyan1",
"lightCyan2",
"lightCyan3",
"lightCyan4",
"lightGoldenrod",
"lightGoldenrod1",
"lightGoldenrod2",
"lightGoldenrod3",
"lightGoldenrod4",
"lightGoldenrodYellow",
"lightGray",
"lightGreen",
"lightGrey",
"lightPink",
"lightPink1",
"lightPink2",
"lightPink3",
"lightPink4",
"lightSalmon",
"lightSalmon1",
"lightSalmon2",
"lightSalmon3",
"lightSalmon4",
"lightSeaGreen",
"lightSkyBlue",
"lightSkyBlue1",
"lightSkyBlue2",
"lightSkyBlue3",
"lightSkyBlue4",
"lightSlateBlue",
"lightSlateGray",
"lightSlateGrey",
"lightSteelBlue",
"lightSteelBlue1",
"lightSteelBlue2",
"lightSteelBlue3",
"lightSteelBlue4",
"lightYellow",
"lightYellow1",
"lightYellow2",
"lightYellow3",
"lightYellow4",
"limeGreen",
"linen",
"magenta",
"magenta1",
"magenta2",
"magenta3",
"magenta4",
"maroon",
"maroon1",
"maroon2",
"maroon3",
"maroon4",
"mediumAquamarine",
"mediumBlue",
"mediumOrchid",
"mediumOrchid1",
"mediumOrchid2",
"mediumOrchid3",
"mediumOrchid4",
"mediumPurple",
"mediumPurple1",
"mediumPurple2",
"mediumPurple3",
"mediumPurple4",
"mediumSeaGreen",
"mediumSlateBlue",
"mediumSpringGreen",
"mediumTurquoise",
"mediumVioletRed",
"midnightBlue",
"mintCream",
"mistyRose",
"mistyRose1",
"mistyRose2",
"mistyRose3",
"mistyRose4",
"moccasin",
"navajoWhite",
"navajoWhite1",
"navajoWhite2",
"navajoWhite3",
"navajoWhite4",
"navy",
"navyBlue",
"oldLace",
"oliveDrab",
"oliveDrab1",
"oliveDrab2",
"oliveDrab3",
"oliveDrab4",
"orange",
"orange1",
"orange2",
"orange3",
"orange4",
"orangeRed",
"orangeRed1",
"orangeRed2",
"orangeRed3",
"orangeRed4",
"orchid",
"orchid1",
"orchid2",
"orchid3",
"orchid4",
"paleGoldenrod",
"paleGreen",
"paleGreen1",
"paleGreen2",
"paleGreen3",
"paleGreen4",
"paleTurquoise",
"paleTurquoise1",
"paleTurquoise2",
"paleTurquoise3",
"paleTurquoise4",
"paleVioletRed",
"paleVioletRed1",
"paleVioletRed2",
"paleVioletRed3",
"paleVioletRed4",
"papayaWhip",
"peachPuff",
"peachPuff1",
"peachPuff2",
"peachPuff3",
"peachPuff4",
"peru",
"pink",
"pink1",
"pink2",
"pink3",
"pink4",
"plum",
"plum1",
"plum2",
"plum3",
"plum4",
"powderBlue",
"purple",
"purple1",
"purple2",
"purple3",
"purple4",
"red",
"red1",
"red2",
"red3",
"red4",
"rosyBrown",
"rosyBrown1",
"rosyBrown2",
"rosyBrown3",
"rosyBrown4",
"royalBlue",
"royalBlue1",
"royalBlue2",
"royalBlue3",
"royalBlue4",
"saddleBrown",
"salmon",
"salmon1",
"salmon2",
"salmon3",
"salmon4",
"sandyBrown",
"seaGreen",
"seaGreen1",
"seaGreen2",
"seaGreen3",
"seaGreen4",
"seashell",
"seashell1",
"seashell2",
"seashell3",
"seashell4",
"sienna",
"sienna1",
"sienna2",
"sienna3",
"sienna4",
"skyBlue",
"skyBlue1",
"skyBlue2",
"skyBlue3",
"skyBlue4",
"slateBlue",
"slateBlue1",
"slateBlue2",
"slateBlue3",
"slateBlue4",
"slateGray",
"slateGray1",
"slateGray2",
"slateGray3",
"slateGray4",
"slateGrey",
"snow",
"snow1",
"snow2",
"snow3",
"snow4",
"springGreen",
"springGreen1",
"springGreen2",
"springGreen3",
"springGreen4",
"steelBlue",
"steelBlue1",
"steelBlue2",
"steelBlue3",
"steelBlue4",
"tan1",
"tan2",
"tan3",
"tan4",
"thistle",
"thistle1",
"thistle2",
"thistle3",
"thistle4",
"tomato",
"tomato1",
"tomato2",
"tomato3",
"tomato4",
"turquoise",
"turquoise1",
"turquoise2",
"turquoise3",
"turquoise4",
"violet",
"violetRed",
"violetRed1",
"violetRed2",
"violetRed3",
"violetRed4",
"wheat",
"wheat1",
"wheat2",
"wheat3",
"wheat4",
"white",
"whiteSmoke",
"yellow",
"yellow1",
"yellow2",
"yellow3",
"yellow4",
"yellowGreen"
};
const Colorf* ColorDefine::Value[] =
{
&ColorDefine::aliceBlue,
&ColorDefine::antiqueWhite,
&ColorDefine::antiqueWhite1,
&ColorDefine::antiqueWhite2,
&ColorDefine::antiqueWhite3,
&ColorDefine::antiqueWhite4,
&ColorDefine::aquamarine,
&ColorDefine::aquamarine1,
&ColorDefine::aquamarine2,
&ColorDefine::aquamarine3,
&ColorDefine::aquamarine4,
&ColorDefine::azure,
&ColorDefine::azure1,
&ColorDefine::azure2,
&ColorDefine::azure3,
&ColorDefine::azure4,
&ColorDefine::beige,
&ColorDefine::bisque,
&ColorDefine::bisque1,
&ColorDefine::bisque2,
&ColorDefine::bisque3,
&ColorDefine::bisque4,
&ColorDefine::black,
&ColorDefine::blanchedAlmond,
&ColorDefine::blue,
&ColorDefine::blue1,
&ColorDefine::blue2,
&ColorDefine::blue3,
&ColorDefine::blue4,
&ColorDefine::blueViolet,
&ColorDefine::brown,
&ColorDefine::brown1,
&ColorDefine::brown2,
&ColorDefine::brown3,
&ColorDefine::brown4,
&ColorDefine::burlywood,
&ColorDefine::burlywood1,
&ColorDefine::burlywood2,
&ColorDefine::burlywood3,
&ColorDefine::burlywood4,
&ColorDefine::cadetBlue,
&ColorDefine::cadetBlue1,
&ColorDefine::cadetBlue2,
&ColorDefine::cadetBlue3,
&ColorDefine::cadetBlue4,
&ColorDefine::chartreuse,
&ColorDefine::chartreuse1,
&ColorDefine::chartreuse2,
&ColorDefine::chartreuse3,
&ColorDefine::chartreuse4,
&ColorDefine::chocolate,
&ColorDefine::chocolate1,
&ColorDefine::chocolate2,
&ColorDefine::chocolate3,
&ColorDefine::chocolate4,
&ColorDefine::coral,
&ColorDefine::coral1,
&ColorDefine::coral2,
&ColorDefine::coral3,
&ColorDefine::coral4,
&ColorDefine::cornflowerBlue,
&ColorDefine::cornsilk,
&ColorDefine::cornsilk1,
&ColorDefine::cornsilk2,
&ColorDefine::cornsilk3,
&ColorDefine::cornsilk4,
&ColorDefine::cyan,
&ColorDefine::cyan1,
&ColorDefine::cyan2,
&ColorDefine::cyan3,
&ColorDefine::cyan4,
&ColorDefine::darkBlue,
&ColorDefine::darkCyan,
&ColorDefine::darkGoldenrod,
&ColorDefine::darkGoldenrod1,
&ColorDefine::darkGoldenrod2,
&ColorDefine::darkGoldenrod3,
&ColorDefine::darkGoldenrod4,
&ColorDefine::darkGray,
&ColorDefine::darkGreen,
&ColorDefine::darkGrey,
&ColorDefine::darkKhaki,
&ColorDefine::darkMagenta,
&ColorDefine::darkOliveGreen,
&ColorDefine::darkOliveGreen1,
&ColorDefine::darkOliveGreen2,
&ColorDefine::darkOliveGreen3,
&ColorDefine::darkOliveGreen4,
&ColorDefine::darkOrange,
&ColorDefine::darkOrange1,
&ColorDefine::darkOrange2,
&ColorDefine::darkOrange3,
&ColorDefine::darkOrange4,
&ColorDefine::darkOrchid,
&ColorDefine::darkOrchid1,
&ColorDefine::darkOrchid2,
&ColorDefine::darkOrchid3,
&ColorDefine::darkOrchid4,
&ColorDefine::darkRed,
&ColorDefine::darkSalmon,
&ColorDefine::darkSeaGreen,
&ColorDefine::darkSeaGreen1,
&ColorDefine::darkSeaGreen2,
&ColorDefine::darkSeaGreen3,
&ColorDefine::darkSeaGreen4,
&ColorDefine::darkSlateBlue,
&ColorDefine::darkSlateGray,
&ColorDefine::darkSlateGray1,
&ColorDefine::darkSlateGray2,
&ColorDefine::darkSlateGray3,
&ColorDefine::darkSlateGray4,
&ColorDefine::darkSlateGrey,
&ColorDefine::darkTurquoise,
&ColorDefine::darkViolet,
&ColorDefine::deepPink,
&ColorDefine::deepPink1,
&ColorDefine::deepPink2,
&ColorDefine::deepPink3,
&ColorDefine::deepPink4,
&ColorDefine::deepSkyBlue,
&ColorDefine::deepSkyBlue1,
&ColorDefine::deepSkyBlue2,
&ColorDefine::deepSkyBlue3,
&ColorDefine::deepSkyBlue4,
&ColorDefine::dimGray,
&ColorDefine::dimGrey,
&ColorDefine::dodgerBlue,
&ColorDefine::dodgerBlue1,
&ColorDefine::dodgerBlue2,
&ColorDefine::dodgerBlue3,
&ColorDefine::dodgerBlue4,
&ColorDefine::firebrick,
&ColorDefine::firebrick1,
&ColorDefine::firebrick2,
&ColorDefine::firebrick3,
&ColorDefine::firebrick4,
&ColorDefine::floralWhite,
&ColorDefine::forestGreen,
&ColorDefine::gainsboro,
&ColorDefine::ghostWhite,
&ColorDefine::gold,
&ColorDefine::gold1,
&ColorDefine::gold2,
&ColorDefine::gold3,
&ColorDefine::gold4,
&ColorDefine::goldenrod,
&ColorDefine::goldenrod1,
&ColorDefine::goldenrod2,
&ColorDefine::goldenrod3,
&ColorDefine::goldenrod4,
&ColorDefine::gray,
&ColorDefine::gray0,
&ColorDefine::gray1,
&ColorDefine::gray10,
&ColorDefine::gray100,
&ColorDefine::gray11,
&ColorDefine::gray12,
&ColorDefine::gray13,
&ColorDefine::gray14,
&ColorDefine::gray15,
&ColorDefine::gray16,
&ColorDefine::gray17,
&ColorDefine::gray18,
&ColorDefine::gray19,
&ColorDefine::gray2,
&ColorDefine::gray20,
&ColorDefine::gray21,
&ColorDefine::gray22,
&ColorDefine::gray23,
&ColorDefine::gray24,
&ColorDefine::gray25,
&ColorDefine::gray26,
&ColorDefine::gray27,
&ColorDefine::gray28,
&ColorDefine::gray29,
&ColorDefine::gray3,
&ColorDefine::gray30,
&ColorDefine::gray31,
&ColorDefine::gray32,
&ColorDefine::gray33,
&ColorDefine::gray34,
&ColorDefine::gray35,
&ColorDefine::gray36,
&ColorDefine::gray37,
&ColorDefine::gray38,
&ColorDefine::gray39,
&ColorDefine::gray4,
&ColorDefine::gray40,
&ColorDefine::gray41,
&ColorDefine::gray42,
&ColorDefine::gray43,
&ColorDefine::gray44,
&ColorDefine::gray45,
&ColorDefine::gray46,
&ColorDefine::gray47,
&ColorDefine::gray48,
&ColorDefine::gray49,
&ColorDefine::gray5,
&ColorDefine::gray50,
&ColorDefine::gray51,
&ColorDefine::gray52,
&ColorDefine::gray53,
&ColorDefine::gray54,
&ColorDefine::gray55,
&ColorDefine::gray56,
&ColorDefine::gray57,
&ColorDefine::gray58,
&ColorDefine::gray59,
&ColorDefine::gray6,
&ColorDefine::gray60,
&ColorDefine::gray61,
&ColorDefine::gray62,
&ColorDefine::gray63,
&ColorDefine::gray64,
&ColorDefine::gray65,
&ColorDefine::gray66,
&ColorDefine::gray67,
&ColorDefine::gray68,
&ColorDefine::gray69,
&ColorDefine::gray7,
&ColorDefine::gray70,
&ColorDefine::gray71,
&ColorDefine::gray72,
&ColorDefine::gray73,
&ColorDefine::gray74,
&ColorDefine::gray75,
&ColorDefine::gray76,
&ColorDefine::gray77,
&ColorDefine::gray78,
&ColorDefine::gray79,
&ColorDefine::gray8,
&ColorDefine::gray80,
&ColorDefine::gray81,
&ColorDefine::gray82,
&ColorDefine::gray83,
&ColorDefine::gray84,
&ColorDefine::gray85,
&ColorDefine::gray86,
&ColorDefine::gray87,
&ColorDefine::gray88,
&ColorDefine::gray89,
&ColorDefine::gray9,
&ColorDefine::gray90,
&ColorDefine::gray91,
&ColorDefine::gray92,
&ColorDefine::gray93,
&ColorDefine::gray94,
&ColorDefine::gray95,
&ColorDefine::gray96,
&ColorDefine::gray97,
&ColorDefine::gray98,
&ColorDefine::gray99,
&ColorDefine::green,
&ColorDefine::green1,
&ColorDefine::green2,
&ColorDefine::green3,
&ColorDefine::green4,
&ColorDefine::greenYellow,
&ColorDefine::grey,
&ColorDefine::grey0,
&ColorDefine::grey1,
&ColorDefine::grey10,
&ColorDefine::grey100,
&ColorDefine::grey11,
&ColorDefine::grey12,
&ColorDefine::grey13,
&ColorDefine::grey14,
&ColorDefine::grey15,
&ColorDefine::grey16,
&ColorDefine::grey17,
&ColorDefine::grey18,
&ColorDefine::grey19,
&ColorDefine::grey2,
&ColorDefine::grey20,
&ColorDefine::grey21,
&ColorDefine::grey22,
&ColorDefine::grey23,
&ColorDefine::grey24,
&ColorDefine::grey25,
&ColorDefine::grey26,
&ColorDefine::grey27,
&ColorDefine::grey28,
&ColorDefine::grey29,
&ColorDefine::grey3,
&ColorDefine::grey30,
&ColorDefine::grey31,
&ColorDefine::grey32,
&ColorDefine::grey33,
&ColorDefine::grey34,
&ColorDefine::grey35,
&ColorDefine::grey36,
&ColorDefine::grey37,
&ColorDefine::grey38,
&ColorDefine::grey39,
&ColorDefine::grey4,
&ColorDefine::grey40,
&ColorDefine::grey41,
&ColorDefine::grey42,
&ColorDefine::grey43,
&ColorDefine::grey44,
&ColorDefine::grey45,
&ColorDefine::grey46,
&ColorDefine::grey47,
&ColorDefine::grey48,
&ColorDefine::grey49,
&ColorDefine::grey5,
&ColorDefine::grey50,
&ColorDefine::grey51,
&ColorDefine::grey52,
&ColorDefine::grey53,
&ColorDefine::grey54,
&ColorDefine::grey55,
&ColorDefine::grey56,
&ColorDefine::grey57,
&ColorDefine::grey58,
&ColorDefine::grey59,
&ColorDefine::grey6,
&ColorDefine::grey60,
&ColorDefine::grey61,
&ColorDefine::grey62,
&ColorDefine::grey63,
&ColorDefine::grey64,
&ColorDefine::grey65,
&ColorDefine::grey66,
&ColorDefine::grey67,
&ColorDefine::grey68,
&ColorDefine::grey69,
&ColorDefine::grey7,
&ColorDefine::grey70,
&ColorDefine::grey71,
&ColorDefine::grey72,
&ColorDefine::grey73,
&ColorDefine::grey74,
&ColorDefine::grey75,
&ColorDefine::grey76,
&ColorDefine::grey77,
&ColorDefine::grey78,
&ColorDefine::grey79,
&ColorDefine::grey8,
&ColorDefine::grey80,
&ColorDefine::grey81,
&ColorDefine::grey82,
&ColorDefine::grey83,
&ColorDefine::grey84,
&ColorDefine::grey85,
&ColorDefine::grey86,
&ColorDefine::grey87,
&ColorDefine::grey88,
&ColorDefine::grey89,
&ColorDefine::grey9,
&ColorDefine::grey90,
&ColorDefine::grey91,
&ColorDefine::grey92,
&ColorDefine::grey93,
&ColorDefine::grey94,
&ColorDefine::grey95,
&ColorDefine::grey96,
&ColorDefine::grey97,
&ColorDefine::grey98,
&ColorDefine::grey99,
&ColorDefine::honeydew,
&ColorDefine::honeydew1,
&ColorDefine::honeydew2,
&ColorDefine::honeydew3,
&ColorDefine::honeydew4,
&ColorDefine::hotPink,
&ColorDefine::hotPink1,
&ColorDefine::hotPink2,
&ColorDefine::hotPink3,
&ColorDefine::hotPink4,
&ColorDefine::indianRed,
&ColorDefine::indianRed1,
&ColorDefine::indianRed2,
&ColorDefine::indianRed3,
&ColorDefine::indianRed4,
&ColorDefine::ivory,
&ColorDefine::ivory1,
&ColorDefine::ivory2,
&ColorDefine::ivory3,
&ColorDefine::ivory4,
&ColorDefine::khaki,
&ColorDefine::khaki1,
&ColorDefine::khaki2,
&ColorDefine::khaki3,
&ColorDefine::khaki4,
&ColorDefine::lavender,
&ColorDefine::lavenderBlush,
&ColorDefine::lavenderBlush1,
&ColorDefine::lavenderBlush2,
&ColorDefine::lavenderBlush3,
&ColorDefine::lavenderBlush4,
&ColorDefine::lawnGreen,
&ColorDefine::lemonChiffon,
&ColorDefine::lemonChiffon1,
&ColorDefine::lemonChiffon2,
&ColorDefine::lemonChiffon3,
&ColorDefine::lemonChiffon4,
&ColorDefine::lightBlue,
&ColorDefine::lightBlue1,
&ColorDefine::lightBlue2,
&ColorDefine::lightBlue3,
&ColorDefine::lightBlue4,
&ColorDefine::lightCoral,
&ColorDefine::lightCyan,
&ColorDefine::lightCyan1,
&ColorDefine::lightCyan2,
&ColorDefine::lightCyan3,
&ColorDefine::lightCyan4,
&ColorDefine::lightGoldenrod,
&ColorDefine::lightGoldenrod1,
&ColorDefine::lightGoldenrod2,
&ColorDefine::lightGoldenrod3,
&ColorDefine::lightGoldenrod4,
&ColorDefine::lightGoldenrodYellow,
&ColorDefine::lightGray,
&ColorDefine::lightGreen,
&ColorDefine::lightGrey,
&ColorDefine::lightPink,
&ColorDefine::lightPink1,
&ColorDefine::lightPink2,
&ColorDefine::lightPink3,
&ColorDefine::lightPink4,
&ColorDefine::lightSalmon,
&ColorDefine::lightSalmon1,
&ColorDefine::lightSalmon2,
&ColorDefine::lightSalmon3,
&ColorDefine::lightSalmon4,
&ColorDefine::lightSeaGreen,
&ColorDefine::lightSkyBlue,
&ColorDefine::lightSkyBlue1,
&ColorDefine::lightSkyBlue2,
&ColorDefine::lightSkyBlue3,
&ColorDefine::lightSkyBlue4,
&ColorDefine::lightSlateBlue,
&ColorDefine::lightSlateGray,
&ColorDefine::lightSlateGrey,
&ColorDefine::lightSteelBlue,
&ColorDefine::lightSteelBlue1,
&ColorDefine::lightSteelBlue2,
&ColorDefine::lightSteelBlue3,
&ColorDefine::lightSteelBlue4,
&ColorDefine::lightYellow,
&ColorDefine::lightYellow1,
&ColorDefine::lightYellow2,
&ColorDefine::lightYellow3,
&ColorDefine::lightYellow4,
&ColorDefine::limeGreen,
&ColorDefine::linen,
&ColorDefine::magenta,
&ColorDefine::magenta1,
&ColorDefine::magenta2,
&ColorDefine::magenta3,
&ColorDefine::magenta4,
&ColorDefine::maroon,
&ColorDefine::maroon1,
&ColorDefine::maroon2,
&ColorDefine::maroon3,
&ColorDefine::maroon4,
&ColorDefine::mediumAquamarine,
&ColorDefine::mediumBlue,
&ColorDefine::mediumOrchid,
&ColorDefine::mediumOrchid1,
&ColorDefine::mediumOrchid2,
&ColorDefine::mediumOrchid3,
&ColorDefine::mediumOrchid4,
&ColorDefine::mediumPurple,
&ColorDefine::mediumPurple1,
&ColorDefine::mediumPurple2,
&ColorDefine::mediumPurple3,
&ColorDefine::mediumPurple4,
&ColorDefine::mediumSeaGreen,
&ColorDefine::mediumSlateBlue,
&ColorDefine::mediumSpringGreen,
&ColorDefine::mediumTurquoise,
&ColorDefine::mediumVioletRed,
&ColorDefine::midnightBlue,
&ColorDefine::mintCream,
&ColorDefine::mistyRose,
&ColorDefine::mistyRose1,
&ColorDefine::mistyRose2,
&ColorDefine::mistyRose3,
&ColorDefine::mistyRose4,
&ColorDefine::moccasin,
&ColorDefine::navajoWhite,
&ColorDefine::navajoWhite1,
&ColorDefine::navajoWhite2,
&ColorDefine::navajoWhite3,
&ColorDefine::navajoWhite4,
&ColorDefine::navy,
&ColorDefine::navyBlue,
&ColorDefine::oldLace,
&ColorDefine::oliveDrab,
&ColorDefine::oliveDrab1,
&ColorDefine::oliveDrab2,
&ColorDefine::oliveDrab3,
&ColorDefine::oliveDrab4,
&ColorDefine::orange,
&ColorDefine::orange1,
&ColorDefine::orange2,
&ColorDefine::orange3,
&ColorDefine::orange4,
&ColorDefine::orangeRed,
&ColorDefine::orangeRed1,
&ColorDefine::orangeRed2,
&ColorDefine::orangeRed3,
&ColorDefine::orangeRed4,
&ColorDefine::orchid,
&ColorDefine::orchid1,
&ColorDefine::orchid2,
&ColorDefine::orchid3,
&ColorDefine::orchid4,
&ColorDefine::paleGoldenrod,
&ColorDefine::paleGreen,
&ColorDefine::paleGreen1,
&ColorDefine::paleGreen2,
&ColorDefine::paleGreen3,
&ColorDefine::paleGreen4,
&ColorDefine::paleTurquoise,
&ColorDefine::paleTurquoise1,
&ColorDefine::paleTurquoise2,
&ColorDefine::paleTurquoise3,
&ColorDefine::paleTurquoise4,
&ColorDefine::paleVioletRed,
&ColorDefine::paleVioletRed1,
&ColorDefine::paleVioletRed2,
&ColorDefine::paleVioletRed3,
&ColorDefine::paleVioletRed4,
&ColorDefine::papayaWhip,
&ColorDefine::peachPuff,
&ColorDefine::peachPuff1,
&ColorDefine::peachPuff2,
&ColorDefine::peachPuff3,
&ColorDefine::peachPuff4,
&ColorDefine::peru,
&ColorDefine::pink,
&ColorDefine::pink1,
&ColorDefine::pink2,
&ColorDefine::pink3,
&ColorDefine::pink4,
&ColorDefine::plum,
&ColorDefine::plum1,
&ColorDefine::plum2,
&ColorDefine::plum3,
&ColorDefine::plum4,
&ColorDefine::powderBlue,
&ColorDefine::purple,
&ColorDefine::purple1,
&ColorDefine::purple2,
&ColorDefine::purple3,
&ColorDefine::purple4,
&ColorDefine::red,
&ColorDefine::red1,
&ColorDefine::red2,
&ColorDefine::red3,
&ColorDefine::red4,
&ColorDefine::rosyBrown,
&ColorDefine::rosyBrown1,
&ColorDefine::rosyBrown2,
&ColorDefine::rosyBrown3,
&ColorDefine::rosyBrown4,
&ColorDefine::royalBlue,
&ColorDefine::royalBlue1,
&ColorDefine::royalBlue2,
&ColorDefine::royalBlue3,
&ColorDefine::royalBlue4,
&ColorDefine::saddleBrown,
&ColorDefine::salmon,
&ColorDefine::salmon1,
&ColorDefine::salmon2,
&ColorDefine::salmon3,
&ColorDefine::salmon4,
&ColorDefine::sandyBrown,
&ColorDefine::seaGreen,
&ColorDefine::seaGreen1,
&ColorDefine::seaGreen2,
&ColorDefine::seaGreen3,
&ColorDefine::seaGreen4,
&ColorDefine::seashell,
&ColorDefine::seashell1,
&ColorDefine::seashell2,
&ColorDefine::seashell3,
&ColorDefine::seashell4,
&ColorDefine::sienna,
&ColorDefine::sienna1,
&ColorDefine::sienna2,
&ColorDefine::sienna3,
&ColorDefine::sienna4,
&ColorDefine::skyBlue,
&ColorDefine::skyBlue1,
&ColorDefine::skyBlue2,
&ColorDefine::skyBlue3,
&ColorDefine::skyBlue4,
&ColorDefine::slateBlue,
&ColorDefine::slateBlue1,
&ColorDefine::slateBlue2,
&ColorDefine::slateBlue3,
&ColorDefine::slateBlue4,
&ColorDefine::slateGray,
&ColorDefine::slateGray1,
&ColorDefine::slateGray2,
&ColorDefine::slateGray3,
&ColorDefine::slateGray4,
&ColorDefine::slateGrey,
&ColorDefine::snow,
&ColorDefine::snow1,
&ColorDefine::snow2,
&ColorDefine::snow3,
&ColorDefine::snow4,
&ColorDefine::springGreen,
&ColorDefine::springGreen1,
&ColorDefine::springGreen2,
&ColorDefine::springGreen3,
&ColorDefine::springGreen4,
&ColorDefine::steelBlue,
&ColorDefine::steelBlue1,
&ColorDefine::steelBlue2,
&ColorDefine::steelBlue3,
&ColorDefine::steelBlue4,
&ColorDefine::tan1,
&ColorDefine::tan2,
&ColorDefine::tan3,
&ColorDefine::tan4,
&ColorDefine::thistle,
&ColorDefine::thistle1,
&ColorDefine::thistle2,
&ColorDefine::thistle3,
&ColorDefine::thistle4,
&ColorDefine::tomato,
&ColorDefine::tomato1,
&ColorDefine::tomato2,
&ColorDefine::tomato3,
&ColorDefine::tomato4,
&ColorDefine::turquoise,
&ColorDefine::turquoise1,
&ColorDefine::turquoise2,
&ColorDefine::turquoise3,
&ColorDefine::turquoise4,
&ColorDefine::violet,
&ColorDefine::violetRed,
&ColorDefine::violetRed1,
&ColorDefine::violetRed2,
&ColorDefine::violetRed3,
&ColorDefine::violetRed4,
&ColorDefine::wheat,
&ColorDefine::wheat1,
&ColorDefine::wheat2,
&ColorDefine::wheat3,
&ColorDefine::wheat4,
&ColorDefine::white,
&ColorDefine::whiteSmoke,
&ColorDefine::yellow,
&ColorDefine::yellow1,
&ColorDefine::yellow2,
&ColorDefine::yellow3,
&ColorDefine::yellow4,
&ColorDefine::yellowGreen
};
const int ColorDefine::Size = sizeof(Value)/sizeof(Colorf*);
const char *ColorDefine::DistinctName[]={
"aliceBlue",
"antiqueWhite",
"aquamarine",
"azure",
"beige",
"bisque",
"black",
"blanchedAlmond",
"blue",
"blueViolet",
"brown",
"burlywood",
"cadetBlue",
"chartreuse",
"chocolate",
"coral",
"cornflowerBlue",
"cornsilk",
"cyan",
"deepPink",
"deepSkyBlue",
"dimGray",
"dodgerBlue",
"firebrick",
"floralWhite",
"forestGreen",
"gainsboro",
"ghostWhite",
"gold",
"goldenrod",
"gray",
"green",
"greenYellow",
"honeydew",
"hotPink",
"indianRed",
"ivory",
"khaki",
"lavender",
"lavenderBlush",
"lawnGreen",
"lemonChiffon",
"limeGreen",
"linen",
"magenta",
"maroon",
"midnightBlue",
"mintCream",
"mistyRose",
"moccasin",
"navajoWhite",
"navy",
"oldLace",
"orange",
"orangeRed",
"orchid",
"papayaWhip",
"peachPuff",
"peru",
"pink",
"plum",
"powderBlue",
"purple",
"red",
"rosyBrown",
"royalBlue",
"saddleBrown",
"salmon",
"sandyBrown",
"seaGreen",
"seashell",
"sienna",
"skyBlue",
"slateBlue",
"slateGray",
"snow",
"springGreen",
"steelBlue",
"thistle",
"tomato",
"turquoise",
"violet",
"violetRed",
"wheat",
"whiteSmoke",
"yellow",
"yellowGreen"
};
const Colorf* ColorDefine::DistinctValue[]={
&ColorDefine::red,
&ColorDefine::indianRed,
&ColorDefine::blue,
&ColorDefine::blueViolet,
&ColorDefine::brown,
&ColorDefine::burlywood,
&ColorDefine::cadetBlue,
&ColorDefine::chartreuse,
&ColorDefine::chocolate,
&ColorDefine::coral,
&ColorDefine::cornflowerBlue,
&ColorDefine::cyan,
&ColorDefine::cornsilk,
&ColorDefine::aliceBlue,
&ColorDefine::antiqueWhite,
&ColorDefine::aquamarine,
&ColorDefine::azure,
&ColorDefine::beige,
&ColorDefine::bisque,
&ColorDefine::black,
&ColorDefine::blanchedAlmond,
&ColorDefine::deepPink,
&ColorDefine::deepSkyBlue,
&ColorDefine::dimGray,
&ColorDefine::dodgerBlue,
&ColorDefine::firebrick,
&ColorDefine::floralWhite,
&ColorDefine::forestGreen,
&ColorDefine::gainsboro,
&ColorDefine::ghostWhite,
&ColorDefine::gold,
&ColorDefine::goldenrod,
&ColorDefine::gray,
&ColorDefine::green,
&ColorDefine::greenYellow,
&ColorDefine::honeydew,
&ColorDefine::hotPink,
&ColorDefine::ivory,
&ColorDefine::khaki,
&ColorDefine::lavender,
&ColorDefine::lavenderBlush,
&ColorDefine::lawnGreen,
&ColorDefine::lemonChiffon,
&ColorDefine::limeGreen,
&ColorDefine::linen,
&ColorDefine::magenta,
&ColorDefine::maroon,
&ColorDefine::midnightBlue,
&ColorDefine::mintCream,
&ColorDefine::mistyRose,
&ColorDefine::moccasin,
&ColorDefine::navajoWhite,
&ColorDefine::navy,
&ColorDefine::oldLace,
&ColorDefine::orange,
&ColorDefine::orchid,
&ColorDefine::papayaWhip,
&ColorDefine::peachPuff,
&ColorDefine::peru,
&ColorDefine::pink,
&ColorDefine::plum,
&ColorDefine::powderBlue,
&ColorDefine::purple,
&ColorDefine::rosyBrown,
&ColorDefine::royalBlue,
&ColorDefine::saddleBrown,
&ColorDefine::salmon,
&ColorDefine::sandyBrown,
&ColorDefine::seaGreen,
&ColorDefine::seashell,
&ColorDefine::sienna,
&ColorDefine::skyBlue,
&ColorDefine::slateBlue,
&ColorDefine::slateGray,
&ColorDefine::snow,
&ColorDefine::springGreen,
&ColorDefine::steelBlue,
&ColorDefine::thistle,
&ColorDefine::tomato,
&ColorDefine::turquoise,
&ColorDefine::violet,
&ColorDefine::violetRed,
&ColorDefine::wheat,
&ColorDefine::whiteSmoke,
&ColorDefine::yellow,
&ColorDefine::yellowGreen
};
const int ColorDefine::DistinctSize=sizeof(DistinctValue)/sizeof(Colorf*);
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/ColorDefine.cpp
|
C++
|
gpl3
| 148,069
|
#pragma once
#include <zGraphicsConfig.hpp>
#include <Math/Math.hpp>
#include <Math/Vector3.hpp>
namespace zzz{
/*
Cartesian3DCoord <-> SphericalCoord
\ ^
_\| |
CubeCoord -> CubeCoordNormalized
everyone use default copy constructor and operator =, all explicit
and provide a operator() to Vector3, implicit
// ___________
// /| /| Y
// / | 2 / | |
// /__|____5_ / | |
// | | | | |________X
// | 1|______|_0_| /
// | / 4 | / /
// | / 3 | / /
// |/________|/ Z
//
// ___
// | |
// ___|_2_|____
// | | | |
// |_1_|_5_|_0_|
// | |
// |_3_|
// | |
// |_4_|
//
// major axis
// direction target sc tc ma
// ---------- ------------------------------- --- --- ---
// +rx TEXTURE_CUBE_MAP_POSITIVE_X_ARB -rz -ry rx
// -rx TEXTURE_CUBE_MAP_NEGATIVE_X_ARB +rz -ry rx
// +ry TEXTURE_CUBE_MAP_POSITIVE_Y_ARB +rx +rz ry
// -ry TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB +rx -rz ry
// +rz TEXTURE_CUBE_MAP_POSITIVE_Z_ARB +rx -ry rz
// -rz TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB -rx -ry rz
*/
typedef enum {POSX=0,NEGX=1,POSY=2,NEGY=3,POSZ=4,NEGZ=5} CUBEFACE;
template <typename T> struct Cartesian3DCoord;
template <typename T> struct CartesianDirCoord;
template <typename T> struct CubeCoordNormalized;
template <typename T> struct SphericalCoord;
struct ZGRAPHICS_CLASS CubeCoord {
CUBEFACE cubeface;
int x,y;
zsize size;
CubeCoord();
CubeCoord(const CUBEFACE _face,const zuint _x,const zuint _y, const zuint _size);
CubeCoord(const CubeCoord& c);
const CubeCoord& operator=(const CubeCoord& c);
inline int ToIndex() const {
return cubeface*size*size+y*size+x;
}
inline void FromIndex(zuint facesize,zuint index) {
size=facesize;
cubeface=(CUBEFACE)(index/(size*size));
y=(index-cubeface*size*size)/size;
x=index-cubeface*size*size-y*size;
}
inline int ToFaceIndex() const {
return y*size+x;
}
inline void FromFaceIndex(zuint facesize,CUBEFACE face,zuint faceindex) {
size=facesize;
cubeface=face;
y=faceindex/size;
x=faceindex-size*y;
}
void Standardize();
};
template <typename T>
struct Cartesian3DCoord : public Vector<3,T> {
using Vector<3,T>::v;
Cartesian3DCoord():Vector<3,T>(){}
Cartesian3DCoord(const T& a,const T& b,const T& c):Vector<3,T>(a,b,c){}
// //positive and negative
// inline Cartesian3DCoord<T> operator+() const {return *this;}
// inline Cartesian3DCoord<T> operator-() const {return Cartesian3DCoord<T>(-v[0],-v[1],-v[2]);}
// //addition
// inline Cartesian3DCoord<T> operator+(const Cartesian3DCoord<T> &a) const {return Cartesian3DCoord<T>(v[0]+a.v[0],v[1]+a.v[1],v[2]+a.v[2]);}
// inline Cartesian3DCoord<T> operator+(const T a) const {return Cartesian3DCoord<T>(v[0]+a,v[1]+a,v[2]+a);}
// inline void operator+=(const Cartesian3DCoord<T> &a) {v[0]+=a.v[0]; v[1]+=a.v[1]; v[2]+=a.v[2];}
// inline void operator+=(const T a) {v[0]+=a; v[1]+=a; v[2]+=a;}
// //subtraction
// inline Cartesian3DCoord<T> operator-(const Cartesian3DCoord<T> &a) const {return Cartesian3DCoord<T>(v[0]-a.v[0],v[1]-a.v[1],v[2]-a.v[2]);}
// inline Cartesian3DCoord<T> operator-(const T a) const {return Cartesian3DCoord<T>(v[0]-a,v[1]-a,v[2]-a);}
// inline void operator-=(const Cartesian3DCoord<T> &a) {v[0]-=a.v[0]; v[1]-=a.v[1]; v[2]-=a.v[2];}
// inline void operator-=(const T a) {v[0]-=a; v[1]-=a; v[2]-=a;}
// //multiplication
// inline VectorBase<3,T> operator*(const Cartesian3DCoord<T> &a) const {return Cartesian3DCoord<T>(v[0]*a.v[0],v[1]*a.v[1],v[2]*a.v[2]);}
// inline VectorBase<3,T> operator*(const T a) const {return Cartesian3DCoord<T>(v[0]*a,v[1]*a,v[2]*a);}
// inline void operator*=(const Cartesian3DCoord<T> &a) {v[0]*=a.v[0]; v[1]*=a.v[1]; v[2]*=a.v[2];}
// inline void operator*=(const T a) {v[0]*=a; v[1]*=a; v[2]*=a;}
// //division
// inline Cartesian3DCoord<T> operator/(const Cartesian3DCoord<T> &a) const {return Cartesian3DCoord<T>(v[0]/a.v[0],v[1]/a.v[1],v[2]/a.v[2]);}
// inline Cartesian3DCoord<T> operator/(const T a) const {return Cartesian3DCoord<T>(v[0]/a,v[1]/a,v[2]/a);}
// inline void operator/=(const Cartesian3DCoord<T> &a) {v[0]/=a.v[0]; v[1]/=a.v[1]; v[2]/=a.v[2];}
// inline void operator/=(const T a) {v[0]/=a; v[1]/=a; v[2]/=a;}
//one number
Cartesian3DCoord(const T c)
{
*this=c;
}
const Cartesian3DCoord<T> &operator=(const T c)
{
Vector<3,T>::operator =(c);
return *this;
}
//CartesianDirCoord
template <typename T1>
Cartesian3DCoord(const CartesianDirCoord<T1> &c)
{
*this=c;
}
template <typename T1>
const Cartesian3DCoord<T> &operator=(const CartesianDirCoord<T1> &c)
{
v[0]=c.v[0]; v[1]=c.v[1]; v[2]=c.v[2];
return *this;
}
//Vector3
template <typename T1>
Cartesian3DCoord(const VectorBase<3,T1> &c)
{
*this=c;
}
template <typename T1>
const Cartesian3DCoord<T> &operator=(const VectorBase<3,T1> &c)
{
VectorBase<3,T>::operator =(c);
return *this;
}
//SphericalCoord
template <typename T1>
const Cartesian3DCoord<T> &operator =(const SphericalCoord<T1> &s)
{
v[0]=(T)s.rho*cos(s.phi)*sin(s.theta);
v[1]=(T)s.rho*sin(s.phi)*sin(s.theta);
v[2]=(T)s.rho*cos(s.theta);
}
template <typename T1>
Cartesian3DCoord(const SphericalCoord<T1> &s)
{
*this=s;
}
//CubeCoordNormalized
template <typename T1>
const Cartesian3DCoord<T> &operator =(const CubeCoordNormalized<T1> &s)
{
switch(s.cubeface)
{
case POSX:
v[0]=0.5f; v[1]=0.5f-s.v; v[2]=0.5f-s.u;
break;
case POSY:
v[0]=-0.5f+s.u; v[1]=0.5f; v[2]=-0.5f+s.v;
break;
case POSZ:
v[0]=-0.5f+s.u; v[1]=0.5f-s.v; v[2]=0.5f;
break;
case NEGX:
v[0]=-0.5f; v[1]=0.5f-s.v; v[2]=-0.5f+s.u;
break;
case NEGY:
v[0]=-0.5f+s.u; v[1]=-0.5f; v[2]=0.5f-s.v;
break;
case NEGZ:
v[0]=0.5f-s.u; v[1]=0.5f-s.v; v[2]=-0.5f;
break;
default:
break;
}
return *this;
}
template <typename T1>
Cartesian3DCoord(const CubeCoordNormalized<T1> &s)
{
*this=s;
}
//CubeCoord
const Cartesian3DCoord<T> &operator =(const CubeCoord &s)
{
T u=(T)((s.x+0.5)/s.size),v=(T)((s.y+0.5)/s.size);
switch(s.cubeface)
{
case POSX:
v[0]=0.5f; v[1]=0.5f-v; v[2]=0.5f-u;
break;
case POSY:
v[0]=-0.5f+u; v[1]=0.5f; v[2]=-0.5f+v;
break;
case POSZ:
v[0]=-0.5f+u; v[1]=0.5f-v; v[2]=0.5f;
break;
case NEGX:
v[0]=-0.5f; v[1]=0.5f-v; v[2]=-0.5f+u;
break;
case NEGY:
v[0]=-0.5f+u; v[1]=-0.5f; v[2]=0.5f-v;
break;
case NEGZ:
v[0]=0.5f-u; v[1]=0.5f-v; v[2]=-0.5f;
break;
default:
break;
}
return *this;
}
Cartesian3DCoord(const CubeCoord &s)
{
*this=s;
}
//Rotate
template <typename T1>
void Rotate(T1 *rotatematrix)//column major 4x4
{
T w=1;
T xx,yy,zz,ww;
xx=rotatematrix[0]*v[0]+rotatematrix[4]*v[1]+rotatematrix[8]*v[2]+rotatematrix[12]*w;
yy=rotatematrix[1]*v[0]+rotatematrix[5]*v[1]+rotatematrix[9]*v[2]+rotatematrix[13]*w;
zz=rotatematrix[2]*v[0]+rotatematrix[6]*v[1]+rotatematrix[10]*v[2]+rotatematrix[14]*w;
ww=rotatematrix[3]*v[0]+rotatematrix[7]*v[1]+rotatematrix[11]*v[2]+rotatematrix[15]*w;
v[0]=xx/ww; v[1]=yy/ww; v[2]=zz/ww;
}
template <typename T1>
void RotateBack(T1 *rotatematrix)//column major 4x4
{
T w=1;
T xx,yy,zz,ww;
xx=rotatematrix[0]*v[0]+rotatematrix[1]*v[1]+rotatematrix[2]*v[2]+rotatematrix[3]*w;
yy=rotatematrix[4]*v[0]+rotatematrix[5]*v[1]+rotatematrix[6]*v[2]+rotatematrix[7]*w;
zz=rotatematrix[8]*v[0]+rotatematrix[9]*v[1]+rotatematrix[10]*v[2]+rotatematrix[11]*w;
ww=rotatematrix[12]*v[0]+rotatematrix[13]*v[1]+rotatematrix[14]*v[2]+rotatematrix[15]*w;
v[0]=xx/ww; v[1]=yy/ww; v[2]=zz/ww;
}
};
typedef Cartesian3DCoord<float> Cartesian3DCoordf;
template <typename T>
struct CartesianDirCoord : public Vector<3,T>
{
using Vector<3,T>::v;
CartesianDirCoord():Vector<3,T>(){}
CartesianDirCoord(const T& a,const T& b,const T& c):Vector<3,T>(a,b,c){}
//Cartesian3DCoord
template <typename T1>
CartesianDirCoord(const Cartesian3DCoord<T1> &c)
{
*this=c;
}
template <typename T1>
const CartesianDirCoord<T> &operator=(const Cartesian3DCoord<T1> &c)
{
v[0]=c.v[0]; v[1]=c.v[1]; v[2]=c.v[2];
return *this;
}
//Vector3
template <typename T1>
CartesianDirCoord(const VectorBase<3,T1> &c)
{
*this=c;
}
template <typename T1>
const CartesianDirCoord<T> &operator=(const VectorBase<3,T1> &c)
{
VectorBase<3,T>::operator =(c);
return *this;
}
//SphericalCoord
template <typename T1>
const CartesianDirCoord<T> &operator =(const SphericalCoord<T1> &s)
{
v[0]=(T)s.rho*cos(s.phi)*sin(s.theta);
v[1]=(T)s.rho*sin(s.phi)*sin(s.theta);
v[2]=(T)s.rho*cos(s.theta);
return *this;
}
template <typename T1>
CartesianDirCoord(const SphericalCoord<T1> &s)
{
*this=s;
}
//CubeCoordNormalized
template <typename T1>
const CartesianDirCoord<T> &operator =(const CubeCoordNormalized<T1> &s)
{
switch(s.cubeface)
{
case POSX:
v[0]=0.5f; v[1]=0.5f-s.v; v[2]=0.5f-s.u;
break;
case POSY:
v[0]=-0.5f+s.u; v[1]=0.5f; v[2]=-0.5f+s.v;
break;
case POSZ:
v[0]=-0.5f+s.u; v[1]=0.5f-s.v; v[2]=0.5f;
break;
case NEGX:
v[0]=-0.5f; v[1]=0.5f-s.v; v[2]=-0.5f+s.u;
break;
case NEGY:
v[0]=-0.5f+s.u; v[1]=-0.5f; v[2]=0.5f-s.v;
break;
case NEGZ:
v[0]=0.5f-s.u; v[1]=0.5f-s.v; v[2]=-0.5f;
break;
default:
break;
}
return *this;
}
template <typename T1>
CartesianDirCoord(const CubeCoordNormalized<T1> &s)
{
*this=s;
}
//CubeCoord
const CartesianDirCoord<T> &operator =(const CubeCoord &s)
{
T uu=(T)((s.x+0.5)/s.size),vv=(T)((s.y+0.5)/s.size);
switch(s.cubeface)
{
case POSX:
v[0]=0.5f; v[1]=0.5f-vv; v[2]=0.5f-uu;
break;
case POSY:
v[0]=-0.5f+uu; v[1]=0.5f; v[2]=-0.5f+vv;
break;
case POSZ:
v[0]=-0.5f+uu; v[1]=0.5f-vv; v[2]=0.5f;
break;
case NEGX:
v[0]=-0.5f; v[1]=0.5f-vv; v[2]=-0.5f+uu;
break;
case NEGY:
v[0]=-0.5f+uu; v[1]=-0.5f; v[2]=0.5f-vv;
break;
case NEGZ:
v[0]=0.5f-uu; v[1]=0.5f-vv; v[2]=-0.5f;
break;
default:
break;
}
Vector<3,T>::Normalize();
return *this;
}
CartesianDirCoord(const CubeCoord &s)
{
*this=s;
}
//Rotate
template <typename T1>
void Rotate(T1 *rotatematrix)//column major 4x4
{
T xx,yy,zz;
xx=rotatematrix[0]*v[0]+rotatematrix[4]*v[1]+rotatematrix[8]*v[2];
yy=rotatematrix[1]*v[0]+rotatematrix[5]*v[1]+rotatematrix[9]*v[2];
zz=rotatematrix[2]*v[0]+rotatematrix[6]*v[1]+rotatematrix[10]*v[2];
v[0]=xx; v[1]=yy; v[2]=zz;
}
template <typename T1>
void RotateBack(T1 *rotatematrix)//column major 4x4
{
T xx,yy,zz;
xx=rotatematrix[0]*v[0]+rotatematrix[1]*v[1]+rotatematrix[2]*v[2];
yy=rotatematrix[4]*v[0]+rotatematrix[5]*v[1]+rotatematrix[6]*v[2];
zz=rotatematrix[8]*v[0]+rotatematrix[9]*v[1]+rotatematrix[10]*v[2];
v[0]=xx; v[1]=yy; v[2]=zz;
}
};
typedef CartesianDirCoord<float> CartesianDirCoordf;
template <typename T>
struct SphericalCoord
{
T theta,phi,rho;
SphericalCoord()
{
theta=phi=rho=(T)0;
}
SphericalCoord(const T _theta,const T _phi,const T _rho)
{
theta=_theta;phi=_phi;rho=_rho;
}
SphericalCoord(const T _theta,const T _phi)
{
theta=_theta;phi=_phi;rho=1.0;
}
//CartesianDirCoord
template <typename T1>
const SphericalCoord<T> &operator =(const CartesianDirCoord<T1>& v)
{
rho=v.Len();
theta=(T)acos(v.v[2]/rho);
phi=(T)atan2(v.v[1],v.v[0]);
return *this;
}
template <typename T1>
SphericalCoord(const CartesianDirCoord<T1>& v)
{
*this=v;
}
//Cartesian3DCoord
template <typename T1>
const SphericalCoord<T> &operator =(const Cartesian3DCoord<T1>& v)
{
rho=v.len();
theta=(T)acos(v.v[2]/rho);
phi=(T)atan2(v.v[1],v.v[0]);
return *this;
}
template <typename T1>
SphericalCoord(const Cartesian3DCoord<T1>& v)
{
*this=v;
}
//CubeCoordNormalized
template <typename T1>
const SphericalCoord<T> &operator =(const CubeCoordNormalized<T1> &v)
{
VectorBase<3,T> tv(0,0,0);
switch(v.cubeface)
{
case POSX:
tv.v[0]=0.5f;tv.v[1]=0.5f-(T)v.v;tv.v[2]=0.5f-(T)v.u;
break;
case POSY:
tv.v[0]=-0.5f+(T)v.u;tv.v[1]=0.5f;tv.v[2]=-0.5f+(T)v.v;
break;
case POSZ:
tv.v[0]=-0.5f+(T)v.u;tv.v[1]=0.5f-(T)v.v;tv.v[2]=0.5f;
break;
case NEGX:
tv.v[0]=-0.5f;tv.v[1]=0.5f-(T)v.v;tv.v[2]=-0.5f+(T)v.u;
break;
case NEGY:
tv.v[0]=-0.5f+(T)v.u;tv.v[1]=-0.5f;tv.v[2]=0.5f-(T)v.v;
break;
case NEGZ:
tv.v[0]=0.5f-(T)v.u;tv.v[1]=0.5f-(T)v.v;tv.v[2]=-0.5f;
break;
default:
break;
}
rho=tv.len();
theta=(T)acos(v.v[2]/rho);
phi=(T)atan2(v.v[1],v.v[0]);
}
template <typename T1>
SphericalCoord(const CubeCoordNormalized<T1> &v)
{
*this=v;
}
//CubeCoord
const SphericalCoord<T> &operator =(const CubeCoord &other)
{
VectorBase<3,T> tv(0,0,0);
T u=(T)((other.x+0.5)/other.size),v=(T)((other.x+0.5)/other.size);
switch(v.cubeface)
{
case POSX:
tv.v[0]=0.5f;tv.v[1]=0.5f-v;tv.v[2]=0.5f-u;
break;
case POSY:
tv.v[0]=-0.5f+u;tv.v[1]=0.5f;tv.v[2]=-0.5f+v;
break;
case POSZ:
tv.v[0]=-0.5f+u;tv.v[1]=0.5f-v;tv.v[2]=0.5f;
break;
case NEGX:
tv.v[0]=-0.5f;tv.v[1]=0.5f-v;tv.v[2]=-0.5f+u;
break;
case NEGY:
tv.v[0]=-0.5f+u;tv.v[1]=-0.5f;tv.v[2]=0.5f-v;
break;
case NEGZ:
tv.v[0]=0.5f-u;tv.v[1]=0.5f-v;tv.v[2]=-0.5f;
break;
default:
break;
}
rho=tv.len();
theta=(T)acos(v.v[2]/rho);
phi=(T)atan2(v.v[1],v.v[0]);
}
SphericalCoord(const CubeCoord &v)
{
*this=v;
}
//to Vector3
template <typename T1>
operator VectorBase<3,T1>()
{
return VectorBase<3,T1>(theta,phi,rho);
}
};
typedef SphericalCoord<float> SphericalCoordf;
template <typename T>
struct CubeCoordNormalized
{
CUBEFACE cubeface;
T u,v;
CubeCoordNormalized()
{
cubeface=POSX;
u=0; v=0;
}
CubeCoordNormalized(const CUBEFACE _face, const T _x, const T _y)
{
cubeface=_face;
u=_x; v=_y;
}
//CartesianDirCoord
template <typename T1>
const CubeCoordNormalized<T> &operator=(const CartesianDirCoord<T1> &p1)
{
Cartesian3DCoord<T1> p=p1;
T1 a=(T1)fabs(p.v[0]);
if (a<fabs(p.v[1])) a=fabs(p.v[1]);
if (a<fabs(p.v[2])) a=fabs(p.v[2]);
p.v[0]/=a*2; p.v[1]/=a*2; p.v[2]/=a*2;
if (fabs(p.v[0])>(T1)(0.5-EPS))
if (p.v[0]>(T1)0.0)
cubeface=POSX;
else
cubeface=NEGX;
else
if (fabs(p.v[1])>(T1)(0.5-EPS))
if (p.v[1]>(T1)0.0)
cubeface=POSY;
else
cubeface=NEGY;
else
if (p.v[2]>(T1)0.0)
cubeface=POSZ;
else
cubeface=NEGZ;
switch(cubeface)
{
case POSX:
u=(T)(0.5-p.v[2]); v=(T)(0.5-p.v[1]);
break;
case POSY:
u=(T)(0.5+p.v[0]); v=(T)(0.5+p.v[2]);
break;
case POSZ:
u=(T)(0.5+p.v[0]); v=(T)(0.5-p.v[1]);
break;
case NEGX:
u=(T)(0.5+p.v[2]); v=(T)(0.5-p.v[1]);
break;
case NEGY:
u=(T)(0.5+p.v[0]); v=(T)(0.5-p.v[2]);
break;
case NEGZ:
u=(T)(0.5-p.v[0]); v=(T)(0.5-p.v[1]);
break;
}
return *this;
}
template <typename T1>
CubeCoordNormalized(const CartesianDirCoord<T1> &p)
{
*this=p;
}
//Cartesian3DCoord
template <typename T1>
const CubeCoordNormalized<T> &operator=(const Cartesian3DCoord<T1> &p1)
{
Cartesian3DCoord<T1> p=p1;
T1 a=(T1)fabs(p.v[0]());
if (a<fabs(p.v[1]())) a=fabs(p.v[1]());
if (a<fabs(p.v[2]())) a=fabs(p.v[2]());
p.v[0]()/=a*2; p.v[1]()/=a*2; p.v[2]()/=a*2;
if (fabs(p.v[0]())>(T1)(0.5-EPS))
if (p.v[0]()>(T1)0.0)
cubeface=POSX;
else
cubeface=NEGX;
else
if (fabs(p.v[1]())>(T1)(0.5-EPS))
if (p.v[1]()>(T1)0.0)
cubeface=POSY;
else
cubeface=NEGY;
else
if (p.v[2]()>(T1)0.0)
cubeface=POSZ;
else
cubeface=NEGZ;
switch(cubeface)
{
case POSX:
u=(T)(0.5-p.v[2]()); v=(T)(0.5-p.v[1]());
break;
case POSY:
u=(T)(0.5+p.v[0]()); v=(T)(0.5+p.v[2]());
break;
case POSZ:
u=(T)(0.5+p.v[0]()); v=(T)(0.5-p.v[1]());
break;
case NEGX:
u=(T)(0.5+p.v[2]()); v=(T)(0.5-p.v[1]());
break;
case NEGY:
u=(T)(0.5+p.v[0]()); v=(T)(0.5-p.v[2]());
break;
case NEGZ:
u=(T)(0.5-p.v[0]()); v=(T)(0.5-p.v[1]());
break;
}
return *this;
}
template <typename T1>
CubeCoordNormalized(const Cartesian3DCoord<T1> &p)
{
*this=p;
}
//CubeCoord
const CubeCoordNormalized<T> &operator=(const CubeCoord &p)
{
cubeface=p.cubeface;
u=(T)((0.5+p.x)/p.size);
v=(T)((0.5+p.y)/p.size);
return *this;
}
CubeCoordNormalized(const CubeCoord &p)
{
*this=p;
}
//To CubeCoord
CubeCoord ToCubeCoord(int size) const
{
return CubeCoord(cubeface,u*size,v*size,size);
}
CubeCoord GetBaseCubeCoord(int size,float &ratioX,float &ratioY) const
{
CubeCoord ret;
ret.cubeface=cubeface;
ret.size=size;
float vcu=u,vcv=v;
vcu=(vcu*size-0.5f)/(size-1.0f);
vcv=(vcv*size-0.5f)/(size-1.0f);
ret.x=(int)(vcu*(size-1)+size)-size;
ret.y=(int)(vcv*(size-1)+size)-size;
ratioX=vcu*(size-1)-ret.x;
ratioY=vcv*(size-1)-ret.y;
return ret;
}
//to Vector3
template <typename T1>
operator VectorBase<3,T1>()
{
return VectorBase<3,T1>(cubeface,u,v);
}
};
typedef CubeCoordNormalized<float> CubeCoordNormalizedf;
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/Coordinate.hpp
|
C++
|
gpl3
| 18,932
|
#pragma once
#include <Math/Vector3.hpp>
#include <Math/Vector4.hpp>
#include <Graphics/Graphics.hpp>
#include <Image/ImageHelper.hpp>
namespace zzz {
#undef RGB // stupid vc
template<typename T>
class Color : public Vector<4,T> {
public:
Color(){}
Color(const Color<T> &other):Vector<4,T>(other){}
Color(T r, T g, T b, T a){SetRGBA(r,g,b,a);}
inline Color(T r, T g, T b); //TIP: need inline, otherwise redefinition will happen
Color(const Vector<4,T> &a){SetRGBA(a[0],a[1],a[2],a[3]);}
Color(const Vector<3,T> &a){SetRGB(a[0],a[1],a[2]);}
using Vector<4,T>::operator=;
using Vector<4,T>::operator[];
void Set(const Color<T> &other){Set(other.r(),other.g(),other.g(),other.a());}
void SetRGBA(T r, T g, T b, T a){v[0]=r; v[1]=g; v[2]=b; v[3]=a;}
void SetRGB(T r, T g, T b){v[0]=r; v[1]=g; v[2]=b;}
void SetR(T r){v[0]=r;}
void SetG(T g){v[1]=g;}
void SetB(T b){v[2]=b;}
void SetA(T a){v[3]=a;}
Vector<3,T> &RGB() {
return *(reinterpret_cast<Vector<3,T>*>(v));
}
const Vector<3,T> &RGB() const {
return *(reinterpret_cast<const Vector<3,T>*>(v));
}
using Vector<4,T>::r;
using Vector<4,T>::g;
using Vector<4,T>::b;
using Vector<4,T>::a;
using Vector<4,T>::Data;
inline void ApplyGL() const;
inline T Brightness() const;
Vector<3,T> ToHSV() const {
Vector<3,T> hsv;
const T minv = RGB().Min();
const T maxv = RGB().Max();
hsv.v = maxv;
const T delta = maxv-minv;
if (maxv!=0.0) {
hsv.s = delta/maxv;
} else {
// Black
hsv.h = 0;
hsv.s = 0;
return;
}
if (delta==0) {
hsv.h = 0;
hsv.s = 0;
} else {
if (r()==maxv) {
hsv.h = (g()-b()) / delta; // between yellow & magenta
} else {
if(g()==maxv) hsv.h = 2 + (b()-r())/delta; // between cyan & yellow
else hsv.h = 4 + (r()-g())/delta; // between magenta & cyan
}
}
// Scale h to degrees
hsv.h *= 60;
if (hsv.h<0.0) hsv.h += 360;
}
void FromHSV(const Vector<3,T> &hsv) {
if (hsv.s==0) {
r() = g() = b() = hsv.v;
return;
}
const T hue = hsv.h/60.0; // sector 0 to 5
const int i = int(floor(hue));
const T f = hue-i; // factorial part of h
const T p = hsv.v*(1-hsv.s);
const T q = hsv.v*(1-hsv.s*f);
const T t = hsv.v*(1-hsv.s*(1-f));
switch (i) {
case 0:
Set(hsv.v,t,p);
break;
case 1:
Set(q,hsv.v,p);
break;
case 2:
Set(p,hsv.v,t);
break;
case 3:
Set(p,q,hsv.v);
break;
case 4:
Set(t,p,hsv.v);
break;
default: // case 5:
Set(hsv.v,p,q);
break;
}
}
void FromXYZ(const Vector<3,T> &c)
{
r()=3.2410*c[0]-1.5374*c[1]-0.4986*c[2];
g()=-0.9692*c[0]+1.8760*c[1]+0.0416*c[2];
b()=0.0556*c[0]-0.2040*c[1]+1.0570*c[2];
}
Vector<3,T> ToXYZ() const
{
return Vector<3,T>(\
0.4124*r()+0.3576*g()+0.1805*b(),\
0.2126*r()+0.7152*g()+0.0722*b(),\
0.0193*r()+0.1192*g()+0.9505*b());
}
bool IsGray(){return r()==g() && g()==b();}
template<typename TO>
Color<TO> ToColor() const {
return Color<TO>(ConvertPixel< Vector<4,T>,Vector<4,TO> >(*this));
}
template<typename TO>
Vector<3,TO> ToRGB() const {
return Color<TO>(ConvertPixel< Vector<4,T>,Vector<4,TO> >(*this)).RGB();
}
private:
using Vector<4,T>::v;
};
template<>
Color<float>::Color(float r, float g, float b)
{
SetRGBA(r,g,b,1.0f);
}
template<>
Color<double>::Color(double r, double g, double b)
{
SetRGBA(r,g,b,1.0);
}
template<>
Color<zubyte>::Color(zubyte r, zubyte g, zubyte b)
{
SetRGBA(r,g,b,255);
}
template<>
void Color<float>::ApplyGL() const
{
glColor4fv(v);
}
template<>
void Color<double>::ApplyGL() const
{
glColor4dv(v);
}
template<>
void Color<zuchar>::ApplyGL() const
{
glColor4ubv(v);
}
template<>
float Color<float>::Brightness() const
{
return 0.212671f*r() + 0.715160f*g() + 0.072169f*b();
}
template<>
double Color<double>::Brightness() const
{
return 0.212671*r() + 0.715160*g() + 0.072169*b();
}
template<>
zubyte Color<zubyte>::Brightness() const
{
return (zubyte)(0.212671*r() + 0.715160*g() + 0.072169*b());
}
typedef Color<zfloat32> Colorf32;
typedef Color<zfloat64> Colorf64;
typedef Color<zuint8> Colorui8;
typedef Color<float> Colorf;
typedef Color<double> Colord;
typedef Color<zuchar> Coloruc;
SIMPLE_IOOBJECT(Colorf);
SIMPLE_IOOBJECT(Colord);
SIMPLE_IOOBJECT(Coloruc);
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/Color.hpp
|
C++
|
gpl3
| 4,693
|
#pragma once
#include <Math/Random.hpp>
#include <Math/Vector3.hpp>
#include <Math/Math.hpp>
#include <Math/HashFunction.hpp>
namespace zzz{
template <typename T>
class NoisePerlin {
public:
NoisePerlin():seed_(TimeSeed()),type_(NOISE_PERLIN),octaves_(1),lambda_(1),omega_(0.5){}
NoisePerlin(const zuint seed):seed_(seed),type_(NOISE_PERLIN),octaves_(1),lambda_(1),omega_(0.5){}
NoisePerlin(const NoisePerlin &noise) {
type_ = noise.type_;
seed_ = noise.seed_;
octaves_ = noise.octaves_;
lambda_ = noise.lambda_;
omega_ = noise.omega_;
}
~NoisePerlin(){}
//1d noise field
T Value(const T x) const{return Value(Vector<3,T>(x,0,0));}
//2d noise field
T Value(const T x,const T y) const{return Value(Vector<3,T>(x,y,0));}
//3d noise field
T Value(const T x,const T y,const T z) const{return Value(Vector<3,T>(x,y,z));}
//3d noise field
T Value(const Vector<3,T> &pos) const {
const zuint x = (zuint) floor(pos.x());
const zuint y = (zuint) floor(pos.y());
const zuint z = (zuint) floor(pos.z());
const T fx = pos.x()<1 ? fmod(pos.x(),1.0) + 1 : fmod(pos.x(),1.0);
const T fy = pos.y()<1 ? fmod(pos.y(),1.0) + 1 : fmod(pos.y(),1.0);
const T fz = pos.z()<1 ? fmod(pos.z(),1.0) + 1 : fmod(pos.z(),1.0);
return Value(x,y,z,0,fx,fy,fz);
}
/*!
\brief 1D noise field on tiled integer lattice
\param x Integer lattice position in x
\param fractionalBits Number of least significant bits used for fraction
\param fx Floating-point fraction in x
*/
T Value(const zuint x, const zuint fractionalBits, const T fx = 0.0) const;
/*!
\brief 2D noise field on tiled integer lattice
\param x Integer lattice position in x
\param y Integer lattice position in y
\param fractionalBits Number of least significant bits used for fraction
\param fx Floating-point fraction in x
\param fy Floating-point fraction in y
*/
T Value(const zuint x,const zuint y,const zuint fractionalBits,const T fx = 0.0,const T fy = 0.0) const;
/*!
\brief 3D noise field on tiled integer lattice
\param x Integer lattice position in x
\param y Integer lattice position in y
\param z Integer lattice position in z
\param fractionalBits Number of least significant bits used for fraction
\param fx Floating-point fraction in x
\param fy Floating-point fraction in y
\param fz Floating-point fraction in z
*/
T Value(const zuint x,const zuint y,const zuint z,const zuint fractionalBits,const T fx = 0.0,const T fy = 0.0,const T fz = 0.0) const;
//
// Configuration
//
typedef enum{NOISE_PERLIN, NOISE_FBM, NOISE_TURBULENCE} NoiseType;
NoiseType type_; ///< Noise type
zuint seed_; ///< Unique seed for noise field
zuint octaves_; ///< Number of harmonics
zuint lambda_; ///< Domain scale factor for subsequent harmonics
T omega_; ///< Range scale factor for subsequent harmonics
const static Vector<3,T> vector_[16]; ///< Fixed set of possible gradients
/*!
\brief 1D Perlin noise field
\param x Integer lattice position in x
\param y Integer lattice position in y
\param fractionalBits Number of least significant bits used for fraction
\param fx Floating-point fraction in x
\param fy Floating-point fraction in y
*/
static T PerlinNoise(const zuint seed,const zuint x,const zuint fractionalBits,const T fx = 0.0);
/*!
\brief 2D Perlin noise field
\param x Integer lattice position in x
\param y Integer lattice position in y
\param fractionalBits Number of least significant bits used for fraction
\param fx Floating-point fraction in x
\param fy Floating-point fraction in y
*/
static T PerlinNoise(const zuint seed,const zuint x,const zuint y,const zuint fractionalBits,const T fx = 0.0,const T fy = 0.0);
/*!
\brief 3D Perlin noise field
\param x Integer lattice position in x
\param y Integer lattice position in y
\param z Integer lattice position in z
\param fractionalBits Number of least significant bits used for fraction
\param fx Floating-point fraction in x
\param fy Floating-point fraction in y
\param fz Floating-point fraction in z
*/
static T PerlinNoise(const zuint seed,const zuint x,const zuint y,const zuint z,const zuint fractionalBits,const T fx = 0.0,const T fy = 0.0,const T fz = 0.0);
/// 1D integer lattice gradient index
static inline zuint Hash(const zuint seed,const zuint x)
{
return HashWangUInt(x^seed)%16;
}
/// 2D integer lattice gradient index
static inline zuint Hash(const zuint seed,const zuint x,const zuint y)
{
return HashWangUInt(x^HashWangUInt(y^seed))%16;
}
/// 3D integer lattice gradient index
static inline zuint Hash(const zuint seed,const zuint x,const zuint y,const zuint z)
{
return HashWangUInt(x^HashWangUInt(y^HashWangUInt(z^seed)))%16;
}
/// Ease in-out curve for interpolation
inline static T Scurve(T t)
{
const T t3 = t*t*t;
const T t4 = t3*t;
const T t5 = t4*t;
return 6*t5 - 15*t4 + 10*t3;
}
};
//////////////////////////////////////////////////////////////////////////
template<typename T>
T NoisePerlin<T>::Value(const zuint x,const zuint y,const zuint z,const zuint fractionalBits,const T fx,const T fy,const T fz) const
{
switch (type_)
{
default:
case NOISE_PERLIN:
return PerlinNoise(seed_,x,y,z,fractionalBits,fx,fy,fz);
case NOISE_FBM:
{
const T sf = 1.0/(1<<lambda_);
zuint f = fractionalBits;
T scale = 1.0;
T ffx = fx;
T ffy = fy;
T ffz = fz;
T val = PerlinNoise(seed_,x,y,z,f,ffx,ffy,ffz);
// Add subsequent harmonics
if (octaves_>0)
for (zuint i=1; i<octaves_; i++)
{
// <x,y,z>/2^lambda
f -= lambda_;
ffx *= sf;
ffy *= sf;
ffz *= sf;
// Add scaled harmonic
if (f>=0)
{
scale *= omega_;
val += PerlinNoise(seed_^i,x,y,z,f,ffx,ffy,ffz)*scale;
}
}
return val;
}
case NOISE_TURBULENCE:
{
const T sf = 1.0/(1<<lambda_);
zuint f = fractionalBits;
T scale = 1.0;
T ffx = fx;
T ffy = fy;
T ffz = fz;
T val = fabs(PerlinNoise(seed_,x,y,z,f,ffx,ffy,ffz));
// Add subsequent harmonics
if (octaves_>0)
for (zuint i=1; i<octaves_; i++)
{
// <x,y,z>/2^lambda
f -= lambda_;
ffx *= sf;
ffy *= sf;
ffz *= sf;
// Add scaled harmonic
if (f>=0)
{
scale *= omega_;
val += Abs(PerlinNoise(seed_^i,x,y,z,f,ffx,ffy,ffz)*scale);
}
}
return val;
}
}
}
template <typename T>
T NoisePerlin<T>::Value(const zuint x,const zuint y,const zuint fractionalBits,const T fx,const T fy) const
{
switch (type_)
{
default:
case NOISE_PERLIN:
return PerlinNoise(seed_,x,y,fractionalBits,fx,fy);
case NOISE_FBM:
{
const T sf = 1.0/(1<<lambda_);
zuint f = fractionalBits;
T scale = 1.0;
T ffx = fx;
T ffy = fy;
T val = PerlinNoise(seed_,x,y,f,ffx,ffy);
// Add subsequent harmonics
if (octaves_>0)
for (zuint i=1; i<octaves_; i++)
{
// <x,y,z>/2^lambda
f -= lambda_;
ffx *= sf;
ffy *= sf;
// Add scaled harmonic
if (f>=0)
{
scale *= omega_;
val += PerlinNoise(seed_^i,x,y,f,ffx,ffy)*scale;
}
}
return val;
}
case NOISE_TURBULENCE:
{
const T sf = 1.0/(1<<lambda_);
zuint f = fractionalBits;
T scale = 1.0;
T ffx = fx;
T ffy = fy;
T val = fabs(PerlinNoise(seed_,x,y,f,ffx,ffy));
// Add subsequent harmonics
if (octaves_>0)
for (zuint i=1; i<octaves_; i++)
{
// <x,y,z>/2^lambda
f -= lambda_;
ffx *= sf;
ffy *= sf;
// Add scaled harmonic
if (f>=0)
{
scale *= omega_;
val += Abs(PerlinNoise(seed_^i,x,y,f,ffx,ffy)*scale);
}
}
return val;
}
}
}
template <typename T>
T NoisePerlin<T>::Value(const zuint x,const zuint fractionalBits,const T fx) const
{
switch (type_)
{
default:
case NOISE_PERLIN:
return PerlinNoise(seed_,x,fractionalBits,fx);
case NOISE_FBM:
{
const T sf = 1.0/(1<<lambda_);
zuint f = fractionalBits;
T scale = 1.0;
T ffx = fx;
T val = PerlinNoise(seed_,x,f,ffx);
// Add subsequent harmonics
if (octaves_>0)
for (zuint i=1; i<octaves_; i++)
{
// <x,y,z>/2^lambda
f -= lambda_;
ffx *= sf;
// Add scaled harmonic
if (f>=0)
{
scale *= omega_;
val += PerlinNoise(seed_^i,x,f,ffx)*scale;
}
}
return val;
}
case NOISE_TURBULENCE:
{
const T sf = 1.0/(1<<lambda_);
zuint f = fractionalBits;
T scale = 1.0;
T ffx = fx;
T val = Abs(PerlinNoise(seed_,x,f,ffx));
// Add subsequent harmonics
if (octaves_>0)
for (zuint i=1; i<octaves_; i++)
{
// <x,y,z>/2^lambda
f -= lambda_;
ffx *= sf;
// Add scaled harmonic
if (f>=0)
{
scale *= omega_;
val += Abs(PerlinNoise(seed_^i,x,f,ffx)*scale);
}
}
return val;
}
}
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/NoisePerlin.hpp
|
C++
|
gpl3
| 9,825
|
#include "NoisePerlin.hpp"
namespace zzz{
template<>
const Vector<3,float> NoisePerlin<float> ::vector_[16] =
{
Vector<3,float>(1, 1, 0),
Vector<3,float>(-1, 1, 0),
Vector<3,float>(1,-1, 0),
Vector<3,float>(-1,-1, 0),
Vector<3,float>(1, 0, 1),
Vector<3,float>(-1, 0, 1),
Vector<3,float>(1, 0,-1),
Vector<3,float>(-1, 0,-1),
Vector<3,float>(0, 1, 1),
Vector<3,float>(0,-1, 1),
Vector<3,float>(0, 1,-1),
Vector<3,float>(0,-1,-1),
Vector<3,float>(1, 1, 0),
Vector<3,float>(-1, 1, 0),
Vector<3,float>(0,-1, 1),
Vector<3,float>(0,-1,-1)
};
template<>
float NoisePerlin<float>::PerlinNoise(const zuint seed,const zuint x,const zuint fractionalBits,const float fx)
{
// Some sanity checking in debug mode
assert(fx>=0.0 && fx<=1.0);
assert(fractionalBits<32);
// Determine the integer co-ordinates of the lattice
// interval to be interpolated. Note that the lattice
// tiles seamlessly and fractionalBits are discarded.
const zuint px[2] = { x>>fractionalBits, (x+(1<<fractionalBits))>>fractionalBits };
// The floating-point fx displacement is
// scaled down to be less significant than the
// fractional components of x,y and z
const float subFraction = 1/float(1<<fractionalBits);
// Combine the fractional bits of x and y
// with the floating-point displacements
// to determine the location within the square
float fx0;
Fraction(fx0,(x<<(32-fractionalBits)));
fx0 += fx*subFraction;
// Determine the complement value of fx0
const float fx1 = fx0-1;
// Apply ease-in ease-out curve, rather
// than interpolating linearly
const float wx = Scurve(fx0);
// Temporary storage for interpolation
zuint i;
float vx0, vx1;
// Interpolate along edge from origin in +x direction
i = Hash(seed,px[0]);
vx0 = vector_[i].x()*fx0;
i = Hash(seed,px[1]);
vx1 = vector_[i].x()*fx1;
return vx0 + wx*(vx1-vx0);
}
template<>
float NoisePerlin<float>::PerlinNoise(const zuint seed,const zuint x,const zuint y,const zuint fractionalBits,const float fx,const float fy)
{
// Some sanity checking in debug mode
assert(fx>=0.0 && fx<=1.0);
assert(fy>=0.0 && fy<=1.0);
assert(fractionalBits<32);
// Determine the integer co-ordinates of the lattice
// square to be interpolated. Note that the lattice
// tiles seamlessly and fractionalBits are discarded.
const zuint px[2] = { x>>fractionalBits, (x+(1<<fractionalBits))>>fractionalBits };
const zuint py[2] = { y>>fractionalBits, (y+(1<<fractionalBits))>>fractionalBits };
// The floating-point fx and fy displacements are
// scaled down to be less significant than the
// fractional components of x,y and z
const float subFraction = 1/float(1<<fractionalBits);
// Combine the fractional bits of x and y
// with the floating-point displacements
// to determine the location within the square
float fx0;
Fraction(fx0,(x<<(32-fractionalBits)));
fx0 += fx*subFraction;
float fy0;
Fraction(fy0,(y<<(32-fractionalBits)));
fy0 += fy*subFraction;
// Determine the complement values of fx0 and fy0
const float fx1 = fx0-1;
const float fy1 = fy0-1;
// Apply ease-in ease-out curve, rather
// than interpolating linearly
const float wx = Scurve(fx0);
const float wy = Scurve(fy0);
// Temporary storage for interpolation
zuint i;
float vx0, vx1, vy0, vy1;
// Interpolate along edge from origin in +x direction
i = Hash(seed,px[0],py[0]);
vx0 = vector_[i].x()*fx0 + vector_[i].y()*fy0;
i = Hash(seed,px[1],py[0]);
vx1 = vector_[i].x()*fx1 + vector_[i].y()*fy0;
vy0 = vx0 + wx*(vx1-vx0);
// Interpolate along edge from +y in +x direction
i = Hash(seed,px[0],py[1]);
vx0 = vector_[i].x()*fx0 + vector_[i].y()*fy1;
i = Hash(seed,px[1],py[1]);
vx1 = vector_[i].x()*fx1 + vector_[i].y()*fy1;
vy1 = vx0 + wx*(vx1-vx0);
// Interpolate between the two edges
return vy0 + wy*(vy1-vy0);
}
template<>
float NoisePerlin<float>::PerlinNoise(const zuint seed,const zuint x,const zuint y,const zuint z,const zuint fractionalBits,const float fx,const float fy,const float fz)
{
// Some sanity checking in debug mode
assert(fx>=0.0 && fx<=1.0);
assert(fy>=0.0 && fy<=1.0);
assert(fz>=0.0 && fz<=1.0);
assert(fractionalBits<32);
// Determine the integer co-ordinates of the lattice
// cube to be interpolated. Note that the lattice
// tiles seamlessly and fractionalBits are discarded.
const zuint px[2] = { x>>fractionalBits, (x+(1<<fractionalBits))>>fractionalBits };
const zuint py[2] = { y>>fractionalBits, (y+(1<<fractionalBits))>>fractionalBits };
const zuint pz[2] = { z>>fractionalBits, (z+(1<<fractionalBits))>>fractionalBits };
// The floating-point fx,fy,fz displacements are
// scaled down to be less significant than the
// fractional components of x,y and z
const float subFraction = 1/float(1<<fractionalBits);
// Combine the fractional bits of x,y and z
// with the floating-point displacements
// to determine the location within the cube
float fx0;
Fraction(fx0,(x<<(32-fractionalBits)));
fx0 += fx*subFraction;
float fy0;
Fraction(fy0,(y<<(32-fractionalBits)));
fy0 += fy*subFraction;
float fz0;
Fraction(fz0,(z<<(32-fractionalBits)));
fz0 += fz*subFraction;
// Determine the complement values of fx0,fy0 and fz0
const float fx1 = fx0-1;
const float fy1 = fy0-1;
const float fz1 = fz0-1;
// Apply ease-in ease-out curve, rather
// than interpolating linearly
const float wx = Scurve(fx0);
const float wy = Scurve(fy0);
const float wz = Scurve(fz0);
// Temporary storage for interpolation
zuint i;
float vx0, vx1, vy0, vy1, vz0, vz1;
// Interpolate along edge from origin in +x direction
i = Hash(seed,px[0],py[0],pz[0]);
vx0 = vector_[i].x()*fx0 + vector_[i].y()*fy0 + vector_[i].z()*fz0;
i = Hash(seed,px[1],py[0],pz[0]);
vx1 = vector_[i].x()*fx1 + vector_[i].y()*fy0 + vector_[i].z()*fz0;
vy0 = vx0 + wx*(vx1-vx0);
// Interpolate along edge from +y in +x direction
i = Hash(seed,px[0],py[1],pz[0]);
vx0 = vector_[i].x()*fx0 + vector_[i].y()*fy1 + vector_[i].z()*fz0;
i = Hash(seed,px[1],py[1],pz[0]);
vx1 = vector_[i].x()*fx1 + vector_[i].y()*fy1 + vector_[i].z()*fz0;
vy1 = vx0 + wx*(vx1-vx0);
// Interpolate between the two edges
vz0 = vy0 + wy*(vy1-vy0);
// Interpolate along edge from +z in +x direction
i = Hash(seed,px[0],py[0],pz[1]);
vx0 = vector_[i].x()*fx0 + vector_[i].y()*fy0 + vector_[i].z()*fz1;
i = Hash(seed,px[1],py[0],pz[1]);
vx1 = vector_[i].x()*fx1 + vector_[i].y()*fy0 + vector_[i].z()*fz1;
vy0 = vx0 + wx*(vx1-vx0);
// Interpolate along edge from +y+z in +x direction
i = Hash(seed,px[0],py[1],pz[1]);
vx0 = vector_[i].x()*fx0 + vector_[i].y()*fy1 + vector_[i].z()*fz1;
i = Hash(seed,px[1],py[1],pz[1]);
vx1 = vector_[i].x()*fx1 + vector_[i].y()*fy1 + vector_[i].z()*fz1;
vy1 = vx0 + wx*(vx1-vx0);
// Interpolate between the two +z edges
vz1 = vy0 + wy*(vy1-vy0);
// Finally, interpolate betwen the two planes
return vz0 + wz*(vz1-vz0);
}
//////////////////////////////////////////////////////////////////////////
template<>
const Vector<3,double> NoisePerlin<double>::vector_[16] =
{
Vector<3,double>(1, 1, 0),
Vector<3,double>(-1, 1, 0),
Vector<3,double>(1,-1, 0),
Vector<3,double>(-1,-1, 0),
Vector<3,double>(1, 0, 1),
Vector<3,double>(-1, 0, 1),
Vector<3,double>(1, 0,-1),
Vector<3,double>(-1, 0,-1),
Vector<3,double>(0, 1, 1),
Vector<3,double>(0,-1, 1),
Vector<3,double>(0, 1,-1),
Vector<3,double>(0,-1,-1),
Vector<3,double>(1, 1, 0),
Vector<3,double>(-1, 1, 0),
Vector<3,double>(0,-1, 1),
Vector<3,double>(0,-1,-1)
};
template<>
double NoisePerlin<double>::PerlinNoise(const zuint seed,const zuint x,const zuint fractionalBits,const double fx)
{
// Some sanity checking in debug mode
assert(fx>=0.0 && fx<=1.0);
assert(fractionalBits<32);
// Determine the integer co-ordinates of the lattice
// interval to be interpolated. Note that the lattice
// tiles seamlessly and fractionalBits are discarded.
const zuint px[2] = { x>>fractionalBits, (x+(1<<fractionalBits))>>fractionalBits };
// The floating-point fx displacement is
// scaled down to be less significant than the
// fractional components of x,y and z
const double subFraction = 1/double(1<<fractionalBits);
// Combine the fractional bits of x and y
// with the floating-point displacements
// to determine the location within the square
double fx0;
Fraction(fx0,(x<<(32-fractionalBits)));
fx0 += fx*subFraction;
// Determine the complement value of fx0
const double fx1 = fx0-1;
// Apply ease-in ease-out curve, rather
// than interpolating linearly
const double wx = Scurve(fx0);
// Temporary storage for interpolation
zuint i;
double vx0, vx1;
// Interpolate along edge from origin in +x direction
i = Hash(seed,px[0]);
vx0 = vector_[i].x()*fx0;
i = Hash(seed,px[1]);
vx1 = vector_[i].x()*fx1;
return vx0 + wx*(vx1-vx0);
}
template<>
double NoisePerlin<double>::PerlinNoise(const zuint seed,const zuint x,const zuint y,const zuint fractionalBits,const double fx,const double fy)
{
// Some sanity checking in debug mode
assert(fx>=0.0 && fx<=1.0);
assert(fy>=0.0 && fy<=1.0);
assert(fractionalBits<32);
// Determine the integer co-ordinates of the lattice
// square to be interpolated. Note that the lattice
// tiles seamlessly and fractionalBits are discarded.
const zuint px[2] = { x>>fractionalBits, (x+(1<<fractionalBits))>>fractionalBits };
const zuint py[2] = { y>>fractionalBits, (y+(1<<fractionalBits))>>fractionalBits };
// The floating-point fx and fy displacements are
// scaled down to be less significant than the
// fractional components of x,y and z
const double subFraction = 1/double(1<<fractionalBits);
// Combine the fractional bits of x and y
// with the floating-point displacements
// to determine the location within the square
double fx0;
Fraction(fx0,(x<<(32-fractionalBits)));
fx0 += fx*subFraction;
double fy0;
Fraction(fy0,(y<<(32-fractionalBits)));
fy0 += fy*subFraction;
// Determine the complement values of fx0 and fy0
const double fx1 = fx0-1;
const double fy1 = fy0-1;
// Apply ease-in ease-out curve, rather
// than interpolating linearly
const double wx = Scurve(fx0);
const double wy = Scurve(fy0);
// Temporary storage for interpolation
zuint i;
double vx0, vx1, vy0, vy1;
// Interpolate along edge from origin in +x direction
i = Hash(seed,px[0],py[0]);
vx0 = vector_[i].x()*fx0 + vector_[i].y()*fy0;
i = Hash(seed,px[1],py[0]);
vx1 = vector_[i].x()*fx1 + vector_[i].y()*fy0;
vy0 = vx0 + wx*(vx1-vx0);
// Interpolate along edge from +y in +x direction
i = Hash(seed,px[0],py[1]);
vx0 = vector_[i].x()*fx0 + vector_[i].y()*fy1;
i = Hash(seed,px[1],py[1]);
vx1 = vector_[i].x()*fx1 + vector_[i].y()*fy1;
vy1 = vx0 + wx*(vx1-vx0);
// Interpolate between the two edges
return vy0 + wy*(vy1-vy0);
}
template<>
double NoisePerlin<double>::PerlinNoise(const zuint seed,const zuint x,const zuint y,const zuint z,const zuint fractionalBits,const double fx,const double fy,const double fz)
{
// Some sanity checking in debug mode
assert(fx>=0.0 && fx<=1.0);
assert(fy>=0.0 && fy<=1.0);
assert(fz>=0.0 && fz<=1.0);
assert(fractionalBits<32);
// Determine the integer co-ordinates of the lattice
// cube to be interpolated. Note that the lattice
// tiles seamlessly and fractionalBits are discarded.
const zuint px[2] = { x>>fractionalBits, (x+(1<<fractionalBits))>>fractionalBits };
const zuint py[2] = { y>>fractionalBits, (y+(1<<fractionalBits))>>fractionalBits };
const zuint pz[2] = { z>>fractionalBits, (z+(1<<fractionalBits))>>fractionalBits };
// The floating-point fx,fy,fz displacements are
// scaled down to be less significant than the
// fractional components of x,y and z
const double subFraction = 1/double(1<<fractionalBits);
// Combine the fractional bits of x,y and z
// with the floating-point displacements
// to determine the location within the cube
double fx0;
Fraction(fx0,(x<<(32-fractionalBits)));
fx0 += fx*subFraction;
double fy0;
Fraction(fy0,(y<<(32-fractionalBits)));
fy0 += fy*subFraction;
double fz0;
Fraction(fz0,(z<<(32-fractionalBits)));
fz0 += fz*subFraction;
// Determine the complement values of fx0,fy0 and fz0
const double fx1 = fx0-1;
const double fy1 = fy0-1;
const double fz1 = fz0-1;
// Apply ease-in ease-out curve, rather
// than interpolating linearly
const double wx = Scurve(fx0);
const double wy = Scurve(fy0);
const double wz = Scurve(fz0);
// Temporary storage for interpolation
zuint i;
double vx0, vx1, vy0, vy1, vz0, vz1;
// Interpolate along edge from origin in +x direction
i = Hash(seed,px[0],py[0],pz[0]);
vx0 = vector_[i].x()*fx0 + vector_[i].y()*fy0 + vector_[i].z()*fz0;
i = Hash(seed,px[1],py[0],pz[0]);
vx1 = vector_[i].x()*fx1 + vector_[i].y()*fy0 + vector_[i].z()*fz0;
vy0 = vx0 + wx*(vx1-vx0);
// Interpolate along edge from +y in +x direction
i = Hash(seed,px[0],py[1],pz[0]);
vx0 = vector_[i].x()*fx0 + vector_[i].y()*fy1 + vector_[i].z()*fz0;
i = Hash(seed,px[1],py[1],pz[0]);
vx1 = vector_[i].x()*fx1 + vector_[i].y()*fy1 + vector_[i].z()*fz0;
vy1 = vx0 + wx*(vx1-vx0);
// Interpolate between the two edges
vz0 = vy0 + wy*(vy1-vy0);
// Interpolate along edge from +z in +x direction
i = Hash(seed,px[0],py[0],pz[1]);
vx0 = vector_[i].x()*fx0 + vector_[i].y()*fy0 + vector_[i].z()*fz1;
i = Hash(seed,px[1],py[0],pz[1]);
vx1 = vector_[i].x()*fx1 + vector_[i].y()*fy0 + vector_[i].z()*fz1;
vy0 = vx0 + wx*(vx1-vx0);
// Interpolate along edge from +y+z in +x direction
i = Hash(seed,px[0],py[1],pz[1]);
vx0 = vector_[i].x()*fx0 + vector_[i].y()*fy1 + vector_[i].z()*fz1;
i = Hash(seed,px[1],py[1],pz[1]);
vx1 = vector_[i].x()*fx1 + vector_[i].y()*fy1 + vector_[i].z()*fz1;
vy1 = vx0 + wx*(vx1-vx0);
// Interpolate between the two +z edges
vz1 = vy0 + wy*(vy1-vy0);
// Finally, interpolate betwen the two planes
return vz0 + wz*(vz1-vz0);
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/NoisePerlin.cpp
|
C++
|
gpl3
| 14,130
|
#include "HeightMap.hpp"
#include "Graphics.hpp"
#include <Math/Random.hpp>
namespace zzz{
HeightMap::HeightMap()
{
Left_ = -(MAP_SIZE / 2);
Right_ = MAP_SIZE / 2;
Front_ = MAP_SIZE / 2;
Back_ = -(MAP_SIZE / 2);
Generate();
}
HeightMap::~HeightMap()
{
}
float HeightMap::GetHeight(int x, int y)
{
return HeightMap_[ToIndex(x,y)];
}
void HeightMap::SetHeight(int X, int Y, float h)
{
HeightMap_[ToIndex(X,Y)]=h;
}
bool HeightMap::SetVertexColor(int x, int y)
{
float fColor = float((GetHeight(x, y) / 256.0f) + 0.15);
// Assign This Blue Shade To The Current Vertex
glColor4f(fColor, fColor, fColor, 1.0f);
return(true);
}
void HeightMap::GetVertexColor(int x, int y, float *col)
{
if(!col) return;
float fColor = float((GetHeight(x, y) / 256.0f) + 0.20);
// Assign This Blue Shade To The Current Vertex
col[0] = fColor;
col[1] = fColor;
col[2] = fColor;
col[3] = 1.0f;
}
void HeightMap::DrawHeightMap(float drawsize)
{
glBegin(GL_QUADS);
for (float X = Left_; X < Right_; X++)
{
for (float Y = Back_; Y < Front_; Y++)
{
SetVertexColor(X,Y);
glVertex3f(X/MAP_SIZE/2*drawsize,GetHeight(X,Y)/MAP_SIZE/2*drawsize,Y/MAP_SIZE/2*drawsize);
SetVertexColor(X+1,Y);
glVertex3f((X+1)/MAP_SIZE/2*drawsize,GetHeight(X+1,Y)/MAP_SIZE/2*drawsize,Y/MAP_SIZE/2*drawsize);
SetVertexColor(X+1,Y+1);
glVertex3f((X+1)/MAP_SIZE/2*drawsize,GetHeight(X+1,Y+1)/MAP_SIZE/2*drawsize,(Y+1)/MAP_SIZE/2*drawsize);
SetVertexColor(X,Y+1);
glVertex3f(X/MAP_SIZE/2*drawsize,GetHeight(X,Y+1)/MAP_SIZE/2*drawsize,(Y+1)/MAP_SIZE/2*drawsize);
}
}
glEnd();
}
void HeightMap::Generate()
{
RandSeed();
HeightMap_[0]=0;
for (int i=Back_+1; i<=Front_; i++)
HeightMap_[ToIndex(Left_,i)]=HeightMap_[ToIndex(Left_,i-1)]+UniformRand(-0.5f,1.5f);
for (int i=Left_+1; i<=Right_; i++)
{
HeightMap_[ToIndex(i,Back_)]=HeightMap_[ToIndex(i-1,Back_)]+UniformRand(-0.5f,1.5f);
for (int j=Back_+1; j<=Front_; j++)
HeightMap_[ToIndex(i,j)]=HeightMap_[ToIndex(i-1,j)]/2.0+HeightMap_[ToIndex(i,j-1)]/2.0+UniformRand(-0.5f,1.5f);
}
}
int HeightMap::ToIndex(int x, int y) const
{
x+=MAP_SIZE/2;
y+=MAP_SIZE/2;
if(x >= 0 && x <= MAP_SIZE && y >= 0 && y <= MAP_SIZE)
{
return x*(MAP_SIZE+1)+y;
}
return 0;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/HeightMap.cpp
|
C++
|
gpl3
| 2,407
|
#include "ArcBall.hpp"
namespace zzz{
ArcBall::ArcBall()
{
rot.Identical();
anchor_rot.Identical();
comb.Identical();
trans.Identical();
inv_rotate=false;
combine=false;
mode2d=false;
}
void ArcBall::SetWindowSize(double w, double h)
{
win_w = w;
win_h = h;
}
void ArcBall::SetOldPos(double x, double y)
{
old_x = x;
old_y = y;
Bind();
}
void ArcBall::Rotate(double x, double y)
{
double ox, oy, cx, cy;
ox = old_x;
oy = old_y;
cx = x;
cy = y;
Normalize(ox, oy);
Normalize(cx, cy);
Quaternion<double> incr;
if (mode2d)
{
double old_theta=atan2(oy,ox);
double theta=atan2(cy,cx);
incr.SetAxisAngle(Vector<3,double>(0,0,1),theta-old_theta);
rot = incr*anchor_rot;
}
else
{
Vector<3,double> oldp(ox, oy, 0.0), currp(cx, cy, 0.0);
ProjectOntoSurface(oldp);
ProjectOntoSurface(currp);
//this is not axis and angle, is quaternion values
Quaternion<double> q1(oldp[0],oldp[1],oldp[2], 0.0);
Quaternion<double> q2(currp[0],currp[1],currp[2], 0.0);
if (inv_rotate)
{
incr = q1*q2;
rot = anchor_rot*incr;
}
else
{
incr = q2*q1;
if(combine)
rot = incr*anchor_rot*comb;
else
rot = incr*anchor_rot;
}
}
rot.Normalize();
trans=Transformation<double>(Rotation<double>(rot));
}
void ArcBall::Reset()
{
rot.Identical();
anchor_rot.Identical();
trans.Identical();
}
Vector<3,double> ArcBall::GetAxis()
{
return rot.Axis();
}
double ArcBall::GetAngle()
{
return rot.Angle();
}
const GLTransformation<double>& ArcBall::GetGLTransform() const
{
return trans;
}
const double* ArcBall::GetGLRotateMatrix() const
{
return trans.Data();
}
void ArcBall::SetInverse(bool val)
{
inv_rotate = val;
}
void ArcBall::CombineRotation(const Quaternion<double> &q)
{
comb = q;
combine = true;
}
void ArcBall::StopCombineRotation()
{
combine = false;
}
const Quaternion<double> ArcBall::GetQuaternion() const
{
return rot;
}
void ArcBall::SetMode2D(bool val)
{
mode2d=val;
}
bool ArcBall::GetMode2D()
{
return mode2d;
}
void ArcBall::ApplyGL() const
{
GetGLTransform().ApplyGL();
}
/// anchors the current rotation
void ArcBall::Bind()
{
anchor_rot = rot;
}
void ArcBall::Normalize(double &x, double &y)
{
x = 2.0 * x / win_w - 1.0;
if (x < -1.0) x = -1.0;
if (x > 1.0) x = 1.0;
y = -(2.0 * y / win_h - 1.0);
if (y < -1.0) y = -1.0;
if (y > 1.0) y = 1.0;
}
void ArcBall::ProjectOntoSurface(Vector<3,double> &v)
{
double radius2 = 1.0;
double len2 = v[0]*v[0] + v[1]*v[1];
if (len2 <= radius2 / 2.0)
v[2] = sqrt(radius2 - len2);
else
v[2] = radius2 / (2 * sqrt(len2));
len2 = sqrt(len2 + v[2]*v[2]);
for (int i = 0; i < 3; ++i) v[i] /= len2;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/ArcBall.cpp
|
C++
|
gpl3
| 2,992
|
#pragma once
#include "../Haar/HaarCoeffCubemap4Triple.hpp"
#include "../SH/SHCoeff.hpp"
#include <Math/Vector3.hpp>
namespace zzz{
template <int HAARN, int SHN, typename T1=float, typename T2=unsigned short >
class HaarSHTransformMatrix
{
public:
typedef T1 VALUE_TYPE;
typedef T2 INDEX_TYPE;
static const int rown_=SHN*SHN;
static const int coln_=HAARN;
Vector<3,VALUE_TYPE> value[HAARN][SHN*SHN];
VALUE_TYPE scale[6][SHN*SHN];
INDEX_TYPE index[HAARN];
inline void operator=(const HaarSHTransformMatrix<HAARN,SHN,VALUE_TYPE,INDEX_TYPE> &f)
{
memcpy(scale[0],f.scale[0],sizeof(VALUE_TYPE)*SHN*SHN);
memcpy(scale[1],f.scale[1],sizeof(VALUE_TYPE)*SHN*SHN);
memcpy(scale[2],f.scale[2],sizeof(VALUE_TYPE)*SHN*SHN);
memcpy(scale[3],f.scale[3],sizeof(VALUE_TYPE)*SHN*SHN);
memcpy(scale[4],f.scale[4],sizeof(VALUE_TYPE)*SHN*SHN);
memcpy(scale[5],f.scale[5],sizeof(VALUE_TYPE)*SHN*SHN);
for (int i=0; i<HAARN; i++)
memcpy(value[i],f.value[i],sizeof(Vector<3,VALUE_TYPE>)*SHN*SHN);
memcpy(index,f.index,sizeof(INDEX_TYPE)*HAARN);
}
struct _sortnode{VALUE_TYPE sum;INDEX_TYPE index;int pos;};
struct _SumGreater{bool operator()(const _sortnode &x,const _sortnode &y){return x.sum>y.sum;}};
struct _IndexLess{bool operator()(const _sortnode &x,const _sortnode &y){return x.index<y.index;}};
inline void operator+=(const HaarSHTransformMatrix<HAARN,SHN,VALUE_TYPE,INDEX_TYPE> &f)
{
for (int i=0; i<6; i++) for (int j=0; j<SHN*SHN; j++)
scale[i][j]+=f.scale[i][j];
Vector<3,VALUE_TYPE> sortdata[HAARN*2][SHN*SHN];
_sortnode sortsum[HAARN*2];
int cur=0,cur2=0;
for (int cur1=0;cur1<HAARN;cur1++)
{
while (cur2<HAARN && index[cur1]>f.index[cur2])
{
sortsum[cur].sum=0;
sortsum[cur].index=f.index[cur2];
sortsum[cur].pos=cur;
for (int j=0; j<SHN*SHN; j++)
{
sortdata[cur][j]=f.value[cur2][j];
sortsum[cur].sum+=abs(sortdata[cur][j].AbsMax());
}
cur++;cur2++;
}
if (cur2<HAARN && index[cur1]==f.index[cur2])
{
sortsum[cur].sum=0;
sortsum[cur].index=index[cur1];
sortsum[cur].pos=cur;
for (int j=0; j<SHN*SHN; j++)
{
sortdata[cur][j]=value[cur1][j]+f.value[cur2][j];
sortsum[cur].sum+=abs(sortdata[cur][j].AbsMax());
}
cur++;cur2++;
continue;
}
if ((cur2>=HAARN) || (cur2<HAARN && index[cur1]<f.index[cur2]))
{
sortsum[cur].sum=0;
sortsum[cur].index=index[cur1];
sortsum[cur].pos=cur;
for (int j=0; j<SHN*SHN; j++)
{
sortdata[cur][j]=value[cur1][j];
sortsum[cur].sum+=abs(sortdata[cur][j].AbsMax());
}
cur++;
continue;
}
}
while (cur2<HAARN)
{
sortsum[cur].sum=0;
sortsum[cur].index=f.index[cur2];
sortsum[cur].pos=cur;
for (int j=0; j<SHN*SHN; j++)
{
sortdata[cur][j]=f.value[cur2][j];
sortsum[cur].sum+=abs(sortdata[cur][j].AbsMax());
}
cur++;cur2++;
}
nth_element(sortsum,sortsum+HAARN,sortsum+cur,_SumGreater());
std::sort(sortsum,sortsum+HAARN,_IndexLess());
for (int i=0; i<HAARN; i++) for (int j=0; j<SHN*SHN; j++)
value[i][j]=sortdata[sortsum[i].pos][j];
for (int i=0; i<HAARN; i++)
index[i]=sortsum[i].index;
}
inline void operator*=(const VALUE_TYPE f)
{
for (int i=0; i<6; i++) for (int j=0; j<SHN*SHN; j++)
scale[i][j]*=f;
for (int i=0; i<HAARN; i++) for (int j=0; j<SHN*SHN; j++)
value[i][j]*=f;
}
inline void operator/=(const VALUE_TYPE f)
{
for (int i=0; i<6; i++) for (int j=0; j<SHN*SHN; j++)
scale[i][j]/=f;
for (int i=0; i<HAARN; i++) for (int j=0; j<SHN*SHN; j++)
value[i][j]/=f;
}
inline void Zero()
{
memset(scale[0],0,sizeof(VALUE_TYPE)*SHN*SHN);
memset(scale[1],0,sizeof(VALUE_TYPE)*SHN*SHN);
memset(scale[2],0,sizeof(VALUE_TYPE)*SHN*SHN);
memset(scale[3],0,sizeof(VALUE_TYPE)*SHN*SHN);
memset(scale[4],0,sizeof(VALUE_TYPE)*SHN*SHN);
memset(scale[5],0,sizeof(VALUE_TYPE)*SHN*SHN);
memset(index,0,sizeof(INDEX_TYPE)*HAARN);
for (int i=0; i<HAARN; i++)
memset(value[i],0,sizeof(Vector<3,VALUE_TYPE>)*SHN*SHN);
}
inline Vector<3,VALUE_TYPE> &At(int haar,int sh)
{
return value[haar][sh];
}
inline const Vector<3,VALUE_TYPE> &At(int haar,int sh) const
{
return value[haar,sh];
}
inline INDEX_TYPE& Index(int n)
{
return index[n];
}
inline const INDEX_TYPE& Index(int n) const
{
return index[n];
}
inline void sort()
{
struct _sort
{
INDEX_TYPE index;
int pos;
bool operator<(const _sort &c) const{return index<c.index;}
}sortindex[HAARN];
for (int i=0; i<HAARN; i++)
{
sortindex[i].index=index[i];
sortindex[i].pos=i;
}
sort(sortindex,sortindex+HAARN);
Vector<3,VALUE_TYPE> tmp[HAARN][SHN*SHN];
for (int i=0; i<HAARN; i++)
memcpy(tmp[i],value[i],sizeof(Vector<3,VALUE_TYPE>)*SHN*SHN);
for (int i=0; i<HAARN; i++) for (int j=0; j<SHN*SHN; j++)
value[i][j]=tmp[sortindex[i].pos][j];
for (int i=0; i<HAARN; i++)
index[i]=sortindex[i];
}
template <int CUBEFACEN>
inline void Multiply(const HaarCoeffCubemap4TripleSparse<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &h, SHCoeff<SHN,VALUE_TYPE> &res)
{
res.Zero();
for (int j=0; j<SHN*SHN; j++)
for (int i=0; i<6; i++)
{
res.v[j]+=scale[i][j]*h.Scale[i];
}
int cur2=0;
for(int cur1=0;cur1<HAARN;cur1++)
{
while(cur2<h.Size && h.Coeff[cur2].index<index[cur1]) cur2++;
if (cur2==h.Size) break;
if (h.Coeff[cur2].index==index[cur1])
{
for (int i=0; i<SHN*SHN; i++)
res.v[i]+=value[cur1][i].Dot(h.Coeff[cur2].value);
}
}
}
template <int CUBEFACEN>
inline void Multiply(const HaarCoeffCubemap4TripleSparse<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &h, SHCoeff4f_SSE &res)
{
res.Zero();
for (int j=0; j<SHN*SHN; j++)
for (int i=0; i<6; i++)
{
res.v[j]+=scale[i][j]*h.Scale[i];
}
for(int cur1=0,cur2=0;cur1<HAARN;cur1++)
{
#ifdef SPARSENEW
int idx=index[cur1];
int pos=h.IndexToLocal[idx];
if (pos==0) continue;
else
{
for (int i=0; i<SHN*SHN; i++)
res.v[i]+=value[cur1][i].Dot(h.Coeff[pos].value);
}
#else
while(cur2<h.Size && h.Coeff[cur2].index<index[cur1]) cur2++;
if (cur2==h.Size) break;
if (h.Coeff[cur2].index==index[cur1])
{
for (int i=0; i<SHN*SHN; i++)
res.v[i]+=value[cur1][i].Dot(h.Coeff[cur2].value);
}
#endif
}
}
template <int CUBEFACEN,int KEEPNUM>
inline void Multiply(const HaarCoeffCubemap4TripleSparseStatic<CUBEFACEN,KEEPNUM,VALUE_TYPE,INDEX_TYPE> &h, SHCoeff4f_SSE &res)
{
res.Zero();
for (int j=0; j<SHN*SHN; j++)
for (int i=0; i<6; i++)
{
res.v[j]+=scale[i][j]*h.Scale[i];
}
int cur2=0;
for(int cur1=0;cur1<HAARN;cur1++)
{
while(cur2<KEEPNUM && h.Coeff[cur2].index<index[cur1]) cur2++;
if (cur2==KEEPNUM) break;
if (h.Coeff[cur2].index==index[cur1])
{
for (int i=0; i<SHN*SHN; i++)
res.v[i]+=value[cur1][i].Dot(h.Coeff[cur2].value);
}
}
}
template <int CUBEFACEN>
inline void Multiply(const HaarCoeffCubemap4TripleFull<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &h, SHCoeff<SHN,VALUE_TYPE> &res)
{
res.Zero();
for (int j=0; j<SHN*SHN; j++) for (int i=0; i<6; i++)
{
res.v[j]+=scale[i][j]*h.Scale[i];
}
for(int cur1=0;cur1<HAARN;cur1++)
{
for (int i=0; i<SHN*SHN; i++)
res.v[i]+=value[cur1][i].Dot(h.Square[index[cur1]]);
}
}
template <int CUBEFACEN>
inline void Multiply(const HaarCoeffCubemap4TripleFull<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &h, SHCoeff4f_SSE &res)
{
res.Zero();
for (int j=0; j<SHN*SHN; j++) for (int i=0; i<6; i++)
{
res.v[j]+=scale[i][j]*h.Scale[i];
}
for(int cur1=0;cur1<HAARN;cur1++)
{
for (int i=0; i<SHN*SHN; i++)
res.v[i]+=value[cur1][i].Dot(h.Square[index[cur1]]);
}
}
};
template <int SHN, typename T1=float, typename T2=unsigned short >
class HaarSHTransformMatrixDynamic
{
public:
typedef T1 VALUE_TYPE;
typedef T2 INDEX_TYPE;
Vector<3,VALUE_TYPE> **value;
VALUE_TYPE scale[6][SHN*SHN];
INDEX_TYPE *index;
int Size;
HaarSHTransformMatrixDynamic()
{
Size=0;
value=NULL;
index=NULL;
for (int i=0; i<6; i++)
memset(scale[i],0,sizeof(VALUE_TYPE)*SHN*SHN);
}
~HaarSHTransformMatrixDynamic()
{
Clear();
}
inline void Create(int n)
{
if (Size==n) return;
if (value)
for (int i=0; i<Size; i++)
delete[] value[i];
delete[] value;
value=NULL;
delete[] index;
index=NULL;
Size=n;
value=new Vector<3,VALUE_TYPE>*[Size];
for (int i=0; i<Size; i++)
value[i]=new Vector<3,VALUE_TYPE>[SHN*SHN];
index=new INDEX_TYPE[Size];
}
inline void Clear()
{
memset(scale[0],0,sizeof(VALUE_TYPE)*SHN*SHN);
memset(scale[1],0,sizeof(VALUE_TYPE)*SHN*SHN);
memset(scale[2],0,sizeof(VALUE_TYPE)*SHN*SHN);
memset(scale[3],0,sizeof(VALUE_TYPE)*SHN*SHN);
memset(scale[4],0,sizeof(VALUE_TYPE)*SHN*SHN);
memset(scale[5],0,sizeof(VALUE_TYPE)*SHN*SHN);
if (value)
for (int i=0; i<Size; i++)
delete[] value[i];
delete[] value;
value=NULL;
delete[] index;
index=NULL;
Size=0;
}
template <int HAARN>
inline void operator=(const HaarSHTransformMatrix<HAARN,SHN,VALUE_TYPE,INDEX_TYPE> &f)
{
Clear();
for (int i=0; i<6; i++)
memcpy(scale[i],f.scale[i],sizeof(VALUE_TYPE)*SHN*SHN);
Size=HAARN;
value=new Vector<3,VALUE_TYPE>*[Size];
for (int i=0; i<Size; i++)
value[i]=new Vector<3,VALUE_TYPE>[SHN*SHN];
index=new INDEX_TYPE[Size];
for (int i=0; i<Size; i++)
{
memcpy(value[i],f.value[i],sizeof(Vector<3,VALUE_TYPE>)*SHN*SHN);
}
memcpy(index,f.index,sizeof(INDEX_TYPE)*Size);
}
template <int HAARN>
inline void operator+=(const HaarSHTransformMatrix<HAARN,SHN,VALUE_TYPE,INDEX_TYPE> &f)
{
for (int i=0; i<6; i++) for (int j=0; j<SHN*SHN; j++)
scale[i][j]+=f.scale[i][j];
Vector<3,VALUE_TYPE> **sortdata;
sortdata=new Vector<3,VALUE_TYPE>*[HAARN+Size];
for (int i=0; i<HAARN+Size; i++)
sortdata[i]=new Vector<3,VALUE_TYPE>[SHN*SHN];
INDEX_TYPE *sortindex=new INDEX_TYPE[HAARN+Size];
int cur=0,cur2=0;
for (int cur1=0;cur1<Size;cur1++)
{
while (cur2<HAARN && index[cur1]>f.index[cur2])
{
for (int j=0; j<SHN*SHN; j++)
sortdata[cur][j]=f.value[cur2][j];
sortindex[cur]=f.index[cur2];
cur++;cur2++;
}
if (cur2<HAARN && index[cur1]==f.index[cur2])
{
for (int j=0; j<SHN*SHN; j++)
sortdata[cur][j]=value[cur1][j]+f.value[cur2][j];
sortindex[cur]=index[cur1];
cur++;cur2++;
continue;
}
if ((cur2>=HAARN) || (cur2<HAARN && index[cur1]<f.index[cur2]))
{
for (int j=0; j<SHN*SHN; j++)
sortdata[cur][j]=value[cur1][j];
sortindex[cur]=index[cur1];
cur++;
continue;
}
}
for (int i=0; i<Size; i++)
delete[] value[i];
delete[] value;
value=sortdata;
Size=cur;
delete[] index;
index=sortindex;
}
inline void Zero()
{
Clear();
}
template <int CUBEFACEN>
inline void Multiply(const HaarCoeffCubemap4TripleSparse<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &h, SHCoeff<SHN,VALUE_TYPE> &res)
{
res.Zero();
for (int j=0; j<SHN*SHN; j++)
for (int i=0; i<6; i++)
{
res.v[j]+=scale[i][j]*h.Scale[i];
}
for(int cur1=0,cur2=0;cur1<Size;cur1++)
{
while(cur2<h.Size && h.Coeff[cur2].index<index[cur1]) cur2++;
if (cur2==h.Size) break;
if (h.Coeff[cur2].index==index[cur1])
{
for (int i=0; i<SHN*SHN; i++)
res.v[i]+=value[cur1][i].Dot(h.Coeff[cur2].value);
}
}
}
template <int CUBEFACEN>
inline void Multiply(const HaarCoeffCubemap4TripleSparse<CUBEFACEN,VALUE_TYPE,INDEX_TYPE> &h, SHCoeff4f_SSE &res)
{
res.Zero();
for (int j=0; j<SHN*SHN; j++)
for (int i=0; i<6; i++)
{
res.v[j]+=scale[i][j]*h.Scale[i];
}
for(int cur1=0,cur2=0;cur1<Size;cur1++)
{
while(cur2<h.Size && h.Coeff[cur2].index<index[cur1]) cur2++;
if (cur2==h.Size) break;
if (h.Coeff[cur2].index==index[cur1])
{
for (int i=0; i<SHN*SHN; i++)
res.v[i]+=value[cur1][i].Dot(h.Coeff[cur2].value);
}
}
}
};
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/TransformMatrix/HaarSHTransformMatrix.hpp
|
C++
|
gpl3
| 13,236
|
#include "BMPFont.hpp"
#include <common.hpp>
#include <Math/Vector4.hpp>
#include <Math/Array.hpp>
#include "Graphics.hpp"
#include "BMPFontData.hpp"
#include "OpenGLTools.hpp"
namespace zzz{
Array<2,zuchar> data;
void BMPFont::Draw(const string &msg)
{
int msglen=msg.size();
zuchar *charidx=new zuchar[msglen];
for (int i=0; i<msglen; i++) charidx[i]=msg[i];
Array<2,zuchar> img(Vector2ui(fontheight,fontwidth*msglen));
zuchar *cur=img.Data();
for (int i=0; i<fontheight; i++) for (int j=0; j<msglen; j++)
{
memcpy(cur,data.Data()+data.ToIndex(Vector2ui(i,charidx[j]*fontwidth)),fontwidth);
cur+=fontwidth;
}
glDrawPixels(fontwidth*msglen,fontheight,GL_LUMINANCE,GL_UNSIGNED_BYTE,img.Data());
CHECK_GL_ERROR()
delete[] charidx;
}
void BMPFont::DrawFont()
{
glDrawPixels(fontwidth*256,fontheight,GL_LUMINANCE,GL_UNSIGNED_BYTE,data.Data());
}
BMPFont::BMPFont()
{
data.SetSize(Vector2ui(fontheight,256*fontwidth));
memcpy(data.Data(),fontmap,fontwidth*fontheight*256);
}
Vector2i BMPFont::Size(const string &msg)
{
return Vector2i(fontwidth*msg.size(),fontheight);
}
zuint BMPFont::FontHeight() const
{
return fontheight;
}
zuint BMPFont::FontWidth() const
{
return fontwidth;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/BMPFont.cpp
|
C++
|
gpl3
| 1,278
|
#pragma once
#include "OpenGLTools.hpp"
#include <Math/Vector3.hpp>
namespace zzz{
template <typename T>
class Translation : public Vector<3,T>
{
using Vector<3,T>::v;
public:
Translation():Vector<3,T>(0){}
Translation(const Translation<T> &other):Vector<3,T>(other.v){}
Translation(const T x, const T y, const T z):Vector<3,T>(x,y,z){}
explicit Translation(const VectorBase<3,T> &other):Vector<3,T>(other){}
using Vector<3,T>::operator=;
VectorBase<3,T> Apply(const VectorBase<3,T>& other) const
{
return other+(*this);
}
// Make it unable to compile
inline void ApplyGL() const;
// {
// cerr<<"Cannot apply for this type\n";
// }
};
template<>
void Translation<float>::ApplyGL() const
{
glTranslatef(v[0],v[1],v[2]);
}
template<>
void Translation<double>::ApplyGL() const
{
glTranslated(v[0],v[1],v[2]);
}
typedef Translation<zfloat32> Translationf32;
typedef Translation<zfloat64> Translationf64;
typedef Translation<float> Translationf;
typedef Translation<double> Translationd;
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/Translation.hpp
|
C++
|
gpl3
| 1,076
|
#pragma once
#include <Math/Matrix3x3.hpp>
#include "Quaternion.hpp"
#include "Transformation.hpp"
namespace zzz{
template <typename T>
class Rotation : public Matrix<3,3,T>
{
public:
Rotation():Matrix<3,3,T>(1,0,0,0,1,0,0,0,1){}
Rotation(const Rotation<T> &other):Matrix<3,3,T>(other){}
explicit Rotation(const MatrixBase<3,3,T> &other):Matrix<3,3,T>(other){}
explicit Rotation(const Quaternion<T> &q)
{
T* v=Data();
v[0] = 1.0 - 2.0 * (q[1] * q[1] + q[2] * q[2]);
v[1] = 2.0 * (q[0] * q[1] - q[2] * q[3]);
v[2] = 2.0 * (q[0] * q[2] + q[1] * q[3]);
v[3] = 2.0 * (q[0] * q[1] + q[2] * q[3]);
v[4]= 1.0 - 2.0 * (q[0] * q[0] + q[2] * q[2]);
v[5] = 2.0 * (q[1] * q[2] - q[0] * q[3]);
v[6] = 2.0 * (q[0] * q[2] - q[1] * q[3]);
v[7] = 2.0 * (q[1] * q[2] + q[0] * q[3]);
v[8] = 1.0 - 2.0 * (q[0] * q[0] + q[1] * q[1]);
}
Rotation(const Vector<3,T> &normal, const T angle)
{
if (normal.Len()==0) Diagonal(1);
else *this=Rotation<T>(Quaternion<T>(normal,angle));
}
// pitch -> x-axis
// yaw -> y-axis
// roll -> z-axis
Rotation(T pitch, T yaw, T roll)
{
T *v=Data();
v[0]=cos(pitch)*cos(yaw);
v[1]=-cos(roll)*sin(yaw)+sin(roll)*sin(pitch)*cos(yaw);
v[2]=sin(roll)*sin(yaw)+cos(roll)+sin(pitch)*cos(yaw);
v[3]=cos(pitch)*sin(yaw);
v[4]=cos(pitch)*cos(yaw)+sin(roll)*sin(pitch)*sin(yaw);
v[5]=-sin(roll)*cos(yaw)+cos(roll)*sin(pitch)*sin(yaw);
v[6]=-sin(pitch);
v[7]=sin(roll)*cos(pitch);
v[8]=cos(roll)*cos(pitch);
}
void ToEulerAngles(T &pitch, T &yaw, T &roll)
{
T *v=Data();
if (v[6] == -1) {
roll = 0;
yaw = C_PI_2;
pitch = atan2(v[1], v[2]);
} else if (v[6] == 1) {
roll = 0;
yaw = -C_PI_2;
pitch = atan2(-v[1], -v[2]);
} else {
yaw = -asin(v[6]);
pitch = atan2(v[7]/cos(yaw), v[8]/cos(yaw));
roll = atan2(v[9]/cos(yaw), v[0]/cos(yaw));
}
}
inline static Rotation<T> GetIdentical() {
Rotation<T> mat;
mat.Identical();
return mat;
}
using Matrix<3,3,T>::operator=;
using Matrix<3,3,T>::Data;
using Matrix<3,3,T>::Diagonal;
VectorBase<3,T> Apply(const VectorBase<3,T> &a) const
{
return (*this)*a;
}
//OpenGL
void ApplyGL() const
{
GLTransformation<T>(*this).ApplyGL();
}
};
typedef Rotation<zfloat32> Rotationf32;
typedef Rotation<zfloat64> Rotationf64;
typedef Rotation<float> Rotationf;
typedef Rotation<double> Rotationd;
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/Rotation.hpp
|
C++
|
gpl3
| 2,590
|
#include "RayTransform.hpp"
#include <Math/Math.hpp>
namespace zzz{
float Ft_in(float costheta1,float eta)
{
if (costheta1>1.0) costheta1=1.0;
float sintheta1=sqrt(1.0-costheta1*costheta1);
float sintheta2=(sintheta1 * eta);
if (sintheta2>1.0) return 0;
float costheta2=sqrt(1.0-sintheta2*sintheta2);
float Rs=(eta*costheta1-costheta2)/(eta*costheta1+costheta2);
Rs=Rs*Rs;
float Rp=(eta*costheta2-costheta1)/(eta*costheta2+costheta1);
Rp=Rp*Rp;
float Ts=1.0-Rs,Tp=1.0-Rp;
return (Ts+Tp)/2.0;
}
float Ft_out(float costheta2,float eta)
{
const float eta2=1.0 / eta;
if (costheta2>1.0) costheta2=1.0;
float sintheta2=sqrt(1.0-costheta2*costheta2);
float sintheta1=(sintheta2 * eta2);
if (sintheta1>1.0) return 0;
float costheta1=sqrt(1.0-sintheta1*sintheta1);
float Rs=(eta2*costheta2-costheta1)/(eta2*costheta2+costheta1);
Rs=Rs*Rs;
float Rp=(eta2*costheta1-costheta2)/(eta2*costheta1+costheta2);
Rp=Rp*Rp;
float Ts=1.0-Rs,Tp=1.0-Rp;
return (Ts+Tp)/2.0;
}
float Ft_out2(float costheta1,float eta)
{
const float eta2=1.0 / eta;
float sintheta1=sqrt(1.0-costheta1*costheta1);
float sintheta2=(sintheta1 * eta);
if (sintheta2>1.0) return 0;
float costheta2=sqrt(1.0-sintheta2*sintheta2);
float Rs=(eta2*costheta2-costheta1)/(eta2*costheta2+costheta1);
Rs=Rs*Rs;
float Rp=(eta2*costheta1-costheta2)/(eta2*costheta1+costheta2);
Rp=Rp*Rp;
float Ts=1.0-Rs,Tp=1.0-Rp;
return (Ts+Tp)/2.0;
}
bool RefractTo(Vector3f inray,Vector3f &outray,float eta,const Vector3f &normal/*=Vector3f(0,0,1)*/)
{//default normal is (0,0,1)
float cos1=normal.Dot(inray);
if (cos1>1-EPS)
{
outray=-inray;
return true;
}
float sin1=sqrt(1-cos1*cos1);
float sin2=sin1*eta;
if (sin2>1) return false;
float tg1=sin1/cos1;
inray/=cos1;
float cos2=sqrt(1.0-sin2*sin2);
float tg2=sin2/cos2;
Vector3f offset=normal-inray;
offset=offset/tg1*tg2;
outray=-normal+offset;
outray.Normalize();
return true;
}
bool RefractFrom(Vector3f outray,Vector3f &inray,float eta,const Vector3f &normal/*=Vector3f(0,0,1)*/)
{//default normal is (0,0,1)
float cos2=normal.Dot(outray);
float sin2=sqrt(1-cos2*cos2);
float sin1=sin2*eta;
Vector3f offset=normal-outray;
offset*=eta;
inray=-normal+offset;
inray.Normalize();
return true;
}
}
|
zzz-engine
|
zzzEngine/zGraphics/zGraphics/Graphics/RayTransform.cpp
|
C++
|
gpl3
| 2,392
|