Jump to content
  • Advertisement
  • entries
  • comments
  • views

Gives us the happy juice!

Sign in to follow this  


I'm officially addicted to this.

Today I've moved up from a single quad to a vertex buffer and index buffer, generating a flat mesh of several quads. The idea is to eventually turn this into a heightmapping system of sorts. Step one of course is to actually generate the mesh data.

I got the mesh generation working pretty quickly with the help of some Google and a little elbow-grease. I think that having a fairly comprehensive amount of experience thinking in 3D coordinate systems (from the Freon project) is making this a lot easier to go through. Despite the fact that I've barely touched polygon rasterization engines since I wrote my own software rasterizer 6 years ago, a lot of things are familiar and make a lot of sense.

The main thing I'm having trouble wrapping my head around at the moment is how I'm going to structure the code so that I can acheive optimal batching to the video hardware. I'm aware of all the tricks like texture baking (so multiple surfaces can be textured with a single SetTexture() call) and all that, but I've yet to really grok how to make my code do all this elegantly. This is of course made slightly more complex by the fact that I'm trying to learn C#'s design paradigms at the same time.

Once that's all sorted in my brain, I still have to find out how programmable shaders fit into all this mess. Incidentally, if anyone knows of a good online site that explains how all the modern pipeline stuff works at a reasonably abstract level, I'd much appreciate a link.

Needless to say, I'm finding all of this ridiculously fun [grin]

Anyways, once I got the mesh generated, I wanted to confirm that it was working. A little bit of Google turned up the ever-handy FillMode flag, so I swapped the renderer over to wireframe mode. That, however, renders the edges of each polygon textured, which I wasn't wanting - I wanted to see nice white lines. So a little bit of playing around with IntelliSense turned up the appropriate flags, and I figured out how to render solid white wireframe overlays on top of the actual textured surface.

The actual technique is pretty stupid, as it basically brute-force renders the entire scene twice, but IMHO it's not bad for a DX newbie [grin]

I absolutely love Managed DirectX, though. The code boils down to basically this:

dev.RenderState.FillMode = FillMode.Solid;
dev.TextureState[0].ColorOperation = TextureOperation.SelectArg1;
dev.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;

dev.RenderState.FillMode = FillMode.WireFrame;
dev.TextureState[0].ColorOperation = TextureOperation.SelectArg1;
dev.TextureState[0].ColorArgument1 = TextureArgument.Constant;
dev.TextureState[0].ConstantColorValue = 0xffffff;

So much more readable and sensible than the C++ bindings. It's borderline orgasmic. Anyways, here's the rendered result:


So far it's just a blob of polygons on a flat plane; my next project is to build in proper world and camera transforms so I can look at this from a more isometric-style angle and show the effects of the heightfield. Woot.
Sign in to follow this  


Recommended Comments

Nice, thanks.

That prompted me to surf around a bit more, at which point I discovered that I suck [grin]

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!