April 24, 2019, 11:49:10 PM

Author Topic: How to put grass on a landscape?  (Read 866 times)

Offline phodiS

  • Jr. Member
  • **
  • Posts: 40
How to put grass on a landscape?
« on: May 09, 2018, 06:29:57 PM »
First up a disclosure.. I am not very good at programming, but I want to learn Blitz3d as so far its been a lot of fun.
Ok so let's get to it.
I have a MESH landscape (not a height-map) that I use for my terrain.
My player is a Sprite as a character that walks around on it. I have loaded a lot of models into the landscape, and all was going GREAT...but..
GRASS!!!.. ok. here's the thing. I have Sprite grass that I want to randomly place over the landscape. And I have done it (kind of), the problem being
although the coverage is good... the Y value of the Grass sprite doesn't actually sit on the Ground :( 
I Know how to do this on a heightmap, but for the life of me I can't get it to work on a mesh landscape. I tried to cheat and generate the grass really high..giving it gravity to
collide on the ground before the game starts.... but not all of the grass finds the ground...as I walk around most of it is at random heights. <<< This is the same as my models like houses and trees..  I end up just running the game... and checking if it's off the ground or not then adjust it back in the code. That's a pain.. but when it comes to grass... OMG!. Hehe.. any ideas guys?.
An alternative would be >> T.ED Terrain Editor V6.7 << but I can't buy a registration code for this awesome software as the site seems to have disappeared!... Any alternatives?.

Online STEVIE G

  • Sr. Member
  • ****
  • Posts: 292
Re: How to put grass on a landscape?
« Reply #1 on: May 09, 2018, 09:18:14 PM »
Make the landscape pickable using Entitypickmode and then use Linepick to place the grass ....

Quote
LinePick ( x#,y#,z#,dx#,dy#,dz#[,radius#] )
Parameters
x# - x coordinate of start of line pick
y# - y coordinate of start of line pick
z# - z coordinate of start of line pick
dx# - distance x of line pick
dy# - distance y of line pick
dz# - distance z of line pick
radius (optional) - radius of line pick 

For example ..

Entitypickmode LandscapeMesh, 2 
LinePick( x, 1000, y, 0,-2000,0 )
Positionentity Grass, x, Pickedy(), y

Where x and y are random coodinates.    Play about with the 1000 and -2000.

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 360
Re: How to put grass on a landscape?
« Reply #2 on: May 09, 2018, 09:23:17 PM »

Offline phodiS

  • Jr. Member
  • **
  • Posts: 40
Re: How to put grass on a landscape?
« Reply #3 on: May 09, 2018, 09:31:45 PM »
Wow guys thanks VERY much for this information!!!...
I have a few weeks off work at the moment... am spending it ~trying to get good at this~ !!! 
Cheers!.

Offline phodiS

  • Jr. Member
  • **
  • Posts: 40
Re: How to put grass on a landscape?
« Reply #4 on: May 09, 2018, 11:33:27 PM »
I hope this is the right area to ask questions.. I don't want to be ~that guy~, so if there is a better place to go for coding questions, please let me know.

My a new problem is....
I want to be able to spawn several of the same enemy at the same time. Problem is for a newbie like me is that only one of them moves. I know I can re-name them to enemy2, enemy3 etc but I'm thinking there must be a better way?..especially if I want like 20 enemies down the road.
This is what I am doing...

; ENEMY
for e=1 to 10
px=Rnd(-300,300) y=10 pz=Rnd(-300,300)
enemy = CreateSprite()
etexture=LoadTexture( "enemy.bmp" )
EntityTexture enemy, etexture, 1
ScaleSprite enemy, 2,2
PositionEntity enemy,px,y,pz
EntityType enemy, type_enemy
next

This is a bill-boarded sprite on a 3d terrain.

Also to prevent them from bumping into each other... I add random speed to each of them when they get to close to each other.. this works fine for like 3 enemies.. as the collisions for these guys dont seem to work on each other. The collisions work with my trees, just not between enemies.

Oh I tried the links for TED but it looks like the only one available needs registration still. But if there are any other links for this Terrain Editor I'd love to get it please.
Cheers.

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 360
Re: How to put grass on a landscape?
« Reply #5 on: May 10, 2018, 02:17:06 PM »
This is the right place but if you have a separate issue it's best to post a separate thread, as someone may miss your question.

Yes, I made a mistake, see the post above again, it has another thread with the reg code in it, also you will need the T.Ed loader code which I also added to my previous post.

My advice is search the old forum before asking a question as there is a lot of answers there, however if you search www.mojolabs.nz in Google/Bing you only get partial results as the whole site isn't indexed. If you want a full search you can download the whole archived site and follow the guide to installing Regain (and Java):
Searchable BlitzBasic forum archive

Offline phodiS

  • Jr. Member
  • **
  • Posts: 40
Re: How to put grass on a landscape?
« Reply #6 on: May 11, 2018, 07:45:50 PM »
Thank you all for the help it's invaluable!.. I will be downloading and going through the Blitz3d archives.

I think I have sorted my ENEMY problem out in the sense I will be treating them like Bullet spawning..each being an individual :)  I didn't think of this before. I come from GAMEMAKER and it's a little different of course.

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 360
Re: How to put grass on a landscape?
« Reply #7 on: May 12, 2018, 01:41:01 PM »
B3D uses Types which are objects like in OOP but they're just a limited subset of OOP. Still types are the best way to code things, they're faster than arrays and make for more readable code.

For types this is a good place to start:
Types (BP and B3D) (beginners)

Another good guide to types is in Blitz 3D Crash Course:
Blitz 3D Crash Course Part 2

And for an advanced types tutorial:
Tutorial - Types in Blitz3D

Probably the best third-party beginners tutorial is Ray Diaz's, downloadable from the 2nd link:
Blitz3D Beginners Tutorials by Ray Diaz
Blitz mirror

Offline phodiS

  • Jr. Member
  • **
  • Posts: 40
Re: How to put grass on a landscape?
« Reply #8 on: May 12, 2018, 10:38:43 PM »
Once again thank you guys, I went to all the sites and am amassing as many Blitz3d programs to look through as I possibly can. It's all great reference material of course.
It's a shame as a lot of demo's in the community magazines are all long gone. But no worries, I have more than enough to mess around with now at the moment.!

Offline grindalf

  • Jr. Member
  • **
  • Posts: 55
Re: How to put grass on a landscape?
« Reply #9 on: May 23, 2018, 09:42:05 AM »
another good way to do enemies would be with an array
An array needs to be declared first in blitz3D so you would write your maximum enemies in these brackets

enemy(10)

then you can cycle through all the different enemies like this

for tempnum=1 to 10
enemy(tempnumber)=do something awesome here
next