In world mouse cursor.

Started by
7 comments, last by zppz 18 years, 9 months ago
Hello, I'm new to programming and I'm trying to implement little Advance Wars type of game in OpenGL. I have a working heightmap sized 256x256 where the units are and I have enabled mouse picking via glRenderPixels and I can already move the units in the world space via pathfinding and mouse. However, I have major problem. I do not know the method to render mouse cursor onto the heightmap. I assume this could be done via projection like shadows, but wouldn't the cursor texture get skewed? I was guessing projections since it sounds easiest. So, Are there any ways to render the mouse cursor without using the coordinates of the terrain, and simply magically projecting it on it? I have this last resort where the mouse cursor would be rendered on the terrain via the terrain coords, but this would require little storing the terrain in memory, which is bad since i use vbos. I wonder how this is done in commercial games such as Command & Conquer Generals and Warcraft3? I checked the faq and this was in there. I'd appreciate any pointers and help. Thanks.
Advertisement
Maybe Texture Splatting? Thats all I can really think of, there was an article on it I read a few weeks ago that explained it pretty well.

Texture Splatting

Hope that helps.




My Current Project Angels 22 (4E5)
This texture splatting is way over my head, but I will try to investigate further into it. Any other ideas? There had to some way people did it before vertex shaders because I'm sure some games had it before shader times.
I'm really just beginning 3D Graphics coding myself, but aren't decals the way to go for you here?

A texture 'hovering' over the Terrain?
I would suggest using that same picking code to find the point on the terrain that the cursor is on, and then render a cursor as a textured quad (probably with an alpha channel and blending enabled, to make it look nice), just above the terrain.
I am sure there are nicer looking ways of doing this, but this is simple.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

or simply keep the cursor 2D (or with a 3d model) but at 2D depth...

the only game that used a 3d cursor that I know of is Black & White....

just project a line from the cursor to the ground/units... or use opengl's selection / picking function... <-- google. :D

cheers, mate!
"Game Maker For Life, probably never professional thou." =)
I figured it out and ended up drawing a quad hovering on terrain. Unfortunately this doesn't work well on very steep surfaces but its a start.
Quote:Original post by el capitan
I figured it out and ended up drawing a quad hovering on terrain. Unfortunately this doesn't work well on very steep surfaces but its a start.


You have to take the slope into account, and angle your quad for the slope.
Maybe projection would be simpler [smile]

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

When you say 'cursor' are you meaning the mark that appears on the ground when you click to send a unit there? If so then I think the effect you are looking for is done by projecting a texture with alpha onto the terrain quads.
If you haven't done any texture projection before, read this article slowly and carefully.

This topic is closed to new replies.

Advertisement