示例#1
0
//----------------------------------------------------------
/// 壁データのロード
/// @param	n: 壁番号(000〜999)
/// @return	ロード成功(true), 失敗(false)
/// @author	Harui
//----------------------------------------------------------
bool CWall::LoadWall(int n){
	string wallname, buf;

	// 今あるデータは除去
	_vertex.clear();
	_coins.clear();
	// z初期化
	z = INIT_Z;

	// 読み込むファイル名生成
	wallname = "Data/wall/wall";
	wallname += (char)('0'+n/100);
	n = n%100;
	wallname += (char)('0'+n/10);
	n = n%10;
	wallname += (char)('0'+n);
//	wallname += ".txt";

	// ファイル読み込み
	FILE *fp = fopen((wallname+".txt").c_str(), "r");
	if( !fp )	return false;

	// 壁の穴の座標
	int nv;
	fscanf(fp, "%d", &nv);		// txtファイルの文字コードがShift_JISでないとエラー起きる注意
	while(nv--){
		double x, y;
		fscanf(fp, "%lf, %lf", &x, &y);
		_vertex.push_back( make_pair<double,double>(x, y) );
	}
	// コインの座標
	int nc;
	fscanf(fp, "%d", &nc);
	while(nc--){
		double x, y;
		fscanf(fp, "%lf,%lf", &x, &y);
		_coins.push_back( make_pair<double,double>(x, y) );
	}
	fclose(fp);

	// 壁の点の順番ソート
	SortWallPoints();

	// 三角形分割
	SplitTriangles();

	// 壁名と同じpngファイルがある時、それを壁にする
	if( imgWall!=-1 )		DeleteGraph(imgWall);
	imgWall = LoadGraph((wallname+".png").c_str());

	return true;
}
示例#2
0
void kDOPTree::BuildNode( kDOPTree::kDOPNode* pNode )
{
    mDepth++;
    
    if( mDepth > mMaxDepth )
        mMaxDepth = mDepth;

    FindBoundingBox( pNode );

    // Test if we're creating a leaf or a node.
    if( pNode->mTriangleIndices.size() > 5 )
    {
        mNumNodes++;

        Float axisMean;
        Axis splitAxis = SelectSplitAxis( pNode->mTriangleIndices, axisMean );

        // Add two nodes.
        kDOPNode* leftNode  = GD_NEW(kDOPNode, this, "Engine::Collision::kDOPTree");
        kDOPNode* rightNode = GD_NEW(kDOPNode, this, "Engine::Collision::kDOPTree");

        pNode->mChildsIndex = mNodes.size();
        
        mNodes.push_back( leftNode );
        mNodes.push_back( rightNode );

        // Split triangles into two list.
        SplitTriangles( pNode, splitAxis, axisMean );

        // No need to store this in nodes.
        pNode->mTriangleIndices.clear();

        // Recursively call build tree.
        BuildNode( leftNode );
        BuildNode( rightNode );
    }
    else
    {
        // No work to do for leaves!
        mNumLeaves++;
    }

    mDepth--;
}