I’ve run into a problem that I just can’t seem to figure out.
I make the ground out of hexagons that are based off a .mdl file that I just change the material of.
I started off with with a base plane that is not meant to be removable based off the HugeObjectCount tutorial(which was a great help!)
[code] StaticModelGroup* hexagonsLastGrp = 0;
if (!hexagonsLastGrp || hexagonsLastGrp->GetNumInstanceNodes() >= 50 * 50)
{
Node* hexPlane = scene_->CreateChild("hexPlane");
hexagonsLastGrp = hexPlane->CreateComponent<StaticModelGroup>();
hexagonsLastGrp->SetModel(cache_->GetResource<Model>("Models/SmallHex.mdl"));
hexagonsLastGrp->SetMaterial(cache_->GetResource<Material>("Materials/Grass/Grass3.xml"));
}
const float testOff = sin(ang) * radius;
for (int x = 0; x != 50; ++x)
{
for (int z = 0; z != 50; ++z)
{
float zPos = z * radius;
if (x % 2 != 0)
{
zPos += testOff;
}
Node* hexFloorNode = scene_->CreateChild("hexPlaneNode");
hexFloorNode->SetPosition(Vector3(x * height, 2.0f, zPos));
hexNodes_.Push(SharedPtr<Node>(hexFloorNode));
hexagonsLastGrp->AddInstanceNode(hexFloorNode);
}
}[/code]
I then added a plane of water above this.
At this point my fps sits around 200.
My next goal was to start adding the editable tiles above this, so I created another plane of hexs above the water using the same method as above, everything rendered fine and my fps was still 200.
But at this point, I realized that if I went to remove 1 individual hex, it would remove the entire plane.
[code]void GiveUp::RemoveHexagon()
{
Vector3 hitPos;
Drawable* hitDrawable;
if (Raycast(250.0f, hitPos, hitDrawable))
{
Node* hitNode = hitDrawable->GetNode();
if (hitNode->GetName() == "hexPlane")
{
hitNode->Remove();
}
//
}
}[/code]
I tried different methods of attempting to get the child of that plane at the mouse location, but couldn’t seem to come up with anything that worked.
I then tried to build the plane without adding the hex’s into a StaticModelGroup, this worked, and I could then remove a hexagon one at a time, but my fps at this point stood around 1-20, I assume because the amount of batches.
Does anyone know of a way to keep the calls low, while still being able to remove an individual model?