Commit a61e2d65 authored by hybrid's avatar hybrid

Fixed doc typos mentioned by Dorth.

Added scalar value operations to vector2d.
Reindentation of Q3 code.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1033 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 8f8702c7
......@@ -280,7 +280,7 @@ namespace video
results of this operation are not defined.
\param vertices: Pointer to array of vertices.
\param vertexCount: Amount of vertices in the array.
\param indexList: Pointer to array of indizes.
\param indexList: Pointer to array of indices.
\param triangleCount: amount of Triangles.
\param vType: Vertex type, e.g. EVT_STANDARD for S3DVertex.
\param pType: Primitive type, e.g. EPT_TRIANGLE_FAN for a triangle fan. */
......@@ -293,8 +293,8 @@ namespace video
results of this operation are not defined.
\param vertices: Pointer to array of vertices.
\param vertexCount: Amount of vertices in the array.
\param indexList: Pointer to array of indizes.
\param triangleCount: amount of Triangles. Usually amount of indizes / 3. */
\param indexList: Pointer to array of indices.
\param triangleCount: amount of Triangles. Usually amount of indices / 3. */
virtual void drawIndexedTriangleList(const S3DVertex* vertices,
u32 vertexCount, const u16* indexList, u32 triangleCount) = 0;
......@@ -305,8 +305,8 @@ namespace video
results of this operation are not defined.
\param vertices: Pointer to array of vertices.
\param vertexCount: Amount of vertices in the array.
\param indexList: Pointer to array of indizes.
\param triangleCount: amount of Triangles. Usually amount of indizes / 3.*/
\param indexList: Pointer to array of indices.
\param triangleCount: amount of Triangles. Usually amount of indices / 3.*/
virtual void drawIndexedTriangleList(const S3DVertex2TCoords* vertices,
u32 vertexCount, const u16* indexList, u32 triangleCount) = 0;
......@@ -317,8 +317,8 @@ namespace video
results of this operation are not defined.
\param vertices: Pointer to array of vertices.
\param vertexCount: Amount of vertices in the array.
\param indexList: Pointer to array of indizes.
\param triangleCount: amount of Triangles. Usually amount of indizes / 3. */
\param indexList: Pointer to array of indices.
\param triangleCount: amount of Triangles. Usually amount of indices / 3. */
virtual void drawIndexedTriangleList(const S3DVertexTangents* vertices,
u32 vertexCount, const u16* indexList, u32 triangleCount) = 0;
......@@ -331,8 +331,8 @@ namespace video
free code sent in by Mario Gruber, lots of thanks go to him!
\param vertices: Pointer to array of vertices.
\param vertexCount: Amount of vertices in the array.
\param indexList: Pointer to array of indizes.
\param triangleCount: amount of Triangles. Usually amount of indizes - 2. */
\param indexList: Pointer to array of indices.
\param triangleCount: amount of Triangles. Usually amount of indices - 2. */
virtual void drawIndexedTriangleFan(const S3DVertex* vertices,
u32 vertexCount, const u16* indexList, u32 triangleCount) = 0;
......@@ -345,8 +345,8 @@ namespace video
free code sent in by Mario Gruber, lots of thanks go to him!
\param vertices: Pointer to array of vertices.
\param vertexCount: Amount of vertices in the array.
\param indexList: Pointer to array of indizes.
\param triangleCount: amount of Triangles. Usually amount of indizes - 2. */
\param indexList: Pointer to array of indices.
\param triangleCount: amount of Triangles. Usually amount of indices - 2. */
virtual void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices,
u32 vertexCount, const u16* indexList, u32 triangleCount) = 0;
......
......@@ -29,11 +29,15 @@ public:
vector2d<T>& operator=(const vector2d<T>& other) { X = other.X; Y = other.Y; return *this; }
vector2d<T> operator+(const vector2d<T>& other) const { return vector2d<T>(X + other.X, Y + other.Y); }
vector2d<T> operator+(const vector2d<T>& other) const { return vector2d<T>(X + other.X, Y + other.Y); }
vector2d<T>& operator+=(const vector2d<T>& other) { X+=other.X; Y+=other.Y; return *this; }
vector2d<T> operator+(const T v) const { return vector2d<T>(X + v, Y + v); }
vector2d<T>& operator+=(const T v) { X+=v; Y+=v; return *this; }
vector2d<T> operator-(const vector2d<T>& other) const { return vector2d<T>(X - other.X, Y - other.Y); }
vector2d<T> operator-(const vector2d<T>& other) const { return vector2d<T>(X - other.X, Y - other.Y); }
vector2d<T>& operator-=(const vector2d<T>& other) { X-=other.X; Y-=other.Y; return *this; }
vector2d<T> operator-(const T v) const { return vector2d<T>(X - v, Y - v); }
vector2d<T>& operator-=(const T v) { X-=v; Y-=v; return *this; }
vector2d<T> operator*(const vector2d<T>& other) const { return vector2d<T>(X * other.X, Y * other.Y); }
vector2d<T>& operator*=(const vector2d<T>& other) { X*=other.X; Y*=other.Y; return *this; }
......
......@@ -29,8 +29,7 @@ CQ3LevelMesh::CQ3LevelMesh(io::IFileSystem* fs, video::IVideoDriver* driver, sce
IReferenceCounted::setDebugName("CQ3LevelMesh");
#endif
s32 i;
for ( i = 0; i!= quake3::E_Q3_MESH_SIZE; ++i )
for ( s32 i = 0; i!= quake3::E_Q3_MESH_SIZE; ++i )
{
Mesh[i] = 0;
}
......@@ -43,43 +42,22 @@ CQ3LevelMesh::CQ3LevelMesh(io::IFileSystem* fs, video::IVideoDriver* driver, sce
// load default shaders
InitShader ();
}
//! destructor
CQ3LevelMesh::~CQ3LevelMesh()
{
if (Textures)
delete [] Textures;
if (LightMaps)
delete [] LightMaps;
if (Vertices)
delete [] Vertices;
if (Faces)
delete [] Faces;
if (Planes)
delete [] Planes;
if (Nodes)
delete [] Nodes;
if (Leafs)
delete [] Leafs;
if (LeafFaces)
delete [] LeafFaces;
if (MeshVerts)
delete [] MeshVerts;
if (Brushes)
delete [] Brushes;
delete [] Textures;
delete [] LightMaps;
delete [] Vertices;
delete [] Faces;
delete [] Planes;
delete [] Nodes;
delete [] Leafs;
delete [] LeafFaces;
delete [] MeshVerts;
delete [] Brushes;
if (Driver)
Driver->drop();
......@@ -87,19 +65,17 @@ CQ3LevelMesh::~CQ3LevelMesh()
if (FileSystem)
FileSystem->drop();
s32 i;
for ( i = 0; i!= quake3::E_Q3_MESH_SIZE; ++i )
for ( s32 i = 0; i!= quake3::E_Q3_MESH_SIZE; ++i )
{
if (Mesh[i])
Mesh[i]->drop();
}
ReleaseShader ();
ReleaseEntity ();
ReleaseShader();
ReleaseEntity();
}
//! loads a level from a .bsp-File. Also tries to load all needed textures. Returns true if successful.
bool CQ3LevelMesh::loadFile(io::IReadFile* file)
{
......@@ -134,12 +110,11 @@ bool CQ3LevelMesh::loadFile(io::IReadFile* file)
}
#endif
s32 i;
for ( i = 0; i!= quake3::E_Q3_MESH_SIZE; ++i )
for ( s32 i = 0; i!= quake3::E_Q3_MESH_SIZE; ++i )
{
Mesh[i] = new SMesh();
}
ReleaseEntity ();
ReleaseEntity();
// load everything
......@@ -169,14 +144,13 @@ bool CQ3LevelMesh::loadFile(io::IReadFile* file)
loadTextures2();
constructMesh2();
cleanMeshes ();
calcBoundingBoxes ();
cleanMeshes();
calcBoundingBoxes();
return true;
}
//! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh.
u32 CQ3LevelMesh::getFrameCount() const
{
......@@ -186,17 +160,18 @@ u32 CQ3LevelMesh::getFrameCount() const
void CQ3LevelMesh::releaseMesh ( s32 index )
{
if ( Mesh [ index ] )
if ( Mesh[index] )
{
Mesh [index]->drop ();
Mesh [index] = 0;
Mesh[index]->drop ();
Mesh[index] = 0;
}
}
//! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level.
IMesh* CQ3LevelMesh::getMesh(s32 frameInMs, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop)
{
return Mesh[ frameInMs ];
return Mesh[frameInMs];
}
......@@ -338,6 +313,7 @@ void CQ3LevelMesh::loadEntities(tBSPLump* l, io::IReadFile* file)
parser_parse ( entity.pointer(), l->length, &CQ3LevelMesh::scriptcallback_entity );
}
// load shaders named in bsp
void CQ3LevelMesh::loadShaders(tBSPLump* l, io::IReadFile* file)
{
......@@ -493,7 +469,6 @@ void CQ3LevelMesh::parser_nextToken ()
return;
}
// user identity
Parser.token.append ( symbol );
......@@ -522,6 +497,7 @@ void CQ3LevelMesh::parser_nextToken ()
return;
}
/*
parse entity & shader
calls callback on content in {}
......@@ -621,7 +597,6 @@ void CQ3LevelMesh::parser_parse ( const void * data, const u32 size, CQ3LevelMes
}
/*
this loader applies only textures for stage 1 & 2
*/
......@@ -660,7 +635,6 @@ s32 CQ3LevelMesh::setShaderMaterial ( video::SMaterial &material, const tBSPFace
if ( 0 == shader )
return shaderState;
const quake3::SVarGroup *group;
s32 index;
......@@ -691,7 +665,6 @@ s32 CQ3LevelMesh::setShaderMaterial ( video::SMaterial &material, const tBSPFace
startPos = 0;
index = group->getIndex ( "depthwrite" );
if ( index >= 0 )
{
......@@ -707,10 +680,8 @@ s32 CQ3LevelMesh::setShaderMaterial ( video::SMaterial &material, const tBSPFace
// try if we can match better
shaderState |= (material.MaterialType == video::EMT_SOLID ) ? 0x00020000 : 0;
}
//material.BackfaceCulling = false;
if ( shader->VarGroup->VariableGroup.size () <= 4 )
......@@ -776,7 +747,6 @@ void CQ3LevelMesh::constructMesh2()
} break;
/*
case 1: // normal polygons
case 2: // patches
......@@ -892,10 +862,9 @@ void CQ3LevelMesh::constructMesh2()
} // end switch
}
}
}
//! constructs a mesh from the quake 3 level file.
void CQ3LevelMesh::constructMesh()
{
......@@ -973,9 +942,9 @@ void CQ3LevelMesh::constructMesh()
break;
} // end switch
}
}
// helper method for creating curved surfaces, sent in by Dean P. Macri.
inline f32 CQ3LevelMesh::Blend( const f64 s[3], const f64 t[3], const tBSPVertex *v[9], int offset)
{
......@@ -992,6 +961,7 @@ inline f32 CQ3LevelMesh::Blend( const f64 s[3], const f64 t[3], const tBSPVertex
return (f32) res;
}
void CQ3LevelMesh::S3DVertex2TCoords_64::copyto ( video::S3DVertex2TCoords &dest ) const
{
dest.Pos.X = core::round_( (f32) Pos.X );
......@@ -1042,17 +1012,13 @@ void CQ3LevelMesh::copy ( S3DVertex2TCoords_64 * dest, const tBSPVertex * source
u32 g = core::s32_min ( source->color[1] * quake3::defaultModulate, 255 );
u32 b = core::s32_min ( source->color[2] * quake3::defaultModulate, 255 );
dest->Color.set ( a * 1.f/255.f,
r * 1.f/255.f,
g * 1.f/255.f,
b * 1.f/255.f
);
dest->Color.set (a * 1.f/255.f, r * 1.f/255.f,
g * 1.f/255.f, b * 1.f/255.f);
}
else
{
dest->Color.set ( 1.f, 1.f, 1.f, 1.f );
}
}
......@@ -1091,6 +1057,7 @@ inline void CQ3LevelMesh::copy ( video::S3DVertex2TCoords * dest, const tBSPVert
}
}
void CQ3LevelMesh::SBezier::tesselate ( s32 level )
{
//Calculate how many vertices across/down there are
......@@ -1149,11 +1116,10 @@ void CQ3LevelMesh::SBezier::tesselate ( s32 level )
/*!
no subdivision
*/
void CQ3LevelMesh::createCurvedSurface3 ( SMeshBufferLightMap* meshBuffer,
s32 faceIndex,
s32 patchTesselation,
s32 storevertexcolor
)
void CQ3LevelMesh::createCurvedSurface3(SMeshBufferLightMap* meshBuffer,
s32 faceIndex,
s32 patchTesselation,
s32 storevertexcolor)
{
tBSPFace * face = &Faces[faceIndex];
u32 j,k,m;
......@@ -1187,13 +1153,13 @@ void CQ3LevelMesh::createCurvedSurface3 ( SMeshBufferLightMap* meshBuffer,
}
}
/*!
*/
void CQ3LevelMesh::createCurvedSurface2 ( SMeshBufferLightMap* meshBuffer,
s32 faceIndex,
s32 patchTesselation,
s32 storevertexcolor
)
void CQ3LevelMesh::createCurvedSurface2(SMeshBufferLightMap* meshBuffer,
s32 faceIndex,
s32 patchTesselation,
s32 storevertexcolor)
{
tBSPFace * face = &Faces[faceIndex];
u32 j,k;
......@@ -1202,12 +1168,10 @@ void CQ3LevelMesh::createCurvedSurface2 ( SMeshBufferLightMap* meshBuffer,
const u32 controlWidth = face->size[0];
const u32 controlHeight = face->size[1];
// number of biquadratic patches
const u32 biquadWidth = (controlWidth - 1)/2;
const u32 biquadHeight = (controlHeight -1)/2;
// Create space for a temporary array of the patch's control points
core::array<S3DVertex2TCoords_64> controlPoint;
controlPoint.set_used ( controlWidth * controlHeight );
......@@ -1243,7 +1207,6 @@ void CQ3LevelMesh::createCurvedSurface2 ( SMeshBufferLightMap* meshBuffer,
}
}
// stitch together with existing geometry
// TODO: only border needs to be checked
const u32 bsize = Bezier.Patch->getVertexCount();
......@@ -1266,7 +1229,6 @@ void CQ3LevelMesh::createCurvedSurface2 ( SMeshBufferLightMap* meshBuffer,
}
*/
// add Patch to meshbuffer
for ( j = 0; j!= bsize; ++j )
{
......@@ -1280,9 +1242,9 @@ void CQ3LevelMesh::createCurvedSurface2 ( SMeshBufferLightMap* meshBuffer,
}
delete Bezier.Patch;
}
void CQ3LevelMesh::createCurvedSurface(SMeshBufferLightMap* meshBuffer, s32 i)
{
// this implementation for loading curved surfaces was
......@@ -1423,6 +1385,7 @@ void CQ3LevelMesh::createCurvedSurface(SMeshBufferLightMap* meshBuffer, s32 i)
}
}
//! get's an interface to the entities
const quake3::tQ3EntityList & CQ3LevelMesh::getEntityList ()
{
......@@ -1445,6 +1408,7 @@ const quake3::SShader * CQ3LevelMesh::getShader ( u32 index ) const
return 0;
}
//! loads the shader definition
// either from file ( we assume /scripts on fileNameIsValid == 0 )
const quake3::SShader * CQ3LevelMesh::getShader ( const c8 * filename, s32 fileNameIsValid )
......@@ -1522,6 +1486,7 @@ const quake3::SShader * CQ3LevelMesh::getShader ( const c8 * filename, s32 fileN
return 0;
}
//! adding default shaders
void CQ3LevelMesh::InitShader ()
{
......@@ -1544,6 +1509,7 @@ void CQ3LevelMesh::InitShader ()
getShader ( "scripts/common.shader", 1 );
}
//!. script callback for shaders
//! i'm having troubles with the reference counting, during callback.. resorting..
void CQ3LevelMesh::ReleaseShader ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment