Example #1
0
/************************************************************************************************
 * CRMPathManager::GenerateRivers
 *	Creates a river which intersects the main path
 *
 * inputs:
 *  none
 *
 * return:
 *	none
 *
 ************************************************************************************************/
void CRMPathManager::GenerateRivers ()
{
	if (mRiverBedDepth == 1)
		// no rivers
		return;

	mMaxDepth = mRiverDepth;
	mDepth = 0;

	int cell_x = 0;
	int cell_y = 0;

	// choose starting cell along an edge
	int edge = TheRandomMissionManager->GetLandScape()->irand(0, 7);
	switch ( edge )
	{
		case 0:
			cell_x = mXNodes / 2; cell_y = 0;
			break;
		case 1:
			cell_x = mXNodes; cell_y = 0;
			break;
		case 2:
			cell_x = mXNodes; cell_y = mYNodes / 2;
			break;
		case 3:
			cell_x = mXNodes; cell_y = mYNodes;
			break;
		case 4:
			cell_x = mXNodes / 2; cell_y = mYNodes;
			break;
		case 5:
			cell_x = 0; cell_y = mYNodes;
			break;
		case 6:
			cell_x = 0; cell_y = mYNodes / 2;
			break;
		case 7:
			cell_x = 0; cell_y = 0;
			break;
	}

	ClearCells(mXNodes+1, mYNodes+1);

	mRiverCount = mPathCount;

	// visit the first cell
	RiverVisit(cell_x,cell_y);

	mRiverCount = mPathCount - mRiverCount;

	return;
}
Example #2
0
/************************************************************************************************
 * CRMPathManager::CreateArray
 *	Create array of nodes that are spaced over the landscape.
 *	Create array of cells, which is used to determine how nodes are connected.
 *
 * inputs:
 *  x_nodes, y_nodes - how many nodes in each dimension to layout
 *
 * return:
 *	true if the node array was created, false if we have a problem
 *
 ************************************************************************************************/
bool CRMPathManager::CreateArray(const int x_nodes, const int y_nodes)
{
    mXNodes = x_nodes;
    mYNodes = y_nodes;

    // fill node array with positions that are spaced over the landscape
    int x,y;

    // dump existing nodes
    for ( x = mNodes.size() - 1; x >=0; x-- )
    {
        if (mNodes[x])
            delete mNodes[x];
    }
    mNodes.clear();
    mNodes.resize(mXNodes * mYNodes, NULL);

    // add a small amount of random jitter to spots chosen
    float x_rnd = 0.2f / (mXNodes+1);
    float y_rnd = 0.2f / (mYNodes+1);

    for (x = 0; x < mXNodes; x++)
    {
        float cell_x = (x + 1.0f) / (mXNodes+1);
//		float cell_x = (x + 2.0f) / (mXNodes+3);

        for (y = 0; y < mYNodes; y++)
        {
            vec3_t pos;
            CRMNode * pnode = new CRMNode();
            mNodes[x + y*mXNodes] = pnode;

            float cell_y = (y + 1.0f) / (mYNodes+1);
//			float cell_y = (y + 2.0f) / (mYNodes+3);

            pos[0] = TheRandomMissionManager->GetLandScape()->flrand(cell_x - x_rnd, cell_x + x_rnd);
            pos[1] = TheRandomMissionManager->GetLandScape()->flrand(cell_y - y_rnd, cell_y + y_rnd);
            pos[2] = 0;

            SetNodePos(x, y, pos);
        }
    }

    ClearCells(mXNodes, mYNodes);

    return true;
}
KG3DTerrainRegionLogical::~KG3DTerrainRegionLogical(void)
{
	ClearCells();
}