|
Post by DJLinux on Dec 12, 2008 3:11:45 GMT -5
|
|
|
Post by smc44 on Dec 12, 2008 12:02:05 GMT -5
really nice job i want to be as good as you one day lol
|
|
|
Post by Darkjester on Dec 12, 2008 12:06:08 GMT -5
OMG its amazing!!! (you sure its bas4gl ) Is that perpixel lighting? Did you make the models? -Darkjester
|
|
|
Post by xteraco on Dec 12, 2008 13:52:46 GMT -5
|
|
|
Post by smc44 on Dec 12, 2008 14:09:10 GMT -5
dude thats a 350z my favorite car nice
|
|
|
Post by xteraco on Dec 12, 2008 14:18:12 GMT -5
308hp to the rear wheels. You just cant go wrong with one.
|
|
|
Post by DJLinux on Dec 12, 2008 15:05:08 GMT -5
if any needs reflections + environment + transparent (glass) rendering it's a 2 pass rendering here are the steps setup opengl init one or more lights set material properties prepare spheremap renderin ' first render pass for all none transparent polys loop over polygones/triangles in you scene is polygone not transparent then draw it normal if polgone reflects environment enable spheremap S/T coords enable blending bind the env. texture draw same poly again !!! end if end if end loop ' ' second render pass for all transparent polys ' enable blending loop over plygones/triangles in you scene is polygone transparent=glass then if polgone reflects environment enable spheremap S/T coords enable blending bind the env. texture draw same poly again !!! end if end if end loop here are the real code you are wondering how short it is? im too :-) Joshy sub InitGL() ' setup opengl glClearColor(0.1, 0.1, 0.2, 0.0) glShadeModel(GL_SMOOTH) glClearDepth(1.0) glEnable(GL_DEPTH_TEST) glBlendFunc(GL_ONE, GL_ONE) glDepthFunc(GL_LEQUAL) glEnable(GL_TEXTURE_2D) glAlphaFunc(GL_GREATER, 0.01) glCullFace(GL_FRONT) glDisable(GL_CULL_FACE)
' setup 2 lights GlEnable(GL_COLOR_MATERIAL) glEnable(GL_LIGHTING) glEnable(GL_LIGHT0) glEnable(GL_LIGHT1) glLightfv(GL_LIGHT0, GL_POSITION,vec4(1,5,1,0)) glLightfv(GL_LIGHT0, GL_DIFFUSE,vec4(1,1,1,1)) glLightfv(GL_LIGHT1, GL_POSITION,vec4(-2,2,0,0)) glLightfv(GL_LIGHT1, GL_DIFFUSE ,vec4(1,0.7,0.4,1)) glLightfv(GL_LIGHT1, GL_SPECULAR,vec4(1,0.8,0.4,1)) ' setup material propertys glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE ,vec4(1,1,1,1)) glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,vec4(1,1,1,1)) glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS,50) glMateriali(GL_FRONT_AND_BACK, GL_COLOR_MATERIAL_PARAMETER, GL_SPECULAR) ' prepare spheremap rendering glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP) glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP) glTexGeni(GL_S, GL_SPHERE_MAP, 0) glTexGeni(GL_T, GL_SPHERE_MAP, 0) ' but don't enable it for all polygones glDisable(GL_TEXTURE_GEN_S) glDisable(GL_TEXTURE_GEN_T) ' looks nicest ;-) glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) end sub ' ' ' sub DrawCar(c) dim p ' first render pass glDisable(GL_BLEND) for p = 0 to Cars(c).nParts-1 if Cars(c).Parts(p).Transparent=False then if Cars(c).Parts(p).TextureID>-1 then glEnable(GL_TEXTURE_2D) glBindTexture(Gl_TEXTURE_2D,Cars(c).Textures(Cars(c).Parts(p).TextureID)) else gldisable(GL_TEXTURE_2D) end if glColor3f(0.2,0.2,0.2) glCallList(Cars(c).Parts(p).List) if Cars(c).Parts(p).EnvMap then glEnable(GL_TEXTURE_GEN_S) glEnable(GL_TEXTURE_GEN_T) glEnable(GL_TEXTURE_2D) glEnable(GL_BLEND) glBindTexture(GL_TEXTURE_2D,EnvMap) glcolor3f(1,1,1) glCallList(Cars(c).Parts(p).List) glDisable(GL_TEXTURE_2D) glDisable(GL_TEXTURE_GEN_S) glDisable(GL_TEXTURE_GEN_T) glDisable(GL_BLEND) end if end if next ' ' second reder pass ' glEnable(GL_BLEND) for p = 0 to Cars(c).nParts-1 if Cars(c).Parts(p).Transparent<>0 then if Cars(c).Parts(p).TextureID>-1 then glEnable(GL_TEXTURE_2D) glBindTexture(Gl_TEXTURE_2D,Cars(c).Textures(Cars(c).Parts(p).TextureID)) else glDisable(GL_TEXTURE_2D) end if glColor3f(.2,.2,.2) glCallList(Cars(c).Parts(p).List) if Cars(c).Parts(p).EnvMap then glEnable(GL_TEXTURE_GEN_S) glEnable(GL_TEXTURE_GEN_T) glEnable(GL_TEXTURE_2D) glEnable(GL_BLEND) glBindTexture(GL_TExture_2D,EnvMap) glcolor3f(1,1,1) glCallList(Cars(c).Parts(p).List) glDisable(GL_TEXTURE_GEN_S) glDisable(GL_TEXTURE_GEN_T) end if end if next end sub
|
|
|
Post by Darkjester on Dec 12, 2008 16:06:59 GMT -5
nice! Thnx for that djlinux smc: My cuzzin had a 350z was pretty slick car but corvettes are better
|
|
|
Post by xteraco on Dec 12, 2008 18:18:57 GMT -5
I don't like American cars.
|
|
|
Post by Empyrion Martyr on Dec 20, 2008 12:34:10 GMT -5
Cuz they're too big and waste too much gas? Very nice demo, considering that the code is so small, yet the impact on the aspect is so immense.
|
|
|
Post by DJLinux on May 14, 2009 23:13:01 GMT -5
here are a windows and linux version made with FreeBASIC. Download: CarsWinLin.ziptest it on your vista and linux box pleasegive me a message if somthing goes wrong thanx Joshy
|
|
|
Post by matthew on May 15, 2009 18:38:16 GMT -5
I'm not running Vista anymore, so I had to test it in XP & it worked fine. I tested CarsLinux in Mandriva Linux but I kept getting a Floating point exception error. However CarsWindows.exe worked perfectly in Wine.
|
|
|
Post by DJLinux on May 15, 2009 20:18:07 GMT -5
thanx for testing
i added a SkyBox and the linux version should work now too
Joshy
|
|
|
Post by matthew on May 16, 2009 7:25:04 GMT -5
Yeah, well done. It's working fine now.
|
|
|
Post by xteraco on May 16, 2009 8:34:29 GMT -5
Wait what? How was a "linux version" made?
|
|