コード例 #1
0
CGroup* CGroupHandler::CreateNewGroup(AIKey aiKey)
{
	if(freeGroups.empty()){
		CGroup* group=SAFE_NEW CGroup(aiKey,firstUnusedGroup++,this);
		groups.push_back(group);
		if(group!=groups[group->id]){
			handleerror(0,"Id error when creating group","Error",0);
		}
		return group;
	} else {
		int id=freeGroups.back();
		freeGroups.pop_back();
		CGroup* group=SAFE_NEW CGroup(aiKey,id,this);
		groups[id]=group;
		return group;
	}
}
コード例 #2
0
CGroupHandler::CGroupHandler(int team)
: firstUnusedGroup(10),
	team(team)
{
	defaultKey.dllName="default";
	defaultKey.aiNumber=0;

	//FindDlls();

	for(int a=0;a<10;++a){
		groups.push_back(SAFE_NEW CGroup(defaultKey,a,this));
	}
}
コード例 #3
0
//----------------------------------------------------------------------------
void CollisionsBoundTree::CreateScene ()
{
    // The root of the scene will have two cylinders as children.
    mScene = new0 Node();
    mWireState = new0 WireState();
    mRenderer->SetOverrideWireState(mWireState);
    mCullState = new0 CullState();
    mCullState->Enabled = false;
    mRenderer->SetOverrideCullState(mCullState);

    // Create a texture image to be used by both cylinders.
    Texture2D* texture = new0 Texture2D(Texture::TF_A8R8G8B8, 2, 2, 1);
    unsigned int* data = (unsigned int*)texture->GetData(0);
    data[0] = Color::MakeR8G8B8(0,     0, 255);  // blue
    data[1] = Color::MakeR8G8B8(0,   255, 255);  // cyan
    data[2] = Color::MakeR8G8B8(255,   0,   0);  // red
    data[3] = Color::MakeR8G8B8(255, 255,   0);  // yellow

    Texture2DEffect* effect = new0 Texture2DEffect(Shader::SF_LINEAR);

    // Create two cylinders, one short and thick, one tall and thin.
    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);

    StandardMesh sm(vformat);
    VertexBufferAccessor vba;
    int i;

    mCylinder0 = sm.Cylinder(8, 16, 1.0f, 2.0f, false);
    vba.ApplyTo(mCylinder0);
    for (i = 0; i < vba.GetNumVertices(); ++i)
    {
        vba.TCoord<Float2>(0, i) = mBlueUV;
    }
    mCylinder0->SetEffectInstance(effect->CreateInstance(texture));
    mScene->AttachChild(mCylinder0);

    mCylinder1 = sm.Cylinder(16,8,0.25,4.0,false);
    vba.ApplyTo(mCylinder1);
    for (i = 0; i < vba.GetNumVertices(); ++i)
    {
        vba.TCoord<Float2>(0, i) = mRedUV;
    }
    mCylinder1->SetEffectInstance(effect->CreateInstance(texture));
    mScene->AttachChild(mCylinder1);

    mScene->Update();

    // Set up the collision system.  Record0 handles the collision response.
    // Record1 is not given a callback so that 'double processing' of the
    // events does not occur.
    CTree* tree0 = new0 CTree(mCylinder0, 1, false);
    CRecord* record0 = new0 CRecord(tree0, 0, Response, this);
    CTree* tree1 = new0 CTree(mCylinder1, 1, false);
    CRecord* record1 = new0 CRecord(tree1, 0, 0, 0);
    mGroup = new0 CGroup();
    mGroup->Add(record0);
    mGroup->Add(record1);

    ResetColors();
    mGroup->TestIntersection();
}