Skip to main content
GameDev.net gamedev.net
🔒 Locked

Multiple Object Best Approach?

Started by Supernat02 Jan 25, 2006 at 11:18 PM 1 replies 600+ views
Original Post
Supernat02
Supernat02
Hi, I was wondering if any of you could just give me some suggestions on how to do this. Any help is appreciated! I want to do something similar to the Direct3DLight system. I want to have a unique ID for different types of terrains. For instance, terrain 1 could be a 3D Brute Force mesh terrain while terrain 2 could be a isometric terrain, both could be loaded and ready to go, but I would only enable and draw one at a time. So, my question is about the approach in storing the terrain data. I have a List template that will store items by name and return an index for the item. So, if you create a mesh, give it a name, it is stored by name and returns index 1 let's say. I want to use that approach with the terrains, but each terrain class will be very different. Should I do like Microsoft and pass in a data structure that contains all of the needed data along with the terrain type? I thought about using object inheritance, but none of the terrain types will have the same generation function or anything else for that matter. Is there a way to do that cleanly while still keeping my List object that assigns a unique ID to each terrain generated, no matter what type it is? Thanks! Chris
Chris ByersMicrosoft DirectX MVP - 2005
Supernat02
Supernat02
I think I have a solution now. Sorry that it was confusing. Basically, I just wanted to use the same template list to store multiple classes. I was just over complicating things. I'm going to just create a base Terrain class and pass that to the templated list. The base Terrain type will only contain an enumeration for the type of terrain, which I can then use to cast the base Terrain pointer to the proper terrain. Other suggestions are still welcome though.

Thanks!
Chris ByersMicrosoft DirectX MVP - 2005

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.