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 / Terrain + Physics

Author
Message
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 12th Jan 2018 14:13
Hi there,

what's the best way to make the terrain a collision object?
For now I do:


Is that the way to go? It takes quite a while for that Create3DPhysicsStaticBody to finish calculation and using a 2048x2048 terrain it just crashes.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 12th Jan 2018 15:08
I believe that's the correct way. It's what I do.
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 12th Jan 2018 15:09
Try with a 512 image. The Create3DPhysicsStaticBody() command can
only work with 1024 submeshes of a total of 2 million triangles.

Quote: "// create the terrain object from a height map
CreateObjectFromHeightMap( 1, "Mexico512.png", 1768, 25, 1768, 1, 16 )
SetObjectImage( 1, 1, 0 )
SetObjectUVScale( 1, 0, 128, 128 ) // scale the detail texture so it repeats
SetObjectShader( 1, 1 )
Create3DPhysicsStaticBody( 1 )"


The coffee is lovely dark and deep,and I have code to write before I sleep.
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 12th Jan 2018 15:22
Thanks guys, much appreciated!
Rick Nasher
6
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 12th Jan 2018 22:44
Is it a bit speedy?
For before without using physics I was told not to make terrain a collision object for would slow down things too much.
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 13th Jan 2018 09:44
Works without frame rate drops here. How else would you do collision stuff with the terrain, Rick?
Rick Nasher
6
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 13th Jan 2018 10:18 Edited at: 13th Jan 2018 10:31
That's good to hear.

Getting it to work with physics would be a bit difficult(if not impossible), but when using the regular collision system this could be done by taking terrainheight as a means of knowing where you are on the terrain, something like:

SetObjectPosition(playerID, playerx#,GetObjectHeightMapHeight(terrainID,playerx#,playerz#),playerz# )


(Note: GetObjectHeightMapHeight is a bit of weird command name, but it does the job. Would read better like GetObjectHeightFromHeightMap. Bit on the lengthy side but instantly clear what is meant)
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 14th Jan 2018 06:50 Edited at: 14th Jan 2018 22:04
Quote: "(Note: GetObjectHeightMapHeight is a bit of weird command name, but it does the job. Would read better like GetObjectHeightFromHeightMap. Bit on the lengthy side but instantly clear what is meant)"


not agree

GetObjectHeightMapHeight is better named than GetObjectHeightFromHeightMap.

"GetObjectHeightFromHeightMap" would involved an ObjectID declared over the terrain. The command actually returns an height from the X,Z coordinates only without any objectID.

(eventually GetObjectHeightMapYFromXZ() )
Rick Nasher
6
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 14th Jan 2018 09:48 Edited at: 14th Jan 2018 09:49
Yup, that's actually true. What was I th(dr)inking at the time..

Login to post a reply

Server time is: 2024-03-29 08:48:05
Your offset time is: 2024-03-29 08:48:05