The Pole
The Pole
I need a little favour from someone who can code 3d engines. I need a very simple 3d world, but I'm not able to code 3d stuff yet. Here's the description. When you start the program, there would only be a sign next to you(read further to find out what the sign says). Everything else around you is a white void. You can freely move your eyes around with the mouse, and can move around with the w,a,s,d keys, but not up or down. A model of the person won't be necesary, just the model of the sign. But a simple model of the person would be preferable so that when you look down, you can see his feet walking.
It's based on a short story I wrote and would love to have a 3d model of the weird world the main character is in to show readers what it would be like. Read the story to understand more about it:
"
He awoke from his sleep, again wishing he could stay that way, wishing it would end. He lost track of time a long time ago. Many centuries probably past by since he first awoke into this world. He can’t really tell how long it’s been because he doesn't have a reference point to determine how much time has elapsed, if there even is such a thing here. All he has are his own gut feelings telling him how many days might have passed were he back on earth. He does feel time go by, that's for sure. The long periods of boredom has never felt more real to him. He faintly remembers a time where he knew something else but this place. He still retains fuzzy images of his parents and friends back on earth, but it's almost impossible to tell at this point if they were real or dreams he's had, because this seems to be all he's ever known.
He stood up and stretched. Around him was an empty white void extending in all directions. He wasn't able to determine how far it extended because there was nothing to focus on. There was a floor because he could feel it under him while he was walking. He just couldn't see it. It was made of the same textureless whiteness that filled the air. The only thing that existed in his world was him and a 5 foot pole that came out of the ground. The pole had a sign on it which read, "Do not venture away from me! Beyond lies a void incomprehensibly large, an infinite sea that never ends. There is nothing out there to see. If you lose track of me, you will most likely never find me again. I am all that remains real. I am what holds you together, what keeps you sane. Do not venture away from me!”
He had stopped questioning the sign a long time ago. He has grown tired trying to figure out if it was true or not, if there was something else out there, if he did need the sign to stay sane. He has attempted many times in the past to see if there was something beyond the horizon. But with no way of marking a trail that leads back to the sign, he was careful as to never lose sight of it. He's come close to losing it several times because he went too far. Luckily for him that didn't happen. He always made sure it stayed in view. He wouldn't know what to do if the pole was no longer with him anymore. The pole was his world. It was the only thing that told him he was not alone, that something else existed besides him. He's had nightmares of him venturing out too far and losing track of the pole. He remembers in his dreams running, panicking, screaming into the void, trying to capture a glimpse of it, wishing he only listened to the sign. He was relieved when he discovered that they were only dreams.
Many times he wished he could kill himself. But apparently he couldn't die. He obviously didn't have to eat or drink, because he would've died a long time ago. He tried smashing his head against the sign a few times but that didn't work. It only gave him a bump on the head. He didn't have any teeth or nails, so he couldn't cut himself open and bleed to death if he wanted to. It seemed he was stuck in this place forever. This discovery has driven him to the edge of insanity and back many times. Several occasions he was ready to give up the pole and leave it behind for the chance that he might discover something else out there. He was so sick of the pole at times. He had read the sign out of boredom millions of times. The message was engrained in his soul forever. Who cares if I never see it again, he thought. But he couldn’t do it. He tried many times but always stopped in his tracks before it disappeared from the horizon. It always managed to pull him back. His conclusion was always that it was better to have its company than no company at all. He might be risking his only friend, the one thing that keeps him sane.
As far as he concluded he was in hell. Either that or it was some sick experiment that he was caught in to see what he would do. Maybe it would all end if he went far enough and showed them that he can give up the pole, he thought many times. Maybe that’s what they were waiting for him to do, seeing how long it would take him to figure that out. These questions and many more plagued his mind for eons. It was too risky, he thought. He couldn’t take that risk. There was too much at stake. On the other hand, what would he gain if it turned out to be a way out of here? He would gain everything. The dilemma is that he also gains everything if he stays, for everything for him right now happens to be the pole. He couldn’t bear to think what it would be like to walk forever lost into the white abyss. He wouldn’t even be able to tell if he’s moving. The only thing that tells him that he’s moving is the relative motion of the pole moving in the opposite direction. Without that sense of space he would surely go completely insane, and into a much darker hell. He dared not think of that. It wasn’t an option anymore.
Another million years pass by, give or take. It has dawned on him many eons ago that he is here to stay, for eternity. The millions of years that he felt go by were but a fraction of a second in comparison to the foreverness of infinite time. He has stopped thinking and trying to find new ways to pass the time. It didn’t matter he thought. No matter how much he distracted himself from the feeling of time, more of it will come.
For the first million years he spent most of that time asleep, learning how to travel in his dreams. But even that became mundane, for his mind had eventually stopped being able to imagine new things, and forgot of the old ones. The whiteness has plagued his mind numbing his ability to dream. He used to dream of wonderful places, people and experiences. Eventually his dreams became more about different textures and colors. And slowly, without him noticing, he had forgotten how to dream. There was as much a void inside his mind as outside of it. He even stopped paying attention to his pole. Sometimes he would go years without noticing it. Nothing mattered to him anymore. Time stopped having any meaning. Years would go by which now felt like seconds. Then, it was centuries that felt like seconds. Time could’ve been standing still and he would not notice. Though, every so often, maybe every million years or so, he would come back to reality to make sure his pole was still there. Sure enough, it was. He would put his arm around it and curl next to it, smile, and fade away into another million years of slumber.
"
I'm sure some of you can do this very rapidly with opengl. I would do it myself of course, but am unable. Anybody up for the challenge? Thanks
It's based on a short story I wrote and would love to have a 3d model of the weird world the main character is in to show readers what it would be like. Read the story to understand more about it:
"
He awoke from his sleep, again wishing he could stay that way, wishing it would end. He lost track of time a long time ago. Many centuries probably past by since he first awoke into this world. He can’t really tell how long it’s been because he doesn't have a reference point to determine how much time has elapsed, if there even is such a thing here. All he has are his own gut feelings telling him how many days might have passed were he back on earth. He does feel time go by, that's for sure. The long periods of boredom has never felt more real to him. He faintly remembers a time where he knew something else but this place. He still retains fuzzy images of his parents and friends back on earth, but it's almost impossible to tell at this point if they were real or dreams he's had, because this seems to be all he's ever known.
He stood up and stretched. Around him was an empty white void extending in all directions. He wasn't able to determine how far it extended because there was nothing to focus on. There was a floor because he could feel it under him while he was walking. He just couldn't see it. It was made of the same textureless whiteness that filled the air. The only thing that existed in his world was him and a 5 foot pole that came out of the ground. The pole had a sign on it which read, "Do not venture away from me! Beyond lies a void incomprehensibly large, an infinite sea that never ends. There is nothing out there to see. If you lose track of me, you will most likely never find me again. I am all that remains real. I am what holds you together, what keeps you sane. Do not venture away from me!”
He had stopped questioning the sign a long time ago. He has grown tired trying to figure out if it was true or not, if there was something else out there, if he did need the sign to stay sane. He has attempted many times in the past to see if there was something beyond the horizon. But with no way of marking a trail that leads back to the sign, he was careful as to never lose sight of it. He's come close to losing it several times because he went too far. Luckily for him that didn't happen. He always made sure it stayed in view. He wouldn't know what to do if the pole was no longer with him anymore. The pole was his world. It was the only thing that told him he was not alone, that something else existed besides him. He's had nightmares of him venturing out too far and losing track of the pole. He remembers in his dreams running, panicking, screaming into the void, trying to capture a glimpse of it, wishing he only listened to the sign. He was relieved when he discovered that they were only dreams.
Many times he wished he could kill himself. But apparently he couldn't die. He obviously didn't have to eat or drink, because he would've died a long time ago. He tried smashing his head against the sign a few times but that didn't work. It only gave him a bump on the head. He didn't have any teeth or nails, so he couldn't cut himself open and bleed to death if he wanted to. It seemed he was stuck in this place forever. This discovery has driven him to the edge of insanity and back many times. Several occasions he was ready to give up the pole and leave it behind for the chance that he might discover something else out there. He was so sick of the pole at times. He had read the sign out of boredom millions of times. The message was engrained in his soul forever. Who cares if I never see it again, he thought. But he couldn’t do it. He tried many times but always stopped in his tracks before it disappeared from the horizon. It always managed to pull him back. His conclusion was always that it was better to have its company than no company at all. He might be risking his only friend, the one thing that keeps him sane.
As far as he concluded he was in hell. Either that or it was some sick experiment that he was caught in to see what he would do. Maybe it would all end if he went far enough and showed them that he can give up the pole, he thought many times. Maybe that’s what they were waiting for him to do, seeing how long it would take him to figure that out. These questions and many more plagued his mind for eons. It was too risky, he thought. He couldn’t take that risk. There was too much at stake. On the other hand, what would he gain if it turned out to be a way out of here? He would gain everything. The dilemma is that he also gains everything if he stays, for everything for him right now happens to be the pole. He couldn’t bear to think what it would be like to walk forever lost into the white abyss. He wouldn’t even be able to tell if he’s moving. The only thing that tells him that he’s moving is the relative motion of the pole moving in the opposite direction. Without that sense of space he would surely go completely insane, and into a much darker hell. He dared not think of that. It wasn’t an option anymore.
Another million years pass by, give or take. It has dawned on him many eons ago that he is here to stay, for eternity. The millions of years that he felt go by were but a fraction of a second in comparison to the foreverness of infinite time. He has stopped thinking and trying to find new ways to pass the time. It didn’t matter he thought. No matter how much he distracted himself from the feeling of time, more of it will come.
For the first million years he spent most of that time asleep, learning how to travel in his dreams. But even that became mundane, for his mind had eventually stopped being able to imagine new things, and forgot of the old ones. The whiteness has plagued his mind numbing his ability to dream. He used to dream of wonderful places, people and experiences. Eventually his dreams became more about different textures and colors. And slowly, without him noticing, he had forgotten how to dream. There was as much a void inside his mind as outside of it. He even stopped paying attention to his pole. Sometimes he would go years without noticing it. Nothing mattered to him anymore. Time stopped having any meaning. Years would go by which now felt like seconds. Then, it was centuries that felt like seconds. Time could’ve been standing still and he would not notice. Though, every so often, maybe every million years or so, he would come back to reality to make sure his pole was still there. Sure enough, it was. He would put his arm around it and curl next to it, smile, and fade away into another million years of slumber.
"
I'm sure some of you can do this very rapidly with opengl. I would do it myself of course, but am unable. Anybody up for the challenge? Thanks
-
- Posts: 2338
- Joined: May 31, 2005 9:59
- Location: Croatia
- Contact:
-
- Posts: 2655
- Joined: Aug 28, 2008 10:54
- Location: new york
-
- Posts: 2338
- Joined: May 31, 2005 9:59
- Location: Croatia
- Contact:
Man, that's horribly depressing. :p
Code: Select all
#include "GL/gl.bi"
#include "GL/glu.bi"
#include "fbgfx.bi"
randomize timer
type vec3f
X as single
Y as single
Z as single
end type
type vec4f
X as single
Y as single
Z as single
W as single
end type
type EntityType
Position as vec3f
LookAt as vec3f
DVector as vec3f
UVector as vec3f
RVector as vec3f
Radius as single
Colr(3) as single
Emission(3) as single
Orbit(1) as single
end type
type polytype
max_vertices as integer
vert_index as integer ptr
end type
type modeltype
max_vertices as integer
vertices as vec3f ptr
max_faces as integer
faces as polytype ptr
end type
declare sub Rot_X( byref Entity as EntityType, byref Angle as single )
declare sub Rot_Y( byref Entity as EntityType, byref Angle as single )
declare sub Rot_Z( byref Entity as EntityType, byref Angle as single )
declare function Vector_Cross ( byref v1 as vec3f, byref v2 as vec3f ) as vec3f
declare function Vector_Magnitude( byref V as vec3f ) as single
declare sub Vector_Normalize ( byref v as vec3f )
declare function Distance( byref P1 as vec3f, byref P2 as vec3f ) as single
dim i as integer,_
i2 as integer, _
Button as integer, _
TempX as integer, _
TempY as integer, _
tDist as single
dim Cam as EntityType, Factor as vec3f
dim as vec4f Light_Position =>(0,50,0,1)
'Initialize the camera's vectors for a right-handed system,
'and give it an initial position...
Cam.Position.X = 0
Cam.Position.Y = 0
Cam.Position.Z = 10
Cam.DVector.X = 0
Cam.DVector.Y = 0
Cam.DVector.Z = -1
Cam.UVector.X = 0
Cam.UVector.Y = 1
Cam.UVector.Z = 0
Cam.RVector.X = 1
Cam.RVector.Y = 0
Cam.RVector.Z = 0
screenres 640,480,32,2,FB.GFX_OPENGL
const MidX = 640\2, MidY = 480\2, False = 0, True = not False
glViewport( 0, 0, 640, 480 )
glMatrixMode( GL_PROJECTION )
glLoadIdentity()
gluPerspective( 45.0, 640.0/480.0, 1, 1000 )
glMatrixMode( GL_MODELVIEW )
glLoadIdentity()
glShadeModel( GL_SMOOTH )
glClearColor( 0.0, 0.0, 0.0, 1.0 )
glClearDepth( 1.0 )
glEnable( GL_DEPTH_TEST )
glEnable( GL_COLOR_MATERIAL )
glEnable( GL_LIGHTING )
glEnable( GL_LIGHT0 )
glDepthFunc( GL_LEQUAL )
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST )
glEnable( GL_LIGHTING )
glEnable( GL_LIGHT0 )
glDisable( GL_BLEND )
glEnable( GL_FOG )
dim as single FogCol(3) = {0.8f,0.8f,0.8f}
glFogfv(GL_FOG_COLOR, @FogCol(0))
glHint( GL_FOG_HINT, GL_NICEST )
glFogi(GL_FOG_MODE, GL_LINEAR)
glFogf(GL_FOG_START, 10.f)
glFogf(GL_FOG_END, 4000.f)
glFogf(GL_FOG_DENSITY, .02)
glFogi(GL_FOG_MODE, GL_EXP)
dim Quadric as GLUquadricObj ptr
Quadric = gluNewQuadric
dim as modeltype room
read room.max_vertices
room.vertices = new vec3f[room.max_vertices]
for i as integer = 0 to room.max_vertices-1
read room.vertices[i].x
room.vertices[i].x*=500
read room.vertices[i].y
room.vertices[i].y*=500
read room.vertices[i].z
room.vertices[i].z*=500
next
read room.max_faces
room.faces = new polytype[room.max_faces]
for i as integer = 0 to room.max_faces-1
read room.faces[i].max_vertices
room.faces[i].vert_index = new integer[ room.faces[i].max_vertices ]
for j as integer = 0 to room.faces[i].max_vertices-1
read room.faces[i].vert_index[j]
room.faces[i].vert_index[j]-=1
next
next
setmouse(MidX, MidY, 0)
do
glClear( GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT )
getmouse(TempX, TempY,, Button)
Factor.Y = (MidX-TempX)/500
Factor.X = (MidY-TempY)/500
setmouse(MidX, MidY, 0)
Factor.Z = -Cam.RVector.Y*.5
Rot_X Cam, Factor.X
Rot_Y Cam, Factor.Y
Rot_Z Cam, Factor.Z
'___________________________________________________________________________
'here is a nice solution...
'create a temporary up vector, which will always be(0,1,0)
'take the cross product of that temp vector and the camera's right vector,
'which will give you a perpendicular vector that you can use for the heading.
'you shouldn't need to normalize it, but just in case some other operation
'causes it to become a non-unit vector, we do it anyway. ;)
dim as vec3f up=>(0,1,0)
dim as vec3f Direction = Vector_Cross( up, Cam.RVector )
vector_normalize(Direction)
'NOTE: This will NOT work correctly, if you wish to implement "roll" in your camera system.
'It should be pretty nice for a FPS style camera though.
'___________________________________________________________________________
if multikey(FB.SC_W) then
Cam.Position.X += Direction.X*.15
Cam.Position.Z += Direction.Z*.15
end if
if multikey(FB.SC_S) then
Cam.Position.X -= Direction.X*.15
Cam.Position.Z -= Direction.Z*.15
end if
if multikey(FB.SC_D) then
Cam.Position.X += Cam.RVector.X*.15
Cam.Position.Z += Cam.RVector.Z*.15
end if
if multikey(FB.SC_A) then
Cam.Position.X -= Cam.RVector.X*.15
Cam.Position.Z -= Cam.RVector.Z*.15
end if
glmatrixmode GL_MODELVIEW
glloadidentity
Cam.LookAt.X = Cam.Position.X + Cam.DVector.X
Cam.LookAt.Y = Cam.Position.Y + Cam.DVector.Y
Cam.LookAt.Z = Cam.Position.Z + Cam.DVector.Z
gluLookAt( Cam.Position.X, Cam.Position.Y, Cam.Position.Z, _
Cam.LookAt.X, Cam.LookAt.Y, Cam.LookAt.Z, _
Cam.UVector.X, Cam.UVector.Y, Cam.UVector.Z )
glLightfv( GL_LIGHT0, GL_POSITION, @light_Position.x )
glPushMatrix()
glColor3f( 1,1,1 )
glRotateF( 90, 1,0,0 )
gluQuadricDrawStyle( Quadric, GLU_FILL )
gluQuadricNormals( Quadric, GLU_SMOOTH )
gluQuadricOrientation( Quadric, GLU_OUTSIDE )
gluSphere( Quadric, .25, 64, 64 )
gluCylinder( Quadric, .25, .25, 8, 32, 32 )
glPopMatrix()
glPushMatrix
glTranslatef( Cam.Position.X, Cam.Position.Y-3, Cam.Position.Z )
glColor3f(1,1,1)
for i as integer = 0 to room.max_faces-1
glBegin( GL_QUADS )
for j as integer = 0 to room.faces[i].max_vertices-1
glVertex3fv( @room.vertices[room.faces[i].vert_index[j]].x )
next
glEnd()
next
glPopMatrix()
flip
sleep 1,1
loop while inkey$ <> chr$(27)
gluDeleteQuadric( Quadric )
'obligatory beep :)
beep
function Distance( byref P1 as vec3f, byref P2 as vec3f ) as single
return sqr((P2.x - P1.x)^2 + (P2.y - P1.y)^2 + (P2.z - P1.z)^2)
end function
function Vector_Cross ( byref v1 as vec3f, byref v2 as vec3f ) as vec3f
dim v as vec3f
v.x = (v1.y * v2.z) - (v2.y * v1.z)
v.y = (v1.z * v2.x) - (v2.z * v1.x)
v.z = (v1.x * v2.y) - (v2.x * v1.y)
return v
end function
function Vector_Magnitude( byref V as vec3f ) as single
dim Mag as single
Mag = sqr(v.x ^2 + v.y ^2 + v.z ^2)
if Mag = 0 then Mag = 1
return Mag
end function
sub Vector_Normalize ( byref v as vec3f )
dim Mag as single
Mag = Vector_Magnitude(V)
v.x = v.x / Mag
v.y = v.y / Mag
v.z = v.z / Mag
end sub
sub Rot_X( byref Entity as EntityType, byref Angle as single )
dim tDir as vec3f, tSin as single, tCos as single
tCos = cos(Angle)
tSin = sin(Angle)
tDir.X = Entity.DVector.X*tCOS+Entity.UVector.X*tSin
tDir.Y = Entity.DVector.Y*tCOS+Entity.UVector.Y*tSin
tDir.Z = Entity.DVector.Z*tCOS+Entity.UVector.Z*tSin
Vector_Normalize( tDir )
Entity.DVector.X = tDir.X
Entity.DVector.Y = tDir.Y
Entity.DVector.Z = tDir.Z
Entity.UVector = Vector_Cross( Entity.DVector, Entity.RVector )
Entity.UVector.X =-Entity.UVector.X
Entity.UVector.Y =-Entity.UVector.Y
Entity.UVector.Z =-Entity.UVector.Z
end sub
sub Rot_Y( byref Entity as EntityType, byref Angle as single )
dim tDir as vec3f, tCos as single, tSin as single
tCos = cos(Angle)
tSin = sin(Angle)
tDir.X = Entity.DVector.X*tCOS-Entity.RVector.X*tSin
tDir.Y = Entity.DVector.Y*tCOS-Entity.RVector.Y*tSin
tDir.Z = Entity.DVector.Z*tCOS-Entity.RVector.Z*tSin
Vector_Normalize( tDir )
Entity.DVector.X = tDir.X
Entity.DVector.Y = tDir.Y
Entity.DVector.Z = tDir.Z
Entity.RVector = Vector_Cross( Entity.DVector, Entity.UVector )
end sub
sub Rot_Z( byref Entity as EntityType, byref Angle as single )
dim tRight as vec3f, tCos as single, tSin as single
tCos = cos(Angle)
tSin = sin(Angle)
tRight.X = Entity.RVector.X*tCOS+Entity.UVector.X*tSin
tRight.Y = Entity.RVector.Y*tCOS+Entity.UVector.Y*tSin
tRight.Z = Entity.RVector.Z*tCOS+Entity.UVector.Z*tSin
Vector_Normalize( tRight )
Entity.RVector.X = tRight.X
Entity.RVector.Y = tRight.Y
Entity.RVector.Z = tRight.Z
Entity.UVector = Vector_Cross( Entity.DVector, Entity.RVector )
Entity.UVector.X =-Entity.UVector.X
Entity.UVector.Y =-Entity.UVector.Y
Entity.UVector.Z =-Entity.UVector.Z
end sub
vertex_list:
data 8
data -1, 0, 1
data -1, 0, -1
data -1, 1, -1
data -1, 1, 1
data 1, 0, 1
data 1, 0, -1
data 1, 1, -1
data 1, 1, 1
face_list:
data 6
data 4
data 2, 3, 4, 1
data 4
data 5, 6, 2, 1
data 4
data 6, 7, 3, 2
data 4
data 3, 7, 8, 4
data 4
data 4, 8, 5, 1
data 4
data 8, 7, 6, 5
Brilliant! I was envisioning pure whiteness, but I like the misty look. Would it be too much trouble to attach the sign to the pole? Then it would be complete.
Ya, it is a depressing story. But I think it's what most of us would do in his circumstance, just wait around, scared to leave the pole.
Thanks Dr_D :)
Ya, it is a depressing story. But I think it's what most of us would do in his circumstance, just wait around, scared to leave the pole.
Thanks Dr_D :)
Here ya go. I think you could actually make a game out of your idea. At least when the protagonist is asleep. You could realize many game-play ideas in his dreams because you wouldn't be locked into this gray world. ;)
http://file-pasta.com/file/The%20Pole.rar
http://file-pasta.com/file/The%20Pole.rar
The sign looks good, but there's a clipping problem. A slice of the right edge is appearing on the left side. Do you know what's causing that? Also, I made a few slight modifications so it looks more of what I had in mind:
Apart from the clipping problem, it looks great. I hope it wasn't too much of a bother for you. Thanks
Code: Select all
#include "GL/gl.bi"
#include "GL/glu.bi"
#include "fbgfx.bi"
randomize timer
type vec2f
x as single
y as single
end type
type vec3f
X as single
Y as single
Z as single
end type
type vec4f
X as single
Y as single
Z as single
W as single
end type
type EntityType
Position as vec3f
LookAt as vec3f
DVector as vec3f
UVector as vec3f
RVector as vec3f
Radius as single
Colr(3) as single
Emission(3) as single
Orbit(1) as single
end type
type polytype
max_vertices as integer
vert_index as integer ptr
uvs as vec2f ptr
end type
type modeltype
max_vertices as integer
vertices as vec3f ptr
max_faces as integer
faces as polytype ptr
end type
declare sub Rot_X( byref Entity as EntityType, byref Angle as single )
declare sub Rot_Y( byref Entity as EntityType, byref Angle as single )
declare sub Rot_Z( byref Entity as EntityType, byref Angle as single )
declare function Vector_Cross ( byref v1 as vec3f, byref v2 as vec3f ) as vec3f
declare function Vector_Magnitude( byref V as vec3f ) as single
declare sub Vector_Normalize ( byref v as vec3f )
declare function Distance( byref P1 as vec3f, byref P2 as vec3f ) as single
dim i as integer,_
i2 as integer, _
Button as integer, _
TempX as integer, _
TempY as integer, _
tDist as single
dim Cam as EntityType, Factor as vec3f
dim as vec4f Light_Position =>(0,50,20,1)
'Initialize the camera's vectors for a right-handed system,
'and give it an initial position...
Cam.Position.X = 0
Cam.Position.Y = .5
Cam.Position.Z = 2
Cam.DVector.X = 0
Cam.DVector.Y = 0
Cam.DVector.Z = -1
Cam.UVector.X = 0
Cam.UVector.Y = 1
Cam.UVector.Z = 0
Cam.RVector.X = 1
Cam.RVector.Y = 0
Cam.RVector.Z = 0
screenres 640,480,32,,FB.GFX_OPENGL or FB.GFX_FULLSCREEN
const MidX = 640\2, MidY = 480\2, False = 0, True = not False
glViewport( 0, 0, 640, 480 )
glMatrixMode( GL_PROJECTION )
glLoadIdentity()
gluPerspective( 45.0, 640.0/480.0, 1, 1000 )
glMatrixMode( GL_MODELVIEW )
glLoadIdentity()
glShadeModel( GL_SMOOTH )
glClearColor( 1.0, 1.0, 1.0, 1 )
glClearDepth( 1.0 )
glEnable( GL_DEPTH_TEST )
glEnable( GL_COLOR_MATERIAL )
glEnable( GL_LIGHTING )
glEnable( GL_LIGHT0 )
glDepthFunc( GL_LEQUAL )
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST )
glEnable( GL_LIGHTING )
glEnable( GL_LIGHT0 )
glDisable( GL_BLEND )
glEnable( GL_FOG )
dim as single FogCol(3) = {1f,1f,1f}
glFogfv(GL_FOG_COLOR, @FogCol(0))
glHint( GL_FOG_HINT, GL_NICEST )
glFogi(GL_FOG_MODE, GL_LINEAR)
glFogf(GL_FOG_START,.1f)
glFogf(GL_FOG_END, 160f)
glFogf(GL_FOG_DENSITY, .1)
dim Quadric as GLUquadricObj ptr
Quadric = gluNewQuadric
gluQuadricTexture( Quadric, GL_FALSE )
gluQuadricDrawStyle( Quadric, GLU_FILL )
gluQuadricNormals( Quadric, GLU_SMOOTH )
gluQuadricOrientation( Quadric, GLU_OUTSIDE )
dim as modeltype room, sign
read room.max_vertices
room.vertices = new vec3f[room.max_vertices]
for i as integer = 0 to room.max_vertices-1
read room.vertices[i].x
room.vertices[i].x*=500
read room.vertices[i].y
room.vertices[i].y*=500
read room.vertices[i].z
room.vertices[i].z*=500
next
read room.max_faces
room.faces = new polytype[room.max_faces]
for i as integer = 0 to room.max_faces-1
read room.faces[i].max_vertices
room.faces[i].vert_index = new integer[ room.faces[i].max_vertices ]
for j as integer = 0 to room.faces[i].max_vertices-1
read room.faces[i].vert_index[j]
room.faces[i].vert_index[j]-=1
next
next
'load the sign
read sign.max_vertices
sign.vertices = new vec3f[sign.max_vertices]
for i as integer = 0 to sign.max_vertices-1
read sign.vertices[i].x
sign.vertices[i].x*=3
read sign.vertices[i].y
sign.vertices[i].y*=3
read sign.vertices[i].z
sign.vertices[i].z*=3
next
read sign.max_faces
sign.faces = new polytype[sign.max_faces]
for i as integer = 0 to sign.max_faces-1
read sign.faces[i].max_vertices
sign.faces[i].vert_index = new integer[ sign.faces[i].max_vertices ]
sign.faces[i].uvs = new vec2f[ sign.faces[i].max_vertices ]
for j as integer = 0 to sign.faces[i].max_vertices-1
read sign.faces[i].vert_index[j]
sign.faces[i].vert_index[j]-=1
next
for j as integer = 0 to sign.faces[i].max_vertices-1
read sign.faces[i].uvs[j].x
sign.faces[i].uvs[j].x*=-1
read sign.faces[i].uvs[j].y
next
next
dim as integer x = 512, y = 256
dim as any ptr the_sign
the_sign = imagecreate(x,y)
bload( "sign.bmp", the_sign )
'swap the r/b bytes so that the image isn't the wrong color
for i as integer = 0 to x*y*4-4 step 4
swap *cast( ubyte ptr, the_sign + i ), *cast( ubyte ptr,the_sign + i + 2 )
next
dim as gluint texture
glGenTextures(1, @texture )
glBindTexture( GL_TEXTURE_2D, texture )
glEnable( GL_TEXTURE_2D )
glTexImage2d( GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, the_sign )
gluBuild2dMipmaps( GL_TEXTURE_2D, GL_RGBA, x, y, GL_RGBA, GL_UNSIGNED_BYTE, the_sign )
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR )
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR )
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
imagedestroy( the_sign )
setmouse(MidX, MidY, 0)
do
glClear( GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT )
getmouse(TempX, TempY,, Button)
Factor.Y = (MidX-TempX)/500
Factor.X = (MidY-TempY)/500
setmouse(MidX, MidY, 0)
Factor.Z = -Cam.RVector.Y*.5
Rot_X Cam, Factor.X
Rot_Y Cam, Factor.Y
Rot_Z Cam, Factor.Z
'___________________________________________________________________________
'here is a nice solution...
'create a temporary up vector, which will always be(0,1,0)
'take the cross product of that temp vector and the camera's right vector,
'which will give you a perpendicular vector that you can use for the heading.
'you shouldn't need to normalize it, but just in case some other operation
'causes it to become a non-unit vector, we do it anyway. ;)
dim as vec3f up=>(0,1,0)
dim as vec3f Direction = Vector_Cross( up, Cam.RVector )
vector_normalize(Direction)
'NOTE: This will NOT work correctly, if you wish to implement "roll" in your camera system.
'It should be pretty nice for a FPS style camera though.
'___________________________________________________________________________
if multikey(FB.SC_W) then
Cam.Position.X += Direction.X*.15
Cam.Position.Z += Direction.Z*.15
end if
if multikey(FB.SC_S) then
Cam.Position.X -= Direction.X*.15
Cam.Position.Z -= Direction.Z*.15
end if
if multikey(FB.SC_D) then
Cam.Position.X += Cam.RVector.X*.15
Cam.Position.Z += Cam.RVector.Z*.15
end if
if multikey(FB.SC_A) then
Cam.Position.X -= Cam.RVector.X*.15
Cam.Position.Z -= Cam.RVector.Z*.15
end if
glmatrixmode GL_MODELVIEW
glloadidentity
Cam.LookAt.X = Cam.Position.X + Cam.DVector.X
Cam.LookAt.Y = Cam.Position.Y + Cam.DVector.Y
Cam.LookAt.Z = Cam.Position.Z + Cam.DVector.Z
gluLookAt( Cam.Position.X, Cam.Position.Y, Cam.Position.Z, _
Cam.LookAt.X, Cam.LookAt.Y, Cam.LookAt.Z, _
Cam.UVector.X, Cam.UVector.Y, Cam.UVector.Z )
glLightfv( GL_LIGHT0, GL_POSITION, @light_Position.x )
glPushMatrix()
glColor3f( 1,1,1 )
glRotateF( 90, 1,0,0 )
gluCylinder( Quadric, .1, .1, 3, 32, 32 )
glPopMatrix()
' glPushMatrix()
' glTranslatef( Cam.Position.X, Cam.Position.Y-3, Cam.Position.Z )
' glColor3f(1,1,1)
'
' for i as integer = 0 to room.max_faces-1
' glBegin( GL_QUADS )
' for j as integer = 0 to room.faces[i].max_vertices-1
' glTexCoord2f( 0,1)
' glVertex3fv( @room.vertices[room.faces[i].vert_index[j]].x )
' next
' glEnd()
' next
' glPopMatrix()
glEnable( GL_TEXTURE_2D )
glBindTexture( GL_TEXTURE_2D, texture )
glPushMatrix()
glTranslatef(0,.4,0)
glColor3f(1,1,1)
for i as integer = 0 to sign.max_faces-1
glBegin( GL_QUADS )
for j as integer = 0 to sign.faces[i].max_vertices-1
glTexCoord2fv( @sign.faces[i].uvs[j].x )
glVertex3fv( @sign.vertices[sign.faces[i].vert_index[j]].x )
next
glEnd()
next
glPopMatrix()
glDisable( GL_TEXTURE_2D )
flip
sleep 1,1
loop while inkey$ <> chr$(27)
gluDeleteQuadric( Quadric )
'obligatory beep :)
beep
function Distance( byref P1 as vec3f, byref P2 as vec3f ) as single
return sqr((P2.x - P1.x)^2 + (P2.y - P1.y)^2 + (P2.z - P1.z)^2)
end function
function Vector_Cross ( byref v1 as vec3f, byref v2 as vec3f ) as vec3f
dim v as vec3f
v.x = (v1.y * v2.z) - (v2.y * v1.z)
v.y = (v1.z * v2.x) - (v2.z * v1.x)
v.z = (v1.x * v2.y) - (v2.x * v1.y)
return v
end function
function Vector_Magnitude( byref V as vec3f ) as single
dim Mag as single
Mag = sqr(v.x ^2 + v.y ^2 + v.z ^2)
if Mag = 0 then Mag = 1
return Mag
end function
sub Vector_Normalize ( byref v as vec3f )
dim Mag as single
Mag = Vector_Magnitude(V)
v.x = v.x / Mag
v.y = v.y / Mag
v.z = v.z / Mag
end sub
sub Rot_X( byref Entity as EntityType, byref Angle as single )
dim tDir as vec3f, tSin as single, tCos as single
tCos = cos(Angle)
tSin = sin(Angle)
tDir.X = Entity.DVector.X*tCOS+Entity.UVector.X*tSin
tDir.Y = Entity.DVector.Y*tCOS+Entity.UVector.Y*tSin
tDir.Z = Entity.DVector.Z*tCOS+Entity.UVector.Z*tSin
Vector_Normalize( tDir )
Entity.DVector.X = tDir.X
Entity.DVector.Y = tDir.Y
Entity.DVector.Z = tDir.Z
Entity.UVector = Vector_Cross( Entity.DVector, Entity.RVector )
Entity.UVector.X =-Entity.UVector.X
Entity.UVector.Y =-Entity.UVector.Y
Entity.UVector.Z =-Entity.UVector.Z
end sub
sub Rot_Y( byref Entity as EntityType, byref Angle as single )
dim tDir as vec3f, tCos as single, tSin as single
tCos = cos(Angle)
tSin = sin(Angle)
tDir.X = Entity.DVector.X*tCOS-Entity.RVector.X*tSin
tDir.Y = Entity.DVector.Y*tCOS-Entity.RVector.Y*tSin
tDir.Z = Entity.DVector.Z*tCOS-Entity.RVector.Z*tSin
Vector_Normalize( tDir )
Entity.DVector.X = tDir.X
Entity.DVector.Y = tDir.Y
Entity.DVector.Z = tDir.Z
Entity.RVector = Vector_Cross( Entity.DVector, Entity.UVector )
end sub
sub Rot_Z( byref Entity as EntityType, byref Angle as single )
dim tRight as vec3f, tCos as single, tSin as single
tCos = cos(Angle)
tSin = sin(Angle)
tRight.X = Entity.RVector.X*tCOS+Entity.UVector.X*tSin
tRight.Y = Entity.RVector.Y*tCOS+Entity.UVector.Y*tSin
tRight.Z = Entity.RVector.Z*tCOS+Entity.UVector.Z*tSin
Vector_Normalize( tRight )
Entity.RVector.X = tRight.X
Entity.RVector.Y = tRight.Y
Entity.RVector.Z = tRight.Z
Entity.UVector = Vector_Cross( Entity.DVector, Entity.RVector )
Entity.UVector.X =-Entity.UVector.X
Entity.UVector.Y =-Entity.UVector.Y
Entity.UVector.Z =-Entity.UVector.Z
end sub
vertex_list:
data 8
data -1, 0, 1
data -1, 0, -1
data -1, 1, -1
data -1, 1, 1
data 1, 0, 1
data 1, 0, -1
data 1, 1, -1
data 1, 1, 1
face_list:
data 6
data 4
data 2, 3, 4, 1
data 4
data 5, 6, 2, 1
data 4
data 6, 7, 3, 2
data 4
data 3, 7, 8, 4
data 4
data 4, 8, 5, 1
data 4
data 8, 7, 6, 5
sign_vertex_list:
data 8
data -0.345, -0.1364, -0.0132
data -0.345, 0.1396, -0.0132
data -0.345, -0.1364, 0.0132
data -0.345, 0.1396, 0.0132
data 0.345, -0.1364, -0.0132
data 0.345, 0.1396, -0.0132
data 0.345, 0.1396, 0.0132
data 0.345, -0.1364, 0.0132
sign_face_list:
data 6
data 4
data 4, 2, 1, 3
data 0.000000, 1.000000
data 0.000000, 1.000000
data 0.000000, 1.000000
data 0.000000, 1.000000
data 4
data 1, 5, 8, 3
data 0.000000, 1.000000
data 0.000000, 1.000000
data 0.000000, 1.000000
data 0.000000, 1.000000
data 4
data 2, 6, 5, 1
data 0.000000, 0.000000
data 1.000000, 0.000000
data 1.000000, 1.000000
data 0.000000, 1.000000
data 4
data 7, 6, 2, 4
data 0.000000, 1.000000
data 0.000000, 1.000000
data 0.000000, 1.000000
data 0.000000, 1.000000
data 4
data 8, 7, 4, 3
data 0.000000, 0.000000
data 0.000000, -1.000000
data 1.000000, -1.000000
data 1.000000, 0.000000
data 4
data 5, 6, 7, 8
data 0.000000, -1.000000
data 0.000000, -1.000000
data 0.000000, -1.000000
data 0.000000, -1.000000
-
- Posts: 2655
- Joined: Aug 28, 2008 10:54
- Location: new york
I didn't mean to offend you but it makes very little sense to create a 3d environment for a character NOT to interact with. Especially with 10 minutes of voice over.Ophelius wrote:Who said this was going to be a video game? Read the post. It's an interactive world relating to the story. A simple demo
Don't get me wrong, your story is good. The idea is good, a man who clings to his only sense of reference, this is a profound and mind boggling idea. It tantalizes the imagination, but when you provide the "reader" with the images, then there is no more room for the imagination.
So basically you are taking everything good about your composition and violating it.
The right medium for a story such as this is the prose poem. If you are interested in digital literature I can be a valuable resource. I dabble myself. Do not force a round peg into a square hole just because you're excited about having written a very good story.
The next step to work with this is to clean up the grammar, and fine-tweak your rhythm, then send it out to be published.
There are plenty of good stories that can use a 3d world but this isn't that story. You should be working on the composition itself, because while good, it isn't finished.
Again, sorry if I offended you. I don't mean anything by it, but I do rub people the wrong way.
rb
-
- Posts: 2655
- Joined: Aug 28, 2008 10:54
- Location: new york
Okay Lachie,
You and me together now are going to imagine interacting with this story...
< I'm hearing the voice over... I see a pole... I can run into the pole... >
Okay I'm done interacting with the story. Now I'm going to listen to 9.5 minutes worth of voice over I could more enjoyably be reading.
No one should be debating me on literature unless they have a doctorate and even then... Even an interactive story needs an EVOLVING character.
rb
And I'm starting to get a little touchy about the word INTERACTIVE and its usage in this context.
You and me together now are going to imagine interacting with this story...
< I'm hearing the voice over... I see a pole... I can run into the pole... >
Okay I'm done interacting with the story. Now I'm going to listen to 9.5 minutes worth of voice over I could more enjoyably be reading.
No one should be debating me on literature unless they have a doctorate and even then... Even an interactive story needs an EVOLVING character.
rb
And I'm starting to get a little touchy about the word INTERACTIVE and its usage in this context.