Scenerio: I have a dbTerrain with rolling hills and a river system running through it. I want to load instances of arrayed objects. Example: I have 3 different tree models, I randomly place 25 on the map surface after doing a height test. That part works fine, but either my loop is not changing to the next type of tree or it is possibly placing the next group of trees in the same exact position as the previous type. I do not clearly understand the the dbRandomize(int seed) to know if I even need it or I am using it correctly. Not even sure the way I am loading these objects is effective enough. Bare in mind I am a novice, but learning a lot creating this project. Not sure how to add a snippet. If it does not add it I will post it. Any help would be appreciated, I can post the entire project code if needed. I also believe this could help other novices in the future. I declared the following:
int trees[3] = {15, 16, 17};
int Tree1 = 15;
int Tree2 = 16;
int Tree3 = 17;
void loadStaticObjects()
{
dbRandomize ( dbTimer ( ) );//do I need this here or somewhere else?
dbLoadObject("Objects/Level1 and 2c//Level1and 2c.X",12);
dbSetObjectTransparency(12, 6);//Reminder, may have to change roof to ground floor roof. It shows transparent between the bricks.
dbSetAlphaMappingOn (12, 100);
SC_SetupObject(12, 1, 0);//used to check collisions against the environment
SC_AllowObjectScaling(12);
dbRotateObject(12,0,180,0);
dbScaleObject(12, 3,3,3);
dbPositionObject(12, dbObjectPositionX(map)+ 1050, dbObjectPositionY(map) + 78, dbObjectPositionZ(map)+946);//position object where it goes
SC_UpdateObject(12);
//Need to creat an array of different tree ect....
dbLoadObject("Objects/Trees/Tree1.dbo",15);
dbLoadObject("Objects/Trees/Tree2.dbo",16);
dbLoadObject("Objects/Trees/Tree3.dbo",17);
//dbLoadObject("Objects/Trees/Tree4.dbo",18);
//dbLoadObject("Objects/Trees/Tree5.dbo",19);
//This was for loading individual trees
//SC_SetupObject(15, 1, 0);//used to check collisions against the environment
//dbSetObjectTransparency(15, 6);
//dbSetAlphaMappingOn (15, 100);
//SC_AllowObjectScaling(15);
//dbScaleObject(15, 100,100,100);
//SC_UpdateObject(15);
//Loop to laod 25 of each type of tree (objects)
for( int i = 15; i < 18; i++)
{
SC_SetupObject(i, 1, 0);//used to check collisions against the environment
dbSetObjectTransparency(i, 6);
dbSetAlphaMappingOn (i, 100);
SC_AllowObjectScaling(i);
dbScaleObject(i, 100,100,100);
SC_UpdateObject(i);
for(int temptree = 9000; temptree < 9024; temptree++)//Generates 25 trees
{
dbInstanceObject(temptree, trees[i] );//Creates the instance of one of the types of tree objects
dbPositionObject(temptree, dbRND(MW), 175, dbRND(MH));//Places the instance at a random position on the map above ground height.
GH = dbGetTerrainGroundHeight(1, dbObjectPositionX(temptree), dbObjectPositionZ(temptree));//Gets the groundheight at that random position
dbPositionObject(temptree, dbObjectPositionX(temptree),GH,dbObjectPositionZ(temptree));//Places the instance at that ground height.
//Need to set a check so vegitation objects can't be placed on other objects. Buildings, roads, other trees, ect...
//Need to test the GH to make sure not on a hillside or in water.
//if(GH > 132.0 && GH < 136.0)
//{
//dbPositionObject(temptree, dbObjectPositionX(temptree), GH, dbObjectPositionZ(temptree));
//}
//else
//{
//temptree-- //if the spot is not good for placement decrease temptree counter by 1 so in the end we end up with the 25 instances
//}
}
}
}