[SOLVED] Mouse pick vertices?

I’m aiming to make a terrain (heightmap) editor. Is it possible to pick individual vertices (I know you can update individual vertices on the fly) in a procedurally generated primitive (well I guess it would apply to any model, if I understand the engine correctly)? I’ve got basic per-model/primitive/geom mouse picking working easily using the manual, but it makes no mention of vertex picking (or I’m retarded).

If this is not possible, one work around I thought of would be to make each vertex an individual geom, but that seems expensive, and also, can I make triangles out of that? Or would I need to make two “layers” (even more expensive - not on a rendering level, but at generation time) - one as each vertex set as individual primitives/geoms for picking, and and another that is the visible primitive? I hope that all makes sense…I feel like I’m not using all the right terminology (have not worked with Panda, or any 3D, in over a year).

Thanks for any help/insight!

EDIT: Yes, I searched the forums and google… Did not come up with anything, but happy to feel silly when you link me 20 related topics :wink:

EDIT2: I’m using Panda3D 1.9.0

EDIT3: Progress so far :smiley: files.experimentfailed.com/Very_ … enshot.png

You shouldn’t pick individual vertices, but in a heightmap terrain, you can easily know the XY coordinates when you do a ray test against the terrain (you can extract them from entry.getSurfacePoint()). You can use that to adjust the value on the heightmap image at that point, or (if you’re using CPU terrain) you can calculate which vertex you need to adjust.

Unless there is now a heightmap collision solid, then a ray/plane collision test will only work with a heightmap terrain if the ray is cast streight down.

There is an alternative. You can draw your terrain with a shader that will output the x and y position to the red and green channel. Render it to a 1x1 pixel buffer with a camera that fallows the mouse ( and have the red and green bits set to 16bit), and finally read back the value. It’s not very fast (it takes a moment to copy the pixel from vram), but it works in a editor. Works in mine at least.

Great, thanks for the replies! I think I have some direction now.

I should mention that my approach is to generate heightmap data off-camera using my own functions which basically spit out per-pixel/per-vertex data. I will then use Panda for a quick preview and very basic editor, then render the final image via Python Image Library. To render in Panda, I’m just generating a square plane and applying the aforementioned height data to it’s vertices. I mention this, as you kinda/sorta make it sound here like Panda has its own in-built methods of generating heightmaps?

Also, this is all done on the CPU for now, as I am very noob and have not learned how to write shaders yet.