forums

TNT Basic Forums > Programming Q&A
New Example ready...
< Last Thread     Next Thread >
Author
Thread        Post A Reply

12-05-2005 18:55

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Hi all, as you may know I've been badgering away on the Open Source TNT since its release, but prior to this I was working on a series of tutorials and examples. Well the latest one isn't quite finished, but it works pretty well and I thought I'd get it out into the PD so you can have a play while I finish of a few bits and bobs...

This is glorious 3D in TNT basic! It runs at about 50 fps and allows you to rotate a cube in real time via the cursor, ',' and '.' keys. Press the spacebar to toggle display modes, currently wireframe or filled polygon (lit wireframe to follow), and <enter> resets the display to it's default (not much use now, but other transforms to come).

I am working on a lengthy tutorial and 'blog' to go with this, which discusses various aspects of the code and 3D methods in general, and this will be released when the final version goes to print...
I was going to work on Isometric displays, but there have been quite a few posts requesting 3D as a feature for TNT. I thought I'd post this to show how easily it can be achieved with the existing functionality...

I've uploaded to the Directory, but it takes a while to show up... in the meantime you can get your eager hands on a copy of the source from here.
Any questions or requests for future source, just drop me a line in the forums...

Happy rendering!

Danny (nods0

12-05-2005 21:34

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Doh!

Er... there's a bug.

line 200: 'if tempZ<=0 'it can be seen, so draw it, but when?'

lose the '=' sign and it works. Sorry.

[tech note: The reason is I make the assumption that there will only ever be three faces visible at any one time, which is generally true. But if the cube is rotated in only the x or y axes, the top and bottom, or left and right faces have a normal vector with a z component of exactly 0. This makes four faces in all, and the one nearest the camera (being the last to be drawn and therefor the fourth) is not rendered..]

Danny (nods)

12-05-2005 22:46

Posted by:
Jacob

Location:
San Francisco, CA

Click Here to Email Jacob   Find more posts by Jacob

I was thinking about making that a long time ago, but I never got around to it.

12-06-2005 20:08

Posted by:
Gustav

Location:
Lund, Sweden

Click Here to Email Gustav   Find more posts by Gustav

[b]Wow.[/b]

(' _')
I'm amazed. "---------THIS COOL---------" man.

12-06-2005 23:03

Posted by:
swagIT

Location:
Great Wet North (Vancouver)

Find more posts by swagIT

cool

12-06-2005 23:28

Posted by:
Jacob

Location:
San Francisco, CA

Click Here to Email Jacob   Find more posts by Jacob

Lit Wireframe

I have code for a lit wireframe mode (from a paint example I made before), but it only runs at 4 fps.

12-08-2005 08:14

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Lit Wireframe is here...

The depth cued wireframe mode is now in and working, it's a bit slower than the other two modes, but it is calculating the colour of every point on screen in realtime, so it's to be expected really...
I've also had a play with the other two modes and managed to get wireframe up to nearly 100 fps, and filled poly to somewhere around 70-80. I did this by removing the 'paint canvas' call which erased the background. I now draw the whole thing again, but in black, and this has nearly doubled the speed. I can't do this with lit wireframe though, hence the slowdown. Why is there no 'CLS' call?
I'm just finishing my 3D tutorial and inane 'BLOG', and will post when complete, but I was so chuffed with the results of the code I had to upload this first.
The link above has been updated to reflect the latest version.

Now do I go back to working on TNT or do I start on Raytraced, texture mapped and fully morphing polyhedrons?... Decisions, decisions...

TNT it is then 8)

Danny (nods)

12-10-2005 18:27

Posted by:
Jason Anderson

Location:
Doylestown, PA

Click Here to Email Jason Anderson   Find more posts by Jason Anderson

I used to experiment a lot with 3D wireframes back in my QuickBasic days. I even had a program that would let you load your own custom made polygons. I used to have my company's logo in 3D and used a rotating version of it in one of my old games.

I am impressed you got it to be shaded.

What I hope to see one day is Super FX quality effects. I want to make a flying shooter like StarFox in TNT!

Just FYI for reference. Polygons are alyways made up of triangles. It allows for bending. Just a tip for when you decide to really develop this thing. (i.e. a square will be two right triangles connected to each other.)

In the meantime, I think I might experiment with this for a while. :)

12-11-2005 13:57

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Cheers Jason...

Glad you liked it, we've had a fair few requests for 3D functionality in TNT coming up on the forums, so I thought I'd try and show how easily it could be done with existing calls. I think the 'depth cued' view looked pretty cool, so it had to go in, I'll probably try some more elaborate stuff in time... I've done a lot of work in 3D in the past, both on PC's using Micro$oft's DirectX, and on the Mac in C (anyone remember the 'Screaming Cabala' library?). I'm currently re-writing the TNT graphics engine and trying to get the hardware mode working, got red and blue books flying around my desk here... Once this is in place then the code example will absolutely fly and I can move on and add to it. Actual 3D calls within TNT will come, but we've got a lot of ground to cover first, we need the calls we already have to work properly before we start adding more.
I know about the polygons btw, but I was only rendering a cube, so concave and convex faces were never and issue, doing it 'properly' would just have bumped up the poly count. Thanks for the reply though, nice to know people are looking at it and hopefully getting inspired to try more complex topics. If you do have a play with it and get anything good going on then please let me know.

Danny (nods)

12-17-2005 22:39

Posted by:
Gordon

Location:
Free Country USA

Find more posts by Gordon

Looks Cool

The normal wireframe appears to get deformed for a few seconds if you hold down a lot of the keys at the same time.

12-17-2005 23:24

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

It does look that way sometimes, but...

It's an optical illusion. When it starts to 'deform', hit space. It's because there's no perception of depth. It's the same piece of code that handles all transforms, so it's not a code thing, but thanks for posting.

Danny (nods)

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.