Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

548 Good

About okonomiyaki

  • Rank
  1. okonomiyaki

    Moving on...

    I'm canceling my gamedev.net premium membership soon, so if you want to follow my work, please follow my blog over at http://jlongster.com/blog. I still plan on working with Scheme and game programming, and I think it will continue to be really interesting stuff. I'm not getting much out of this account, and I'm tidying up my budget, so $12/trimonth was nixed. Cheers!
  2. okonomiyaki

    Farmageddon is released!

    Posted from http://jlongster.com/blog/2010/04/03/farmageddon-available/ *** For the past couple months I have been working on a 3d iPhone game in Gambit Scheme. It is called Farmageddon and I submitted it to Apple a couple days ago. It was just accepted and is now live on the App Store! You can find it
  3. okonomiyaki

    Farmageddon Gameplay

    I am coming into the final stages of my iPhone game, Farmageddon. I made a video showing about 2 minutes of gameplay and posted it to youtube here: Please check it out and let me know what you think! I really wish gamedev let me embed videos. Farmageddon is a game where animals have gone insane. They have turned against humans and fling themselves towards YOU, and you must be the one to stop them with your power of lightning before they destroy you (and crack your precious iPhone's screens)! Chickens, ducks, sheeps, pigs, and cows are all part of the fight. Pigs and cows are especially dangerous because of their large, heavy bodies which explode into pieces that still hurt you. There is a rumor that a few humans have been able to disguise a nuke as an animal and throw it into the fray. If you find these nukes and explode them, you will find that they destroy all the existing animals. Supposedly, the radioactive material in the nukes give the animal a greenish appearance, so be on the lookout. If you would like to follow the progress of Farmageddon, which should be released on the App Store next week, be sure to follow this twitter account: http://twitter.com/farmageddongame There is a website too: http://farmageddongame.com/
  4. okonomiyaki

    A look at my iPhone game: Farmageddon

    Posted from http://jlongster.com/blog/2010/02/23/farmageddon/: I thought it would be valuable to, for the first time, show some screenshots of the iPhone game I've been working on. The game is called Farmageddon. Farm animals have turned against humans and the world is entering an apocalypse. If you stand by idly, you will be destroyed. You must use your power of lightning to explode the animals which are bent on assulting you by flinging themselves through the air and cracking your screen. There are several levels, each having a specific goal. You might have to kill 5 animals without hurting any people, or you might just simply have to survive to 15 seconds. You must not kill humans which have been captured and thrown in to the air by the animals. The game is very close to being done, but I'm still designing the levels so I will save a detailed explanation of the game until I release it. Until then, enjoy these screenshots, and please let me know what you think! As I've said before, I need help marketing this game, so if you like what you see let your friends know about it! I also wanted to thank all of you who responded to my previous post about marketing ideas. I learned a number of things from various people, and I will try to reciprocate your generosity by posting my marketing plan in the future.
  5. okonomiyaki

    A look at my iPhone game: Farmageddon

    Posted from http://jlongster.com/blog/2010/02/23/farmageddon/: I thought it would be valuable to, for the first time, show some screenshots of the iPhone game I've been working on. The game is called Farmageddon. Farm animals have turned against humans and the world is entering an apocalypse. If you stand by idly, you will be destroyed. You must use your power of lightning to explode the animals which are bent on assulting you by flinging themselves through the air and cracking your screen. There are several levels, each having a specific goal. You might have to kill 5 animals without hurting any people, or you might just simply have to survive to 15 seconds. You must not kill humans which have been captured and thrown in to the air by the animals. The game is very close to being done, but I'm still designing the levels so I will save a detailed explanation of the game until I release it. Until then, enjoy these screenshots, and please let me know what you think! As I've said before, I need help marketing this game, so if you like what you see let your friends know about it! I also wanted to thank all of you who responded to my previous post about marketing ideas. I learned a number of things from various people, and I will try to reciprocate your generosity by posting my marketing plan in the future. img src="/media/images/farmageddon/farmageddon_8aaa.jpg" alt="/media/images/farmageddon/farmageddon_8aaa.jpg" />
  6. Posted from http://jlongster.com/blog/2010/02/08/fonts-ugh/: Fonts. Ugh. I knew it would be a pain to integrate text rendering in my OpenGLES-based graphics framework. I was able to avoid it for long while using textures, but now that I'm about to publish an iPhone game, there's really no avoiding it any longer. I begrudgingly opened up google and typed in "opengl font rendering". The first result was A Survey Of OpenGL Font Technology straight from opengl.org. "There is no native font support in OpenGL. The ARB has rarely ever even discussed fonts." Yes, I knew that, so what options do I have? That page lists a smattering of font rendering libraries, most of them completely unusable due to some major restriction. The only one with potential was FTGL. Searching for a solution FTGL turned out to be my best bet, but the only problem was that it targeted OpenGL and I'm working with OpenGLES, which lacks many features of OpenGL. Luckily, it looks like David Petrie ported FTGL to OpenGLES with the cleverly-named project FTGLES. I'm very thankful for David's work on the port, but I was disappointed to find that I simply couldn't get the library to work. Another minor gripe is that FTGLES only comes with an Xcode project and not autoconf/automake scripts. So I forked the damn thing and got to work. At this point, I was frustrated. With all of the games being made on mobile devices in OpenGLES, you would think there would be more options or at least a clear and straightforward solution to text rendering. What are all of you guys doing? And why aren't you releasing or documenting it? Am I missing something? There are a couple good articles on this such as Adding Font support in OpenGL - Acorn Heroes, but that's far from a good reusable library. FTGL itself could use better documentation. I only found an FTGL User Guide which only contains a tutorial for the basic functionality. There are also a few API reference docs out there, but there really should be readable, helpful, and thorough documentation for a library that seems to be so critical for OpenGL applications (it really seems to be one of the few solutions for font rendering). We aren't even talking about smart textual layout yet. Writing an OpenGL backend for Pango is really interesting but there's only a proof of concept finished at this point. Supposedly Pango might be too slow for OpenGL applications, so I'll digress. Do games even integrate a textual layout system or do developers do everything manually? FTGLES Back to my fork of FTGLES. I integrated the FTGLES source code with the original FTGL autoconf/automake build system so you can do the standard ./configure && make install. I also fixed a few bugs in the source which make it behave more predictably. I plan to contact David to see where he wants to take it from here, as I don't really like maintaining a separate fork of a project. FreeType 2 and compiling for iPhone FTGLES uses FreeType 2 to load TrueType font files, so we need to compile FreeType 2 for the iPhone. At this point I realized that people might need to compile many libraries for the iPhone (requiring cross-compilation to ARM), and it's really annoying to always remember how to configure the project to build correctly for the iPhone. I created the configure-iphone project to help with this. It is basically a single shell script which wraps around your ./configure call and appends the correct arguments to link with the right iPhone SDK and possibly cross-compile. Please see the project README for more info. With the configure-iphone utility script, I was able to compile FreeType 2 like so: wget http://download.savannah.gnu.org/releases-noredirect/freetype/freetype-2.3.11.tar.gz tar xvzf freetype-2.3.11.tar.gz cd freetype-2.3.11 configure-iphone 3.1.2 -t os sudo make install By default, configure-iphone installs libraries in /usr/local/iphone, but you can override that with the -d options. Our libraries would end up in /usr/local/iphone/iPhoneOS3.1.2. Please note that there are articles such as this one which describe tweaking parts of FreeType 2 in order for it to compile; you do NOT have to do this anymore as far as I'm concerned. Maybe they fixed that in that last couple minor versions, but the above commands compiles FreeType 2 for the iPhone just fine. Compiling FTGLES Compiling and installing FTGLES uses similar commands as compiling FreeType 2. You must tell FTGLES where your FreeType 2 library is located. Here is how it would look: git clone git@github.com:jlongster/ftgles.git cd ftgles configure-iphone 3.1.2 -t os -- --with-ft-prefix=/usr/local/iphone/iPhoneOS3.1.2 make sudo make install Now just make sure you link with the ftgl library and add /usr/local/iphone/iPhoneOS3.1.2/include and /usr/local/iphone/iPhoneOS3.1.2/lib to your header and library paths. The version and target may change, of course (target being either OS or Simulator). Using FTGLES For general information about using FTGL, read through this FTGL User Guide. The only thing specific to FTGLES is that you must call ftglInitImmediateModeGL to setup the vertex buffers correctly every frame before rendering any of the fonts. It took me a while to figure that out. Extruded, pixmap, and polygon fonts are not yet supported in the FTGLES port. The following is some pseudo C code which assumes init is called at the beginning of the program and render is called every frame. It renders the text "Hello, World" with the Batang TrueType font at the screen position (10, 0). #include "FTGL/ftgles.h" FTGLFont *font; void init() { font = ftglCreateTextureFont("Batang.ttf"); } void render() { // ... draw stuff ... ftglInitImmediateModeGL(); glMatrixMode(GL_PROJECTION); glOrthof(0.0f, width, 0.0f, height, -10.0f, 10.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(10.0f, 0.0f, 0.0f); ftglSetFontFaceSize(font, 72); ftglRenderFont(font, "Hello, World"); } Scheme bindings I have also writting some Scheme bindings, of course, if anyone is interested. Finally, I have OpenGL fonts in Scheme! And of course, my tweening functionality works just fine with fonts. Roll over, boy! http://www.youtube.com/v/h_mul5bFRBU Woohoo!
  7. okonomiyaki

    Sneak Peek of My 3d Scheme Game

    I am in the final development stages of my Scheme game that will initially be released for the iPhone. It's been an incredible adventure to leave my job and pursue this full-time. I have learned so much and I really hope I can continue doing this. This is one of a few posts I will be making in which I will one, begin showing you my game and two, ask for your assistance. I will be brief this time, but soon I will show you the whole game and explain more of my vision for Scheme and game development. Sneak Peek First, here is a video of just one aspect of my game, which is fully written in Gambit Scheme. I couldn't resist sharing it. I won't disclose many details of my game yet, but yes, those are cows, and yes, you are exploding them by shooting them with bolts of lightning! Unfortunately gamedev.net doesn't allow youtube embedding, so please watch it here: . Here's a teaser screenshot: My game should hopefully be released on the iPhone in the next couple weeks. I will post a much more detailed overview of my game soon when I start my big marketing push. A Request for Help Speaking of marketing, that's where I need some assistance. I'm a one-man shop right now with little connections in the game industry. It's going to be extremely difficult to make this game successful. I'm asking for your support by either buying my game when it's released (it will be cheap on the iPhone App Store), or helping me market my game in any way possible. You can either email me ideas or simply tell your friends about it (I'm mostly interested in how to gain wide exposure on the app store). Why should you support me? Well, you may want to support small businesses or indie game companies. Or, you may see that I really strive to give back to the game community. I really want more independant people developing games, and I want to make it easy to do so. I will frequently update my blog with useful information and release as many open-source libraries as possible. (I'm even considering releasing the source to my game when I'm done.) So far, I have written articles about writing apps for the iPhone in Scheme, debugging games interactively, tweening techniques, and more. I want to expound on these ideas. Although my focus is on Scheme, I hope to offer some cool ideas to the game development community that is good for anyone to think about. But I can only continue doing that if enough people buy my games, and I need help getting the word out!
  8. Posted from http://jlongster.com/blog/2010/01/29/tweening/ -- I want to share something I just finished implementing for my 3d graphics framework in Scheme which I am building my iPhone game off of. Keep in mind that I am not intentionally building a separate 3d graphics framework as a general platform, but I am building only what is needed to get my game out the door, so it is rough and the API is awkward and not well thought out. Given my custom scene objects which abstract away OpenGL rendering, I built a system for interpolating these objects' properties (such as scale and color) over time, or "tweening." This turned out to be incredibly useful. Here's the story. (Note: I'm not extremely confident I'm using the word "tween" correctly, but if not, I'm re-defining it.) What's the problem? The problem was that I needed a system for presenting the title screen, level titles, and a 2d overlay for my 3d iPhone game. These 2d elements should smoothly fade in and out of the screen over time. I don't need a full GUI toolkit, but I'm more interested in smooth animations when levels change, text appears, etc. This turned out to be a huge bear in my old system: because of the primitive nature of my Scheme graphics libraries, I had to manually do all the fading every frame for every object. Horrible. Establishing the Tween I started re-hauling parts of my system. It started small, only supporting alpha fading of 2d objects. However, as I worked on more and more, I realized all properties should be tweenable. So I set out to implement tweening for any object properties, such as position, rotation, scale, color, and anything else. And why not let 3d objects be tweened as well? No reason not to! It turns out that this is a good way to specify simplistic behaviors of objects. I'm sure anyone experienced in developing games is used to this. I've seen various forms of tweening in game frameworks, especially particle systems. I'm not sure if I've seen it expressed this way though. Is there a formal or established name for this, and any examples of how most engines do this? Once the system was in place, I implemented many types of tweens such as "linear," "quadratic", "cubic", and "bounce", each defining a different interpolation function based on time. More details about these types, including graphics of each function, can be seen in this documentation. Examples Here are some examples from my tweening system. I will show you code and a video of what it does. I will not go into details about the code because it isn't public yet, and it's really rough, but hopefully it will help expose what I'm trying to achieve. Types of Tweens Here I show you all the types of tweens my system currently supports. A quick list would include linear, quadratic, cubic, bouncing, and all the variations of applying them at the end or the start of the interpolation. (begin (define (tween-type type) (scene-list-clear!) (scene-list-add (make-tween (make-2d-object 2d-perspective position: (make-vec3d .1 (- .5 .025) 0.) scale: (make-vec3d .05 (/ .05 1.5) 1.) color: (make-vec4d 1. 1. 1. 1.)) position: (make-vec3d .65 (- .5 .025) 0.) color: (make-vec4d (+ (* (random-real) .5) .5) (+ (* (random-real) .5) .5) (+ (* (random-real) .5) .5) (+ (* (random-real) .5) .5)) scale: (make-vec3d .2 (/ .2 1.5) 1.) length: .7 type: type))) (tween-type 'linear)) Queued Tweens You can queue up tweens as well so that one fires off as another one ends. (begin (scene-list-clear!) (define tx (image-opengl-load "survived.png")) (let ((obj (make-2d-object 2d-ratio-perspective position: (make-vec3d (- .5 .025) .1 0.) scale: (make-vec3d .05 .05 1.) color: (make-vec4d 1. 1. 1. 1.) rotation: (make-vec4d 0. 0. 1. 0.) texture: tx ))) (scene-list-add (make-tween obj position: (make-vec3d (- .5 .025) .75 0.) scale: (make-vec3d .4 .4 1.) color: (make-vec4d 0. 1. 0. .5) rotation: (make-vec4d 0. 0. 1. 90.) type: 'ease-out-bounce length: 1.5 on-finished: (lambda () (scene-list-add (make-tween obj type: 'ease-inout-cubic position: (make-vec3d .8 .1 0.) scale: (make-vec3d .1 .1 1.) color: (make-vec4d 1. .5 0. 1.) length: 1.)) #f))))) 3d Tween There's no reason you can't apply tweens to a 3d object as well. (begin (scene-list-clear!) (let ((obj (make-mesh-object 3d-perspective mesh: sheep-mesh position: (make-vec3d 0. 0. 10.) rotation: (make-vec4d 0. 0. 1. 0.) scale: (make-vec3d 2. 2. 2.)))) (scene-list-add (make-tween obj scale: (make-vec3d 6. 6. 6.) rotation: (make-vec4d 0. 0. 1. 90.) length: 1. type: 'ease-out-cubic on-finished: (lambda () (thread-sleep! 1.) (scene-list-add (make-tween obj scale: (make-vec3d .7 .7 .7) type: 'ease-inout-cubic on-finished: (lambda () (scene-list-add (make-tween obj position: (make-vec3d 0. 5. 10.) type: 'ease-out-bounce on-finished: (lambda () (scene-list-add (make-tween obj type: 'ease-out-bounce position: (make-vec3d 0. -5. 10.))) #f))) #f))) #f))))) Improvements I'm still wrapping my head around how to implement a full motion system with this. As of now, if you specify a cubic tween between point (x, y) to (x1, y1), it will perform a cubic interpolation on both the x and y as a function of time. The result is that the object moves in a straight line from point A to point B, but the speed of the movement is cubic. For example, here's a cubic curve: Even though it is a curve, if I apply cubic interpolation to positions, which are 3-dimensional vectors with an x, y, and z property, the object moves between point A and point B in a straight line, with cubic-varying speed. If we tracked the movement, it would look like this: What if I wanted the object to curve when moving from point A to point B? Surely I can express that with interpolations? The problem lies in the fact that I've bound my interpolations of multi-dimensional vectors to be constant across each dimension. I would need to support different kinds of interpolations across each x, y, and z axis. This sounds really neat, and I will have to extend my system to support this later. Now that I think about it, I think the special case of interpolating movement should be handled with [splines](http://en.wikipedia.org/wiki/Spline_\(mathematics\)). In fact, it's probably downright inappropriate for me to interpolate position this way. Splines are on my todo list for research. Conclusion Having this simplistic tweening system will make it easy for me to apply smooth animations consistently across my iPhone game. It's feels a lot more polished when I use this to fade in items and slide them off the screen. I wouldn't really have thought of this unless I forced myself to build a real game. Building a game from scratch has forced me to learn all kinds of things, and I find this experience invaluable. I'm not building something simply because the idea of it sounds cool, but I *have* to build my framework with certain features so that my game will not only *run* but look good too. Having this dictate my development forces me to drastically alter my ideals quickly as I learn how games are laid out. Scheme is a huge support in this kind of simplistic agile development. Between its dynamic type system and functional simplicity, I can constantly re-shape huge parts of the system as if I'm a sculpter removing and adding huge chunks of clay. On top of that, The Lisp methodology of interactive/iterative development allows me to add details extremely quickly. The turn around time for feeling reward from intense coding sessions is *really* fast and extremely motivating!
  9. okonomiyaki

    Request for .max - .obj conversion

    This is definitely not an interesting post, but rather a request. Does anyone have 3ds Max that would be willing to convert a model from the .max format into something more standard? .obj would be the best, but .3ds is fine too. I have found a few good free 3d models online for my game, but they all come in .max format unfortunately. It's unfortunate that this is a proprietary format for something far beyond my budget. Here's the one I found: http://www.3dxtras.com/3dxtras-free-3d-models-details.asp?prodid=6912 I hope this kind of request isn't in bad taste. I am certainly not a modeler and that one looks great. Just PM me and I'll send you the model I downloaded if you're willing to help. Thanks! EDIT: Nevermind, I was able to get the trial version of 3ds Max and use it once.
  10. okonomiyaki

    On Spit and Polish, and Emacs Remote REPL

    Posted from http://jlongster.com/blog/2009/09/9/spit-and-polish-emacs-repl/: ------------------------------ On Spit and Polish, and Emacs Remote REPL September 09, 2009 Here I am, several weeks into a serious project, and what's happening? I'm getting distracted. Why is it so hard to finish projects? I think I know the answer to that question, but I don't like it. **I hate spit-and-polish work.** I love *low-level* work, even to the point of dealing with memory management and optimizing assembly code. It's the spit and polish, the sanding of the surface, everything that makes a product *look* and *feel* right that gets me. And I know why: not only is it menial work, I never anticipated it in the first place! Jeff Atwood recently discussed this difficulty using Stack Overflow as an example. It's easy to oversimplify software; actually, it's *really* easy to *super extremely* simplify software. I started coding games in Scheme over a month ago. I spend about 3 days a week on it. Now, that doesn't seem like much, but I fiercely believed that there *had* to be simple games I could make. My initial target would be the iPhone. Unfortunately, I'm not very interested in 2d, but there has to be at least one simple 3d game I can make, right? I'm well on my way to finishing that game. However, I just want to make it clear how badly I underestimated the amount of work it would take. I started out strong; I ported Gambit Scheme to the iPhone, and whipped up some helpful tools for it. But suddenly, weeks would go by seemingly without much progress. I thought about where my time was going, and realized all that's necessary for a complete game: I have to market myself, find/contract all of my art and models, write different levels for the game, make a menu screen, keep track of the score, write game instructions, make it look pretty, etc. Anyway, I am not frustrated. I have simply re-learned the same mantra I've learned so many other times: software is not simple. This all hit me when I stayed up all night trying to figure out how to add fur to one of my sheep models in Blender. I spent 5 hours, and all I came up with is this! Suddenly I realized that I am *not* a modeler and I can't afford to spend time doing this. If I'm not careful with how I'm spending my time, I'll end up 6 months down the road with nothing to show but a creepy sheep wearing a bear coat. So, how about some real content, you say? Here are a few things I've done recently. iPhone game Despite the tone of the opening paragraphs, I have successfully built most of my first iPhone app. It is completely written in Scheme, of course. I'm not going to disclose everything yet, but here's an early screenshot (without spit and polish, of course...): Remote REPL in Emacs I wrote a previous post about using a remote REPL for debugging/interacting with your apps. Many people have asked me if I have integrated it with Emacs yet, as that's the next logical step. Indeed I have. This is just a teaser, though. I'm not releasing my Emacs package because Marc Feeley (creator of Gambit Scheme) and I have talked and he wants me to finish his work on SLIME integration instead (also, it's rather buggy). I agree with him. Using Gambit Scheme under SLIME will give much more power, and we've already done a lot of the work. Please stay tuned for the release of it. Until then, here's the kind of stuff you can do with it: (click to view video) Montreal Speaking of Marc Feeley, I made a trip up to Montreal a couple weeks ago and visited the guys working on Gambit Scheme. I also went to the Scheme conference in Boston and met many other guys working on Scheme. It was a very inspirational trip. There are some *really* smart guys working on Scheme, and I hope to work closely with them over the next few years. Marc even invited me to present at MSLUG, which was a real honor! He videotaped the meeting and if I can get my hands on it maybe I'll post it here. I presented my recent work of using Gambit on the iPhone and discussed developing native apps in Gambit Scheme using Gambit's portable C compilation and the remote REPL. More importantly, we all went out for beer afterward. Many thanks also to Christian Jaeger who let me stay at his place. Snow Leopard and OpenCL I've been keeping an eye on OpenCL and I now have a chance to play with it! I just upgraded to Snow Leopard, so I have a system fully capable of running OpenCL. I'm really look forward to playing around with it. If you haven't already seen it, you should read Arstechnica's great review of the new OS, specifically the sections about Grand Central Dispatch and OpenCL. I'm thinking of testing matrix multiplications with OpenCL. It may be more optimal to manage a Scene Graph by pushing off all of its hierarchical matrix transformations off to the GPU. All of that depends on how much overhead there is transferring the data, of course. I can't wait to blog about my results! Until then, I'm going to sit down and enjoy a nice some good coffee.
  11. okonomiyaki

    Physics and 3d models in Scheme

    Posted from http://jlongster.com/blog/2009/08/3/iphone-physics-and-models/: ------------------------- Physics and 3d models in Scheme August 3, 2009 I finished two major parts of my Scheme 3d graphics framework this past week, and got it running on the iPhone: basic physics simulation and importing 3d models. * Disclaimer Apple's been getting some really terrible press about the iPhone App Store recently, from Google Voice being taken down to general crapness in their treatment of developers. I'm still confident that I'll be able to get my Scheme apps through the App Store, but please note that most of my work here is applicable for any Scheme game, whether it's on Windows, OS X, or whatever. I look forward to working on full PC games when I have enough resources. * Physics (Click here if you don't see the video above) In this video, you can see my current physics environment. I implemented velocity and acceleration, which lets me simulate gravity by applying a global acceleration downward of about 9.8 m/s. I proceed to toss balls up in the air randomly, and gravity takes care of the rest. I then use the procedure `kick` to kick around balls. It simply pushes all the objects in the scene by adding a velocity vector to each object, giving them instant acceleration in the specified direction. Lastly, I change gravity so the balls gravitate to other areas in the world. Pretty fun stuff. I'm able to develop interactively using the technique described in my previous post about using remote REPLs. * Models I wrote a OBJ file parser so that I can finally import 3d models. It wasn't really that hard, and I think I will just post it here. It's a work in progress, of course, and will be tracked in my git project in the `lib` directory. Honestly, I didn't do a whole of research before I wrote this, but first, it didn't seem like there was a simple OBJ loader written in C out there, and second, it's nice to have this native in Scheme anyway. It sure looks a lot prettier than this loader written in Objective-C. I also found this blog post, which suggests using a Blender script to output... C header files with embedded data? That's crazy! I can't imagine having to re-compile my program every time I changed a model. (define (read-map #!optional f) (unfold (lambda (x) eof-object?) (lambda (x) (if f (f x) x)) (lambda (x) (read)) (read))) (define (enforce-length name len lst) (if (eq? (length lst) len) lst (error name "assert-length failed"))) (define (obj-parse-vertex) (enforce-length "vertex" 3 (read-map exact->inexact))) (define (obj-parse-normal) (let ((v (vec3d-unit (apply make-vec3d (enforce-length "normal" 3 (read-map exact->inexact)))))) (list (vec3d-x v) (vec3d-y v) (vec3d-z v)))) (define (obj-parse-face) (enforce-length "face" 3 (read-map (lambda (n) (- n 1))))) (define (obj-parse-line obj line) (define (appendd lst lst2) (append (reverse lst) lst2)) (with-input-from-string line (lambda () (let ((type (read))) (case type ((v) (obj-vertices-set! obj (appendd (obj-parse-vertex) (obj-vertices obj)))) ((vn) (obj-normals-set! obj (appendd (obj-parse-normal) (obj-normals obj)))) ((f) (obj-indices-set! obj (appendd (obj-parse-face) (obj-indices obj))))))))) (define-type obj id: 9F8E77AF-49A7-4974-A071-C91616CD1DD0 constructor: really-make-obj num-vertices num-indices vertices normals indices) (define (make-obj) (really-make-obj #f #f '() '() '())) (define (obj-load file #!optional avoid-c-vectors?) (define (convert data) (list->vector (reverse data))) (define (make-c-vectors mesh) (if (not avoid-c-vectors?) (begin (obj-vertices-set! mesh (vector->GLfloat* (obj-vertices mesh))) (obj-normals-set! mesh (vector->GLfloat* (obj-normals mesh))) (obj-indices-set! mesh (vector->GLushort* (obj-indices mesh)))))) (with-input-from-file file (lambda () (let ((mesh (make-obj))) (let loop () (let ((line (read-line))) (if (not (eof-object? line)) (begin (obj-parse-line mesh line) (loop))))) (obj-num-vertices-set! mesh (length (obj-vertices mesh))) (obj-num-indices-set! mesh (length (obj-indices mesh))) (obj-vertices-set! mesh (convert (obj-vertices mesh))) (obj-normals-set! mesh (convert (obj-normals mesh))) (obj-indices-set! mesh (convert (obj-indices mesh))) (make-c-vectors mesh) mesh)))) Usage: (obj-load "mesh.obj") There are a few caveats to my loader: it doesn't index normals (assumes every vertex has a normal), requires triangulation (faces can only have 3 vertices), and doesn't support texture mapping yet. I will add texture mapping soon, but as to the other caveats, I'm not sure if I want to complicate my loader when I can simply tell Blender to export things properly. Maybe someday though. ** Optimizing Now, it's a bit slow to load a model with about 3000 vertices and 2000 indices. Why not use Gambit's nice serialization features to speed this up? Folks, *this* is why I use Scheme, and Gambit Scheme specifically. Gambit Scheme provides two interesting procedures: `object->u8vector` and `u8vector->object`. These procedures convert objects to byte vectors and back. Byte vectors can easily be written to files, too! So, by adding the following two procedures to our OBJ loader, we immediately support a very efficient binary model format. `compress` basically takes the constructed mesh, converts it to a `u8vector` and saves it out to disk. `decompress` does the opposite. (define (compress filename mesh) (with-output-to-file filename (lambda () (let* ((v (object->u8vector mesh)) (len (u8vector-length v)) (len-u8 (object->u8vector len)) (boot (u8vector-length len-u8))) (write-u8 boot) (write-subu8vector len-u8 0 boot) (write-subu8vector v 0 (u8vector-length v)))))) (define (decompress filename) (with-input-from-file filename (lambda () (let* ((boot (read-u8)) (len-u8 (make-u8vector boot))) (read-subu8vector len-u8 0 boot) (let* ((len (u8vector->object len-u8)) (v (make-u8vector len))) (read-subu8vector v 0 len) (u8vector->object v)))))) I created a quick script to compress meshes: ;;; saves it with the ".gso" extension (define (main filename) (compress (string-append filename ".gso") (obj-load filename #f #t))) I modified `obj-load` to take an extra parameter indicating if the file is compressed or not. So, lets see what we gained with this no-effort improvement: james% du -h logo.obj* 1020K logo.obj 800K logo.obj.gso (obj-load "logo.obj") => 1.05s (obj-load "logo.obj.gso" #t) => .215s We got a 32% compression and 5x load time speed increase!
  12. okonomiyaki

    New look and new future for jlongster

    Posted from http://jlongster.com/blog/2009/07/31/new-look-jlongster/: *** New look and new future for jlongster July 31, 2009 I spent some time redesigning this site this past week. The initial design was only temporary until I figured out how I was going to lay everything out. After putting up some content for a couple weeks, I think I have a feel for where I want to take this site. I fleshed out all of the projects in the software section so they now have individual pages. Of particular interest is the project page for the Scheme iPhone Example which will serve as a hub for all of my work on Scheme iPhone development. Please let people know about it! As you can see, this blog received a few improvements as well, mainly a better way of viewing previous posts. The future of this blog will be to track my progress as an independent game developer trying to make it in the vicious world of gaming. I am inexperienced in the gaming business, so this will be interesting. I feel that I have something new to bring to the table, and that is Scheme. I will be developing all of my games in Scheme. Currently, I am spending 2-3 days a week developing iPhone games in Scheme. I am not entirely sure my games won't be rejected by Apple (can anyone be sure?), but it's the only market I have a chance at success in. If I can build a few successful iPhone games, I will have the resources for spending more time on bigger products. I hope to build a competitive 3d engine in Scheme someday. As I said before, although I have been working with 3d graphics for a while, I am new to this business. Please let me know if you have any tips or want to help out in any way! P.S. I'm glad to see Haskell on the iPhone, but it's too bad that it takes 19 patches to GHC! Luckily, it's a good bit simpler to get Gambit Scheme running on the iPhone.
  13. Posted from http://jlongster.com/blog/2009/07/27/barcamp-presentation-scheme-and-using-it-iphone/. --------------------------------- Barcamp Presentation on Scheme on the iPhone July 27, 2009 I presented at the Chattanooga Barcamp this past weekend. In the former half, I introduced Scheme and attempted to explain why it's a good language for development. The latter half presents some cool practical examples, specifically showing what I've been working on with using Scheme on the iPhone. It was warmly received; thanks to all who came! I'm glad you enjoyed it. (looks like I can't embed it here) Writing iPhone apps in Scheme.
  14. Posted from http://jlongster.com/blog/: -------------------------------------------- Touch and accelerometer functionality available for Scheme on the iPhone July 20, 2009 I have finished the Gambit Scheme libraries for touch and accelerometer support. The green smudge was produced by my fingers, and the orange smudge was produced by tilting the phone. I've introduced a basic events system. To capture a an event, you define an event handler using DEFINE-EVENT-HANDLER. Currently, the only events implemented are "touches-began", "touches-moved", "touches-ended", "touched-cancelled", and "did-accelerate". The arguments of the event are the same as they would be in Objective-C. Here's an example, taken from the application shown above: (define-event-handler (touches-began touches event) (for-each (lambda (touch) (let ((loc (UITouch-location touch))) (add-point (car loc) (cdr loc)))) touches)) (define-event-handler (touches-moved touches event) (for-each (lambda (touch) (let ((loc (UITouch-location touch))) (add-point (car loc) (cdr loc)))) touches)) (define-event-handler (did-accelerate device accel) (define (shift n weight) (+ n (* weight 70))) (add-point (shift 150 (UIAcceleration-x accel)) (shift 100 (- (UIAcceleration-y accel))))) ** Download ** I'm still polishing up a few things in these FFIs, but they are ready to use. Soon, I will create a separate github project for Gambit Scheme FFIs. For now, they are included in my gambit scheme on the iphone example project. Specifically: lib/ffi/osx.scm lib/ffi/osx#.scm lib/ffi/iphone.scm lib/ffi/iphone#.scm lib/events.scm Don't forget to setup a few hooks in your Objective-C app, as seen here (accelerometer) and here (touch). You can view this iphone application included in my github project as well for example usage.
  15. Posted from http://jlongster.com/blog/2009/07/5/remotely-debugging-iphone-scheme/. ------------------------------------ Remotely debugging your iPhone Scheme apps with a REPL July 5, 2009 View the remote debugger source In an earlier blog post, I showed you how to develop on the iPhone with Gambit Scheme. Although that is cool, what about debugging? Haven't we just cut ourselves off from using either GDB (we aren't using Objective-C) or Gambit's debugger (we aren't running the program from a console)? A debugger is an essential tool, especially in dynamic languages like Scheme. It may not be as important in languages like Haskell because of type-checking, but even then you want to watch "data flow" as the program is running. I think we can say that using Scheme on the iPhone is impractical until we can use Gambit's debugger for our iPhone apps. Fortunately, Marc Feeley, implementer of Gambit Scheme, recently wrote a "proof of concept" remote debugger. It allows you to push REPLs from a running Gambit application (the client) to a different machine (the server). You guessed it. The client will be our iPhone application and the server will be our main computer, allowing us access to REPLs on our computer which are running inside the iPhone application. I think this is best explained in the screencast below. First, let me explain the philosophy of the remote debugger a little more. Marc wrote the remote debugger in response to someone asking about debugging multiple Gambit Scheme threads at once on the Gambit mailing list (view original message). With the remote debugger, you can tell Gambit to create a remote REPL for errors on each thread. So if two threads errored, two separate debugging REPLs would open up on the server. Now we have facilities for debugging Scheme iPhone apps remotely. We can run Scheme apps on either the iPhone Simulator or the iPhone itself, and when an errors occurs we get a real Gambit REPL on our computer for debugging the problem. What's even cooler is that we have everything we need for running a full Scheme REPL to *interact with our iPhone app real-time*! Check it out in the screencast below. Please note that this library is still "proof of concept," and there are more things to figure out and bugs to fix. I am not publishing it standalone yet, but you can find it included in the gambit iPhone example program on github or in Marc's reply. You can also see how I integrated the debugger library in the example iPhone app here. A couple lines further down and you can see how I fire up a main REPL. (I apologize for all the static. It was raining and I didn't realize it would pick it up.) Next up is support for touch events and access to the accelerometer! View the remote debugger source
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!