Exemplo n.º 1
0
bool InputGeom::loadMesh(rcContext* ctx, const char* filepath, bool trinityCoreSettings)
{
	if (m_mesh)
	{
		delete m_chunkyMesh;
		m_chunkyMesh = 0;
		delete m_mesh;
		m_mesh = 0;
	}
	m_offMeshConCount = 0;
	m_volumeCount = 0;
	
	m_mesh = new rcMeshLoaderObj;
	if (!m_mesh)
	{
		ctx->log(RC_LOG_ERROR, "loadMesh: Out of memory 'm_mesh'.");
		return false;
	}
	if (!m_mesh->load(filepath))
	{
		ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Could not load '%s'", filepath);
		return false;
	}

    rcCalcBounds(m_mesh->getVerts(), m_mesh->getVertCount(), m_meshBMin, m_meshBMax);

    if (trinityCoreSettings)
    {
        char charBuff[3];
        memset(charBuff, 0, sizeof(charBuff));
        memcpy(charBuff, &filepath[13], sizeof(char) * 2);
        int tileY = atoi(charBuff);
        memset(charBuff, 0, sizeof(charBuff));
        memcpy(charBuff, &filepath[15], sizeof(char) * 2);
        int tileX = atoi(charBuff);

        // this is for width and depth
        m_meshBMax[0] = (32 - int(tileX)) * 533.3333f;
        m_meshBMax[2] = (32 - int(tileY)) * 533.3333f;
        m_meshBMin[0] = m_meshBMax[0] - 533.3333f;
        m_meshBMin[2] = m_meshBMax[2] - 533.3333f;
    }

	m_chunkyMesh = new rcChunkyTriMesh;
	if (!m_chunkyMesh)
	{
		ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Out of memory 'm_chunkyMesh'.");
		return false;
	}
	if (!rcCreateChunkyTriMesh(m_mesh->getVerts(), m_mesh->getTris(), m_mesh->getTriCount(), 256, m_chunkyMesh))
	{
		ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Failed to build chunky mesh.");
		return false;
	}		

	return true;
}
Exemplo n.º 2
0
bool InputGeom::loadMesh(const char* filepath)
{
	rcSetLog(&SharedData::getSingleton().mDbgLog);

	if (m_mesh)
	{
		delete m_chunkyMesh;
		m_chunkyMesh = 0;
		delete m_mesh;
		m_mesh = 0;
	}
	m_offMeshConCount = 0;
	m_volumeCount = 0;
	
	m_mesh = new rcMeshLoaderObj;
	if (!m_mesh)
	{
		if (rcGetLog())
			rcGetLog()->log(RC_LOG_ERROR, "loadMesh: Out of memory 'm_mesh'.");
		return false;
	}

	if (!m_mesh->load(filepath))
	{
		if (rcGetLog())
		{
			rcGetLog()->log(RC_LOG_ERROR, "buildTiledNavigation: Could not load '%s'", filepath);
		}
		return false;
	}
	//return true; // Bypass Nav Data building
	rcCalcBounds(&m_mesh->getVerts()[0], m_mesh->getVertCount(), m_meshBMin, m_meshBMax);

	m_chunkyMesh = new rcChunkyTriMesh;
	if (!m_chunkyMesh)
	{
		if (rcGetLog())
			rcGetLog()->log(RC_LOG_ERROR, "buildTiledNavigation: Out of memory 'm_chunkyMesh'.");
		return false;
	}
	if (!rcCreateChunkyTriMesh(&m_mesh->getVerts()[0], &m_mesh->getTris()[0], m_mesh->getTriCount(), 256, m_chunkyMesh))
	{
		if (rcGetLog())
			rcGetLog()->log(RC_LOG_ERROR, "buildTiledNavigation: Failed to build chunky mesh.");
		return false;
	}		

	return true;
}
Exemplo n.º 3
0
bool InputGeom::loadMesh(rcContext* ctx, const char* filepath)
{
	if (m_mesh)
	{
		delete m_chunkyMesh;
		m_chunkyMesh = 0;
		delete m_mesh;
		m_mesh = 0;
	}
	m_offMeshConCount = 0;
	m_volumeCount = 0;
	
	m_mesh = new rcMeshLoaderObj;
	if (!m_mesh)
	{
		ctx->log(RC_LOG_ERROR, "loadMesh: Out of memory 'm_mesh'.");
		return false;
	}
	if (!m_mesh->load(filepath))
	{
		ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Could not load '%s'", filepath);
		return false;
	}

	rcCalcBounds(m_mesh->getVerts(), m_mesh->getVertCount(), m_meshBMin, m_meshBMax);

	m_chunkyMesh = new rcChunkyTriMesh;
	if (!m_chunkyMesh)
	{
		ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Out of memory 'm_chunkyMesh'.");
		return false;
	}
	if (!rcCreateChunkyTriMesh(m_mesh->getVerts(), m_mesh->getTris(), m_mesh->getTriCount(), 256, m_chunkyMesh))
	{
		ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Failed to build chunky mesh.");
		return false;
	}		

	return true;
}
Exemplo n.º 4
0
bool InputGeom::loadMesh(rcContext* ctx)
{
	m_chunkyMesh.reset();
	m_offMeshConCount = 0;
	m_volumeCount = 0;
	
	m_loader.reset(new MapGeometryLoader(m_zoneShortName, m_eqPath, m_meshPath));
	if (!m_loader->load())
	{
		ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Could not load '%s'",
			m_zoneShortName.c_str());
		return false;
	}

	if (m_loader->getVerts() == nullptr)
		return false;

	rcCalcBounds(m_loader->getVerts(), m_loader->getVertCount(),
		&m_meshBMin[0], &m_meshBMax[0]);

	m_meshBMinCustom = m_meshBMin;
	m_meshBMaxCustom = m_meshBMax;

	// Construct the partitioned triangle mesh
	m_chunkyMesh.reset(new rcChunkyTriMesh);
	if (!rcCreateChunkyTriMesh(
		m_loader->getVerts(),        // verts
		m_loader->getTris(),         // tris
		m_loader->getTriCount(),     // ntris
		256,                         // trisPerChunk
		m_chunkyMesh.get()))         // [out] chunkyMesh
	{
		ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Failed to build chunky mesh.");
		return false;
	}

	return true;
}
Exemplo n.º 5
0
bool InputGeom::loadFromMeshLoader(rcContext* ctx, rcMeshLoaderObj* meshLoader)
{
	if (m_mesh)
	{
		delete m_chunkyMesh;
		m_chunkyMesh = 0;
		delete m_mesh;
		m_mesh = 0;
	}
	m_offMeshConCount = 0;
	m_volumeCount = 0;
	
	m_mesh = meshLoader;
	if (!m_mesh)
	{
		ctx->log(RC_LOG_ERROR, "loadMesh: Failed to load 'm_mesh'.");
		return false;
	}

	printf("%d verts   %d tris\n", m_mesh->getVertCount(), m_mesh->getTriCount());

	rcCalcBounds(m_mesh->getVerts(), m_mesh->getVertCount(), m_meshBMin, m_meshBMax);

	m_chunkyMesh = new rcChunkyTriMesh;
	if (!m_chunkyMesh)
	{
		ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Out of memory 'm_chunkyMesh'.");
		return false;
	}
	if (!rcCreateChunkyTriMesh(m_mesh->getVerts(), m_mesh->getTris(), m_mesh->getTriCount(), 256, m_chunkyMesh))
	{
		ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Failed to build chunky mesh.");
		return false;
	}		

	return true;
}
Exemplo n.º 6
0
bool InputGeom::loadMesh(const char* filepath)
{
	if (m_mesh)
	{
		delete m_chunkyMesh;
		m_chunkyMesh = 0;
		delete m_mesh;
		m_mesh = 0;
	}
	m_offMeshConCount = 0;
	m_volumeCount = 0;
	
	m_mesh = new rcMeshLoaderObj;
	if (!m_mesh)
	{
		return false;
	}
	if (!m_mesh->load(filepath))
	{
		return false;
	}

	rcCalcBounds(m_mesh->getVerts(), m_mesh->getVertCount(), m_meshBMin, m_meshBMax);

	m_chunkyMesh = new rcChunkyTriMesh;
	if (!m_chunkyMesh)
	{
		return false;
	}
	if (!rcCreateChunkyTriMesh(m_mesh->getVerts(), m_mesh->getTris(), m_mesh->getTriCount(), 256, m_chunkyMesh))
	{
		return false;
	}		

	return true;
}