Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Procedural City (OpenGL)


  • Please log in to reply
7 replies to this topic
Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
Another little OpenGL program - generates a "city" procedurally, then displays it interactively.

Screenshot:

Posted Image

Controls:

W - Move forward
S - Move backward
A - Move left
D - Move right
Q - Move down (global axis)
E - Move up (global axis)


Download:

Here

SoggyDog
  • Members
  • 803 posts
  • Last active: Mar 04 2013 06:27 AM
  • Joined: 02 May 2006
Haven't played, but looks cool as hell.

Occasional AHKer
  • Members
  • 10 posts
  • Last active: Jul 01 2011 01:38 AM
  • Joined: 23 Mar 2011
Please include your includes. :) Box.ahk is missing.

  • Guests
  • Last active:
  • Joined: --
Very impressive!

Code looks to include box.ahk, but works okay when it's commented out.

Occasional AHKer
  • Members
  • 10 posts
  • Last active: Jul 01 2011 01:38 AM
  • Joined: 23 Mar 2011
Sorry it does work without Box.ahk it just takes about 30 seconds to load for me. Very impressive indeed.

Have you thought about making a virtual avatar? Just a face that could be rotated around or an entire body? THAT would be impressive.

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
Wow :shock:

This is great! I played with the texture a little to make it more colorful. It can be change in paint.

Some ideas:
• Full screen mode (F4?)
• Fly around mode (no actions needed)
• Screensaver! (connected to the previous)

Pics:
Posted Image                                                                                                  (There's SciTE, must have had it open...)
Posted Image
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

tidbit
  • Administrators
  • 2709 posts
  • Hates playing Janitor
  • Last active: Jan 15 2016 11:37 PM
  • Joined: 09 Mar 2008
very nice!

couple notes:
doesn't work with BBLean shell. no window shows and my mouse gets locked in the upper-middle of the screen. but other OpenGL games work just fine... even your other AHK3d doodads.
and
don't be so wimpy with the starting values!

I changed the fog to start at 100 and end at 200
and made the city 100x100 and up to 12 tall with no fps drop and instant load time (on a 5 year old pc)

rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .


Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010

Have you thought about making a virtual avatar? Just a face that could be rotated around or an entire body? THAT would be impressive.


Probably not that hard, with the right tools. Here's a simple importer for the OBJ file format (you can import a 3d model with it):

#NoEnv

;LoadOBJ(A_ScriptDir . "\Mesh.obj")

LoadOBJ(ByRef Mesh,ObjectName)
{
 VerticesIndex := 1, TexCoordsIndex := 1, VertexNormalsIndex := 1
 Str := A_IsUnicode ? "AStr" : "Str"
 hOpenGL32 := DllCall("GetModuleHandle","Str","opengl32")
 pBegin := DllCall("GetProcAddress","UInt",hOpenGL32,Str,"glBegin")
 pNormal := DllCall("GetProcAddress","UInt",hOpenGL32,Str,"glNormal3f")
 pTexCoord := DllCall("GetProcAddress","UInt",hOpenGL32,Str,"glTexCoord2f")
 pVertex := DllCall("GetProcAddress","UInt",hOpenGL32,Str,"glVertex3f")
 pEnd := DllCall("GetProcAddress","UInt",hOpenGL32,Str,"glEnd")

 ListIndex := DllCall("opengl32\glGenLists","Int",1)
 DllCall("opengl32\glNewList","UInt",ListIndex,"UInt",0x1300) ;GL_COMPILE
 Loop, Parse, Mesh, `n, `r
 {
  Temp1 := InStr(A_LoopField," "), Action := SubStr(A_LoopField,1,Temp1 - 1), Temp1 := SubStr(A_LoopField,Temp1 + 1)
  If IsLabel("LoadOBJAction" . Action)
   Gosub, LoadOBJAction%Action%
 }
 DllCall("opengl32\glEndList")
 Return, ListIndex . "|0,0,0|0,0,0|1,1,1|"

 LoadOBJActionv:
 Vertices%VerticesIndex% := Temp1, VerticesIndex ++
 Return
 LoadOBJActionvt:
 TexCoords%TexCoordsIndex% := Temp1, TexCoordsIndex ++
 Return
 LoadOBJActionvn:
 VertexNormals%VertexNormalsIndex% := Temp1, VertexNormalsIndex ++
 Return
 LoadOBJActionf:
 DllCall(pBegin,"UInt",0x9) ;GL_POLYGON
 Loop, Parse, Temp1, %A_Space%
 {
  StringSplit, TempVar, A_LoopField, /
  If TempVar3
  {
   StringSplit, TempVertexNormals, VertexNormals%TempVar3%, %A_Space%
   DllCall(pNormal,"Float",TempVertexNormals1,"Float",TempVertexNormals2,"Float",TempVertexNormals3)
  }
  If TempVar2
  {
   StringSplit, TempTexCoords, TexCoords%TempVar2%, %A_Space%
   DllCall(pTexCoord,"Float",TempTexCoords1,"Float",TempTexCoords2)
  }
  StringSplit, TempVertices, Vertices%TempVar1%, %A_Space%
  DllCall(pVertex,"Float",TempVertices1,"Float",TempVertices2,"Float",TempVertices3)
 }
 DllCall(pEnd)
 Return
}

Still needs a display though, which I'll probably write pretty soon.

Some ideas:
• Full screen mode (F4?)
• Fly around mode (no actions needed)
• Screensaver! (connected to the previous)


Interesting...

[*:2knpz00d]Added option for fullscreen mode. It's not actually fullscreen though, I've just placed the GUI at 0, 0, and made it fill the display.
[*:2knpz00d]Also added, as an option.
[*:2knpz00d]It's probably possible to make a screensaver by combining these options.

couple notes:
doesn't work with BBLean shell. no window shows and my mouse gets locked in the upper-middle of the screen. but other OpenGL games work just fine... even your other AHK3d doodads.
and
don't be so wimpy with the starting values!

I changed the fog to start at 100 and end at 200
and made the city 100x100 and up to 12 tall with no fps drop and instant load time (on a 5 year old pc)


I don't know what's up with BBLean, but if the AHK 3D Platformer works, this should work as well (it's basically the same codebase, after all).

The starting values: Well, I think it looks a bit too funky when the building are really tall, but I've added options to change the city size. Doesn't yet work with it's AutoFly though.


Also, removed the Box.ahk #include. Yes, it wasn't necessary, I was using it for debugging. Redownload to get all that autoflying, fullscreen goodness!