Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Heightmap tree generation.

Author
Message
Phodis
8
Years of Service
User Offline
Joined: 3rd Oct 2015
Location:
Posted: 30th Oct 2018 20:17
Hi guys,
I'm just trying to add some trees to my heightmap terrain, but..being new..I am doing something wrong.

//tree
for t=1 to 1000
tree=CreateObjectBox(3,50,3)
x# = random(-3000,3000)
z# = random(-3000,3000)
y# = getobjectheightmapheight(tree,x#,z#) // <<<<< this line I think is the reason.....can anyone shed some light on this for me please?.

SetobjectPosition (tree,x#,y#,z#)
next

The author of this post has marked a post as an answer.

Go to answer

puzzler2018
User Banned
Posted: 30th Oct 2018 20:21 Edited at: 30th Oct 2018 20:23
This post has been marked by the post author as the answer.
Are you sure it should be "tree" in the

getobjectheightmapheight(tree,x#,z#)

command.. and not the terrain object instead? - maybe?

Wow - 1000 tree objects too, the FPS will fail for you- maybe look at mesh memblock work instead when you get used to AGK
[img]null[/img]https://forum.thegamecreators.com/thread/222071

Welcome by the way

Phodis
8
Years of Service
User Offline
Joined: 3rd Oct 2015
Location:
Posted: 30th Oct 2018 21:35
OMG, lol..I am such an idiot... literally face palmed myself hehe

THANK YOU!!..

//tree
for t=1 to 100
tree=CreateObjectBox(3,50,3)
x# = random(-3000,3000)
z# = random(-3000,3000)
y# = getobjectheightmapheight(1,x#,z#)
SetobjectPosition (tree,x#,y#,z#)
next

I am on uncertain territory here... but I am using the CreateObjectFromHeightMap command not the CreateObjectFromObject mesh..and it does seem to run ok even with 50000 trees at (35fps)
So far, (I know very little)..I have not investigated mesh culling to save some gpu... but for now. And I am very green at programming. I will have a read up on the link you posted...heck, for now I am just happy to have the terrain and trees working.
Cheers again.
puzzler2018
User Banned
Posted: 30th Oct 2018 21:44 Edited at: 30th Oct 2018 21:45
welcome - its always good to have 4 eyes on any coding mishaps - dont worry about it- we all been there

Enjoy AGK

Login to post a reply

Server time is: 2024-04-20 06:11:52
Your offset time is: 2024-04-20 06:11:52