• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=dmillerw;41618402]Fuck, my head hurts. Say I have one point in 3D space, and I know the angles (in degrees) in which it's facing. Given a random distance, how can I find the 2nd point at the end of that distance, keeping all those angles in mind.[/QUOTE] Not sure if exactly this will work on 3D, but in my (2D) game what I usually do is: beginning_point = Vector(x, y) mystery_point = beginning_point + Vector(math.cos(angle), math.sin(angle)):normalized()*distance where normalized() returns the normalized Vector (divide each component by its length (which is sqrt(x*x + y*y))).
[QUOTE=Rayjingstorm;41629223]I like the idea of keeping a desired state and letting a coordinator keep track of interactions between objects, and I agree that using objects without any behavior is counter-intuitive, so how about something like this: A Player knows whether it is in play (can move) and keeps track of a direction (where to move next, if it can) and a list of its positions (just as {x,y} coordinate pairs in a world it is not actually aware of). Then, the coordinator has a list of players. The coordinator, each update tick, checks for collisions; if a player is colliding with another its playing flag is set to false to let it know it can't move any more. The coordinator then tells every player to update and those that can do and those that can't stay still. This repeats until the coordinator determines someone has won (all other players are not playing), displays the winner and asks to start a new game.[/QUOTE] Sounds good. You didn't specify the list of positions, I'm assuming that's for the trails? You only need to add to that list when you change directions. You could store the trails outside the bike, but for such a small detail it won't matter much; I'm not even sure what the trade-offs are. In a more complex environment you could want to attach trails to different things though.
So I'm working with OpenGL and rendering randomly generated terrain meshes. I'm having trouble rendering more than about 100x100 with high FPS. My question is what would be an efficient way of drawing the triangles? I'm currently using a double loop to go through my stored points and I believe this is why it's so slow.
[QUOTE=ZeekyHBomb;41629410]Sounds good. You didn't specify the list of positions, I'm assuming that's for the trails? You only need to add to that list when you change directions. You could store the trails outside the bike, but for such a small detail it won't matter much; I'm not even sure what the trade-offs are. In a more complex environment you could want to attach trails to different things though.[/QUOTE] Oh I see what you mean now, the player is just a bike that makes turns and moves, and the trails can either be separate or an artifact of never removing the player nodes from the map. That would simplify things even further. The reason I was thinking in those terms is that I am probably going to incorporate elements of Worm (where the player only lengthens when it picks up an item) so the player is not just a bike, but an entire work with a body. For this version I think I'll just stick with the direction though, thank you!
[QUOTE=Pangogie;41629902]So I'm working with OpenGL and rendering randomly generated terrain meshes. I'm having trouble rendering more than about 100x100 with high FPS. My question is what would be an efficient way of drawing the triangles? I'm currently using a double loop to go through my stored points and I believe this is why it's so slow.[/QUOTE] I'm assuming by looping, you mean that you're using immediate mode OpenGL (glBegin, glEnd, etc). The first step is to stop using immediate mode. The second step is to [url=http://open.gl/]start[/url] [url=http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Chapter-1:-The-Graphics-Pipeline.html]learning[/url] [url=http://www.arcsynthesis.org/gltut/]modern[/url] [url=http://www.opengl-tutorial.org/]OpenGL[/url] After that you should be able to handle ~1024x1024 heightmaps without a problem. Beyond that, you can look into level of detail algorithms and do frustum culling. I've implemented this in my game that's based on procedurally-generated terrain: [url]http://dice.se/publications/terrain-rendering-in-frostbite-using-procedural-shader-splatting/[/url] [editline]28th July 2013[/editline] (slides 38-40, not the whole thing)
Finishing up a program in Java, getting a file IO error. The File "vta" is being retrieved from a JFileChooser. Here is the immediately relevant code: [code] File new_flex = new File(vta.getParent() + "\\shifted\\" + vta.getName()); System.out.println("New file: " + new_flex.getPath()); if (!new_flex.exists()) { new_flex.mkdirs(); new_flex.createNewFile(); }[/code] The "new_flex.CreateNewFile();" line is generating this error: [code]java.io.IOException: The system cannot find the path specified[/code] I have some debug that prints vta's getPath(), getAbsolutePath(), and getParent(). That debug, as well as the new filename, is as such: [code]D:\_FlexShifter\jaw_drop.vta D:\_FlexShifter\jaw_drop.vta D:\_FlexShifter New file: D:\_FlexShifter\shifted\jaw_drop.vta[/code] When I hard-coded the paths to be relative to where Eclipse is installed, it worked fine. Eclipse is installed on my D:/. I have tried with these files in both C:\ and D:\. The "shifted" folder does not exist and has to be created. It is not being created. The file that "vta" references does exist, and exists in the location that it is returning. "new_file"'s getPath() and getAbsolutePath() both return the same path. Anyone have any ideas? This is literally the last thing I have to get working for this program to be release-ready.
[QUOTE=robmaister12;41630127]I'm assuming by looping, you mean that you're using immediate mode OpenGL (glBegin, glEnd, etc). The first step is to stop using immediate mode. The second step is to [url=http://open.gl/]start[/url] [url=http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Chapter-1:-The-Graphics-Pipeline.html]learning[/url] [url=http://www.arcsynthesis.org/gltut/]modern[/url] [url=http://www.opengl-tutorial.org/]OpenGL[/url] After that you should be able to handle ~1024x1024 heightmaps without a problem. Beyond that, you can look into level of detail algorithms and do frustum culling. I've implemented this in my game that's based on procedurally-generated terrain: [url]http://dice.se/publications/terrain-rendering-in-frostbite-using-procedural-shader-splatting/[/url] [editline]28th July 2013[/editline] (slides 38-40, not the whole thing)[/QUOTE] Ugh, that's what I was afraid of. Oh well, I need to learn OpenGL a bit better before I continue my project anyway. To the tutorials! :eng101:
[QUOTE=Pangogie;41631564]Ugh, that's what I was afraid of. Oh well, I need to learn OpenGL a bit better before I continue my project anyway. To the tutorials! :eng101:[/QUOTE] Yeah, there's a fairly steep learning curve with modern OpenGL, but once you get it, it's smooth sailing from there (except for how annoying it is to debug, that will stick with you the whole way)
[QUOTE=dvondrake;41633752]Almost done... I have a string that looks like this... [code]files: 50 / 200 ( 25.00% )[/code] Is there an easy way to extract all the useful information from that into separate variables? One each for the current file number, the total, and percent? Using C++, but I'm sure whatever logic from another language can be adapted.[/QUOTE] Maybe [url]http://www.cplusplus.com/reference/cstdio/sscanf/[/url] --- What about regular expressions? [code](\d+).+?(\d+).+?([\d\.]+)[/code] [IMG]http://i.imgur.com/pqk6npn.png[/IMG] [b]Edited:[/b] [code](\d+)[^\d]+(\d+)[^\d]+([\d\.]+)[/code] works the same too
[QUOTE=Gmod4ever;41630433]Finishing up a program in Java, getting a file IO error. The File "vta" is being retrieved from a JFileChooser. Here is the immediately relevant code: [code] File new_flex = new File(vta.getParent() + "\\shifted\\" + vta.getName()); System.out.println("New file: " + new_flex.getPath()); if (!new_flex.exists()) { new_flex.mkdirs(); new_flex.createNewFile(); }[/code] The "new_flex.CreateNewFile();" line is generating this error: [code]java.io.IOException: The system cannot find the path specified[/code] I have some debug that prints vta's getPath(), getAbsolutePath(), and getParent(). That debug, as well as the new filename, is as such: [code]D:\_FlexShifter\jaw_drop.vta D:\_FlexShifter\jaw_drop.vta D:\_FlexShifter New file: D:\_FlexShifter\shifted\jaw_drop.vta[/code] When I hard-coded the paths to be relative to where Eclipse is installed, it worked fine. Eclipse is installed on my D:/. I have tried with these files in both C:\ and D:\. The "shifted" folder does not exist and has to be created. It is not being created. The file that "vta" references does exist, and exists in the location that it is returning. "new_file"'s getPath() and getAbsolutePath() both return the same path. Anyone have any ideas? This is literally the last thing I have to get working for this program to be release-ready.[/QUOTE] mkdirs() will create jaw_drop.vta as directory, if it would work that is. I'm not sure why it wouldn't, unless maybe if your drive is full to the brim. Does Windows perhaps not allow a dot in directory names?
[QUOTE=ZeekyHBomb;41634558]mkdirs() will create jaw_drop.vta as directory, if it would work that is. I'm not sure why it wouldn't, unless maybe if your drive is full to the brim. Does Windows perhaps not allow a dot in directory names?[/QUOTE] Dots are fine, Windows Explorer just complains if names start or (maybe) end with a dot but the system handles it fine. The problem is that mkdirs() creates the full path as directory, not only the parent directory. The imprecise error message is probably a Windows quirk, in reality it can't replace the folder with a file.
[QUOTE=Tamschi;41635180]Dots are fine, Windows Explorer just complains if names start or (maybe) end with a dot but the system handles it fine. The problem is that mkdirs() creates the full path as directory, not only the parent directory. The imprecise error message is probably a Windows quirk, in reality it can't replace the folder with a file.[/QUOTE] But there is neither a folder [b]nor[/b] a file. The code doesn't make anything at all. The odd thing is I can hard-code the [b]exact[/b] same path as the file I am testing with, and it works just fine. As soon as I make it dynamic, though, it fails. Even though my debug lines print the exact same paths.
Maybe there's a new-line character or something in there? Try outputting the string as byte-array.
[QUOTE=Gmod4ever;41638607]But there is neither a folder [b]nor[/b] a file. The code doesn't make anything at all. The odd thing is I can hard-code the [b]exact[/b] same path as the file I am testing with, and it works just fine. As soon as I make it dynamic, though, it fails. Even though my debug lines print the exact same paths.[/QUOTE] There must be some character that you can't see in there, try printing each byte individually
Good idea, guys. As soon as I am able, I shall do that.
Im extremely new to java, I might be doing something wrong thats very obvious im not sue. Its supposed to count to 15 in console but nothing shows up. Any idea on what I'm doing wrong? [CODE] import java.util.Scanner; public class CountingNumbers { static Scanner input = new Scanner(System.in); public static void main(String[] args) { CountNumber(); } public static void CountNumber(){ int i = 0; while (i <= 15); System.out.println(i); i++; } } [/CODE]
[QUOTE=Gmod4ever;41641593]Good idea, guys. As soon as I am able, I shall do that.[/QUOTE] Well... Uhh... It apparently magically fixed itself..? I just ran it again to verify it still didn't work, and it worked just fine...
[QUOTE=TittySprinkle;41644398]Im extremely new to java, I might be doing something wrong thats very obvious im not sue. Its supposed to count to 15 in console but nothing shows up. Any idea on what I'm doing wrong? [CODE] import java.util.Scanner; public class CountingNumbers { static Scanner input = new Scanner(System.in); public static void main(String[] args) { CountNumber(); } public static void CountNumber(){ int i = 0; while (i <= 15); System.out.println(i); i++; } } [/CODE][/QUOTE] [code]while (i <= 15);[/code] That line means while i <= 15, do nothing. You want to open a new scope: [code]while (i <= 15) { System.out.println(i); i++; }[/code]
I have a string "Damsiresire" how would I split it into an array using regex, I need the words "dam" and "sire" to be separate. [editline]30th July 2013[/editline] Scratch that, just got it!
You're kinda unspecific. Is the string always that? Then you could use a substring-function. Probably not though... Do you want to extract all "dam"s and "sire"s and discard everything else? Search for (dam)|(sire) until you get nothing. I'm unsure of a way to do that automatically, since you'd need to match the expression (dam)|(sire)|. repeatedly without making it a group (or . will be captured). A singe dam and sire? I'm not sure that's matchable against a regex, but you could search for "dam" and "sire" separately and compare the beginning indices too see which order they were. Maybe (dam)|(sire).*?|\1*(dam)|(sire).
I found this JSON file very hard to read because of its nesting, without having to store everything in intermediate objects. [url]https://gist.github.com/CptAsgard/4970ac06e610bf237077[/url] Any suggestions on how to get to the required data instantly? It might be the limitation of the JSON parser I'm using, but I couldn't get JSON.NET to work within Unity.
[QUOTE=ZeekyHBomb;41646008]You're kinda unspecific. Is the string always that? Then you could use a substring-function. Probably not though... Do you want to extract all "dam"s and "sire"s and discard everything else? Search for (dam)|(sire) until you get nothing. I'm unsure of a way to do that automatically, since you'd need to match the expression (dam)|(sire)|. repeatedly without making it a group (or . will be captured). A singe dam and sire? I'm not sure that's matchable against a regex, but you could search for "dam" and "sire" separately and compare the beginning indices too see which order they were. Maybe (dam)|(sire).*?|\1*(dam)|(sire).[/QUOTE] [code]preg_split("/(dam|sire)/i",$lineage->LineageDescription,NULL,PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY)[/code] the strings are always in that kind of format, they represent relationships between horses.
[QUOTE=Asgard;41646010]I found this JSON file very hard to read because of its nesting, without having to store everything in intermediate objects. [url]https://gist.github.com/CptAsgard/4970ac06e610bf237077[/url] Any suggestions on how to get to the required data instantly? It might be the limitation of the JSON parser I'm using, but I couldn't get JSON.NET to work within Unity.[/QUOTE] How do you handle it on the C# side?
[QUOTE=Arxae;41646199]How do you handle it on the C# side?[/QUOTE] I use Wyrmtale's JSON.cs [url]http://www.wyrmtale.com/blog/2013/98/json-formatting-and-parsing-in-unity3d[/url] It's lightweight and relatively easy to use, but I can't easily reach nested objects.
[QUOTE=Asgard;41646010]I found this JSON file very hard to read because of its nesting, without having to store everything in intermediate objects. [url]https://gist.github.com/CptAsgard/4970ac06e610bf237077[/url] Any suggestions on how to get to the required data instantly? It might be the limitation of the JSON parser I'm using, but I couldn't get JSON.NET to work within Unity.[/QUOTE] If by instantly you mean not having to manually write a parser, you can look into JSON Schema. It might still be a draft, so perhaps you won't find any tool to generate $PROGRAMMINGLANGUAGE code. You could also use a bridge like [url=https://code.google.com/p/protobuf-json/]protobuf-json[/url]. If by instantly you mean that you can basically memory-map the file and treat the data like your object, then you should look at switching to a binary format.
[QUOTE=ZeekyHBomb;41646219]If by instantly you mean not having to manually write a parser, you can look into JSON Schema. It might still be a draft, so perhaps you won't find any tool to generate $PROGRAMMINGLANGUAGE code. You could also use a bridge like [url=https://code.google.com/p/protobuf-json/]protobuf-json[/url]. If by instantly you mean that you can basically memory-map the file and treat the data like your object, then you should look at switching to a binary format.[/QUOTE] I will probably do the latter, thanks.
I need a better, quicker way to clear the console. I'm using system("cls") right now but its too slow and I really don't want to get in the habit of using system() I'm making a little realtime text based side scroller/shooter thing. Also, is there a way to get input that doesn't lock everything? I used _getch() and _getch_nolock() but they both wait for input before anything else happens.
[QUOTE=Dragonflare;41646311]I need a better, quicker way to clear the console. I'm using system("cls") right now but its too slow and I really don't want to get in the habit of using system() I'm making a little realtime text based side scroller/shooter thing. Also, is there a way to get input that doesn't lock everything? I used _getch() and _getch_nolock() but they both wait for input before anything else happens.[/QUOTE] Can't you use an ANSI escape string to clear it?
[QUOTE=SGI Onyx;41646317]Can't you use an ANSI escape string to clear it?[/QUOTE] I thought the windows console didn't support ANSI escape sequences. [B][U]EDIT:[/U][/B] Should have mentioned this is on Win32, sorry.
[QUOTE=Dragonflare;41646510]I thought the windows console didn't support ANSI escape sequences[/QUOTE] I've never done anything in the windows console, but a few of the console programs I wrote for MS-DOS worked fine (so long as I had ansi.sys loaded in DOS) [editline]30th July 2013[/editline] include <conio.h> clrscr() Would have to do the trick though.
Sorry, you need to Log In to post a reply to this thread.