I’m trying to reproduce plant life at least grass. I’m getting this from the following code. The grass ends up in the air although the center point is exactly on the bottom of the mesh.
[code] /// Define random point variables
int randomSpotx;
int randomSpotz;
/// Loop 1,000 times to find a suitable location
for(int i=0; i<40000; i++)
{
randomSpotx=rand()%512;
randomSpotz=rand()%512;
randomSpotx-=256;
randomSpotz-=256;
/// Select a possible position to place a plant
Vector3 selectPosition=Vector3(randomSpotx,terrain->GetHeight(Vector3(randomSpotx,randomSpotz)),randomSpotz);
/// Add a plant to the seen - plant Node
Node * plantNode = scene_ -> CreateChild("plantNode");
StaticModel* plantStaticModel = plantNode ->CreateComponent<StaticModel>();
plantStaticModel->SetModel(cache->GetResource<Model>("Resources/Models/Grass01.mdl"));
plantStaticModel->ApplyMaterialList("Resources/Models/Grass01.txt");
plantStaticModel->SetCastShadows(true);
//RigidBody* plantBody= plantNode->CreateComponent<RigidBody>();
//CollisionShape* plantshape = plantNode->CreateComponent<CollisionShape>();
//plantshape->SetBox(Vector3::ONE);
//plantshape ->SetLodLevel(1);
// plantBody->SetCollisionLayer(1);
/// Set plant position
plantNode->SetPosition(selectPosition);
}[/code]