//simple hacked together load function, assumes file exists and mesh is initialized to default
void WarlockeryModelLoader::LoadWarlockeryModelFileToMesh(const std::string& fileName, Mesh* mesh, bool useCommonFilePath){
	const std::string WarlockeryModelExt = ".c23";
	std::string fullModelPath = fileName + WarlockeryModelExt;

	if (useCommonFilePath)
		fullModelPath = COMMON_MODEL_FILE_PATH + fileName + "/" + fileName + WarlockeryModelExt;

	BinaryFileParser WarlockeryModelParser = BinaryFileParser(fullModelPath);

	m_fileHeader.ReadFileHeader(WarlockeryModelParser);

	if (VerifyWarlockeryModelFile(&m_fileHeader)){
		//read num vertices
		//mesh = new Mesh();
		mesh->m_numVerticesToDraw = WarlockeryModelParser.ReadNextUInt();
		
		//read to vertex 3Ds
		Vertex3Ds meshVerts;
		meshVerts.clear();
		meshVerts.reserve(mesh->m_numVerticesToDraw * sizeof(Vertex3D));

		for (unsigned int i = 0; i < mesh->m_numVerticesToDraw; i++){
			meshVerts.push_back(WarlockeryModelParser.ReadNextVertex3D());
		}

		mesh->CopyMeshVertexData(meshVerts);

		//bind indices
		mesh->m_numIndicesToDraw = WarlockeryModelParser.ReadNextUInt();

		//DEBUG temporarily test lighting with vertex arrays
		mesh->m_numIndicesToDraw = 0;

		std::vector<unsigned int> meshIndices;
		meshIndices.clear();
		meshIndices.reserve(mesh->m_numIndicesToDraw * sizeof(unsigned int));

	

		if (mesh->m_numIndicesToDraw > 0){
			for (unsigned int i = 0; i < mesh->m_numIndicesToDraw; i++){
				meshIndices.push_back(WarlockeryModelParser.ReadNextUInt());
			}

			mesh->CopyMeshIndexData(meshIndices);
		}
		else{
			mesh->m_numIndicesToDraw = 0;
		}

	

	}
}
void RenderDebugPathMeshOnMap2D(OpenGLRenderer* renderer, MeshRenderer& pathMeshRenderer, Path& pathToRender, Map* map){
	UNUSED(renderer);
	//renderer->SetTextureViewTransparent();

	ModelViewMatrix& mapToWorldTransform = map->m_mapToWorldTransformMatrix;

	//set mesh renderer
	Vertex3Ds inPathVerts;
	inPathVerts.clear();

	Tile* pathingTile = NULL;
	
	//render start/goal/open tiles
	if (map && !pathToRender.IsOpenListEmpty()){

		//render start tile
		pathingTile = map->GetTileAtMapPosition(pathToRender.m_startPosition);
		GenerateVertexArrayTextureQuad(inPathVerts, pathingTile->m_renderBounds, AABB2::ZERO_TO_ONE, Rgba::SILVER, false);

		
		//render goal tile
		pathingTile = map->GetTileAtMapPosition(pathToRender.m_goalPosition);
		GenerateVertexArrayTextureQuad(inPathVerts, pathingTile->m_renderBounds, AABB2::ZERO_TO_ONE, Rgba::GOLD, false);

		if (pathToRender.m_activeNode){
			pathingTile = map->GetTileAtMapPosition(pathToRender.m_activeNode->m_position);
			GenerateVertexArrayTextureQuad(inPathVerts, pathingTile->m_renderBounds, AABB2::ZERO_TO_ONE, Rgba::MAGENTA, false);

			//OUTPUT_COLOR_STRING_TO_SCREEN(IntToString(pathToRender.m_activeNode->m_nodeCost.f), pathingTile->m_renderBounds.mins.x, pathingTile->m_renderBounds.maxs.y, Rgba::GOLD);
		}
	
		static Rgba openListColor = Rgba::BLUE;
		openListColor.a = 127;

		for (OpenListPathMapIterator it = pathToRender.m_openList.begin(); it != pathToRender.m_openList.end(); ++it){
			PathNode& pathnode = *(it->second);

			pathingTile = map->GetTileAtMapPosition(pathnode.m_position);

			GenerateVertexArrayTextureQuad(inPathVerts, pathingTile->m_renderBounds, AABB2::ZERO_TO_ONE, openListColor , false);

			//OUTPUT_COLOR_STRING_TO_SCREEN(IntToString(pathnode.m_nodeCost.f), pathingTile->m_renderBounds.mins.x, pathingTile->m_renderBounds.maxs.y, Rgba::GOLD);
		}

	}


	//create path mesh for all of closed list
	if (map && pathToRender.m_closedList.size() > 1 ){

		static Rgba closedListColor = Rgba::RED;
		closedListColor.a = 127;

		for (ClosedListIterator it = pathToRender.m_closedList.begin() + 1; it != pathToRender.m_closedList.end() - 1; ++it){
			PathNode& pathnode = (*it);

			pathingTile = map->GetTileAtMapPosition(pathnode.m_position);

			GenerateVertexArrayTextureQuad(inPathVerts, pathingTile->m_renderBounds, AABB2::ZERO_TO_ONE, closedListColor, false);
			
			//OUTPUT_COLOR_STRING_TO_SCREEN(IntToString(pathnode.m_nodeCost.f), pathingTile->m_renderBounds.mins.x, pathingTile->m_renderBounds.maxs.y, Rgba::GOLD);
			
		}//end of for

		if (pathToRender.m_isImpossible){
			return;
		}
	
		static Rgba pathColor = Rgba::GREEN;
		pathColor.a = 210;

		//Create path mesh for only path
		ClosedListIterator mypathIterator = pathToRender.m_closedList.end() - 1;
		PathNode& myPathGoalNode = (*mypathIterator);
		//start traversing from goal back to start
		PathNode* traversalPathNode = &myPathGoalNode;
		//traversalPathNode = traversalPathNode->m_parent;

		//create last closed node added
		pathingTile = map->GetTileAtMapPosition(traversalPathNode->m_position);
		GenerateVertexArrayTextureQuad(inPathVerts, pathingTile->m_renderBounds, AABB2::ZERO_TO_ONE, pathColor, false);

		if (traversalPathNode->m_parent != NULL)
			traversalPathNode = traversalPathNode->m_parent;

		//create path
		while (traversalPathNode->m_parent != NULL){
			   
			   pathingTile = map->GetTileAtMapPosition(traversalPathNode->m_position); //has an infinite loop in certain cases
			   GenerateVertexArrayTextureQuad(inPathVerts, pathingTile->m_renderBounds, AABB2::ZERO_TO_ONE, pathColor, false);
		
				//OUTPUT_COLOR_STRING_TO_SCREEN(IntToString(traversalPathNode->m_nodeCost.f), pathingTile->m_renderBounds.mins.x, pathingTile->m_renderBounds.maxs.y, Rgba::WHITE);
			
				traversalPathNode = traversalPathNode->m_parent;
		}//end of while

	
	

	}//end of outer if

	//copy all verts to mesh
	pathMeshRenderer.m_mesh->CopyMeshVertexData(inPathVerts);
	pathMeshRenderer.RenderMesh2D(&mapToWorldTransform);
	inPathVerts.clear();
	
}