• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=acarvromvroom;46828064]You're right, I was multiplying them in the wrong order rotation is fine now, thanks. I still have no clue how to move to screen space coordinates though. I could interpolate the positions when setting the translation and scale vectors, but that'd be quite hacky, I know that projection matrices do this but they are all 4x4.[/QUOTE] I'm not really sure about the terminology here. In any case, after your camera transforms the world coordninates you need to do another transformation into the (-1, -1) to (1, 1) rectangle. It's just a scale and a translate. Let's see. If you want to map a rectangle with (0, 0) in the bottom left and (width, height) in the top right to a rectangle with (-1, -1) in bottom right and (1, 1) in the top left the matrix should be something like [code] 2/width 0 -1 0 2/height -1 0 0 0[/code] Play with that a bit. The aspect ratio transform should come after that.
[QUOTE=Darwin226;46828189]I'm not really sure about the terminology here. In any case, after your camera transforms the world coordninates you need to do another transformation into the (-1, -1) to (1, 1) rectangle. It's just a scale and a translate. Let's see. If you want to map a rectangle with (0, 0) in the bottom left and (width, height) in the top right to a rectangle with (-1, -1) in bottom right and (1, 1) in the top left the matrix should be something like [code] 2/width 0 -1 0 2/height -1 0 0 0[/code] Play with that a bit. The aspect ratio transform should come after that.[/QUOTE] Thank you, that worked perfectly, and strangely it does the aspect ratio fix too so I have to discard the previous one for it to work right. So far I've understood everything but the mapping, I get the last column so that it translates everything to the top left of the screen so 0, 0 is there and not in the center, but why the scale that way? You have to scale everything so a 10 pixels to the right is translate(10, 0) and not translate(0.01, 0) or similar, but why 2 if the maximum is 1, so you divide the max by the resolution you want? [editline]asd[/editline] Never mind I get it now, it's because it starts at -1, so it's not the max, it's the total, and the total is 2. So 2/resolution will scale everything down to the right size. Everything works and everything makes sense, thanks a lot.
[QUOTE=Tamschi;46826914][code]hg clone -r 994f9a94e406 https://bitbucket.org/Tamschi/tq-tools C:\projects\tq-tools cd tq-tools nuget restore[/code] Doesn't build. I have no clue why, but during build (not editing!) it says it can't find [I]Ablicht[/I] from where it's used in [I]TextureItem.cs[/I] in [I]Meshview[/I]. I think it's a problem with [I]Ablicht[/I], but I have no idea what the reason is :( [editline]31st December 2014[/editline] Nevermind, apparently there's some duplicate import weirdness that's invisible in VS. [editline]31st December 2014[/editline] No, still broken :([/QUOTE] I found it. I had accidentally renamed the assemblies to have the name file name when copy-pasting between two project files.
[QUOTE=acarvromvroom;46828516]Thank you, that worked perfectly, and strangely it does the aspect ratio fix too so I have to discard the previous one for it to work right. So far I've understood everything but the mapping, I get the last column so that it translates everything to the top left of the screen so 0, 0 is there and not in the center, but why the scale that way? You have to scale everything so a 10 pixels to the right is translate(10, 0) and not translate(0.01, 0) or similar, but why 2 if the maximum is 1, so you divide the max by the resolution you want? [editline]asd[/editline] Never mind I get it now, it's because it starts at -1, so it's not the max, it's the total, and the total is 2. So 2/resolution will scale everything down to the right size. Everything works and everything makes sense, thanks a lot.[/QUOTE] Glad I could help! I was wondering if it would do the aspect ratio transform automatically.
Hey just got a Mac to do programming on, and I'm having trouble using Android Studio on Yosemite. When I try run it, it says no JVM is found. I know I can fix the error for each run by putting: [code]$ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk $ open /Applications/Android\ Studio.app[/code] in the terminal. Just wondering how I could set it up so it always does that with the exe so I don't have to run it in the terminal every time
[QUOTE=Over-Run;46829288]Hey just got a Mac to do programming on, and I'm having trouble using Android Studio on Yosemite. When I try run it, it says no JVM is found. I know I can fix the error for each run by putting: [code]$ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk $ open /Applications/Android\ Studio.app[/code] in the terminal. Just wondering how I could set it up so it always does that with the exe so I don't have to run it in the terminal every time[/QUOTE] Idk about OSX, but in other Unix OS's you can add that to your .profile file
I'm trying out OpenGL again. I am following the tutorial on [url]www.open.gl[/url], just like last time. But now that I'm at the Element Buffer part, nothing works. I took the source code from [url=https://open.gl/content/code/c2_triangle_elements.txt]here[/url]. Copy/pasted it and changed the syntax to Java (For lwjgl). Full code [url=http://pastebin.com/VbH5VJyp]here[/url]. Now, when I run it I get an error GL_INVALID_OPERATION after each glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0). If I use glDrawArrays(GL_TRIANGLES, 0, 6), it does draw half the quad.
If you change GL_TRIANGLES to GL_POLYGON it should work. I think the vertices are a bit weird because I noticed the same thing with some of the code segments on open.gl.
[QUOTE=G4MB!T;46834850]If you change GL_TRIANGLES to GL_POLYGON it should work. I think the vertices are a bit weird because I noticed the same thing with some of the code segments on open.gl.[/QUOTE] Tried it, didn't work. It just changed the error ID to GL_INVALID_ENUM.
Ok sorry about that. I just read the man-page and GL_POLYGON isnt supported by glDrawElements. What are the vertices you are using? Keep in mind that if you are using GL_TRIANGLES your vertices need to in clockwise order in a triangle format (ie: top left, top right, bottom left, top right, bottom right, bottom left).
Right so I've drew up yet another idea for a little game in my head and planned it all out, but I'm not sure what to use to build it in. Basically the game will be heavy on UI elements with a lot of text and such, and I want to be able to publish it on mobile. I know unity but in my opinion it feels a little "heavy" for a UI focused mobile game. But on the other hand, because there would be so much UI work I don't want to spend a year in a code editor typing pixel coordinates in to build the game. Can anyone point me in the right direction?
[QUOTE=PieClock;46838440]Right so I've drew up yet another idea for a little game in my head and planned it all out, but I'm not sure what to use to build it in. Basically the game will be heavy on UI elements with a lot of text and such, and I want to be able to publish it on mobile. I know unity but in my opinion it feels a little "heavy" for a UI focused mobile game. But on the other hand, because there would be so much UI work I don't want to spend a year in a code editor typing pixel coordinates in to build the game. Can anyone point me in the right direction?[/QUOTE] I'd still suggest Unity for that to be honest. The new UI system is pretty awesome and sounds like a perfect fit for what you want to make.
Yeah I've been taking a closer look at that over the last few hours. Definitely seems like it could be a winner.
[QUOTE=LuaChobo;46834339]I'm encountering an issue with C# that I have never encountered before and I can't find anything about it on the internet. Basically when I'm debugging it within visual studio 2013 its all fine, but when I try to run it outside of visual studio an empty console window pops up for about 10 seconds, closes and then the actual application opens i have no idea whats going on, I noticed that if I disable some debug stuff with visual studio it does it when im trying to debug aswell why the fuck is debugging faster edit: its doing it with fresh and essentially empty projects too[/QUOTE] This happens to me with some IDEs where I select "windows console application" or something like that as the preset. Are you sure you're compiling [i]totally[/i] empty projects?
Trying to make a small simple Android app to query themoviedb and show the most popular films. I'm just wondering has anybody used their API before? I'm just not sure how to use it within Android studio. I have my API key and stuff just don't know how to combine it all together in Android studio.
[QUOTE=Zyx;46834783]I'm trying out OpenGL again. I am following the tutorial on [url]www.open.gl[/url], just like last time. But now that I'm at the Element Buffer part, nothing works. I took the source code from [url=https://open.gl/content/code/c2_triangle_elements.txt]here[/url]. Copy/pasted it and changed the syntax to Java (For lwjgl). Full code [url=http://pastebin.com/VbH5VJyp]here[/url]. Now, when I run it I get an error GL_INVALID_OPERATION after each glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0). If I use glDrawArrays(GL_TRIANGLES, 0, 6), it does draw half the quad.[/QUOTE] The docs say this about glDrawElements "GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to an enabled array or the element array and the buffer object's data store is currently mapped"
I need some help with fread. I want to load a byte into an integer. I have: [code] int xWidth; fread(xWidth, sizeof(int), 2, img); //img is the file pointer. [/code] but I get the warning: [code] collin@collin-notebook:~/Documents/Code/C/CurseIMG$ gcc curseimg.c -o curseimg -std=c11 -lncurses curseimg.c: In function ‘main’: curseimg.c:28:3: warning: passing argument 1 of ‘fread’ makes pointer from integer without a cast [enabled by default] fread(xWidth, sizeof(int), 2, img); ^ In file included from curseimg.c:1:0: /usr/include/stdio.h:709:15: note: expected ‘void * restrict’ but argument is of type ‘int’ extern size_t fread (void *__restrict __ptr, size_t __size, ^ collin@collin-notebook:~/Documents/Code/C/CurseIMG$ [/code] and I get a segmentation fault when I try to use [code] printf("%d",xWidth);[/code]
how do you make a server wrapper? I assumed all you had to do was start a server, listen on a port and forward the data to the servers port and server data back to the correct client, doing whatever with the data you wanted before, but I can't get that working at all, so I'm a bit lost like I'm not even touching the data right now and just forwarding it
[QUOTE=proboardslol;46843614]I need some help with fread. I want to load a byte into an integer. I have: [code] int xWidth; fread(xWidth, sizeof(int), 2, img); //img is the file pointer. [/code] but I get the warning: [code] collin@collin-notebook:~/Documents/Code/C/CurseIMG$ gcc curseimg.c -o curseimg -std=c11 -lncurses curseimg.c: In function ‘main’: curseimg.c:28:3: warning: passing argument 1 of ‘fread’ makes pointer from integer without a cast [enabled by default] fread(xWidth, sizeof(int), 2, img); ^ In file included from curseimg.c:1:0: /usr/include/stdio.h:709:15: note: expected ‘void * restrict’ but argument is of type ‘int’ extern size_t fread (void *__restrict __ptr, size_t __size, ^ collin@collin-notebook:~/Documents/Code/C/CurseIMG$ [/code] and I get a segmentation fault when I try to use [code] printf("%d",xWidth);[/code][/QUOTE] If you want byte to int, you need sizeof(byte) and cast it into int later. And you need to pass pointer into fread functio, not int. That is why you get segmentation fault, because it excepts pointer where it can write to. Also you are inputing '2' into fread function, which means it will read 2 two times. I think you want 1 byte? [code] byte* xWidth_pointer; int xWidth; fread(xWidth_pointer, sizeof(byte), 1, img); //img is the file pointer. xWidth = (int)(*xWidth_pointer); //dereferencing. [/code] Read a bit about pointers, to clear things up. If you don't, you won't be able to do shit in C. [url]http://boredzo.org/pointers/[/url] [editline]3rd January 2015[/editline] [QUOTE=Shadaez;46843910]how do you make a server wrapper? I assumed all you had to do was start a server, listen on a port and forward the data to the servers port and server data back to the correct client, doing whatever with the data you wanted before, but I can't get that working at all, so I'm a bit lost like I'm not even touching the data right now and just forwarding it[/QUOTE] Depends for what use and what level of wrapper? Yes you need to start some sort of process, listen on port and then parse data, process it and if needed, send it back to same client. I don't get what you mean by listen on a port and forward data to the servers port? Like, you have one process/computer for parsing data and passing data to another server? So you want two servers/two threads that serve? You see you are a bit funky with idea here.
[QUOTE=Fourier;46844049]If you want byte to int, you need sizeof(byte) and cast it into int later. And you need to pass pointer into fread functio, not int. That is why you get segmentation fault, because it excepts pointer where it can write to. Also you are inputing '2' into fread function, which means it will read 2 two times. I think you want 1 byte? [code] byte* xWidth_pointer; int xWidth; fread(xWidth_pointer, sizeof(byte), 1, img); //img is the file pointer. xWidth = (int)(*xWidth_pointer); //dereferencing. [/code] Read a bit about pointers, to clear things up. If you don't, you won't be able to do shit in C. [url]http://boredzo.org/pointers/[/url][/QUOTE] Do you mean char, not byte? byte isn't a primitve [editline]2nd January 2015[/editline] also it gives me segmentation fault [editline]2nd January 2015[/editline] ahh fuck I forgot to malloc the pointer.
[QUOTE=proboardslol;46844475]Do you mean char, not byte? byte isn't a primitve [editline]2nd January 2015[/editline] also it gives me segmentation fault [editline]2nd January 2015[/editline] ahh fuck I forgot to malloc the pointer.[/QUOTE] Dude wtf it's c, how is there no byte? ... yeah I see, it's char. Ok, I hope I helped you out :).
Yeah It helped. I thought it had something to do with that but when I didn't malloc the pointer it would give me a segmentation fault so I had ruled that out as a solution. Also I don't need an entirely separate integer, I can just reference the pointer itself
[QUOTE=Fourier;46844049]Depends for what use and what level of wrapper? Yes you need to start some sort of process, listen on port and then parse data, process it and if needed, send it back to same client. I don't get what you mean by listen on a port and forward data to the servers port? Like, you have one process/computer for parsing data and passing data to another server? So you want two servers/two threads that serve? You see you are a bit funky with idea here.[/QUOTE] I mean like, a server wrapper for a game's server, how are those made? To add functionality like /commands or whatever. like [url]https://github.com/CarrotsAreMediocre/StarryPy[/url] they seem to be running starbound server and then the starrypy wrapper and doing what I described, i think? there's a whole lot of code to figure out what's going on though
Pardon someone who's learning, but I've been looking over this code for the past age, and I honest to god can't find what's going wrong, I think I'm missing something on how Python treats objects. My goal is to multiply together two polynomials. Here's my code so far in relevant methods. [code] def mul(self, p2): if len(self.coefficients) < len(p2.coefficients): longlength = len(p2.coefficients) else: longlength = len(self.coefficients) print "NOT YET IN FOR LOOP\n POLYNOMIAL 1: " + str(self) + "\n POLYNOMIAL 2: " + str(p2) templist = list([0] * longlength) answer = Polynomial(templist) length = len(self.coefficients) print "Entering FOR loop" for i in range(length): temppoly = Polynomial(p2.coefficients) temppoly = temppoly.scalarmul(self.coefficients[i]) powerIncrease = length - i - 1 print "ITERATION VALUE : " + str(i) print "WHAT SHOULD BE THE POWER INCREASE : " + str(powerIncrease) print "PRE POWER INCREASE:\n POLYNOMIAL 1: " + str(self) + "\n POLYNOMIAL 2: " + str(p2) + "\n" if powerIncrease > 0: temppoly = temppoly.increasePower(powerIncrease) print "POST POWER INCREASE" print "POLYNOMIAL 1: " + str(self) print "POLYNOMIAL 2: " + str(p2) print "TEMPORARY POLYNOMIAL: " + str(temppoly) answer += temppoly del temppoly return answer [/code] Here's where I think I've pinpointed the issue, in the increasePower method. I have no idea what I'm fucking up here. [code] def increasePower(self, n): if n <= 0: return Polynomial(self.coefficients) temp = Polynomial(self.coefficients) extension = list([0] * n) temp.coefficients.extend(extension) return temp [/code] There's a lot of stuff that's probably redundant, but that's the result of trying to find the error for way too long. For the record, here's what I'm getting vs what I should get. [code] >>> p = Polynomial([1, 2]) >>> p2 = p >>> p.mul(p2) NOT YET IN FOR LOOP POLYNOMIAL 1: 1.000 z + 2.000 POLYNOMIAL 2:1.000 z + 2.000 Entering FOR loop ITERATION VALUE : 0 WHAT SHOULD BE THE POWER INCREASE : 1 PRE POWER INCREASE: POLYNOMIAL 1: 1.000 z + 2.000 POLYNOMIAL 2: 1.000 z + 2.000 POST POWER INCREASE POLYNOMIAL 1: 1.000 z**2 + 2.000 z + 0.000 POLYNOMIAL 2: 1.000 z**2 + 2.000 z + 0.000 TEMPORARY POLYNOMIAL: 1.000 z**2 + 2.000 z + 0.000 ITERATION VALUE : 1 WHAT SHOULD BE THE POWER INCREASE : 0 PRE POWER INCREASE: POLYNOMIAL 1: 2.000 z**2 + 4.000 z + 0.000 POLYNOMIAL 2: 2.000 z**2 + 4.000 z + 0.000 POLYNOMIAL 1: 2.000 z**2 + 4.000 z + 0.000 POLYNOMIAL 2: 2.000 z**2 + 4.000 z + 0.000 TEMPORARY POLYNOMIAL: 2.000 z**2 + 4.000 z + 0.000 3.000 z**2 + 6.000 z + 0.000 [/code] I should be getting [code] 1.000 z**2 + 4.000 z + 4.000 [/code] Any help at all would be greatly appreciated. Please feel free to reprimand me for any mistakes within the code, or how it's posted.
[QUOTE=proboardslol;46844475]Do you mean char, not byte? byte isn't a primitve [editline]2nd January 2015[/editline] also it gives me segmentation fault [editline]2nd January 2015[/editline] ahh fuck I forgot to malloc the pointer.[/QUOTE] Why not just use a stack allocated char and get its address with the & operator? [code] char byte; fread (&byte, sizeof (char), 1, img); int xwidth = (int) byte; [/code] Also I can think of another solution but it's probably not portable or even works. [code] int xwidth = 0; fread (&xwidth, sizeof (char), 1, img); [/code]
[QUOTE=elevate;46847343]Why not just use a stack allocated char and get its address with the & operator? [code] char byte; fread (&byte, sizeof (char), 1, img); int xwidth = (int) byte; [/code] Also I can think of another solution but it's probably not portable or even works. [code] int xwidth = 0; fread (&xwidth, sizeof (char), 1, img); [/code][/QUOTE] The second one seems more intuitive to me, but what's exactly wrong with it?
[QUOTE=proboardslol;46848296]The second one seems more intuitive to me, but what's exactly wrong with it?[/QUOTE] Everything. It's undefined in C whether a "char" is signed or unsigned. It's undefined in how signed numbers (signed chars, ints) are internally represented. It's undefined what the byte order of a multibyte integer is. Suppose that you're on a 64-bit big-endian system and using a compiler where the char is signed, "int" is optimized to 8 bytes and signed numbers use two's complement. The code [cpp]int xwidth = 0; fread (&xwidth, sizeof (char), 1, img);[/cpp] would in such a case result in xwidth's most significant byte being modified. The positive values would be around [i]9151314442816847872[/i].
My application doesn't close the console window when I exit my main()-function. Is this a common issue?
[QUOTE=war_man333;46848759]My application doesn't close the console window when I exit my main()-function. Is this a common issue?[/QUOTE] Which language and do you start any threads not marked as "background"?
[QUOTE=Tamschi;46849604]Which language and do you start any threads not marked as "background"?[/QUOTE] It magically solved itself, out of nowhere. But since you ask so nicely, C++ and not creating any threads.
Sorry, you need to Log In to post a reply to this thread.