For my game project (A rogue-like with random levels) I need to create different size cubic models and apply textures to them on the fly.
I’m currently doing this by loading the default cube.egg model and scaling it accordingly. Trouble is, the texture doesn’t wrap…obviously because the coordinates are already specified in the model file.
Thing is, I need that texture to wrap according to the size of the cube…for example:
- If a cube’s x and y scale values are set to (1, 1) the texture won’t wrap.
- If they are set to (1, 3) the texture would wrap three times on the appropriate faces.
I’ve come up with a few ideas of going about this, but I’m quite new to this engine, Python (I already know programming from Java and C# at least ) and 3d game development in general, so I’d appreciate a little guidance.
Here are the approaches I’ve come with:
-
Actually create the cube model dynamically, specifying it’s vectors and texture coordinates from the application itself. [I couldn’t find anything about this, so I’m not thinking it’s possible without communicating directly with the renderer in C++…which is something I want to avoid at all costs]
-
Modify the texture coordinates of the model in memory once I load it [I’ve looked over the reference section and couldn’t find any methods which would allow me to do this]
-
Use “tiles”, so that, for example, a wall is actually made up of several cubes. This was actually the approach I originally tried, but a little experiment proved that this was a bad idea.
I basically loaded 10,000 cubes into memory and set them up on the map as one big chunk. Needless to say that my video card had a hard time digesting all those vertices when viewed from a distance (10,000 * the 23 vertices in the cube file = 230,000 vertices!).
This means that speed will not be consistent, and I was hoping to aim this game at a large audience, which may not have the same hardware specs as I do–Roguelikes usually require extremely minimal specs.
To be honest, there will never be an instance in the game where the camera will have all those vertices on screen. However, it’s still extremely limiting. I abandoned this approach pretty early, but maybe there’s some way to improve the speed?
I’ve got other ideas in mind, which are easier, less time consuming, and more efficient. But the above three would certainly make my game a whole lot more dynamic and (dare I say it?) cool!
Any advice would be appreciated, but I’m not looking for algorithm handouts, more like something along the lines of “check out this module”.
P.S. Big props to the python community and the Panda team. This is probably the easiest and cleanest Engine/Script combination I’ve experimented with. It’s slowly transforming me into a python addict.