Browse Source

Delete MeshManager

Daniele Bartolini 13 years ago
parent
commit
7673a3e048
2 changed files with 0 additions and 377 deletions
  1. 0 268
      src/MeshManager.cpp
  2. 0 109
      src/MeshManager.h

+ 0 - 268
src/MeshManager.cpp

@@ -1,268 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "MeshManager.h"
-#include "Log.h"
-#include "MathUtils.h"
-
-namespace crown
-{
-
-MeshManager::MeshManager()
-{
-}
-
-Mesh* MeshManager::Create(const char* name, bool& created)
-{
-	Mesh* mesh = static_cast<Mesh*>(ResourceManager::Create(name, created));
-
-	return mesh;
-}
-
-Mesh* MeshManager::Load(const char* /*name*/)
-{
-	Log::E("MeshManager::Load: Not implemented yet.");
-	return 0;
-}
-
-Mesh* MeshManager::LoadCube(const char* name, float size)
-{
-	bool created;
-	Mesh* mesh = Create(name, created);
-
-	if (mesh != NULL && created)
-	{
-		MeshChunk* chunk = new MeshChunk();
-
-		float actual = math::abs(size) * 0.5f;
-
-		/**
-
-		         19------18
-		         /      / 
-		       16------17
-
-		    15    6------7   10       
-		    /|    |      |   /|
-		  14 |  3------2 | 11 |
-		   |12  | 5----|-4  | 9
-		   |/   |      |    |/
-		  13    0------1    8
-
-		         20------21
-		         /      /
-		       23------22
-
-		*/
-
-		// 6 faces, with pos, normal and uv
-		// Face ================================================================================================== Index
-		// Front
-		chunk->mVertexList.push_back(VertexData(Vec3(-actual, -actual,  actual),  Vec3::ZAXIS, Vec2(0.0f, 0.0f))); // 0
-		chunk->mVertexList.push_back(VertexData(Vec3( actual, -actual,  actual),  Vec3::ZAXIS, Vec2(1.0f, 0.0f))); // 1
-		chunk->mVertexList.push_back(VertexData(Vec3( actual,  actual,  actual),  Vec3::ZAXIS, Vec2(1.0f, 1.0f))); // 2
-		chunk->mVertexList.push_back(VertexData(Vec3(-actual,  actual,  actual),  Vec3::ZAXIS, Vec2(0.0f, 1.0f))); // 3
-
-		// Back
-		chunk->mVertexList.push_back(VertexData(Vec3( actual, -actual, -actual), -Vec3::ZAXIS, Vec2(0.0f, 0.0f))); // 4
-		chunk->mVertexList.push_back(VertexData(Vec3(-actual, -actual, -actual), -Vec3::ZAXIS, Vec2(1.0f, 0.0f))); // 5
-		chunk->mVertexList.push_back(VertexData(Vec3(-actual,  actual, -actual), -Vec3::ZAXIS, Vec2(1.0f, 1.0f))); // 6
-		chunk->mVertexList.push_back(VertexData(Vec3( actual,  actual, -actual), -Vec3::ZAXIS, Vec2(0.0f, 1.0f))); // 7
-
-		// Right
-		chunk->mVertexList.push_back(VertexData(Vec3( actual, -actual,  actual),  Vec3::XAXIS, Vec2(0.0f, 0.0f))); // 8
-		chunk->mVertexList.push_back(VertexData(Vec3( actual, -actual, -actual),  Vec3::XAXIS, Vec2(1.0f, 0.0f))); // 9
-		chunk->mVertexList.push_back(VertexData(Vec3( actual,  actual, -actual),  Vec3::XAXIS, Vec2(1.0f, 1.0f))); // 10
-		chunk->mVertexList.push_back(VertexData(Vec3( actual,  actual,  actual),  Vec3::XAXIS, Vec2(0.0f, 1.0f))); // 11
-
-		// Left
-		chunk->mVertexList.push_back(VertexData(Vec3(-actual, -actual, -actual), -Vec3::XAXIS, Vec2(0.0f, 0.0f))); // 12
-		chunk->mVertexList.push_back(VertexData(Vec3(-actual, -actual,  actual), -Vec3::XAXIS, Vec2(1.0f, 0.0f))); // 13
-		chunk->mVertexList.push_back(VertexData(Vec3(-actual,  actual,  actual), -Vec3::XAXIS, Vec2(1.0f, 1.0f))); // 14
-		chunk->mVertexList.push_back(VertexData(Vec3(-actual,  actual, -actual), -Vec3::XAXIS, Vec2(0.0f, 1.0f))); // 15
-
-		// Top
-		chunk->mVertexList.push_back(VertexData(Vec3(-actual,  actual,  actual),  Vec3::YAXIS, Vec2(0.0f, 0.0f))); // 16
-		chunk->mVertexList.push_back(VertexData(Vec3( actual,  actual,  actual),  Vec3::YAXIS, Vec2(1.0f, 0.0f))); // 17
-		chunk->mVertexList.push_back(VertexData(Vec3( actual,  actual, -actual),  Vec3::YAXIS, Vec2(1.0f, 1.0f))); // 18
-		chunk->mVertexList.push_back(VertexData(Vec3(-actual,  actual, -actual),  Vec3::YAXIS, Vec2(0.0f, 1.0f))); // 19
-
-		// Bottom
-		chunk->mVertexList.push_back(VertexData(Vec3(-actual, -actual, -actual), -Vec3::YAXIS, Vec2(0.0f, 0.0f))); // 20
-		chunk->mVertexList.push_back(VertexData(Vec3( actual, -actual, -actual), -Vec3::YAXIS, Vec2(1.0f, 0.0f))); // 21
-		chunk->mVertexList.push_back(VertexData(Vec3( actual, -actual,  actual), -Vec3::YAXIS, Vec2(1.0f, 1.0f))); // 22
-		chunk->mVertexList.push_back(VertexData(Vec3(-actual, -actual,  actual), -Vec3::YAXIS, Vec2(0.0f, 1.0f))); // 23
-
-		// 12 triangles, CCW order
-		chunk->mFaceList.push_back(FaceData(0, 1, 2));
-		chunk->mFaceList.push_back(FaceData(0, 2, 3));
-
-		chunk->mFaceList.push_back(FaceData(4, 5, 6));
-		chunk->mFaceList.push_back(FaceData(4, 6, 7));
-
-		chunk->mFaceList.push_back(FaceData(8, 9, 10));
-		chunk->mFaceList.push_back(FaceData(8, 10, 11));
-
-		chunk->mFaceList.push_back(FaceData(12, 13, 14));
-		chunk->mFaceList.push_back(FaceData(12, 14, 15));
-
-		chunk->mFaceList.push_back(FaceData(16, 17, 18));
-		chunk->mFaceList.push_back(FaceData(16, 18, 19));
-
-		chunk->mFaceList.push_back(FaceData(20, 21, 22));
-		chunk->mFaceList.push_back(FaceData(20, 22, 23));
-
-		mesh->AddMeshChunk(chunk);
-		mesh->UpdateBoundingBox();
-		mesh->RecompileMesh();
-	}
-
-	return mesh;
-}
-
-Mesh* MeshManager::LoadPlane(const char* name, float width, float height)
-{
-	bool created;
-	Mesh* mesh = Create(name, created);
-
-	if (mesh != NULL && created)
-	{
-		MeshChunk* chunk = new MeshChunk();
-
-		float actualWidth = math::abs(width) * 0.5f;
-		float actualHeight = math::abs(height) * 0.5f;
-
-		/**
-
-			    (-x; +y)      (+x; +y)
-		          ______________
-		         /             /
-		        /     ^ (+z)  /
-		       /      |      /
-		      /             /
-		     /_____________/
-
-		(-x; -y)      (+x; -y)
-
-		*/
-
-		// Only a face, with pos, normal and UVs
-		chunk->mVertexList.push_back(VertexData(Vec3(-actualWidth, -actualHeight,  0.0f),  Vec3::ZAXIS, Vec2(0.0f, 0.0f)));
-		chunk->mVertexList.push_back(VertexData(Vec3( actualWidth, -actualHeight,  0.0f),  Vec3::ZAXIS, Vec2(1.0f, 0.0f)));
-		chunk->mVertexList.push_back(VertexData(Vec3( actualWidth,  actualHeight,  0.0f),  Vec3::ZAXIS, Vec2(1.0f, 1.0f)));
-		chunk->mVertexList.push_back(VertexData(Vec3(-actualWidth,  actualHeight,  0.0f),  Vec3::ZAXIS, Vec2(0.0f, 1.0f)));
-
-		// 2 triangles, CCW order
-		chunk->mFaceList.push_back(FaceData(0, 1, 2));
-		chunk->mFaceList.push_back(FaceData(0, 2, 3));
-
-		mesh->AddMeshChunk(chunk);
-		mesh->UpdateBoundingBox();
-		mesh->RecompileMesh();
-	}
-
-	return mesh;
-}
-
-Mesh* MeshManager::LoadGrid(const char* name, uint32_t size, float tileSize)
-{
-	if (size < 1)
-	{
-		Log::E("MeshManager::LoadGrid: Size must be > 0");
-		return 0;
-	}
-
-	bool created;
-	Mesh* mesh = Create(name, created);
-
-	if (mesh != NULL && created)
-	{
-		MeshChunk* chunk = new MeshChunk();
-
-		float actual = ((float)size * tileSize * 0.5f);
-
-		/**
-
-			   (-x; -z)    (+x; -z)
-		         ____________
-		        /__/__/__/__/
-		       /__/__/__/__/  ^ (+y)
-		      /__/__/__/__/   |
-		     /__/__/__/__/
-
-		(-x; +z)    (+x; +z)
-
-		*/
-
-		// Populate vertex list (generate a grid lying on the xz-plane and facing upwards)
-		float vCoord = 0.0f;//(float)size;
-		float zPos = actual;
-		for (uint32_t h = 0; h <= size; h++)
-		{
-			float uCoord = 0.0f;
-			float xPos = -actual;
-			for (uint32_t w = 0; w <= size; w++)
-			{
-				chunk->mVertexList.push_back(VertexData(Vec3(xPos, 0.0f, zPos), Vec3::YAXIS, Vec2(uCoord, vCoord)));
-				xPos += tileSize;
-				uCoord += 1.0f;// / ((float)size + 1.0f);
-			}
-			zPos -= tileSize;
-			vCoord += 1.0f;// / ((float)size + 1.0f);
-		}
-
-		// Generate faces
-		for (uint32_t h = 0; h < size; h++)
-		{
-			for (uint32_t w = 0; w < size; w++)
-			{
-				uint32_t firstRow = (h * (size + 1)) + w;
-				uint32_t secondRow = ((h + 1) * (size + 1)) + w;
-				chunk->mFaceList.push_back(FaceData(firstRow, firstRow + 1, secondRow + 1));
-				chunk->mFaceList.push_back(FaceData(firstRow, secondRow + 1, secondRow));
-			}
-		}
-
-		mesh->AddMeshChunk(chunk);
-		mesh->UpdateBoundingBox();
-		mesh->RecompileMesh();
-	}
-
-	return mesh;
-}
-
-Mesh* MeshManager::CreateSpecific(const char* name)
-{
-	return new Mesh();
-}
-
-MeshManager meshMgr;
-MeshManager* GetMeshManager()
-{
-	return &meshMgr;
-}
-
-} // namespace crown
-

+ 0 - 109
src/MeshManager.h

@@ -1,109 +0,0 @@
-/*
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "ResourceManager.h"
-#include "Mesh.h"
-
-namespace crown
-{
-
-/**
- * Manages mesh loading.
- */
-class MeshManager : public ResourceManager
-{
-
-public:
-
-	MeshManager();
-
-	/**
-	 * Creates a mesh resource with the given name.
-	 * If a resource with the same name already exists, the
-	 * already existent resource will be returned.
-	 * @param name The name of the resource
-	 * @return A point32_ter to the created resource
-	 */
-	Mesh* Create(const char* name, bool& created);
-
-	/**
-	 * Loads a mesh resource from file.
-	 * The name of the file determines the name of the resource and vice-versa.
-	 * @param name Tha name of the resource
-	 * @return A point32_ter to the loaded resource
-	 */
-	Mesh* Load(const char* name);
-
-	/**
-	 * Loads a prefab cube mesh.
-	 * @param name The name of the mesh
-	 * @param size The size of the cube in units
-	 * @return A point32_ter to the loaded resource
-	 */
-	Mesh* LoadCube(const char* name, float size = 1.0f);
-
-	/**
-	 * Loads a prefab plane mesh.
-	 * @note Plane differs from a grid in the way a plane has
-	 * only four vertices while a grid has many more, depending
-	 * on the size. You can imagine a plane as a singe sheet of
-	 * paper.
-	 * The function generates a plane of size 'width' x 'height' units,
-	 * centered at the origin and facing +Z. 
-	 * @param name The name of the mesh
-	 * @param width The width of the plane in units
-	 * @param height The height of the plane in units
-	 * @return A point32_ter to the loaded resource
-	 */
-	Mesh* LoadPlane(const char* name, float width = 1.0f, float height = 1.0f);
-
-	/**
-	 * Loads a prefab plane mesh.
- 	 * @note A grid differs from a plane in the way a grid
-	 * has many more vertices than a plane, depending on the
-	 * size. You can think of a grid as a set of small-tiled
-	 * planes or as a single "triangulated" plane.
-	 * @param name The name of the mesh
-	 * @param size The size of the plane in units
-	 * @param tileSize The size of a tile in units
-	 * @return A point32_ter to the loaded resource
-	 */
-	Mesh* LoadGrid(const char* name, uint32_t size = 20, float tileSize = 1.0f);
-
-	virtual Mesh* CreateSpecific(const char* name);
-
-private:
-
-	// Disable copying
-	MeshManager(const MeshManager&);
-	MeshManager& operator=(const MeshManager&);
-};
-
-MeshManager* GetMeshManager();
-
-} // namespace crown
-