Placing trees on Terrain with mouse?

You ****ing beauty!!!

er it works Relic!

You da man!

And Gork wasnt required!

You do know now when ever I am in the **** I am going to scream

RELIC! RELIC! RELIC!

my god what have you done

Thanx to all the Ironduke Code Stallion

(okay shetland pony)

Yes, it’s because Relic reads the modelviewmatrix and the
projectionmatrix directly after drawing the terrain. Not later, where you maybe would have altered the matrix by calls to glrotate or gltranslate.
Look 9 posts above…

So…
What if you just want to place the ‘tree’ (a single vertex in my case) only 1.0f units ‘inside the screen’ and not directly on the terrain?
I’m asking because I’m just writing and editor to create the terrain itself.
what value do you use as the third parameter of gluUnProject? The mouse position is two dimensional. Where do you get a z-component from?

hehe i suggest u start over at the top of the page and read all the comments again. the answers there

Tee hee:P

If no one has helped you I should have found my old code for this in a day or two.

Hey zed,
I read the whole thread already three times by now and I still don’t get the answer. Everybody here uses glReadPixels to get the z-value for the window coordinates but doesn’t that give you the point of impact on the terrain? How can I read the depth component of pixels that were never drawn? I don’t have a scene where I could place things. I start of in the void. I just want it 1.0 units deep in the screen.

And ironduke, if I could have a look at the code, that would be wonderfull.

>>Everybody here uses glReadPixels to get the z-value for the window coordinates but doesn’t that give you the point of impact on the terrain? How can I read the depth component of pixels that were never drawn? <<

well in that case readpixels will either return crap or whatever u clear the z depth to (im not sure).
in such a situation its impossible to find out exactlly where you’ve clicked just set the z value (for gluUnproject) to some figure (eg 0.5)

Yeah, well the 0.5 thingie works. Sortof. Not very exact but at least the Z value is between 2 and 3 now and not somewhere around 997. You said you have code for that. What do you put in for the windows z posistion?