Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: Soulprayer on December 18, 2008

Title: OpenGL Tunnel?!
Post by: Soulprayer on December 18, 2008
Hi,

well i am sort of a beginner but "successfully understand and compiled" the NeHe tutorials at gamedev.net ;)

But what i am looking for is an algorithm for a nice tunnel in OpenGL. :/

While working with the codes of NeHe i got some clues about 3D and so, but not really about an tunnel.
Sure i can use a loooooong torus or a camera tracking shot through a möbius strip, but it does not solve my problem...
I want it going random. To the left and to the bottom, to top and to the right, as i say: shaky.
Some bass XM in the background and on a random bass note the direction changes.

In fact, i think the easy part is with XM play and random changes, the difficult with my requirement to code a random tunnel going infinite.
My first demo showing a tunnel was Comas demo "Cocoon"  @ 40sec - 55sec (use the norway mirror)
http://scene.org/file.php?file=/parties/2004/start04/demo/comacocoon_partyrelease.divx51.avi&fileinfo
and ever since then i want to program my own tunnel with cool effects and some more.

Is my "project" possible?
If not, can you at last share with me some knowledge about programming a tunnel?
Many thanks

Regards
Soulprayer

ps: hope my english is good enough to understand my request
Title: Re: OpenGL Tunnel?!
Post by: Hezad on December 18, 2008
Hi SoulPrayer and welcome here :)

Maybe you could store only a part of the tunnel : behind you, you don't have to calculate anything since you don't see it, but in front of you, you can calculate the tunnel faces position from your position to a selected distance : you can generate the tunnel while you're traveling in.

To handle memory, you can store calculated triangles in an array or a ptr and delete triangles behind you : like this, you won't need a huge amount of memory and since the tunnel is generated in real-time it can be totally infinite :)
Title: Re: OpenGL Tunnel?!
Post by: benny! on December 18, 2008
@Soulprayer:

Welcome to the forum. Tunnels are indeed some very fascinating
effect. To have a basic understanding you might be interested in
a very old challenge which was held by this forum - have a look
at the posts in this thread for some tunnel examples (with sources):

http://www.dbfinteractive.com/forum/index.php/topic,80.0.html (http://www.dbfinteractive.com/forum/index.php/topic,80.0.html)
Title: Re: OpenGL Tunnel?!
Post by: relsoft on December 18, 2008
I love tunnels!!! My next game(if ever that comes at all) would involve an abstract tunnel.

(http://rel.betterwebber.com/images/screenies/glass_tunnel.jpg)

Anyways,some tunnels I made in OpenGL:

Ascaris:
http://rel.betterwebber.com/junk.php?id=47

Flower tunnel:
http://rel.betterwebber.com/junk.php?id=57

Glass Tunnel:
http://rel.betterwebber.com/junk.php?id=91

Source included and I'll be online for 3days so you could post your Q's regarding the source anytime.
Title: Re: OpenGL Tunnel?!
Post by: Soulprayer on December 18, 2008
Hey many thanks for your ideas, I'll try!
And I'll give me time to understand, don't expect me doing this in some days ;)

@relsoft
I love tunnels too! :)
The Ascaris demos are cool!
Thanks for the code, I'll work with it and try to do my demo in C++

@benny
Thanks, I'll have a look at them! :D

@Hezad
Good idea, i'll give it a try.
Title: Re: OpenGL Tunnel?!
Post by: va!n on December 19, 2008
@Soulprayer:
some more infos about how you could code a tunnel effect:
http://www.dbfinteractive.com/forum/index.php/topic,1942.0.html (http://www.dbfinteractive.com/forum/index.php/topic,1942.0.html)
Title: Re: OpenGL Tunnel?!
Post by: relsoft on December 19, 2008
@relsoft
I love tunnels too! :)
The Ascaris demos are cool!
Thanks for the code, I'll work with it and try to do my demo in C++


Guess what? I have a C++ version too!!!

http://rel.betterwebber.com/junk.php?id=48
Title: Re: OpenGL Tunnel?!
Post by: matthew on December 19, 2008

(http://matthew-4gl.wikispaces.com/space/showimage/A1_Basic4GL_PLasmaTunnel_Pic.jpg)

Hi Soulprayer, there is a tunnel written in Delphi which uses OpenGL here (http://www.sulaco.co.za/opengl_project_plasma_tunnel.htm).

I converted the program to Basic4GL some time ago & you can download it here (http://matthew-4gl.wikispaces.com/space/showimage/PlasmaTunnel.rar).

I also had written a version of it in thinBasic which you can download here (http://matthew-4gl.wikispaces.com/space/showimage/PlasmaTunnel_tb.rar).

Source code & .exes are included with both downloads.
Title: Re: OpenGL Tunnel?!
Post by: hellfire on December 19, 2008
Quote
My first demo showing a tunnel was Comas demo "Cocoon" and ever since then i want to program my own tunnel with cool effects and some more.
Well, the demo is called Coma (http://www.pouet.net/prod.php?which=11457) and the group's name is Cocoon (http://cocoon.planet-d.net) ;)

Quote
i can use a loooooong torus [...] but I want it going random
I'm pretty sure for this specific tunnel Nytrik did exactly that in 3dsmax.
To do it procedurally, you could generate a torus along a spline where you create the position-samples from filtered noise (perlin or such).
You could generate segments of reasonable size as soon as they become visible and trash them after the camera passed through (- just as Hezad pointed out already).

May I ask where in NRW you are located?
Title: Re: OpenGL Tunnel?!
Post by: Soulprayer on December 19, 2008
Whow, you're great!
Many thanks for your support! 
The tutorial is in German, great! :D
And thanks for the link to Cocoons hp!

Now i know what to do in my spare time over christmas and New Year's Eve!
Title: Re: OpenGL Tunnel?!
Post by: va!n on December 19, 2008
@matthew:
oh you are right.. i totally forgot the site of my good old friend Sulaco from Africa who sadly died some years ago... He was a very very cool and friendly guy, where people can find and learn a lot about OpenGL coding!  :goodpost:
Title: Re: OpenGL Tunnel?!
Post by: relsoft on December 20, 2008
@matthew:
oh you are right.. i totally forgot the site of my good old friend Sulaco from Africa who sadly died some years ago... He was a very very cool and friendly guy, where people can find and learn a lot about OpenGL coding!  :goodpost:

WTF?!!! He's dead?!!! I learned a lot from that guy!  Man this sucks.
Title: Re: OpenGL Tunnel?!
Post by: matthew on December 20, 2008
WTF?!!! He's dead?!!! I learned a lot from that guy!  Man this sucks.

Yeah he died back in 2002, his parents were featured in a religious documentary shortly after his death.

A copy of the documentary can be downloaded from this (http://www.sulaco.co.za/messages.htm) webpage.