Ok, another question, which I could have asked in my current thread, but I thought since this is unrelated, it may be best to ask it in a different thread.
Anyways. I have been able to figure out how to load a base terrain (planes) as required and exclude the unwanted ones. Now the issue comes with foliage on the large terrains. I'm using the Instance command to clone many of these objects, although the issue comes with the grass. There is so many of these objects that to make it look like a dense grassy area, I'm looking at >1500 objects, just for the grass, not including trees. The objects are simple planes, although it slows down the system significantly!
So, to make another long story shorter, how would I go about repositioning the objects which are off screen to specific locations in the next map section. (each section is 1000x1000 units)
Here is some code for you all:
For loading the files and instancing
LoadingOthers:
Load Image "Data/Health.tga",100
Create Animated Sprite 10,"Data/Health.tga",6,6,100
Load Object "Data/Models/Map/Trees/Tree1.x",100
Load Object "Data/Models/Map/Trees/Tree2.x",101
Load Object "Data/Models/Map/Trees/Tall Grass1.x",102
Load Object "Data/Models/Map/Trees/Tall Grass2.x",103
Load Object "Data/Models/Map/Trees/Tall Grass3.x",104
Load Image "Data/Textures/TallGrass01.tga",101
Load Image "Data/Textures/TallGrassN.tga",102
Load Image "Data/Textures/Ferns.tga",103
Load Image "Data/Textures/FernsN.tga",104
For x = 102 to 104
Convert Object FVF x,274
`Fix Object Pivot x
Set object effect x, 1
Next x
Texture Object 102,0,103
Texture Object 102,1,104
Texture Object 103,0,101
Texture Object 103,1,102
Texture Object 104,0,101
Texture Object 104,1,102
For clone = 105 to 400
Instance Object clone,100
Next clone
For clone2 = 401 to 800
Instance Object clone2,101
Next clone2
For clone3 = 801 to 1200
Instance Object Clone3,102
Next Clone3
For Clone4 = 1201 to 1500
Instance Object Clone4,103
Next Clone4
For Clone5 = 1501 to 2000
Instance Object Clone5,104
Next Clone5
For Position = 100 to 800
If Object Exist(Position)
Position Object Position, RND(5000),0,RND(5000)
Set Object Cull Position, 0
xeno make rigid body static Box Position
Endif
Next Position
For Position2 = 801 to 2000
If Object Exist(Position2)
Position Object Position2,RND(1000),0,RND(1000)
Set Object Cull Position2,0
Endif
Next Position2
Return
For the LOD:
LODSystemTrees:
LODDistance# = 700
For LODObj=101 to 2000 `step 2
If Object Exist(LODObj)
Distance# = LODFunction(LODObj,1)
Distance# = Distance# - LODDistance#
If Distance# < 0 then Distance# = 0
If Distance# > 500
Exclude Object ON LODObj
Else
Exclude Object OFF LODObj
Endif
Endif
Next LODObj
Return
Finally the Map Update Function:
Function Load_Section()
CurrentPosition = MapPosition
MapPositionX = (Object Position X(1)+500)/1000
MapPositionZ = (Object Position Z(1)+500)/1000
MapPosition = Map(MapPositionX,MapPositionZ)
Text 700,10,"Maptile "+Str$(MapPosition)
If MapPosition <> CurrentPosition
Exclude Object OFF MapPosition
If Object Exist (MapPosition+1)
Exclude Object OFF MapPosition+1
Endif
If Object Exist (MapPosition-1)
Exclude Object OFF MapPosition-1
Endif
If Object Exist (MapPosition + MapXSize)
Exclude Object OFF MapPosition+ MapXSize
Endif
If Object Exist (MapPosition - MapXSize)
Exclude Object OFF MapPosition - MapXSize
Endif
If Object Exist (MapPosition + MapXSize + 1)
Exclude Object Off MapPosition + MapXSize + 1
Endif
If Object Exist (MapPosition + MapXSize - 11)
Exclude Object Off MapPosition + MapXSize - 11
Endif
If Object Exist (MapPosition + MapXSize -1)
Exclude Object Off MapPosition + MapXSize - 1
Endif
If Object Exist (MapPosition + MapXSize - 9)
Exclude Object Off MapPosition + MapXSize - 9
Endif
If Object Exist (MapPosition + 2)
Exclude Object ON MapPosition+2
If Object Exist (MapPosition - 2)
Exclude Object ON MapPosition - 2
Endif
Endif
For x = 7 to 25
If Object Exist (MapPosition + x)
Exclude Object ON MapPosition + x
If Object Exist (MapPosition - x)
Exclude Object On MapPosition - x
Endif
Endif
Next x
REMSTART
`THIS IS WHAT I WAS THINKING TO REARRANGE THE GRASS AND TREES, BUT KIND OF LOST
For MapPos = 1000 to 1025
If MapPosition = MapPos
XZMin = (MapPos-1000)*1000
XZMax = (MapPos-1000)*1000
`ZMin = MapPos-1000
`ZMax = 1000
For x = 100 to 250
Next x
Endif
Next MapPos
Endif
REMEND
For PointObj = 801 to 2000
If Object Exist (PointObj)
If Object In Screen (PointObj)
Point Object PointObj, Camera Position X(), 0, Camera Position Z()
Endif
Endif
Next PointObj
EndFunction
So, I'm sure there are better, and easier ways to go about this issue. Any ideas on how to optimize this section, or minimize the number of objects. Minimizing objects would be best, because this is not even close to the size of the map I would like to have.
Thanks all!
www.myspace.com/norseblod