my gaming past, present and future
Tuesday June 18th 2013

GameTalk

To view the read-only archive of the original GameTalk forum, click here.

Guest  

Show or hide header
Welcome Guest, posting in this forum requires registration.




planet romero » Gaming » Game Dev / Asset Production » Creating a simple 3D engine...

Pages: [1] 2 3 4
Author Topic: Creating a simple 3D engine...
Boone
Member
Posts: 92
Post Creating a simple 3D engine...
on: February 24, 2010, 11:22

Okay, so this week I’ve been doing lots of maths, and finally cracked how to calculate – using simultaneous equations – how to find the intersection of two parametric lines.

That has enabled me to figure out how to render at least vertical walls. My problem left is figuring out how to do texture mapped floors and ceilings.

I looked up “flats” for the DOOM iD-1 engine, but don’t fully understand it, plus it seems over-kill for what I am aiming for. The idea is to make a Wolf3D engine but with arbitrary walls(which poses no problem to me), and to have the same floor and ceiling throughout a level(map or stage, whatever) – similar to the fact that Wolf3D uses the colour grey to represent a floor or ceiling!

So I am going to make it as simple as I can get it – split the screen into two rectangles, one for the top half of the screen to represent the ceiling, and one for the floor.

Now, for perspective, I noticed in the C64 version of Space Harrier, the block rows(representing the game world floor) towards the horizon are thinner than the block rows coming towards the player: This is obvious as objects appear smaller in the distance, but larger close up. So that’s a task for the vertical side of rendering…

Not quite sure how to go about the actual mapping of the floor texture itself – short of going all out on a polygon rendering fucntion! I think what I can do, though is maybe plot lines and clip them to the rectangles. I would be creating a grid for the game world anyway, so the only thing I would have to map to the view is the points of each square tile of the floor, and can go for either a mirroring option for the ceiling(just flip the floor) or can go for an open sky option with wrap-around horizontal texturing.

I would prefer a textured floor though! ^_^

Anyway, first thing I need to do is create a maths engine in Java. Once I have finished that I’ll move on to a level creation tool for plotting lines, which I had done before in C++ but didn’t have the level of maths knowledge to make it usable(which I now have! Hurrah!). Really excited about this project as it’s been bugging me for almost a decade…

Some might wonder why I am going through the pain of writing a 3D engine in software, when an API can do all the donkey work for me. Well, I simply want to increase my maths and programming knowledge. Its the challenge, and the reward of knowing that I can create a “living” 3D world from scratch and without the aid of APIs(although they can do faster, more efficiently, and even better).

Still, I’m going to make a first test game that’s slightly more advanced than wolf3D and then maybe have a crack at a full polygon engine afterwards. I just needed to “talk” about this little project as it really means a lot to me. I think I have a weeks holiday in April(better check with them at work!), so that’s when I will bang out the first test demo and post it here.

(sorry for the long winded post!) ^_^

Boone
Member
Posts: 92
Post Re: Creating a simple 3D engine...
on: February 25, 2010, 22:13

Looked into two more possibilities: Using the static shading from the SNES version of DOOM, or simply use a method called floor-casting.

I have to say, this graphics programming is mighty good fun! Was pondering how to render a Dungeon Master-style 3D engine, but now knowing the basics of floor-casting, it’s a cinch!

I’ve got a strong passion to create a decent FPA(First-person-adventure, see Metroid Prime) with a Doom style engine. However, I wouldn’t mind a crack at a quick Dungeon Master clone.

The level editor would be easy to put together(the world is tile based) and the engine itself would be a simplified version of the FPA engine I wish to make. As the world is only viewed in four possible directions, I can quite easily add in floors and ceilings. Hurrah!

Not sure what the game setting or story will be, but I think I might go for a space-fantasy scenario.

Crikey, this has really brought me back into writing games! I haven’t been this passionate in years… ^_^

occsdude
Member
Posts: 3
Post Re: Creating a simple 3D engine...
on: February 28, 2010, 07:38

I look forward to seeing what you’re working on. You’ve discovered something I’ve been passionate about for a long time. It’s pretty addicting and very time consuming isn’t it? It can drive you mad and burn you out though. Try to keep things fun. Maybe one day you’ll have an actual game to show for all your work. I tell ya it isn’t easy to make an engine and a game for it. I wish you luck. I have my own software 3d renderer which hasn’t seen a game yet. I have some cool tech demo type stuff to show for it though. Pm me if you want. I’d love to chat with you.

Boone
Member
Posts: 92
Post Re: Creating a simple 3D engine...
on: February 28, 2010, 10:21

Awesome! Have you got your demo in a YouTube vid? Would love to see it! ^_^

Boone
Member
Posts: 92
Post Re: Creating a simple 3D engine...
on: February 28, 2010, 10:50

Other thoughts at the moment: 3D Applications(Max, Maya, Lightwave etc)..

I’ve used 3D software for a long time now, and the applications I’ve used have been TrueSpace, Real3D, Maya, Max, Blender and Silo. Created contest entries, animations and countless tests.

However, apart from Silo, they have all annoyed me. They usually are great at doing one 3D pipeline task, but suck at another. Or maybe the whole package is great at everything, but let down by either bugs or a bad interface. And if none of the above, then they’ll sure as hell get you on the price: price tags are rarely in the hundreds but most assuredly in the thousands of dollars(or pounds sterling! Oo-er!).

But anyway, I’ve always been happy with most programs in the model creation department. Even Blender will give you good enough tools to produce a fantastic 3D model. For me, I found Silo(Nevercenter) to be the best poly-modeller on the market, but these days any package is more than enough to deal with modelling.

What has annoyed me is when it comes to the 3D animation stage. Its such a complex process as you have the issue of creating rigs for the model as well as animating it. If anything needed to be simplified, its the animation tools!

Maya was built for animation, and it does a fairly good job. But going further, I found Messiah to be even better. It ditches the Modelling tools and deals only in animation and rendering. And so long as there are no bugs, it works a treat.

My friends believe the “pipeline” should never be broken, due to compatibility, but I am finding dedicated programs that focus only on one or two parts of the pipeline to a better solution.

Okay, I’m going to start a new reply to break this up…

Boone
Member
Posts: 92
Post Re: Creating a simple 3D engine...
on: February 28, 2010, 11:23

…continued!

So anyway this is what I’ve always wanted to do: Write a dedicated 3D rigging and animation program of my own.

Last year or whenever it was, I was playing with the idea of creating a Resident Evil style game, mainly as each room is an individual level or map in its own right and you have more to work with – not to mention easier to handle!

I had got as far as writing a demo in C++ and DirectX 9 whereby it was like playing DOOM on the map screen. I could also then place stationary objects like giant eyeballs to see if the player was visible or hidden should a wall block it’s view. And of course, the player( a rotated sprite robot thingy ) could go up to a door and go to the next room.

So – using some else’s code for finding the intersection of two lines – I could have written the game engine for a basic Resident Evil-style game.

Using DirectX 9, I could have done it as well. I converted one of my maps into a simple room and made a simple 3D room. I even made the view look up and down by increasing/decreasing the Z coordinate of the viewing point. Oh, and of course strafing and running was quite easy to implement, so that added a bit more to the experience…

But then, for any 3D mesh that was animated, I had to go back and learn how a skeleton is made and how to bind a mesh to it, then slap it in the 3D engine of my game demo.

My only choice at that time would maybe be to create a whole mesh for certain keyframes of an animation, and maybe interpolate each vertex for all the frames in between. I think this is how they did it for Quake 1 and 2, but it seems to be quite limiting…

Saying that, I did come up with a game idea(even started a developer diary) to build a game world around those limitations…

I’ll take this into another post(sorry this is so long winded!)…

Boone
Member
Posts: 92
Post Re: Creating a simple 3D engine...
on: February 28, 2010, 12:02

…continued…yawn…

so anyway, a game like Doom 3 or Half life 2 etc relies on a very dynamic and changing world. This applies to the animated 3D characters in the game where weapons have to be swapped over and with so many different characters with different animations carrying so many different objects, Skeleton tech is the only way to go. You cant use pre-created meshes for everything…it just wont do at all, as you’ll run out of storage in memory or reasonable hard disk space…

So going back, I found that the old FreeScape games(Castle Master, Driller etc) to be a more practical solution. Using the smooth controls from my “Resident-Doom” demo and some well placed animations, chuck in some alpha blending etc…I could make a nice little game. I will do that after my DOOM-FPA(“First Person Adventure”winking and boy I really look forward to it! The only challenge on that one will be coding a software renderer for displaying texture mapped polygons.

But I’ve gone off track for a moment. DOH!

One of the things that really pisses me off in 3D applications is how they import/export rigs and animation. Where 3D models are easy enough with the standard and easy to understand .Obj or .3ds files, animations are anything but standard nor easy to understand…

So, in the end, I will have to write a skeleton animation system for my demos anyway. I may as well just write an animation tool and be done with it! If I could pull that off, I would be free of waiting for the perfect 3D application to be written or updated by someone else.

Its really amazing how powerful the art of maths and programming can be!

Well, sorry about the very long posts I’ve made this morning, but its given me a chance to look at where I really want to be going. I really must get back to that Dungeon Master clone I’m working on… -_-

occsdude
Member
Posts: 3
Post Re: Creating a simple 3D engine...
on: March 1, 2010, 00:07

It would be awesome to have a 3d modeling/animation program of your own. The lego set (so to speak) of your dreams by which you can create whatever you want winking. Keep the posts coming man. Your enthusiasm is inspiring me and making me want to start some kind of project-or maybe finish the old sandbox fps I was working on. Heck maybe we’ll start a little game dev competition to push each other : ). I’ll post more soon. Been posting from my phone since I have no connection where I live lol.

Boone
Member
Posts: 92
Post Re: Creating a simple 3D engine...
on: March 1, 2010, 16:50

Cheers bro!

So looking at things again, last night, I’m starting to wonder if Dungeon Master ever did use anything like Ray-Casting/Floor-casting for it’s 3D. Was it all sprite based with clever placement or maybe a hint of scaling…at the moment I really haven’t a clue. I don’t even know what that kind of 3D rendering is called!

Eye Of The Beholder was a bit of a 50/50 affair with me, but I have a few RPG books lying around and would like to do a quick Star Wars/KOTOR game instead of the usual “Arm yourself with your table cloth and sandals” D&D kind of thing

I don’t actually play these D&D games for real as they seem a bit…”nerdy”. Sitting there with dice, spouting off stats, quoting the manuals…and playing with “little men” on a game board…nah, that’s just the sort of behaviour that gets you beaten up by alpha males and disgusted looks from sexy hot’n'stunning females. I confess to playing Space Crusade, Hero Quest and Warhammer 40K back in my teens, but that’s as far as I went…

So why do I own an RPG or two? Well, I think they are best suited to being played out on a computer! Rolling dice, pissing about looking in the rules and updating the game board…it’s such a complex and cumbersome effort for a board game. A computer will perform a turn in under a mere second.

Also, D&D is also about building worlds from scratch, and so one could spend more time creating art to help visualise a campaign and it’s different elements such as characters, locations, items etc. So once one had translated the rules into a game engine, its then up to the programmer to then indulge in their artistic side! Hurrah!

Looking back, my first game was a DOS-style command line game(back in 2000! Fack me!) written in C based on Bubblegum Crisis RPG, by R.Talsorian games. Although after that I moved on to more graphically awesome shoot-em-ups, it was the only game I honestly enjoyed creating. Working on the story line, battle engine, cutscenes and general roleplay mechanics…it really was the most rewarding experience I have ever had in programming or gaming. It was nothing less than art.

I could write a follow up game very quickly in a 2D point’n'click interface, but I dunno. I’d do an original story and world this time, as the previous BGC game was too crude to be played by anyone but me(it was commandline!). It would be nice to include some 3D bits, or possibly implement an overhead version of DOOM in a resident evil style? Hmmm?

Damn, decisions-decisions! o_O

Boone
Member
Posts: 92
Post Re: Creating a simple 3D engine...
on: March 3, 2010, 12:34

Okay, looking at right-angle trigonometry and a bit of Andre LaMothes’ 3D Tricks book, I have figured out the basic trick behind ray-casting.

Personally I find the rendering method for arbitrary lines much more straight forward(although still looking for a decent method of eliminating over-draw), but this is simple enough for a quick Dungeon Crawler.

How they did these games back in the 80s…I reckon its just clever 2D image placement. No 3D at all…

However, the Wolf3D Ray-casting engine seems the best choice for the modern Dungeon Crawler. All one needs to do is factor in Floor-casting and the basic sprites for objects and characters(such as monsters).

I am not a big fan of looking through other people’s code to understand how something works. That’s fine if you are working with others on a project – there is some agreed rules, conventions and guidelines to follow – but not someone who is a complete stranger. You’re spending most of your time trying to understand their programming style, rather than the idea of what it is you were originally looking for! And if it’s programmed in a messy way…good luck!

I think if you have maths, design and programming skills, then all you need is the basic “gist” of how something is done. Otherwise, you’ll most likely spend your time copying code out of other people’s programs. Which was exactly how I started off, and I totally regret it. But that’s another story for another time…

I spent last night going back through basic trigonometry(damn, I need to do some maths courses!), and I think I have enough maths for twin-casting, and therefore the texture-mapped walls that make up the dungeon.

Floor-casting is still a little fuzzy to understand, but I’m sure once I have a working demo up and running, I will nail it through trial and error…

Adding sprites. Hmm. Not sure if I use Ray-casting like I do for the walls(a sprite can be half covered by a wall), or use a “Z-mask” after I have calculated the walls. I can test distance of each visible object in the world and then sort them into a z-buffer list and check them against the zbuffer for walls, and work from there. Although I still wonder if there is a simpler way of doing it…

Pages: [1] 2 3 4
WP-Forum by: Fredrik Fahlstad, Version: 2.4
Page loaded in: 1.543 seconds.
>

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)