• What do you need help with? V. 3.0
    4,884 replies, posted
We need to make a java alphabet casting applet. Someone spoonfeed and recieve a cookie!
[QUOTE=jalb;32534409]Are you sure that's the exact algorithm? I know which algorithm it is, it has a name too, but there's an issue with it right off the bat... [cpp]while(s < N) { s = s+1; v = a[s];[/cpp] This code will end up trying to fetch the array at index 5. The array has 5 indices so there is only 0, 1, 2, 3, 4. There is not an index at 5. I'm assuming you're suppose to just read this and "play the computer." Maybe that error was intentional. Maybe they want you to assume that arrays go from 1-5 rather than 0-4. If not, that's a really novice error to make... As for your hint: Try following what the value v is doing.[/QUOTE] The code was a direct copy from a paper I'm looking at so it must've been an error on their part. That would explain why v was -858993460... Thanks heaps man. I didn't particularly like playing the computer for this kind of algorithm...
Okay, what? If I pass no arguments to the previous function, I get this: [cpp]collision = NewtonCreateBox(nWorld, 0, 0, 0, NULL, 0);[/cpp] [cpp]newton.h|655|error: too few arguments to function 'NewtonBody* NewtonCreateBody(const NewtonWorld*, const NewtonCollision*, const float*)'|[/cpp] [cpp]NEWTON_API NewtonBody* NewtonCreateBody (const NewtonWorld* newtonWorld, const NewtonCollision* collision, const dFloat* matrix);[/cpp] But then if I add the missing parameter, I get this: [cpp]collision = NewtonCreateBox(nWorld, 0, 0, 0, NULL, 0, 0);[/cpp] [cpp]newton.h|465|error: too many arguments to function 'NewtonCollision* NewtonCreateBox(const NewtonWorld*, float, float, float, int, const float*)'|[/cpp] [cpp]NEWTON_API NewtonCollision* NewtonCreateBox (const NewtonWorld* newtonWorld, dFloat dx, dFloat dy, dFloat dz, int shapeID, const dFloat *offsetMatrix);[/cpp] I don't even. :pwn:
As you can see, you get further compilation when you actually do what the compiler says. Where are you calling CreateBody?
[QUOTE=Jookia;32536389]Where are you calling NewtonCreateBody?[/QUOTE] Nowhere. I just call this: [cpp]collision = NewtonCreateBox(nWorld, 0, 0, 0, NULL, 0, 0);[/cpp] I think NewtonCreateBox calls NewtonCreateBody by itself somewhere down the line, but still. What the hell. Why doesn't this shit work? I just copied the code over from a tutorial. [b]Edit:[/b] [quote=Jookia]As you can see, you get further compilation when you actually do what the compiler says.[/quote] I know, but it still puzzles me because I'm the only one in the whole internet having this problem, apparently. Because all tutorials and everything else tells me to use it that way. I'm just copying the source from a tutorial to make sure there's nothing wrong. [b]Edit 2:[/b] nvm I was using code from another tutorial, I am actually calling CreateBody.
[QUOTE=Samuka97;32536340]Okay, what? If I pass no arguments to the previous function, I get this: [cpp]collision = NewtonCreateBox(nWorld, 0, 0, 0, NULL, 0);[/cpp] [cpp]newton.h|655|error: too few arguments to function 'NewtonBody* NewtonCreateBody(const NewtonWorld*, const NewtonCollision*, const float*)'|[/cpp] [cpp]NEWTON_API NewtonBody* NewtonCreateBody (const NewtonWorld* newtonWorld, const NewtonCollision* collision, const dFloat* matrix);[/cpp] But then if I add the missing parameter, I get this: [cpp]collision = NewtonCreateBox(nWorld, 0, 0, 0, NULL, 0, 0);[/cpp] [cpp]newton.h|465|error: too many arguments to function 'NewtonCollision* NewtonCreateBox(const NewtonWorld*, float, float, float, int, const float*)'|[/cpp] [cpp]NEWTON_API NewtonCollision* NewtonCreateBox (const NewtonWorld* newtonWorld, dFloat dx, dFloat dy, dFloat dz, int shapeID, const dFloat *offsetMatrix);[/cpp] I don't even. :pwn:[/QUOTE] Well, the first code you showed uses NewtonCreateBox and the error is about NewtonCreateBody?
[QUOTE=ZeekyHBomb;32536538]Well, the first code you showed uses NewtonCreateBox and the error is about NewtonCreateBody?[/QUOTE] Shit hold on I'm blind, I [b]am[/b] calling NewtonCreateBody, I forgot because I deleted my source and copied from another tutorial.
I don't think so, at least the online repository shows no indication of that. Could you post your whole code on a pastebin or something?
[QUOTE=ZeekyHBomb;32537032]I don't think so, at least the online repository shows no indication of that. Could you post your whole code on a pastebin or something?[/QUOTE] Shit I'm blind. I am calling NewtonCreateBody. I just thought I didn't because I was actually looking at the source of another tutorial. [url=http://pastebin.com/0fxjykYR]Here's the code[/url] anyways, but I'll fix it asap. Give me my boxes. [b]Edit:[/b] I edited the code to pass the correct amount of arguments, but now the program crashes when I launch the EXE. Hold on. [b]Edit 2:[/b] Okay, I don't know what's going on. Not much goes on when I launch the EXE, just the standard Windows crash, and no errors on the console. [url=http://i.cubeupload.com/lJ4bpC.png]Here's a picture.[/url]
Have you tried debugging the program? That should show where it segfaulted. It's probably due to you trying to use something after calling Irrlicht's drop(), OR not grab()ing the return value of something, causing the object to be deleted.
Looks like progress :) Debug
[QUOTE=ZeekyHBomb;32537230]Looks like progress :) Debug[/QUOTE] [cpp]Program received signal SIGSEGV, Segmentation fault. In newton_d!NewtonMeshGetFirstPoint () (G:\Samuka97\9. Projects\C++\Irrlicht\IrrlichtBase_IrrNewt\bin\Debug\newton_d.dll) Debugger finished with status 0[/cpp] Is this of any help at all? [b]Edit:[/b] Alright, I've downloaded NewtonSDK from the SVN and replaced newton_d.dll with the one from the SVN to test it out. Now I get this: [cpp]Program received signal SIGSEGV, Segmentation fault. In newton_d!NewtonBodySetDestructorCallback () (G:\Samuka97\9. Projects\C++\Irrlicht\IrrlichtBase_IrrNewt\bin\Debug\newton_d.dll) Debugger finished with status 0[/cpp]
Do you have any pointers in the scope that are invalid?
I think that's a NULL pointer somewhere. What are you passing as third argument to NewtonCreateBody? The documentation doesn't seem to specify that NULL is fine there.
[QUOTE=ZeekyHBomb;32537411]I think that's a NULL pointer somewhere. What are you passing as third argument to NewtonCreateBody? The documentation doesn't seem to specify that NULL is fine there.[/QUOTE] Thanks, that fixed it! I was passing a array instead of a matrix4 into it. Now I get a blank screen instead of a crash, but at least there's some progress. I'll try to mess around with the camera positions and see if I can find where the box is. [b]Edit:[/b] Okay, so I couldn't get the camera in a position to see the box, so I just re-copied the entire source from [url=http://content.gpwiki.org/index.php/Irrlicht:Physics]this tutorial[/url] to make sure everything was okay. But now it seems to crash in any line that references "device()": [cpp]while(device->run()) - Program received signal SIGSEGV, Segmentation fault. At G:\Samuka97\9. Projects\C++\Irrlicht\IrrlichtBase_IrrNewt\main.cpp:112 Debugger finished with status 0[/cpp] All I did differently was break down int main() into smaller functions like the tutorial was doing. I'm also not very experienced with C++ so please excuse me if it's something stupid I'm missing. Anyways, [url=http://pastebin.com/eYGv2Nsg]here's my code[/url], if you want to see it all put togheder.
[url=http://stackoverflow.com/questions/246445/create-stdstring-from-char-in-a-safe-way]StackOverflow seems to think[/url] code of the form [cpp] std::string getCurrentDirectory() { char* raw = getcwd(); std::string returnVal(raw); free(raw); return returnVal; } [/cpp] is 'unsafe'. [url=http://www.cplusplus.com/reference/string/string/string/]According to cplusplus.com[/url], the string constructor makes a copy of the char* data, so that means I should be able to free it without any issue, right? Am I missing something here? EDIT: It should probably be getcwd(0, 0); according unistd.h
-snip broken merge. help the guy above first, I'm off to school for 6h-
[QUOTE=mechanarchy;32537592]EDIT: It should probably be getcwd(0, 0); according unistd.h[/QUOTE] No, no; You should first malloc enough space and assign that to raw, then call getcwd(raw, buf_size); where buf_size is the amount of memory you just allocated. [editline]29th September 2011[/editline] Oh crap we're in C++, you obviously would use new here. (Or an array. Arrays would be a good idea here.) [cpp] std::string getCurrentDirectory() { char raw[128]; // Don't use a magic number in actual code getcwd(raw, 128); std::string returnVal(raw); return returnVal; }[/cpp] [editline]29th September 2011[/editline] I think an array would make the most sense here since you have to specify the size of the buffer regardless.
[QUOTE=esalaka;32537691]No, no; You should first malloc enough space and assign that to raw, then call getcwd(raw, buf_size); where buf_size is the amount of memory you just allocated.[/QUOTE] Well I considered that given it seems to be the accepted standard, but unistd.h says [quote] /* Get the pathname of the current working directory, and put it in SIZE bytes of BUF. Returns NULL if the directory couldn't be determined or SIZE was too small. If successful, returns BUF. In GNU, if BUF is NULL, an array is allocated with `malloc'; the array is SIZE bytes long, unless SIZE == 0, in which case it is as big as necessary. */ extern char *getcwd (char *__buf, size_t __size) __THROW __wur; [/quote] So, I assumed that if you just passed zero for both arguments it'd allocate the right amount of space itself and it'd save me having to deal with picking an arbitrary maximum filename length. EDIT: man getcwd says [quote] As an extension to the POSIX.1-2001 standard, Linux (libc4, libc5, glibc) getcwd() allocates the buffer dynamically using malloc(3) if buf is NULL. In this case, the allocated buffer has the length size unless size is zero, when buf is allocated as big as necessary. The caller should free(3) the returned buffer. [/quote]
[QUOTE=Samuka97;32537510]Thanks, that fixed it! I was passing a array instead of a matrix4 into it. Now I get a blank screen instead of a crash, but at least there's some progress. I'll try to mess around with the camera positions and see if I can find where the box is. [b]Edit:[/b] Okay, so I couldn't get the camera in a position to see the box, so I just re-copied the entire source from [url=http://content.gpwiki.org/index.php/Irrlicht:Physics]this tutorial[/url] to make sure everything was okay. But now it seems to crash in any line that references "device()": [cpp]while(device->run()) - Program received signal SIGSEGV, Segmentation fault. At G:\Samuka97\9. Projects\C++\Irrlicht\IrrlichtBase_IrrNewt\main.cpp:112 Debugger finished with status 0[/cpp] All I did differently was break down int main() into smaller functions like the tutorial was doing. I'm also not very experienced with C++ so please excuse me if it's something stupid I'm missing. Anyways, [url=http://pastebin.com/eYGv2Nsg]here's my code[/url], if you want to see it all put togheder.[/QUOTE] If you encounter crashes, debug it. I would think you should attempt to learn more C++ before using these libraries. The error is quite simple a NULL pointer, and that is because you never assign to the global device-variable, but instead create a local one in InitScene.
[QUOTE=ZeekyHBomb;32537857]If you encounter crashes, debug it. I would think you should attempt to learn more C++ before using these libraries. The error is quite simple a NULL pointer, and that is because you never assign to the global device-variable, but instead create a local one in InitScene.[/QUOTE] I know. I've learned quite a bit more C++ (although not enough apparently) since that last failed try with the std::list danmaku experiment. I'm just baffled that all these tutorials don't work, because I instantly assume every single tutorial on earth is meant to work perfectly if you just copy the code over. That's why I don't try any obvious fixes when following tutorials. [b]Edit:[/b] To put it more simply, whenever I run into an error using code from a tutorial, I just assume I've set my shit up wrongly and keep messing with the search directories and stuff instead of the tutorial's code, because I always think every tutorial has to be right. That's also why I didn't try just not passing arguments into NewtonCreate in the first place.
Perhaps you just need to be more aware of the errors then, because they usually tell you what and where something is wrong.
Anyone tried UDK? what is the main difference between it and XNA?
[QUOTE=marcin1337;32538171]Anyone tried UDK? what is the main difference between it and XNA?[/QUOTE] Well, UDK is a full-fledged engine for making games with a level editor, custom scripting language and a bunch of other stuff. XNA is not.
[QUOTE=marcin1337;32538171]Anyone tried UDK? what is the main difference between it and XNA?[/QUOTE] As you are asking in the programming forum, I'll say that the biggest difference is that UDK runs on it's own custom Javascript-like language, for which there is absolutely no documentation unless you have a unreal engine license. The best way to learn how to program in the UDK is probably to make use of an intellisense IDE to figure out where stuff is, because they arn't helping. We spent two semesters in UDK level design, and then in our final project class scrapped it all and learned unity in two weeks to make something we could actually program.
[url]http://msdn.microsoft.com/en-us/library/ms171542.aspx[/url] According to this, Windows Forms Buttons don't raise any right-click events... How do I work around this? They can't have possibly thought that no one would ever need a right-clickable button.
[QUOTE=RyanDv3;32540664][url]http://msdn.microsoft.com/en-us/library/ms171542.aspx[/url] According to this, Windows Forms Buttons don't raise any right-click events... How do I work around this? They can't have possibly thought that no one would ever need a right-clickable button.[/QUOTE] TBH at least I've been conditioned not to right-click on buttons. I just don't assume you can.
Yeah, right-clicking on buttons is unusual... and 'unusual' generally means 'bad' in UI design. Familiarity is one of the most important things.
[QUOTE=RyanDv3;32540664][url]http://msdn.microsoft.com/en-us/library/ms171542.aspx[/url] According to this, Windows Forms Buttons don't raise any right-click events... How do I work around this? They can't have possibly thought that no one would ever need a right-clickable button.[/QUOTE] Try making it a SplitButton? [url]http://stackoverflow.com/questions/1597320/split-button-in-net-winforms[/url]
-snip- I've got most of it working now and I know how to fix the rest.
Sorry, you need to Log In to post a reply to this thread.