• What do you need help with? V4 (January 2012)
966 replies, posted
[QUOTE=Jimbomcb;34246286]I'm trying to create a handheld effect for a camera by interpolating the camera back and forth to random points within a range, however it just looks dumb and nothing at all like I want it to. I know it's vague and barely a question but yeah, anyone have any input/ideas on how they would (by offsetting the position) achieve a sorta shaky handheld effect?[/QUOTE] Try something like: [code] yaw_offset = scale * (cos(a*t) + cos(b*t) + cos(c*t)); pitch_offset = scale * (cos(d*t) + cos(e*t) + cos(f*t)); [/code] Where a, b, c, d, e, and f are a bunch of [i]coprime[/i] coefficients for angular frequency.
Guys Is [url=http://www.flipcode.com/archives/Frustum_Culling.shtml]this[/url] still a valid description of frustum culling or is there some ~~NEW TECHNOLOGY~~ that simplifies it or makes the process more efficient?
[QUOTE=esalaka;34248062]Guys Is [url=http://www.flipcode.com/archives/Frustum_Culling.shtml]this[/url] still a valid description of frustum culling or is there some ~~NEW TECHNOLOGY~~ that simplifies it or makes the process more efficient?[/QUOTE] Frustum culling is basic geometry. The basic process doesn't change. Obviously, some scene structures are better suited than others (i.e. hierarchical structures are better than flat structures), but anything you read in an old article probably still works today. Speaking of which, I've been thinking about breaking the frustum/occlusion culling (well, it's just frustum culling now, but I've got occlusion culling planned out on paper) code from my engine and making it into a dedicated library. It's the sort of thing every game developer really needs, but AFAIK, there isn't really a good library for it right now, short of proprietary middleware.
[QUOTE=ROBO_DONUT;34248033]Try something like: [code] yaw_offset = scale * (cos(a*t) + cos(b*t) + cos(c*t)); pitch_offset = scale * (cos(d*t) + cos(e*t) + cos(f*t)); [/code] Where a, b, c, d, e, and f are a bunch of [i]coprime[/i] coefficients for angular frequency.[/QUOTE] looks awesome, thanks. just out of interest, why do the coefficients need to be coprime
This error is pissing me right the fuck off. [code] main.cpp:307: error: no matching function for call to &#8216;layer::debug::Library::findFunction(const char [19])&#8217; [/code] main.cpp [cpp] layer::debug::Library sqlite("/usr/lib/libsqlite3.so"); const char* (*whatwhat)() = sqlite.findFunction<const char*, void>("sqlite3_libversion"); // line 307 const char* ver3 = whatwhat(); ::layer::info("blah says \"%s\"\n", ver3); // printf-equiv [/cpp] Library is defined as [cpp] class Library { public: Library(const GString& path); // GString is typedef'd std::string ~Library(); void* findFunction(const GString& functionName) const; template<typename R, typename... T> R (*findFunction(const GString& funcName))(T... Ts) const { return (R (*)(...))findFunction(funcName); } private: void* _libraryHandle; }; [/cpp] Compiling with -std=c++0x -pedantic -Wall [editline]17th January 2012[/editline] if I use the non-templated function and some bullshit casting, it works fine. [cpp] void* simple = sqlite.findFunction("sqlite3_libversion"); const char* (*simpleimpl)(void) = (const char* (*)(void))(simple); ::layer::info("blah says \"%s\"\n", simpleimpl()); [/cpp]
Using QT4 in Ruby, how can I set a variable equal to what was entered into lineEdit? I've spent the past hour googling this, and I haven't had any luck. The results I got showed bits of code that were of no relevance to what I'm looking for.
[QUOTE=Jimbomcb;34253974]looks awesome, thanks. just out of interest, why do the coefficients need to be coprime[/QUOTE] You get a longer period before the pattern repeats. It won't appear to be random movement if they have a small common factor.
creating an xml file with .net in c#, it works, but the generated file only uses 1 line like this: [code] <?xml version="1.0"?><Client><server>192.168.12.1</server></Client> [/code] But i want it to look much more organized, like this: [code] <?xml version="1.0"?> <Client> <server>192.168.12.1</server> </Client> [/code] This is the code I currently have: [code] XmlTextWriter textWriter = new XmlTextWriter("preferences.xml", null); textWriter.WriteStartDocument(); //Start write textWriter.WriteStartElement("Client"); textWriter.WriteStartElement("server"); textWriter.WriteString("192.168.12.1"); textWriter.WriteEndElement(); textWriter.WriteEndElement(); //End Write textWriter.WriteEndDocument(); textWriter.Close(); [/code]
Hmm, you could try: [code] textWriter.Settings.NewLineOnAttributes = true; [/code]
On ubuntu 11.10 (64 bit), my cmake can't seem to find the xrandr library: [img]http://i.imgur.com/Aneq7.png[/img] even though I can use it in the terminal: [img]http://i.imgur.com/15SVv.png[/img] (using cmake 2.8.5). [editline]17th January 2012[/editline] Fixed, had to install the dev versions of everything (e.g. libsndfile-dev)
I'm getting some weird shit here. I'm writing a backup utility for all my stuff and I'm getting 'access denied' to non-system paths when using the System.IO.File.Copy method. I even changed the manifest to [I]requireAdministrator [/I]and it didn't help. Any ideas? [editline]17th January 2012[/editline] One of the paths in question is: C:\Users\.\Desktop\Minecraft\Server [editline]17th January 2012[/editline] Haha, that's unfortunate for me, I just realized I'm using File.Copy in an attempt to copy folders. Sorry - nevermind me.
In LOVE is there any way I can open a directory in an explorer window?
[QUOTE=PieClock;34266072]In LOVE is there any way I can open a directory in an explorer window?[/QUOTE] I'm not too crash hot with love or lua but some quick googling says there's "os.execute". Just do that and call [code] os.execute("explorer \"directory name here with spaces\"") [/code]
Yep, just stumbled upon that myself there now. Works great. Thanks :smile: Though this is what I'm doing: [code]os.execute("C:\\windows\\explorer.exe /e, C:\\")[/code]
This is for a problem on an assignment. I'm having trouble sorting three numbers in order of ascension without the use of array, here's what I have in Java so far: [code] System.out.println("Enter the first number: "); int num1= input.nextInt(); System.out.println("Enter the second number: "); int num2 = input.nextInt(); int minInput = Math.min(num1, num2); int maxInput = Math.max(num1, num2); System.out.println("Enter the third number: "); int num3= input.nextInt(); minInput = Math.min(minInput, num3); maxInput = Math.max(maxInput, num3); System.out.println("Numbers in order: " + minInput + " " + maxInput); [/code] The problem is that I can't seem to figure out how to get the middle value. Any help appreciated.
[QUOTE=Plastical;34272053]This is for a problem on an assignment. I'm having trouble sorting three numbers in order of ascension without the use of array, here's what I have in Java so far: [code] code [/code] The problem is that I can't seem to figure out how to get the middle value. Any help appreciated.[/QUOTE] I'd skip the whole 'min' and 'max' approach and just check for all the combinations using "if a < b and a < c" sort of things. [editline]18th January 2012[/editline] Not particularly glamorous, but it works for something of this small scale.
[QUOTE=mechanarchy;34272159]I'd skip the whole 'min' and 'max' approach and just check for all the combinations using "if a < b and a < c" sort of things. [editline]18th January 2012[/editline] Not particularly glamorous, but it works for something of this small scale.[/QUOTE] I did this using 9 if statements. It wasn't beautiful and I had to create a temporary variable, but it worked. Thanks.
[QUOTE=Plastical;34272465]I did this using 9 if statements. It wasn't beautiful and I had to create a temporary variable, but it worked. Thanks.[/QUOTE] Yeaah... I kinda expected it would look a bit dreadful. [editline]18th January 2012[/editline] Just decided to see how it was done. Here's a working python implementation: [code] a = int(raw_input("first: ")) b = int(raw_input("second: ")) theMin = min(a, b) theMax = max(a, b) c = int(raw_input("third: ")) theMid = 0 if min(c, theMin) == theMin and max(c, theMax) == theMax: # c is middle theMid = c elif min(c, theMin) == theMin: # c is max theMid = theMax theMax = c else: # c is min theMid = theMin theMin = c print "minimum value:", theMin print "middle value:", theMid print "maximum value:", theMax [/code] [editline]18th January 2012[/editline] It's completely different to what I suggested and far closer to what you had, but oh well. When I started writing it, this was how it turned out compared to what I'd planned.
what would be the best way to integrate Lua into c#?
[QUOTE=kaukassus;34277002]what would be the best way to integrate Lua into c#?[/QUOTE] [url]http://code.google.com/p/luainterface/[/url]
I need some help with this problem. (C++) 2. Write a program that will prompt the user for a positive integer n, and will use a recursive function to convert n to binary. For example, if n is 19, the output shold be 10011. It should then print the binary number. [code] #include <iostream> using namespace std; int convertToBinary(int); int main() { int n; cout << "Enter non-zero integer or 0 to stop: "; cin >> n; while (n != 0) { int binary = convertToBinary(n); cout << "The binary of integer " << n << " is " << binary << ".\n"; cout << "Enter non-zero integer or 0 to stop: "; cin >> n; } cout << "Bye!\n"; } int convertToBinary(int n) { if (n == 0) return 0; return convertToBinary(n/2) + n%2; } [/code] I don't know where to go from here, it's adding the numbers together, and that's not what I want. Any ideas on what I'm doing wrong?
[QUOTE=Leonmyster;34280279]I need some help with this problem. (C++) 2. Write a program that will prompt the user for a positive integer n, and will use a recursive function to convert n to binary. For example, if n is 19, the output shold be 10011. It should then print the binary number. [code] #include <iostream> using namespace std; int convertToBinary(int); int main() { int n; cout << "Enter non-zero integer or 0 to stop: "; cin >> n; while (n != 0) { int binary = convertToBinary(n); cout << "The binary of integer " << n << " is " << binary << ".\n"; cout << "Enter non-zero integer or 0 to stop: "; cin >> n; } cout << "Bye!\n"; } int convertToBinary(int n) { if (n == 0) return 0; return convertToBinary(n/2) + n%2; } [/code] I don't know where to go from here, it's adding the numbers together, and that's not what I want. Any ideas on what I'm doing wrong?[/QUOTE] Well for one thing, you want it to build a string, while instead it's adding integers together.
[QUOTE=Octave;34280737]Well for one thing, you want it to build a string, while instead it's adding integers together.[/QUOTE] How would I incorporate the string? From what I understand, I can't return it as a string because it's an integer, convertToBinary that is. My knowledge of strings aren't too good, since my previous professor never taught us string, while this one is all about it.
[QUOTE=Leonmyster;34280810]How would I incorporate the string? From what I understand, I can't return it as a string because it's an integer, convertToBinary that is. My knowledge of strings aren't too good, since my previous professor never taught us string, while this one is all about it.[/QUOTE] I'd like to preface this with the fact that my C++ is very limited :v: but for starters, you can change the return type to be a string [code]string convertToBinary(int n) { static string result; // Static so that it will remain between calls of this function rather than being initialized every time if (n == 0) return 0; result.append((n % 2) ? "1" : "0"); return convertToBinary(n/2); } [/code] Haven't tested this yet, but it's a start.
That would just return 0. Maybe try something like: [code]string convertToBinary( int n ) { if( n == 0 ) return "0"; return convertToBinary( n / 2 ).append( toString( n % 2 ) ); }[/code] [editline]18th January 2012[/editline] No idea how to append to a string in C++ though, maybe with a stream
[del]A lot of the time you want to use stringstreams to convert things into strings. Read more about 'em [url=http://www.cplusplus.com/reference/iostream/stringstream/]here[/url]. Should explain the concept adequately, seeing as you know how streams work already (cin, cout).[/del] Maybe I should learn how to read
Okay, fixed some things, this works but the output is reversed, looking for a string reversal function now... [cpp]string convertToBinary(int n) { static string buf; if (n == 0) return buf; buf.append((n % 2) ? "1" : "0"); return convertToBinary(n/2); }[/cpp]
Avoid recursion when it isn't beneficial. If you use it in places where there aren't small upper bounds on the depth of the recursion, you risk a stack overflow. Not to mention the function call overhead. This would probably be better: [cpp]string convertToBinary(int n) { int bits = 8 * sizeof(int); int mask = 1 << bits - 1; string result; for (int i=0; i < bits; i++) { result.append(n & mask ? "1" : "0"); mask >>= 1; } return result; }[/cpp]
Instead of reversing the string at the end you could construct it in the opposite order. Also, I'm not sure you can declare static variables inside a method C++, although it has been a while since I last used it.
[QUOTE=Ziks;34281179]Also, I'm not sure you can declare static variables inside a method C++, although it has been a while since I last used it.[/QUOTE] It's a function, not a method.