Definition in file ALoad.cpp.
#include "AEngine.h"
#include "AUtil.h"
#include "ASharedFunc.h"
Include dependency graph for ALoad.cpp:

Go to the source code of this file.
Functions | |
| AFont | load_font (string fontName, string filename) |
| AMesh | load_mesh (string filename) |
| ATexture | load_texture (string filename) |
| ATerrain | load_terrain (string filename, FLOAT sizeX, FLOAT sizeY, FLOAT sizeZ, FLOAT offsetZ) |
|
||||||||||||
|
Definition at line 27 of file ALoad.cpp. References AFont, and util_loadFont().
00028 {
00029 AS.res_fonts.push_back( util_loadFont(fontName,filename,18) );
00030 return (int)AS.res_fonts.size()-1;
00031 }
|
|
|
Definition at line 33 of file ALoad.cpp. References AMesh, MeshVertex::cindex, MeshEntry::IBstart, MeshVertex::normal, MeshVertex::pos, MeshEntry::size, MeshEntry::TriCount, UINT, MeshVertex::uv, MeshEntry::VBcount, MeshEntry::VBmin, Vec2D, and Vec3D.
00034 {
00035 ifstream f(filename.c_str());
00036 if(!f) throw Error("Can't read mesh file : "+filename );
00037
00038 vector<Vec3D> vec_pos, vec_normal;
00039 vector<Vec2D> vec_uv;
00040 string cmd;
00041 FLOAT f1, f2, f3;
00042 FLOAT minX, maxX, minY, maxY, minZ, maxZ;
00043 minX = minY = minZ = 100000.0f;
00044 maxX = maxY = maxZ = -100000.0f;
00045
00046 // read it vertex pos, texture, normal arrays
00047 while(true)
00048 {
00049 f >> cmd;
00050 if( cmd=="#" ) // just a comment line. ignore it
00051 {
00052 getline( f, cmd );
00053 }
00054 else if( cmd=="v" ) // vertex position
00055 {
00056 f >> f1 >> f2 >> f3;
00057 vec_pos.push_back( Vec3D(f1,f2,f3) );
00058 if(f1<minX) minX=f1; else if(f1>maxX) maxX=f1;
00059 if(f2<minY) minY=f2; else if(f2>maxY) maxY=f2;
00060 if(f3<minZ) minZ=f3; else if(f3>maxZ) maxZ=f3;
00061 }
00062 else if( cmd=="vt" ) // texture coordinate
00063 {
00064 f >> f1 >> f2 >> f3;
00065 vec_uv.push_back( Vec2D(f1,1.0f-f2) );
00066 }
00067 else if( cmd=="vn" ) // normal
00068 {
00069 f >> f1 >> f2 >> f3;
00070 vec_normal.push_back( Vec3D(f1,f2,f3) );
00071 }
00072 else if( cmd=="g" ) // end of vertex info list
00073 {
00074 getline( f, cmd );
00075 break;
00076 }
00077 }
00078
00079 // read in triangle indices, create&map tuples
00080 map< Int3Tuple, int > tuplesMap;
00081 vector<Int3Tuple> vertices;
00082 vector<USHORT> indices;
00083 map<Int3Tuple,int>::iterator iter;
00084 char skip;
00085 int posIndex, uvIndex, normalIndex;
00086
00087 while(true)
00088 {
00089 f >> cmd;
00090 if( cmd!="f" ) break;
00091
00092 // read the 3 corners of a triangle
00093 for( int corner=0; corner<3; corner++ )
00094 {
00095 f >> posIndex >> skip >> uvIndex >> skip >> normalIndex;
00096 Int3Tuple tuple(posIndex-1,uvIndex-1,normalIndex-1); // -1 because .obj is 1-based
00097 iter = tuplesMap.find(tuple);
00098 if( iter==tuplesMap.end() ) // if this vertex is new, add it
00099 {
00100 tuplesMap[tuple] = (int) vertices.size();
00101 indices.push_back( (USHORT)vertices.size() );
00102 vertices.push_back(tuple);
00103 }
00104 else // but if it's already there, use existing vertex number
00105 indices.push_back( iter->second );
00106 }
00107
00108 }
00109
00110 // concat new data to entire Mesh VB&IB
00111 int vertexOffset = (int) AS.mesh_raw_vb.size();
00112 int indexOffset = (int) AS.mesh_raw_ib.size();
00113 MeshVertex v;
00114 for( UINT i=0; i<vertices.size(); i++ ) // add all vertices
00115 {
00116 v.pos = vec_pos[ vertices[i].a ];
00117 v.uv = vec_uv[ vertices[i].b ];
00118 v.normal = vec_normal[ vertices[i].c ];
00119 v.cindex = 0;
00120 AS.mesh_raw_vb.push_back(v);
00121 }
00122 for( UINT i=0; i<indices.size(); i++ ) // add all indices
00123 {
00124 AS.mesh_raw_ib.push_back( indices[i]+vertexOffset );
00125 }
00126
00127 // add MeshEntry
00128 MeshEntry entry;
00129 entry.IBstart = indexOffset;
00130 entry.TriCount = (UINT) indices.size() / 3;
00131 entry.VBcount = (UINT) vertices.size();
00132 entry.VBmin = vertexOffset;
00133 entry.size = Vec3D( maxX-minX, maxY-minY, maxZ-minZ );
00134 AS.res_meshes.push_back( entry );
00135
00136 return (int)AS.res_meshes.size() - 1;
00137 }
|
|
||||||||||||||||||||||||
|
Definition at line 148 of file ALoad.cpp. References ATerrain, and terrain_create(). Referenced by Globals::ArtWork::ArtWork().
00149 {
00150 return terrain_create(filename,sizeX,sizeY,sizeZ,offsetZ);
00151 }
|
|
|
Definition at line 139 of file ALoad.cpp. References ATexture. Referenced by displayLoadingScreen().
00140 {
00141 LPDIRECT3DTEXTURE8 pTexture;
00142 HRESULT hr = D3DXCreateTextureFromFile( AS.pDevice, filename.c_str(), &pTexture );
00143 if( FAILED(hr) ) throw Error("Cannot Load Texture : "+filename);
00144 AS.res_textures.push_back(pTexture);
00145 return (int)AS.res_textures.size()-1;
00146 }
|
1.3-rc2