|
Post by Wayne Rayner on Mar 19, 2009 19:42:47 GMT -5
k thanks it's going to be real simple and also I will need help with the coordinates where to place a object.
Wayne rayner
|
|
|
Post by twasik4 on Mar 20, 2009 8:50:06 GMT -5
I tried 3ds max it said you had to register.. and to register = money.. and im putting all of my funds to my server, but is there a free version of it? and no smc; not at them moment, shadow and i are deciding if we are going to change the code up and do some matenanice on it(yes i spelt that wrong, ive had .5 hours of sleep last night)
|
|
|
Post by smc44 on Mar 20, 2009 11:48:32 GMT -5
no offense twaswik but i saw your collision code, not a fast nor strong routine, thats why im williing to help with the collison engine for your game, maybe even make you a plugin
|
|
|
Post by Darkjester on Mar 20, 2009 14:44:40 GMT -5
his collision code is fine it just needs tweaked and coded a bit smarter, as well as sorting your faces cause your rendering like 100 faces and it laggs on my gaming computer gotta love the ineficincy of bas4gl jp tom -darkjester
|
|
|
Post by twasik4 on Mar 20, 2009 14:57:09 GMT -5
lol, exactly what im talking to shadow about.. and now have changed the way we are typing the code, i will give you all an update on our project in the near future
|
|
|
Post by smc44 on Mar 20, 2009 16:16:13 GMT -5
his collision code is fine it just needs tweaked and coded a bit smarter, as well as sorting your faces cause your rendering like 100 faces and it laggs on my gaming computer gotta love the ineficincy of bas4gl jp tom -darkjester duh what do you think i was talking about lol
|
|
|
Post by shadow008 on Mar 20, 2009 19:22:50 GMT -5
well i have looked over ur code for the past 2 hours and have found stuff not usefull which = less lines of code. i have taken out stuff that has no visual affect on the overall code. if it helps...
Struc sPlayer Dim PosX#, PosY#, PosZ# Dim Speed# Dim HitX#, HitY#, HitZ#, OnGround#, Gravity# Dim Angle#(2) Dim Drop# Dim Health# Dim OnLadder#(10) EndStruc Dim sPlayer Player Player.PosX# = 0: Player.PosY# = 45: Player.PosZ# = 90: Player.Speed# = 2 Player.Health# = 100
Struc sPlane Dim PosX#, PosY#, PosZ# Dim SizeX#, SizeY#, SizeZ# Dim Texture EndStruc Dim sPlane Plane(1) Player.Gravity# = 0.75 glEnable(GL_TEXTURE_2D) Plane(0).Texture = Loadmipmaptexture("textures/Floor01.jpg")'mipmap looks better
glEnable(GL_NORMALIZE) glShadeModel(GL_SMOOTH)
Struc sBox Dim Vert#(23)(2) Dim Norm#(5)(2)
Dim PosX#, PosY#, PosZ# Dim SizeX#, SizeY#, SizeZ# Dim HitX#, HitY#, HitZ# EndStruc Dim sBox Box(10) Box(0).PosX# = 0: Box(0).PosY# = -1.501: Box(0).PosZ# = -0.001 Box(0).SizeX# = 0.1: Box(0).SizeY# = 0.5: Box(0).SizeZ# = 1
Box(1).PosX# = 0.24: Box(1).PosY# = -5: Box(1).PosZ# = 10.5 Box(1).SizeX# = 0.04: Box(1).SizeY# = 0.5: Box(1).SizeZ# = 0.05
Box(0).Vert#(0) = Vec3(-1, -1, -1) Box(0).Vert#(1) = Vec3(1, -1, -1) Box(0).Vert#(2) = Vec3(1, 1, -1) Box(0).Vert#(3) = Vec3(-1, 1, -1) '' Box(0).Vert#(12) = Vec3(-1, -1, -1) Box(0).Vert#(13) = Vec3(1, -1, -1) Box(0).Vert#(14) = Vec3(1, -1, 1) Box(0).Vert#(15) = Vec3(-1, -1, 1) '' Box(0).Vert#(16) = Vec3(-1, -1, 1) Box(0).Vert#(17) = Vec3(1, -1, 1) Box(0).Vert#(18) = Vec3(1, 1, 1) Box(0).Vert#(19) = Vec3(-1, 1, 1) '' Box(0).Vert#(20) = Vec3(-1, 1, 1) Box(0).Vert#(21) = Vec3(-1, 1, -1) Box(0).Vert#(22) = Vec3(1, 1, -1) Box(0).Vert#(23) = Vec3(1, 1, 1)
Sub CreateBox(PosX#, PosY#, PosZ#, SizeX#, SizeY#, SizeZ#) glPushMatrix() glTranslatef(PosX#, PosY#, PosZ#) glScalef(SizeX#, SizeY#, SizeZ#) glRotatef(90, 0, 0, 1) glBegin(Gl_QUADS)
glVertex3fv(Box(0).Vert#(0)) glVertex3fv(Box(0).Vert#(1)) glVertex3fv(Box(0).Vert#(2)) glVertex3fv(Box(0).Vert#(3))
glVertex3fv(Box(0).Vert#(8)) glVertex3fv(Box(0).Vert#(9)) glVertex3fv(Box(0).Vert#(10)) glVertex3fv(Box(0).Vert#(11))
glVertex3fv(Box(0).Vert#(12)) glVertex3fv(Box(0).Vert#(13)) glVertex3fv(Box(0).Vert#(14)) glVertex3fv(Box(0).Vert#(15))
glVertex3fv(Box(0).Vert#(16)) glVertex3fv(Box(0).Vert#(17)) glVertex3fv(Box(0).Vert#(18)) glVertex3fv(Box(0).Vert#(19))
glVertex3fv(Box(0).Vert#(20)) glVertex3fv(Box(0).Vert#(21)) glVertex3fv(Box(0).Vert#(22)) glVertex3fv(Box(0).Vert#(23)) glEnd() glPopMatrix() EndSub ' Plane 1 Plane(0).PosX# = 0: Plane(0).PosY# = 9: Plane(0).PosZ# = 0 Plane(0).SizeX# = 50: Plane(0).SizeY# = 10: Plane(0).SizeZ# = 50 ' Plane 2 Plane(1).PosX# = 0: Plane(1).PosY# = .4: Plane(1).PosZ# = -0.4 Plane(1).SizeX# = .5: Plane(1).SizeY# = 1: Plane(1).SizeZ# = 0.5
Sub CreatePlane(PosX#, PosY#, PosZ#, SizeX#, SizeY#, SizeZ#, Texture) glTranslatef(PosX#, PosY#, PosZ#) glScalef(SizeX#, SizeY#, SizeZ#) glBindTexture(GL_TEXTURE_2D, Texture) glBegin (GL_QUADS) glTexCoord2f(10, 0): glVertex3f(-1, -1, -1) glTexCoord2f(10,10): glVertex3f(1, -1, -1) glTexCoord2f(0, 10): glVertex3f(1, -1, 1) glTexCoord2f(0, 0): glVertex3f(-1, -1, 1) glEnd() EndSub
Sub Createladder(PosX#, PosY#, PosZ#, SizeX#, SizeY#, SizeZ#, Texture) glTranslatef(PosX#, PosY#, PosZ#) glScalef(SizeX#, SizeY#, SizeZ#) glBindTexture(GL_TEXTURE_2D, Texture) glBegin(GL_QUADS) glTexCoord2f(5, 0): glVertex3f(2, -1, 5.05) glTexCoord2f(5, 5): glVertex3f(2, 3, 5.05) glTexCoord2f(0, 5): glVertex3f(-2, 3, 5.05) glTexCoord2f(0, 0): glVertex3f(-2, -1,5.05) glEnd() EndSub
Dim BoxSX# = 1, BoxSY# = 7, BoxSZ# = 1 Dim BoxPosX# = 0, BoxPosY# = 1, BoxPosZ# = 0 Dim BoxTex = LoadTex("textures/wall01.jpg") Dim Level = glGenLists(1) glNewList(Level, GL_COMPILE) glPushMatrix(): CreateLadder(BoxPosX#, BoxPosY#, BoxPosZ#, BoxSX#, BoxSY#, BoxSZ#, BoxTex) CreatePlane(Plane(0).PosX#, Plane(0).PosY#, Plane(0).PosZ#, Plane(0).SizeX#, Plane(0).SizeY#, Plane(0).SizeZ#, Plane(0).Texture) CreatePlane(Plane(1).PosX#, Plane(1).PosY#, Plane(1).PosZ#, Plane(1).SizeX#, Plane(1).SizeY#, Plane(1).SizeZ#, Plane(0).Texture) CreateBox(Box(0).PosX#, Box(0).PosY#, Box(0).PosZ#, Box(0).SizeX#, Box(0).SizeY#, Box(0).SizeZ#) glPopMatrix() glEndList() Dim Bullet = glGenLists(1) glNewList(Bullet, GL_COMPILE) glPushMatrix() CreateBox(Box(1).PosX#, Box(1).PosY#, Box(1).PosZ#, Box(1).SizeX#, Box(1).SizeY#, Box(1).SizeZ#) glPopMatrix() glEndList() TextMode(TEXT_OVERLAID) glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
While TRUE glClear(GL_DEPTH_BUFFER_BIT or GL_COLOR_BUFFER_BIT) glLoadIdentity() 'the green was getting really annoying... 'glClearColor(1, .5, 1, 1) so were all other colors 'glRotatef(Player.Angle#(2), 1, .5, 0) <-- unloved glRotatef(Player.Angle#(1), 1, 0, 0) glRotatef(Player.Angle#(0), 0, 1, 0) glTranslatef(-Player.PosX#, Player.PosY#, -Player.PosZ#) glScalef(10, 10, 10) ' Draw Objects glCallList(Level) Locate 0, 0: Printr "Health:"; Player.Health# DrawText() SwapBuffers()
GoSub Collision GoSub PlayerControl Wend PlayerControl: Player.HitX# = Player.PosX#: Player.HitY# = Player.PosY#: Player.HitZ# = Player.PosZ# Player.Angle#(0) = Player.Angle#(0) + Mouse_XD()*60.0 Player.Angle#(1) = Player.Angle#(1) + Mouse_YD()*60.0 if KeyDown("W") Then Player.PosX# = Player.PosX# + Cosd(Player.Angle#(0)-90)/Player.Speed#*3 Player.PosZ# = Player.PosZ# + Sind(Player.Angle#(0)-90)/Player.Speed#*3 Endif if KeyDown("S") Then Player.PosX# = Player.PosX# - Cosd(Player.Angle#(0)-90)/Player.Speed# Player.PosZ# = Player.PosZ# - Sind(Player.Angle#(0)-90)/Player.Speed# Endif if KeyDown("D") Then Player.PosX# = Player.PosX# + Cosd(Player.Angle#(0))/Player.Speed# Player.PosZ# = Player.PosZ# + Sind(Player.Angle#(0))/Player.Speed# Endif if KeyDown("A") Then Player.PosX# = Player.PosX# - Cosd(Player.Angle#(0))/Player.Speed# Player.PosZ# = Player.PosZ# - Sind(Player.Angle#(0))/Player.Speed# Endif Player.PosY# = Player.PosY# + 0.75 Return Collision: if Box(1).PosX# <= 0.24 Then Box(1).PosX# = 0.24 Endif if Box(1).PosY# > 1 Then Player.PosX# = 1 Endif if Box(1).PosY# < -498 Then Player.PosX# = -498 Endif if Box(1).PosY# > 498 Then Player.PosZ# = 498 Endif if Box(1).PosY# < -498 Then Player.PosZ# = -498 Endif ' Ladder Collision if Player.PosX# < BoxPosX#+(BoxSX#+2.25*10) And Player.PosX# > BoxPosX#-(BoxSX#+2.25*10) Then if Player.PosZ# < BoxPosZ#+(BoxSZ#+6*10) And Player.PosZ# > BoxPosZ#-(BoxSZ#-6*10) Then if Player.PosY# < BoxPosY#+(BoxSY#*10) And Player.PosY# > BoxPosY#-(BoxSY#+23*10) Then Player.PosZ# = Player.HitZ#: Player.OnLadder#(0) = TRUE if Player.Angle#(1) <= -70 And Player.OnLadder#(0) = TRUE Then Player.PosY# = Player.PosY# - 1.25 Endif Endif Endif Endif ' Plane 2 Collision if Player.PosY# < Plane(1).PosY#+(Plane(1).SizeY#-23*10) And Player.PosY# > Plane(1).PosY#-(Plane(1).SizeY#+23*10) Then if Player.PosZ# < Plane(1).PosZ#+(Plane(1).SizeZ#+5.5*10) And Player.PosZ# > Plane(1).PosZ#-(Plane(1).SizeZ#+45*10) Then if Player.PosX# < Plane(1).PosX#+(Plane(1).SizeX#+25*10) And Player.PosX# > Plane(1).PosX#-(Plane(1).SizeX#+25*10) Then Player.PosY# = Player.HitY# Endif Endif Endif ' Divider Collision if Player.PosX# < Box(0).PosX#+(Box(0).SizeX#+3.7*10) And Player.PosX# > Box(0).PosX#-(Box(0).SizeX#+3.7*10) Then if Player.PosZ# < Box(0).PosZ#+(Box(0).SizeZ#+6*10) And Player.PosZ# > Box(0).PosZ#-(Box(0).SizeZ#+45*10) Then if Player.PosY# < Box(0).PosY#+(Box(0).SizeY#+6*10) And Player.PosY# > Box(0).PosY#-(Box(0).SizeY#+1*10) Then Player.PosX# = Player.HitX#: Player.PosZ# = Player.PosZ# + 0.01 Endif Endif Endif if Player.PosZ# < Box(0).PosZ#+(Box(0).SizeZ#+4.5*10) And Player.PosZ# > Box(0).PosZ#-(Box(0).SizeZ#+45.3*10) Then if Player.PosX# < Box(0).PosX#+(Box(0).SizeX#+3.7*10) And Player.PosX# > Box(0).PosX#-(Box(0).SizeX#+3.7*10) Then if Player.PosY# < Box(0).PosY#+(Box(0).SizeY#+6*10) And Player.PosY# > Box(0).PosY#-(Box(0).SizeY#+17.2*10) Then Player.PosZ# = Player.HitZ#: Player.PosX# = Player.PosX# + Sind(Player.Angle#(0))*0.01 Endif Endif Endif if Player.PosX# > 498 Then Player.PosX# = 498 Endif if Player.PosX# < -498 Then Player.PosX# = -498 Endif if Player.PosZ# > 498 Then Player.PosZ# = 498 Endif if Player.PosZ# < -498 Then Player.PosZ# = -498 Endif if Player.PosY# > 49 Then Player.PosY# = 49 Endif Return
went from 365 lines of code to 245, btw, explain why people try to use lighting on their models, it really doesnt do much... questions: dont understand normalize, plz explain the SUB CREATE"structured variable"
hope it helps-shadow008
|
|
|
Post by smc44 on Mar 20, 2009 19:46:54 GMT -5
thanks shadow, that code was unfinished, the lighting and the normals arent finished, i was going to finish it but didnt get around to it
|
|
|
Post by shadow008 on Mar 21, 2009 13:58:11 GMT -5
understood. i really like that demo though. it helped me figure out my camera rotation problem
|
|
|
Post by smc44 on Mar 21, 2009 14:30:00 GMT -5
your welcome lol
|
|
|
Post by Darkjester on Mar 21, 2009 21:12:43 GMT -5
ah but you see lighting does alot it makes it all look better with lighting i can smooth a model out so that it looks higher poly than it is and you can do other effects with it as well. as youll all see with my engine when its complete Normalize is the gl call that when you scale your model or something it recaculates your normals so that lighting works correctly otherwise your normals will get to long.
|
|
|
Post by smc44 on Mar 21, 2009 21:49:31 GMT -5
i actually forget to call it a few more times, i knew what it did, but shadow didnt, its a very useful function shadow
|
|
|
Post by Darkjester on Mar 21, 2009 22:33:50 GMT -5
i actually forget to call it a few more times, i knew what it did, but shadow didnt, its a very useful function shadow ummm.... you only call it once you do it like this while true glenable(gl_normalize) 'rendering code here gldisable(gl_normalize) swapbuffers() wend keep calling it and youll slow down the program immensly so therefore calling it once each pass through the loop is satisfactory -darkjester
|
|
|
Post by smc44 on Mar 21, 2009 22:36:58 GMT -5
i actually forget to call it a few more times, i knew what it did, but shadow didnt, its a very useful function shadow ummm.... you only call it once you do it like this while true glenable(gl_normalize) 'rendering code here gldisable(gl_normalize) swapbuffers() wend keep calling it and youll slow down the program immensly so therefore calling it once each pass through the loop is satisfactory -darkjester wow, im not talkin about that normalization function neither was shadow, we were talking about Normalize(X, Y, Z)
|
|
|
Post by shadow008 on Mar 23, 2009 7:05:40 GMT -5
ive been looking at the flyaround2 demo and trying to learn about lighting that way. darkjester, when you said about mine and twasic's code rendering 100 faces and lagging down ur comp, do you know what is the most efficient way b4gl renders gemotric shapes: (gl_quads),(gl_triangle_fan), ect? that would be really helpful to know
|
|