• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=ZeekyHBomb;42908142] You can try just using [url=http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#yield()]Thread.yield()[/url]. If that is still too much CPU usage, or you simply still want more control, try the [url=http://stackoverflow.com/questions/824110/accurate-sleep-for-java-on-windows/2986919#2986919]"spin-yield"[/url].[/QUOTE] I had actually looked at that particular thread, and spin-yield in particular, several times before. However, I don't know how to implement it properly - I can get to a point where the "sleepNano" throttles the operations accordingly, but it still thrashes the core the same amount, so there's no point in me having it - when it takes the same amount of core usage to do 40,000 ops as it does to do 20,000,000, then I may as well just have it go all-out and do the 20,000,000. The issue is that I don't want it thrashing the core so much. I think I have come to the conclusion that there is no way to do what I want. It is either I melt the core and throttle it 100%, or I put my threads up to the mercy of the Windows thread scheduler and have a maximum speed of 1000 calls per second. It is beginning to seem like there is no middle ground, which I find a bit frustrating.
[QUOTE=Gmod4ever;42911876]I had actually looked at that particular thread, and spin-yield in particular, several times before. However, I don't know how to implement it properly - I can get to a point where the "sleepNano" throttles the operations accordingly, but it still thrashes the core the same amount, so there's no point in me having it - when it takes the same amount of core usage to do 40,000 ops as it does to do 20,000,000, then I may as well just have it go all-out and do the 20,000,000. The issue is that I don't want it thrashing the core so much. I think I have come to the conclusion that there is no way to do what I want. It is either I melt the core and throttle it 100%, or I put my threads up to the mercy of the Windows thread scheduler and have a maximum speed of 1000 calls per second. It is beginning to seem like there is no middle ground, which I find a bit frustrating.[/QUOTE] Try uneven usage, run the loop until you hit the limit for the current second and then sleep for the rest (and compensate the sleep error in the next iteration). It's probably better regarding energy usage too, as the core will be able to reduce its speed during the sleep part.
That is an idea I haven't considered before. It is an idea worth pursuing. I shall see what can be done of it. Thank you for the suggestion. [editline]Fish[/editline] Thank you very much for that suggestion. It fluctuates a bit (I had it peak at 30% max CPU usage at 3,000,000 ops / second across all 8 of my logical cores, had it valley at 3%), but it does seem to average out to about 15%. That will work gloriously. Such a simple solution, but one that I never really came to on my own. Though I have to admit it is kinda funny watching the CPU usage charts become a mountain range, with the variation of high-usage and then sleep. :v:
[QUOTE=JohnStamosFan;42911872]Anyhow, what's throwing me for a loop is the getline function. On my previous assignment, the getline part worked just fine, but, now it's giving me an error that says "no instance of overloaded function “getline” matches argument list". I'm not sure if maybe I've just screwed something up, or what. I know it's possible that maybe I've mixed something up. Anyhow, what do you guys think?[/QUOTE] inputLine is not defined. Also, there's a parameterless std::istream::get().
[QUOTE=ZeekyHBomb;42912657]inputLine is not defined. Also, there's a parameterless std::istream::get().[/QUOTE] Ahh, weird. I didn't have any of that in my other assignment that seemed to run just fine. Hmm, oh well. I'll go look that up in my book and make sure I'm not making a mess of that. Thanks!
[QUOTE=Gmod4ever;42900567]Okay, so this isn't really a "what I need help with," but more of just a general question. What, exactly, is a psuedorandom number generator's period a measure of? Put another way, a 32-bit word Mersenne Twister is said to have a period of 2^19937 - 1. Does that mean that you can create 2^19937 - 1 calls to a MT before the sequence starts repeating itself [b]without changing the seed[/b]? Or does it mean that the absolute maximum sequence that the algorithm creates is 2^19937 - 1 in length, with all possible seeds? The reason I ask is I want to create a system where, when a PRNG is about to start repeating its sequence, the seed is changed so that a new sequence is generated instead. I want to know if the period is a measure of that, or if the period is the absolute maximum number of unique numbers the PRNG can generate. All the documentation I have found on the matter has been a bit fuzzy to me.[/QUOTE] I wanted to reply to this yesterday but I was slightly too drunk to operate my phone properly. Firstly, the seed is a different concept from the initial internal state of the PRNG. The initial state describes the whole system: every bit counts. The seed can be a shortened version - a number used to generate the initial state. Often the seed is just a 32-bit integer, limiting the possible initial states to 2^32, even if the PRNG could have 2^thousands of different states. Then, to answer the question: period length is a measure of how long it takes the PRNG to reach its current internal state again by iterating the random number generation process. The period length can vary wildly depending on the PRNG's parameters, including its seed if it's a bad generator. Usually generators are designed to generate every possible internal state from every other internal state. The generator produces a single, repeating sequence of states. Therefore, regardless of the initial state - and thus, regardless of the seed - the sequence of states is the same. The actual outputted random number is a function of the PRNG's internal state, and may repeat even faster than what the PRNG's period is. Using the entire state of the generator as a random number is not ideal either: it's not random at all. LCGs, my favourite example, often output their entire internal state: aside from other issues, that means that they will visit each number [i]exactly[/i] once until they've reached the end of the sequence. You know the number you just got has a zero chance of reappearing in the next 2^32-1 or whatever numbers - whereas with true random numbers its chance of reappearing would be nonzero. Periodically seeding a PRNG with another pseudorandom number to make it "more random" is a really bad idea. Periodically changing a PRNG's entire internal state to a true random number is a good idea.
I'm thinking of working on a game similar in style to Fallout 1 and 2. I have Open GL experience and have written an Obj parser before, but I feel like I need a file format that supports animations. Any suggestions? If a parser already exists for it in C++, that would be a huge help too.
Hi everyone, I installed Visual Studio 2012 to start my new year in uni and were working a lot with web services and general web stuff in C#, I was wondering if anyone could help me out here. I'm currently trying to make a Silverlight application for an assignment (I know it's not commonly used but I just need to do this for the grades :P), I create a blank project and try and compile and run to any web browser and I'm getting "Oops! Google Chrome could not find localhost:56604", I'm no expert on this but I think it might have something to do with "ISS"? The same project will work fine on the uni computers but mine isn't start a local sort of server or something? If anyone could help that would be amazing! I'm using windows 7 64bit professional (if it helps)
[QUOTE=borisjake;42919622]Hi everyone, I installed Visual Studio 2012 to start my new year in uni and were working a lot with web services and general web stuff in C#, I was wondering if anyone could help me out here. I'm currently trying to make a Silverlight application for an assignment (I know it's not commonly used but I just need to do this for the grades :P), I create a blank project and try and compile and run to any web browser and I'm getting "Oops! Google Chrome could not find localhost:56604", I'm no expert on this but I think it might have something to do with "ISS"? The same project will work fine on the uni computers but mine isn't start a local sort of server or something? If anyone could help that would be amazing![/QUOTE] What windows version are you running? If i remember correctly it's related to the OS being 64-bit, but it's so long ago i had that problem i don't remember what i did to fix it.
[QUOTE=Dj-J3;42919707]What windows version are you running? If i remember correctly it's related to the OS being 64-bit, but it's so long ago i had that problem i don't remember what i did to fix it.[/QUOTE] I'm using windows 7 64bit professional.
[QUOTE=WTF Nuke;42917334]I'm thinking of working on a game similar in style to Fallout 1 and 2. I have Open GL experience and have written an Obj parser before, but I feel like I need a file format that supports animations. Any suggestions? If a parser already exists for it in C++, that would be a huge help too.[/QUOTE] I use IQM and it has everything I need without any extra shit. Easy to read in, has import/export scripts for Blender. [url]http://sauerbraten.org/iqm/[/url]
I'm currently working on an android app for my University. In it we decided to use OpenGL because I always wanted to learn how to correctly use it. We went for OpenGL 2.0. Now the problem I have is that I cannot find a way to make the objects on the screen drawable without causing a concurrent modification exception. I already tried to circumvent this problem by making a temporary queue that is flushed into the 'real' render queue before each drawing call. But this still crashes my app at random times. Now my question is. How do I correctly make my application logic/rendering thread safe? Or am I doing it completely wrong? I have only about 3 more weeks to finish this app and this is a real blocker for me. (I'm not asking for the full written answer or something, just perhaps a paradigm I was unaware of or some best practices to avoid this.) Help would be awesome, thanks
What is the best place to start learning Java ?
[QUOTE=zero_slo;42904290]I'm making a simple game for my Computer Graphics class and I need some help. I'm using lwjgl and JBullet. (video) Does anyone have any idea why that up-and-down stuttering and clipping through the ground is happening? The "vehicle" is a RaycastVehicle and the ground is just a RigidBody with a StaticPlaneShape collision shape. Are there any good JBullet (i guess i could survive with c++ bullet) tutorial you guys recommend?[/QUOTE] The [url=http://bulletphysics.org/mediawiki-1.5.8/index.php/Vehicles]wiki[/url] says: "If you are using a btStaticPlaneShape for your ground, your vehicles won't work." I'm working on a project for school too and i'm using these tutorials. [video=youtube;1CEI2pOym1Y]http://www.youtube.com/watch?v=1CEI2pOym1Y[/video] Unfortunately he has nothing on vehicles.
- fixed -
Scrub programmer inc: I'm programming in C and I want to read a string of characters assigned to an array and change all the spaces with hyphens, and I have no idea how to do this. Here's what I have so far char *str = "u wot fam"; while(str != '\0') { if (str == ' ') { (code to change space to hyphen) } else { (code to not change the character) } i++; }
Just encase someone comes across this problem and finds this, this is how I fixed it: went to: "C:\Windows\System32\drivers\etc\hosts" and opened with notepad, and changed "0.0.0.0 localhost" to "127.0.0.1 localhost". I'm not sure why I had this problem but there you go :smile: [QUOTE=borisjake;42919622]Hi everyone, I installed Visual Studio 2012 to start my new year in uni and were working a lot with web services and general web stuff in C#, I was wondering if anyone could help me out here. I'm currently trying to make a Silverlight application for an assignment (I know it's not commonly used but I just need to do this for the grades :P), I create a blank project and try and compile and run to any web browser and I'm getting "Oops! Google Chrome could not find localhost:56604", I'm no expert on this but I think it might have something to do with "ISS"? The same project will work fine on the uni computers but mine isn't start a local sort of server or something? If anyone could help that would be amazing! I'm using windows 7 64bit professional (if it helps)[/QUOTE]
[QUOTE=Cam00;42925988]Scrub programmer inc: I'm programming in C and I want to read a string of characters assigned to an array and change all the spaces with hyphens, and I have no idea how to do this. Here's what I have so far char *str = "u wot fam"; while(str != '\0') { if (str == ' ') { (code to change space to hyphen) } else { (code to not change the character) } i++; }[/QUOTE] You seem to be mixing two ideas, either of which could work. Here's one using pointers: [code]char str[] = "u wot fam"; char *ptr = str; while(*ptr != '\0') { if(*ptr == ' ') *ptr = '-'; ptr++; }[/code] Here's one using an integer iterator: [code]char str[] = "u wot fam"; int pos = 0; while(str[pos] != '\0') { if(str[pos] == ' ') str[pos] = '-'; pos++; }[/code]
sorted
So, I have a question, a teacher of mine said the "...for Dummies" books are pretty good for someone who is more of a book learner, than a visual learner. So doing some research on this, there are a bunch of "Java for Dummies" books. The newest one seems to be coming out on March 24th, 2014. There is "Beginning Programming with Java for Dummies" which came out in 2012. There is "Java All-In-One For Dummies" which came out in 2011. There is also a new one coming in 2014. So I'm curious, which would be the appropriate to get? Note, I only know basic C# coding.
Im trying to move some stuff to use indecies, mainly so that I can smooth normals easier. I build the Vertex and index list like: [cpp] for(int y = 0; y < 100; y++) { for(int x = 0; x < 100; x++) { glm::vec3 p1( x, NoisePP.Generate(x, y) * 50, y ); mVertexList.push_back(p1); } } for(int y = 0; y < 99; y++) { for(int x = 0; x < 99; x++) { mIndexList.push_back(x + y*100); mIndexList.push_back(x + (y+1)*100 ); mIndexList.push_back(x+1 + y*100); mIndexList.push_back(x+1 + y*100); mIndexList.push_back(x + (y+1)*100); mIndexList.push_back(x+1 + (y+1)*100); } } [/cpp] Is there any quick automatic way of selecting each vertex and checking all 4 or 8 vertices around it and smooth their normals?
[QUOTE=layla;42921078]I use IQM and it has everything I need without any extra shit. Easy to read in, has import/export scripts for Blender. [url]http://sauerbraten.org/iqm/[/url][/QUOTE] I've looked into this and have a few questions. What exactly is IQE? Is it an intermediate format to be transformed into IQM? I use Maya, or at least wish to learn how to use it. From what I understand I can save the animated file as MD5, SMD, FBX, or OBJ and export it to IQM?
So I'm wondering what you guys think I should use as an autopilot platform for a quadcopter So for my senior engineering project one of my ideas is to use a micro arduino powered quadcopter to explore an indoor area, collect some ranges from ultrasonic sensors, and beam this back to a base station (most likely a screen equipped raspberry pi) for collation and display as a 2d map. Question is, anyone got any idea what base UAV software I should use? Ardupilot seems more about setting waypoints and I need something that is more autonomous. It seems silly for us to write a whole autopilot software (admittedly, a sparse and minimal one at that) and try to make a mapping utility. I already have a few ideas on how I can make it path its way through areas and distinguish between halls and rooms, but need to find a base to build off of Unless you all want me to be posting in here constantly asking questions :v:
Hey guys do you know where I can find a tutorial or something that will help me make a program to edit certain values of an xml file? I'm trying to make a tool for rimworld so it's easier to edit values in the game.
[QUOTE=WTF Nuke;42930020]I've looked into this and have a few questions. What exactly is IQE? Is it an intermediate format to be transformed into IQM? I use Maya, or at least wish to learn how to use it. From what I understand I can save the animated file as MD5, SMD, FBX, or OBJ and export it to IQM?[/QUOTE] If maya doesn't have an export for IQM then you'd just export to something Blender can import and export as IQM there. IQE is just an intermediate format that's easier to import I guess. I think IQM has a tool that will compile an SMD straight to IQM though.
[QUOTE=WTF Nuke;42930020]I've looked into this and have a few questions. What exactly is IQE? Is it an intermediate format to be transformed into IQM? I use Maya, or at least wish to learn how to use it. From what I understand I can save the animated file as MD5, SMD, FBX, or OBJ and export it to IQM?[/QUOTE] IQE is a text format that's less compact than IQM. It's just easier to write an exporter for than IQM. I forked IQM on GitHub with the intention of writing a Maya exporter, since I'm using IQM in a game I'm working on, but I've been busy with other projects for the past few months so that's gotten nowhere. I'm not particularly looking forward to it either, MEL looks annoying to use.
[QUOTE=Richy19;42929879]Is there any quick automatic way of selecting each vertex and checking all 4 or 8 vertices around it and smooth their normals?[/QUOTE] I'm not sure what you mean by automatic, but it kinda sounds like you want a blur filter, which can probably be done rather quickly in a shader. [QUOTE=Vilusia;42930790]Hey guys do you know where I can find a tutorial or something that will help me make a program to edit certain values of an xml file? I'm trying to make a tool for rimworld so it's easier to edit values in the game.[/QUOTE] Language?
[QUOTE=ZeekyHBomb;42934271]I'm not sure what you mean by automatic, but it kinda sounds like you want a blur filter, which can probably be done rather quickly in a shader. Language?[/QUOTE] C++? Idk this is literally my first time ever making a program.
It might be a bit too soon to attempt to make something actually useful. If you want to try though, look [url=http://stackoverflow.com/questions/9387610/what-xml-parser-should-i-use-in-c/9387612#9387612]over here[/url] for deciding on a XML library.
So I decided to try and use PDCurses (Windows port of NCurses, the updated version of Libcurses) just because. However, when I create a new window, my program crashes on "wrefresh(win)". My code is below the editline. And my GCC compiler line: [code]gcc test.c "D:/Tools/ExternalLibs/C/PDCurses/pdcurses.a" -I "D:/Tools/ExternalLibs/C/PDcurses/"[/code] You can safely assume that pdcurses.a and curses.h exist in the described filepath. The program compiles and runs fine, but as soon as it gets to that "wrefresh(win)" it crashes with "a.exe has stopped responding." If I comment that line out, it runs fine (though the 'window' doesn't actually draw). I am using 64-bit Windows 7 with the latest version of MinGW installed and gcc version 4.5.4. [editline]21st November 2013[/editline] [b]test.c[/b] [code]#include <stdio.h> #include "curses.h" WINDOW* nwin(int width,int height,int startx,int starty); int main(int argc,char** argv) { //printf("Hello world!\n"); WINDOW* win; int width,height,startx,starty; int ch; height = 3; width = 10; starty = (LINES - height) * 0.5; startx = (COLS - width) * 0.5; initscr(); cbreak(); printw("Testing a custom window!"); refresh(); win = nwin(width,height,startx,starty); getch(); endwin(); return 0; } WINDOW* nwin(int width, int height, int startx, int starty) { WINDOW* win; win = newwin(height,width,starty,startx); //box(win,0,0); wrefresh(win); return win; }[/code] [editline]21st November 2013[/editline] Had to make it two separate posts because Facepunch got pissed at me for making such a large post (redirected to a broken Cloudflare captcha because of a "spam attack.") [editline]21st November 2013[/editline] Also, I am using [url=http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/windows.html]this NCurses[/url] tutorial for window creation, because documentation on PDCurses seems to be more or less nonexistent.
Sorry, you need to Log In to post a reply to this thread.