Mercurial > hg > forks > gldragon
diff dmmodel.h @ 21:1404dfcee7b8
More work on scenefile and model loading support.
Can now load PLY models and simple scene definition files.
Converted dragon mesh to binary PLY format.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 22 Nov 2019 03:03:52 +0200 |
parents | a329f0216491 |
children | 03b86b9c2f29 |
line wrap: on
line diff
--- a/dmmodel.h Fri Nov 22 00:14:16 2019 +0200 +++ b/dmmodel.h Fri Nov 22 03:03:52 2019 +0200 @@ -88,6 +88,7 @@ std::string filename; std::string line; std::ifstream file; + std::string *key; }; @@ -121,23 +122,34 @@ }; -struct DMVertex +struct DMVector3 { float x, y, z; }; +struct DMVector4 +{ + float x, y, z, w; +}; + + struct DMModel { int nvertices, nfaces; - std::vector<DMVertex> vertices, normals; + std::vector<DMVector3> vertices, normals; std::vector<unsigned int> faces; DMColor color; - DMVertex translate, scale, rotate; + DMVector3 translate, scale, rotate; unsigned int id_prog, id_fs, id_vs; + std::string + modelFile, + fragShaderFile, vertShaderFile, + fragShaderStr, vertShaderStr; + bool loadFromPLY(const std::string &filename); bool loadFromPLY(const std::string &filename, DMPLYFileInfo &info); @@ -155,6 +167,8 @@ DMModel() { + nfaces = nvertices = 0; + translate.x = translate.y = translate.z = 0; rotate.x = rotate.y = rotate.z = 0; scale.x = scale.y = scale.z = 1; @@ -164,22 +178,22 @@ struct DMLight { - DMVertex pos; - float ambient[4], diffuse[4], specular[4]; + DMVector3 pos, pointAt; + DMVector4 ambient, diffuse, specular; }; struct DMCamera { - DMVertex pos, lookAt; + DMVector3 pos, pointAt; }; struct DMSimpleScene { - DMModel model; DMCamera camera; std::vector<DMLight> lights; + std::vector<DMModel> models; bool loadInfo(const std::string &filename); };