• What are you working on? February 2012
    3,497 replies, posted
  • I just hit f6 to "rebuild" the popular threads page... too much programming. Also haven't posted anything in a while from RTS but I've made a lot of progress. Harvesting resources, basic flocking (ugly), MUCH faster pathfinding, construction, stockpiles, and a lot more. [IMG]http://i.imgur.com/A7kZy.gif[/IMG]
  • Success! I recursively checked the reflected rays for anyone interested. Tomorrow my plan is to fix the problem whereby the rays length is not restricted when hitting a mirror, then if all goes well i'll try my hand at refraction. All the math here is home-brewed, which i'm really proud of considering GCSE math teaches us fuck all about anything interesting! [media]http://www.youtube.com/watch?v=0MZTtHUtm20[/media] Also, making u3ber 1337 disco's is really fun but the colour code needs fixing...
  • Redesigning lolnotes. So much information, so little space. Compacting the players a little bit. Removing the tabs for the different queues. Instead I will just have it display the current queue stats with the ability to switch to the others. I think I will change it to only display 5 recent games at a time. That way I can display more data like gpm. [t]http://img194.imageshack.us/img194/4396/wggesezxidqjg.png[/t]
  • [QUOTE=Dotmister;34851854]You can't say you know a language just because you read a book[/QUOTE] I know the language because I read a lot that book. I dedicated myself on C this time while I was reading the book. Now I am able to learn C + +because it is a derivative of C. See ya :)
  • [QUOTE=AntonioR;34852371]I was first in my region in both Geography and German language, but they still didn't let me to go to the "country wide" competition. It was blasphemy ! It was madness ![/QUOTE] Which region?
  • [QUOTE=NotMeh;34852660]I think you should read an English language book first.[/QUOTE] That's not fair, English isn't his first language iirc. At least he's trying!
  • Oh and, free source [url]http://dl.dropbox.com/u/33076954/3d.rar[/url] It's a bit of a mess, but just follow through the engine function to understand whats going on. Uses boost::thread for multithreading, dll is included There is a lot of commented out code, and old useless code in there. I suggest ignoring it, but its in there so i can go back and steal it in the future, or see how i did something in the past For a quick rundown on how it works (ill take it through one frame) Parse object initially reads and loads an object from an object (.obj) file. Doesn't support any sort of texturing, faces have to be triangles, doesn't touch the .mtl files. The obj (wavefront?) file format is pretty simply, but the corresponding function to load all my the shit i've written is abysmal. Truely, truely abysmal. Gets the job done though, but it makes me cringe looking at how terrible it is Theres some basic input handing here. Pretty reasonable stuff, except future plans is to shove it all into the engine class to simplify starting the whole thing going. Oh, and moving the camera q and e-wards does nothing, not sure why. Ill have to check the view calculations again at some point v3d (vector 3d) light is the light position, then we set the ambience and the light (the engine ONLY supports one light currently. Ill make a light class later and array them up, but for the moment this is fine) Then we get to draw objects. If you want to saunter across to Engine.cpp (capitalised for extra fun), then go about halfway down to find draw_objects. You'll notice that the depthsort flag does nothing - its currently a relic from when i used depthsorting rather than the current method (which is a mix of per pixel checks, and checking several points on a triangle against the current depth buffer). The latter of that bracket is extremely imperfect, but speeds up rendering somewhat at no visual cost. The former works. The swap was made because after moving to multithreading, the draw order of triangles was no longer guaranteed. You can probably hunt down an attempted multithreading fix involving mutexes and a variable in the code, but its much too embarrassing to actually point you there So now the current system works independently of when you draw a triangle. By the way, viewer.z is the FOV. So yes, if you look a the olist iterator, it strolls through each object and on its way starts up 4, hardcoded (oh no the evil, but doing it properly would waste much time) threads to process a 1/4 of the vertices/triangles/faces from the object each So move up a bit nearer the top of the file, until we get to add_objects. tb is the triangle to begin at, and te is the triangle to end at, and T is obviously the object we are parsing. After some wonderful view calculations on all of the vertices, where you can see the old gouraud cosine-lambert what have you lighting vertex thing all /* */'d out. The vertexes get shoved into a triangle for no proper reason, then after all 3 vertex are put into a triangle, they get added to a separate triangle (i should stop it doing that. Why is it doing that? i should just pass n to shape_handler). Anyway. You'll see shape handler down below, and some failed multithreading attempts. Technically they succeeded, but it turns out that for some, strange reason, spawning thousands of threads per second is actually surprisingly slow! :v: Shape handler pretty much instantly goes to triangle_shape::compile, so make your way over to triangle_shape.cpp and scroll about halfway down. This function is a bit of a mess because its edited reasonably often, but not as bad as triangle_fill_d essentially it checks if any of the vertices are off screen (could probably do it better with a min/max, but this works for now), checks to see if all of the corners, the center, and the points between the center and the corners are all blocked from view. If they are, dont bother with the triangle because it's completely occluded (most likely) Oh, and perpixel is completely obsolete as well, because it does per pixel checks anyway, and just returns if a triangle is off the screen. The if(quit) return is completely useless as well, but i havent gotten around to removing it yet. There it goes. Triangle_fill_d is where all the exciting things happen. Its in common.cpp, about 1/3rd of the way down. Probably doesn't deserve to be in common, but for the moment it'll live. It gets passed 3 vertex positions, perpixel (obsolete), screenwidth and screenheight (both obsolete and 0). This function has been rewritten so often that its a complete and utter mess. So it starts off, finds the minimum/maximum points of the triangle (hooray for squares), then finds the area. Fairly standard. t1 is H, which is the half vector something something something lighting. Google it if you find it that exciting. Ideally, i only need to calculate it once per frame. Thats going to get integrated into my lighting class though, so for the moment s'alright being calculated once per drawn triangle The form function calculates the area given three points and.. something which i forget. I have no idea. All i know is, its a terribly, terribly written function, and takes up a lot of processing time. I should write it into the code and simplify the whole thing a bit, but see above with regards to it not being the most important thing So a pixel is determined to be in the triangle when it is roughly (floating point hooray) equal to the area determined at the beginning of the function, helpfully named area. Half, if you look at the comments, was originally an attempt to create fuzzy triangles (and thus edge smoothing), but i gave up on that after i realised it was a lot of hassle. Scrolling down a bit further, past some more random commented out code, youll find the meat of the interpolation code for normal positions, and depth. I have no idea how that works, i pulled an equation off the internet then used a simultaneous equation matrix solver (or something) to sort it all out for me. Gives me the smoothed values i want, but if anyone knows of a better solution i'd love to know it. This is the actual Phong interpolation in phong shading, by the way Scrolling a bit further downwards, you'll see the various shading methods that can be implemented by messing around with the comments. The comments are just there to remove code, not to remove it in an orderly fashion, so youll have to think for about 5 seconds if you want to enable the one embedded in the middle of cook-torrence (//'d out). The one currently in operation there is beckmann. I picked that one because why not, looks nicer than phong, runs better (much) than torrence-cook add the ambient light to the diffuse light, to the specular light, you get light. Seeing as everyhting is white for the moment, i just multiplied that by 255 and slapped that straight onto the colour/depth buffer (after a depth check). Moving back into Engine.cpp, and Engine::draw_objects, scrolling past the vast amount of commented out, poorly multithreaded and generally inefficient code, youll see the variable clear actually does something and cleares and draws the screen if true (otherwise just draw the screen). The draw fill here is a memory bandwidth limited operation, and there didn't seem any benefit in multithreading it much, so it runs in 2 threads for fun Anyway. After that, SFML takes over and draws everything from the colour buffer to the screen. And then after that, the buffer is flipped (somewhere else) Hooray. Long post, hope i bored you to death and you didn't learn anything about how to program well, efficiently, and above all, in a fashion that doesn't look atrocious
  • [QUOTE=NotMeh;34852660]I think you should read an English language book first.[/QUOTE] Just waiting my classes back. English classes are waiting for me. XD
  • [QUOTE=supersnail11;34851945]More like C# [editline]Fake Automerge[/editline] High, C# is literally Microsoft's version of Java.[/QUOTE] What?
  • [QUOTE=Darwin226;34852663]Which region?[/QUOTE] Splitsko-dalmatinska županija.
  • oh god i can't believe actually just wrote this [code] $rating = $ratingArr['rating']; if ($rating == '1') $oneStar += 1; else if ($rating == '2') $twoStar += 1; else if ($rating == '3') $threeStar += 1; else if ($rating == '4') $fourStar += 1; else if ($rating == '5') $fiveStar += 1; [/code]
  • [QUOTE=icantread49;34852810]oh god i can't believe actually just wrote this [code] $rating = $ratingArr['rating']; if ($rating == '1') $oneStar += 1; else if ($rating == '2') $twoStar += 1; else if ($rating == '3') $threeStar += 1; else if ($rating == '4') $fourStar += 1; else if ($rating == '5') $fiveStar += 1; [/code][/QUOTE] I generally find switch statements to be unwieldy, and offer no real performance gain for a small number of possibilities. An else if chain can work perfectly well, especially when the most likely possibility is the first one checked. Of course, when you're dealing with a larger set of possibilities, it makes more sense to use switch.
  • [QUOTE=WTF Nuke;34852801]What?[/QUOTE] The syntaxes and features are very similar. For instance, compare a hello world in C#: [csharp]using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine("Hello, world!"); Console.ReadLine(); } } }[/csharp] to one in Java [csharp] public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } } [/csharp] [quote=Wikipedia] James Gosling, who created the Java programming language in 1994, and Bill Joy, a co-founder of Sun Microsystems, the originator of Java, called C# an "imitation" of Java; Gosling further claimed that "[C# is] sort of Java with reliability, productivity and security deleted."[2][16] Klaus Kreft and Angelika Langer (authors of a C++ streams book) stated in a blog post that "Java and C# are almost identical programming languages. Boring repetition that lacks innovation," [/quote] [url]http://en.wikipedia.org/wiki/C_Sharp_(programming_language)#History[/url] [url]http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java[/url]
  • Not sure if good or bad... :pwn: The value went up really fast, then overflowed (what i assume) :v: [img]http://puu.sh/iefo[/img]
  • [QUOTE=icantread49;34852810]oh god i can't believe actually just wrote this [code] $rating = $ratingArr['rating']; if ($rating == '1') $oneStar += 1; else if ($rating == '2') $twoStar += 1; else if ($rating == '3') $threeStar += 1; else if ($rating == '4') $fourStar += 1; else if ($rating == '5') $fiveStar += 1; [/code][/QUOTE] i'd believe it
  • [QUOTE=Smashmaster;34852903]I generally find switch statements to be unwieldy, and offer no real performance gain for a small number of possibilities. An else if chain can work perfectly well, especially when the most likely possibility is the first one checked. Of course, when you're dealing with a larger set of possibilities, it makes more sense to use switch.[/QUOTE] point is, i can just use $rating as an index into an array
  • Shift click lets you build the same building type consecutively without having to go through the menu again (not shown), and stockpile types! [IMG]http://i.imgur.com/FEUtY.gif[/IMG]
  • So I've had an Android phone for over a year, and while learning Java I tried to touch on Android development many times and faltered. Now that I feel I'm comfortable with Java, I'm going head-first into Android starting at the top, and I'm already loving it. I forgot the thrill of learning something completely new and challenging, and learning how this OS works is actually kind of exciting. I expect to have regular progress to show :)
  • [QUOTE=Cesar Augusto;34851748]A programmer can not dedicate only in one programming language[/QUOTE] I can what not to good loo.
  • [QUOTE=icantread49;34852810]oh god i can't believe actually just wrote this [code] $rating = $ratingArr['rating']; if ($rating == '1') $oneStar += 1; else if ($rating == '2') $twoStar += 1; else if ($rating == '3') $threeStar += 1; else if ($rating == '4') $fourStar += 1; else if ($rating == '5') $fiveStar += 1; [/code][/QUOTE] wouldn't $star[$rating] += 1 or something have worked
  • yeah, I'm all for occasionally picking on null but this is something he admitted himself. :v:
  • [QUOTE=geel9;34854586]Null himself pointed that out.[/QUOTE] It almost seems as if he was a nullpointer
  • [QUOTE=Cesar Augusto;34852626]I know the language because I read a lot that book. I dedicated myself on C this time while I was reading the book. Now I am able to learn C + +because it is a derivative of C. See ya :)[/QUOTE] You can start directly from C++. Learning C before attempting to C++ is waste of time. If you really want to know behind the scenes learn assembly,binary etc.
  • [QUOTE=supersnail11;34853064]The syntaxes and features are very similar. For instance, compare a hello world in C#: [csharp]using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine("Hello, world!"); Console.ReadLine(); } } }[/csharp] to one in Java [csharp] public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } } [/csharp] [url]http://en.wikipedia.org/wiki/C_Sharp_(programming_language)#History[/url] [url]http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java[/url][/QUOTE] Oh no, I agree about that but I don't get why you said more like C# because it's java and not C#, unless you where trying to point out their similarities then ok.
  • [QUOTE=LuaGuy;34854688]You can start directly from C++. Learning C before attempting to C++ is waste of time. If you really want to know behind the scenes learn assembly,binary etc.[/QUOTE] It's not a waste of time. You need to know a lot of how C works to understand what C++ does, since it's built on C. On the other hand, you can learn a VM language like Java or C# without learning anything else.