8 ms·
Quake 3 engine in Rust
- gpcz 14y agoIt looks like pretty good progress! Are you going to be implementing the Quake Virtual Machine (QVM) architecture so that your engine can run the Quake 3 game and its mods?
- Jeaye 14y agoThe goal is to create a Quake 3 like game, but with a destructible voxelized world (Ace of Spades doesn't do it for me). As you can see, and as others have commented, this is currently only a rough BSP renderer with almost-complete TTF rendering. Q3 is the inspiration, but my goal is for this is to be a different game.
- chipsy 14y agoIf your goal is a voxelized world, what's your reasoning for starting with the Q3 BSP strategy, and not something more like Voxlap?
- Jeaye 14y agoI went with BSP loading first because I'd like to voxelize arbitrary Q3 maps. It's planned to be a feature of the game to be able to load in any Q3 or QL map and be able to destroy it.
- Jayschwa 14y agoAny tips for rendering text? I'm doing a similar project for Quake 2 with Julia[1]. I haven't tackled text yet, but I probably will need to soon. [1]: https://github.com/jayschwa/Quake2.jl https://github.com/jayschwa/Quake2.jl
- Jeaye 14y agoMy TTF rendering code is based off the examples provided here: http://en.wikibooks.org/wiki/OpenGL_Programming http://en.wikibooks.org/wiki/OpenGL_Programming
- georgemcbay 14y agoI highly recommend looking at signed distance maps for text rendering. Relatively easy to implement and gives very good results even when drastically scaling the text to different sizes. Potentially useful links: http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_... http://www.gamedev.net/topic/491938-signed-distance-bitmap-font-tool/ http://www.gamedev.net/topic/491938-signed-distance-bitmap-f... https://github.com/OpenGLInsights/OpenGLInsightsCode/tree/master/Chapter%2012%202D%20Shape%20Rendering%20by%20Distance%20Fields/demo https://github.com/OpenGLInsights/OpenGLInsightsCode/tree/ma...
- Noelkd 14y agoI will be keeping an eye on this for sure now.
- devinus 14y agoThis is very cool, but I wonder why people are already inventing different indentation styles for Rust already. Guys, we have the canonical way all Rust code should look from the Rust compiler itself. Let's not all start using disparate styles just because we can like C/C++.
- pointyhatuk 14y agoGood point. Need a rustfmt like gofmt in go.
- gloob 14y agoI, too, feel that perfectly uniform brace positioning is one of the critical technical challenges facing any new language today. There is no longer any excuse to get such an important and fundamental advance wrong.
- jlgreco 14y agoSarcasm? It may not be a "critical technical challenge" but if you are writing a new language there is really no excuse to not cement things like that down before it is too late.
- kybernetyk 14y agoWhy do you want to force people to use your style? That's pretty much against the hacker mindset.
- sophacles 14y agoWhy do you want to force people to whatever style you want to read in? There is a strong case for having one style: namely that now it becomes easy to understand aspects of a program at a glance (e.g. structure of flow, where you can gloss over for now, and where you have complexity) and also helps identify errors and on right away. Sometimes it's imperfect, but consistency is more important than "looks pretty". Besides, if we're talking about the hacker mindset: 1) there are other languages 2) you can do amazingly complex and deep things with your brain, but you can't adapt to a style? 3) consistency and correctness is more important than "what I whimsically decide is neat looking today, no matter how many errors it is hiding".
- kayoone 14y agoThis is more like a renderer for the BSP map format. Still awesome stuff though, interesting to see how it progresses
- kibwen 14y agoAh, thanks. From the title I thought that someone had single-handedly re-implemented all of Quake 3 in Rust, which seemed a bit implausible.
- onedognight 14y agoDoes anyone know if type parameters in Rust can be integers so that you could write vec<3> and get an optimized unrolled implementation of three dimensional vectors without having to hard-code as in vec2, vec3 and vec4, etc? [1] http://static.rust-lang.org/doc/rust.html#type-parameters http://static.rust-lang.org/doc/rust.html#type-parameters [2] https://github.com/Jeaye/q3/blob/master/src/math/vec2.rs https://github.com/Jeaye/q3/blob/master/src/math/vec2.rs [3] https://github.com/Jeaye/q3/blob/master/src/math/vec3.rs https://github.com/Jeaye/q3/blob/master/src/math/vec3.rs [4] https://github.com/Jeaye/q3/blob/master/src/math/vec4.rs https://github.com/Jeaye/q3/blob/master/src/math/vec4.rs
- erickt 14y agoThere is not support for this at the moment, but one of core developers mentions one approach for starting to address this need in: http://smallcultfollowing.com/babysteps/blog/2013/04/02/associated-items/ http://smallcultfollowing.com/babysteps/blog/2013/04/02/asso...
- AaronFriel 14y agoWhat you're actually asking for is dependent types, where instead of passing in a type argument you're passing in a value you're asking to have lifted to the type system. C++ implements this in their templates because templates are rather more dumb than what a "proper" type system would do, because templates are essentially what C++ uses as a powerful macro system. A "Vec<3>" in C++ then is instantiated as a separate class/struct. A "Vector<Int>", if allowed to do it is separately compiled from a "Vector<Double>"[1] and this is what has given templates an uncanny power in C++ as a method of doing very powerful transformations of code, as used by libraries like Eigen to unroll very complex multiple-pass algorithms into a single fast loop. Very neat stuff. I would be a little surprised, actually, to see Rust implement the same feature because the way C++ has done it is by a rather curious and roundabout[2] and it was just happenstance that made it one the first widely used implementations of dependent types. It's strange to think about, but templates are one way C++'s type system is more expressive than Haskell's. (Wow, that felt strange to write.) The associated constant idea is kind of neat, but the implementation of associated constants wildly differs from associated functions[3] and I find it difficult to imagine the way they operate having anything, anything at all to do with one another. If they do implement their associated constants proposal, it'd definitely be something worth following from a type systems perspective because, well, dependent types are one of those things that are curiously difficult to implement, and if they implement it as part of a general type system, it could even be undecidable[4]. [1] This may not be the case now, but it certainly was the case in the past. So this statement is only true to the extent of "very simple C++ compilers" and may not be true of more optimized compilation strategies. I'm not sure what the state of the art is here. [2] And theoretically unsound, in that the macro/template language is be Turing complete. That's not really very desirable from the perspective of being able to share code or doing "compiler as a service" execution where someone could upload infinite loops or non-terminating templated types. http://ubietylab.net/ubigraph/content/Papers/pdf/CppTuring.pdf http://ubietylab.net/ubigraph/content/Papers/pdf/CppTuring.p... [3] In C#, they're called Extension Methods, and they're an instance of the compiler simply being smart enough to find functions that say they can work just like a method of a type, but only depend on an already public API. Extension methods are great because they let you turn regular C# generic types into Monads by adding implementations for Select, SelectMany, and so on and so forth. http://ericlippert.com/category/monads/ http://ericlippert.com/category/monads/ [4] Apologies for the link to wikipedia, but it's the most terse source on it that I can find. It should be noted that just because it's undecidable in some systems doesn't mean it's undecidable in all systems. Let us not make here the mistake of applying Gödel's Incompleteness Theorem to the reals. http://en.wikipedia.org/wiki/Type_system#Dependent_types http://en.wikipedia.org/wiki/Type_system#Dependent_types
- Arjuna 14y agoIf you are interested in reading further about BSP (Binary Space Partitioning) [1], check out the following chapters from Michael Abrash's Graphics Programming Black Book: Chapter 59: The Idea of BSP Trees http://downloads.gamedev.net/pdf/gpbb/gpbb59.pdf http://downloads.gamedev.net/pdf/gpbb/gpbb59.pdf Chapter 60: Compiling BSP Trees http://downloads.gamedev.net/pdf/gpbb/gpbb60.pdf http://downloads.gamedev.net/pdf/gpbb/gpbb60.pdf Chapter 62: One Story, Two Rules, and a BSP Renderer http://downloads.gamedev.net/pdf/gpbb/gpbb62.pdf http://downloads.gamedev.net/pdf/gpbb/gpbb62.pdf [1] https://en.wikipedia.org/wiki/Binary_space_partitioning https://en.wikipedia.org/wiki/Binary_space_partitioning
- deleted 14y ago[deleted]
- mikevm 14y agoBy the way, you can download Michael Abrash's Graphics Programming Black Book from here (it's out of print now): http://orangetide.com/graphics_programming_black_book/ http://orangetide.com/graphics_programming_black_book/
- binarycrusader 14y agoThere's also his Ramblings in Realtime here: http://www.bluesnews.com/abrash/ http://www.bluesnews.com/abrash/ And gamedev.net also has the book here: http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/graphics-programming-black-book-r1698 http://www.gamedev.net/page/resources/_/technical/graphics-p...
- zerr 14y agoCan someone comment whether if Abrash's Graphics Programming Black Book is still actual today? There are some reviews on amazon, from 1999/2000 mentioning that it is outdated. I guess some percentage could be still actual, of course. So I'm interested what percentage it is.
- aardvark179 14y agoSome parts are still worth reading, but a lot of it is dealing with rendering without any real acceleration. Some of the low level parts on optimisation may still be worth reading, as are the BSP chapters, but you should read more modern books on optimising code, and on spatial indexing schemes of various types as well. For the pure rendering side I'd say Real-Time Rendering (third edition) gives a good overview of techniques, but you'll want to look elsewhere if you want to see how those algorithms can be really optimised for a given API and GPU.
- Maro 14y agoWhy is this interesting?
- sophacles 14y agoWhy is this comment necessary? You don't have to read code or links if you don't want to. This is even worse than the "how is this topic relevant to hacker news" style comment. I found it interesting because it is a nice example of real, non-toy, code in rust. I presume others find it interesting because it is a good progress mark of rust.
- perishabledave 14y agoThe comment could be out of a genuine desire to understand what makes the code interesting. The brevity makes it a bit ambiguous.
- coldtea 14y agoNo, the comment seems like the author being a jackass. A genuine desire to understand would have used different questions altogether.
- zerr 14y agoIt is actually a pretty neutral and dry comment, which is not necessary a "jackassness". Also, this is not a one-to-one conversation, other people read these threads as well. So some of them, which are genuinely interested, could benefit from detailed answers.
- coldtea 14y ago>It is actually a pretty neutral and dry comment, which is not necessary a "jackassness". Not really convinced. Even something like "In what ways is this interesting? Can you explain?" would be way more neutral than the current one. If he was perplexed by something on the article he would ask more specific questions. As it stands, it's identical to tons of other dismissive comments that follow every announcement. It wants to imply the author is "too technical" for this, e.g "hmm, a yet another 3D engine just done on some new language this time? who cares" or "why is this on top of HN".
- georgemcbay 14y agoThis is a great bit of nostalgia, not just for Quake 3 but because quite a while back (2000-2001-ish) I wrote a Q3 BSP format renderer for the Nebula Device open source engine, written in C++. Sadly the code seems to be somewhat lost at this point. I don't have a local copy of it and some cursory searches for it aren't finding much, I suspect it exists in some now-obsolete branch of an SVN repo on SourceForge, but don't care enough to really go looking. Surprisingly there is still a tripod page with screenshots: http://gmcbay.tripod.com/ http://gmcbay.tripod.com/ Anyway, great work so far! I am curious why you're doing BSP rendering if your goal is to have a destructible/voxelized-style world, since the two things are on opposite ends of the spectrum of mutability.
- Jeaye 14y agoThanks! I went with BSP loading first because I'd like to voxelize arbitrary Q3 maps. It's planned to be a feature of the game to be able to load in any Q3 or QL map and be able to destroy it.
- BruceM 14y agoI miss the Nebula Device. Nebula3 was really shaping up into something great.
- georgemcbay 14y agoBruce Mitchener, I presume? I remember you from the days of hacking on Nebula! I wasn't around by the time Nebula 3 came to pass, I actually didn't realize there was a Nebula 3 until I did a google search to see if I could find any of my old nebula code.
- Ygg2 14y agoSo from what I gather this is basically a wrapper around some libraries that renders a quake map, I've been browsing through and found very little code, which seems implausible for a game of such complexity. EDIT: was there something wrong with what I wrote? This seems very simple for Quake 3 engine (based on my knowledge of 3D code and skimming the documentation). I've seen code is calling a lot into glfw and opengles libraries.
- ZoFreX 14y agoYou are correct that it is very simple for a Quake 3 engine - the submission's title is misleading. Calling it "basically a wrapper around some libraries" is a bit harsh though. It's not like it's loading up libloadandrenderaquake3map.so! From a quick glance at the code it implements opening a .bsp file, representing it in memory, and rendering it with direct OpenGL calls. This is pretty close to the metal, so to speak.
- 38leinad 14y agonot 100% on topic, but as the author is doing his mod because he likes to have a voxelized and fully destrutable word: I remember Red Faction. Is there any in-depth review/interview on the technology they used at the time? Looked like "simply" carving out destructed structures from a polygon model; But would be interested in the details...
- primitur 14y agoWas anyone able to build this? I got rustc 0.6 built and installed on my amd64 linux machine, but seems that this q3 codebase triggers some bug in the compiler ..