• What do you need help with? V. 3.0
    4,884 replies, posted
[QUOTE=ZeekyHBomb;30516037]iirc, display lists should be about as efficient as VBOs. VAOs are less efficient, because the attributes are stored in client-memory. [editline]17th June 2011[/editline] [url]http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=246468[/url][/QUOTE] I read somewhere that in modern implementations, display lists are implemented as VBOs anyway.
Would someone mind explaining how perspective projection matrices work? Basically, how I see it, you need to defide the x and y coordinates with the z coordinate. And as far as I know, with Matrix x Vector multiplication, I can only multiply a certain coordinate with some constant, and add that to the complete sum for that coordinate. No division there. I'm obviously missing something crucial and it's not as simple as that, but what is it?
How do I change the origin of my g.rotate(), I am trying to rotate a rectangle, but the rectangle rotates at the point of 0,0, and I want it so it rotates in the middle.
I don't really know the context there but usually you can't. You need to draw the triangle so that 0,0 is in it's center.
But then my rectangle would be partly off-screen, also, I would want it to move.
[QUOTE=Darwin226;30518373]Would someone mind explaining how perspective projection matrices work? Basically, how I see it, you need to defide the x and y coordinates with the z coordinate. And as far as I know, with Matrix x Vector multiplication, I can only multiply a certain coordinate with some constant, and add that to the complete sum for that coordinate. No division there. I'm obviously missing something crucial and it's not as simple as that, but what is it?[/QUOTE] Remember that A / B is the same as A * ( 1 / B ), so you can express division as a multiplication. [editline]17th June 2011[/editline] Like this is a matrix that scales a vector by 2: [code]2 0 0 0 2 0 0 0 2[/code] And this is one which divides it by two: [code]0.5 0 0 0 0.5 0 0 0 0.5[/code]
Yes, it divides by a constant. Try making a matrix that divides the x with z and you'll see what I mean. [editline]17th June 2011[/editline] [QUOTE=Staneh;30518756]But then my rectangle would be partly off-screen, also, I would want it to move.[/QUOTE] Oh, I thought it rotated around the 0,0 of the rectangle, not the entire scene. There's probably some method to rotate only the rectangle. There other thing I can think of is maybe you should do what I said, rotate it, and then move it when it's rotated. I don't know how that will work but it might.
I see what you mean, I think there must be another operation after transforming with the perspective matrix [editline]17th June 2011[/editline] Probably just manually dividing each component by the z value like you thought
[QUOTE=Ziks;30519022]I see what you mean, I think there must be another operation after transforming with the perspective matrix[/QUOTE] I think the operation you're referring to is the projection matrix, which happens before the perspective transformation.
So? Is it manually divided with the z? That would actually make sense since when I did the Matrix plaything I did it like that and the default OpenTK projection matrices worked. [editline]17th June 2011[/editline] It appears they are [url]http://www.opengl.org/resources/faq/technical/transformations.htm[/url]
[QUOTE=Darwin226;30518953]Yes, it divides by a constant. Try making a matrix that divides the x with z and you'll see what I mean. [editline]17th June 2011[/editline] Oh, I thought it rotated around the 0,0 of the rectangle, not the entire scene. There's probably some method to rotate only the rectangle. There other thing I can think of is maybe you should do what I said, rotate it, and then move it when it's rotated. I don't know how that will work but it might.[/QUOTE] Well, what i'm trying to accomplish is making a moving, rotating rectangle, all at the same time.
Can anyone give me a good explanation of how quaternions and quaternion rotation work?
-snip- fixed
[QUOTE=Overv;30518226]I read somewhere that in modern implementations, display lists are implemented as VBOs anyway.[/QUOTE] [B]May be[/B] implemented. Heck, if they wanted they could even do it the other way around!
I've made a slightly Blackjack-y card game as a very beginner thing. However, the way I've generated the numbers is more like a dice roll than picking from a deck. How much harder would it be to make it so that I couldn't have more than say 4 7s or 4 3s in a single game? [code] using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Random x = new Random(); int first = x.Next(1, 12); int second = x.Next(1, 12); int extra; string play = "Y"; int tot = (first + second); int cards = 2; string choice; bool stuck = false; Console.WriteLine("Welcome to Pontoon"); while (play == "Y") { Console.WriteLine("The cards you have been dealt are {0} and {1}, putting you on a total of {2}.", first, second, tot); while (tot < 21 && cards < 5) { Console.WriteLine("You are on {0}, and you currently have {1} cards in total.", tot, cards); Console.ReadLine(); Console.WriteLine("Do you wish to take another card?[Y/N]"); choice = (Console.ReadLine()); if (choice == "Y") { extra = x.Next(1, 12); tot = (tot + extra); cards++; Console.WriteLine("You are dealt another card, it is a {0}.", extra); } else { Console.WriteLine("You stuck on {0}.", tot); Console.ReadLine(); break; } } if (tot == 21) { Console.WriteLine("Pontoon!"); Console.ReadLine(); } if (tot > 21) { Console.WriteLine("You're bust!"); Console.ReadLine(); } if (cards == 5) { Console.WriteLine("Congratulations, you got 5 cards without busting. Winner!"); Console.ReadLine(); } Console.WriteLine("Play again?[Y/N]"); play = (Console.ReadLine()); first = x.Next(1,12); second = x.Next(1, 12); cards = 2; tot = (first + second); stuck = false; } } } } [/code]
[QUOTE=esalaka;30520838][B]May be[/B] implemented. Heck, if they wanted they could even do it the other way around![/QUOTE] That wouldn't really be efficient though.
Yeah, I doubt they'd be that silly :v:
What is the speed difference of 2D arrays and lists in C#? Currently I am using lists to store my tiles and items, and loop through the whole list and only draw or update the ones that are on screen. I can also put my map into a 2D array and only loop though specific indexes based on the current location of the camera. Which one is faster, and do the null references in the 2D array have any impact? Thanks for any help.
I want to write an asynchronous client/server socket wrapper where no function (except connect from the client maybe) blocks. Aaand I need it to be posix compatible. How do I call accept, recv, send without them blocking?
[url=http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html#blocking]Uh you make them sockets non-blocking[/url]?
[code] ..\source\network\network_server.cpp:18:18: error: 'F_SETFL' was not declared in this scope ..\source\network\network_server.cpp:18:27: error: 'O_NONBLOCK' was not declared in this scope ..\source\network\network_server.cpp:18:37: error: 'fcntl' was not declared in this scope[/code] oh what the hell And yes, I included the headers. Using MinGW
[QUOTE=Staneh;30518529]How do I change the origin of my g.rotate(), I am trying to rotate a rectangle, but the rectangle rotates at the point of 0,0, and I want it so it rotates in the middle.[/QUOTE] I would really like help with this.
[QUOTE=Staneh;30524822]I would really like help with this.[/QUOTE] Translate to the origin you want to rotate around, rotate, translate back.
[QUOTE=WeltEnSTurm;30524907]Translate to the origin you want to rotate around, rotate, translate back.[/QUOTE] I've been trying to use g.translate, what I did was: [cpp] b.translate(rectx - 20, recty - 20);[/cpp] The code says it needs to translate to the center of the rectangle, but it seems to be still rotating around the 0,0 axis of the level, but, the distance of the rectangle increased.
[QUOTE=Staneh;30524822]I would really like help with this.[/QUOTE] Could you give us code? I don't promise to help but it would be easier. [editline]17th June 2011[/editline] You should probably translate by -halfWidth, -halfHeight
[QUOTE=WeltEnSTurm;30524819][code] ..\source\network\network_server.cpp:18:18: error: 'F_SETFL' was not declared in this scope ..\source\network\network_server.cpp:18:27: error: 'O_NONBLOCK' was not declared in this scope ..\source\network\network_server.cpp:18:37: error: 'fcntl' was not declared in this scope[/code] oh what the hell And yes, I included the headers. Using MinGW[/QUOTE] Ooh, when you said POSIX compatible I was assuming you were working on a POSIX system. Look the function up on the msdn, it might be in a different header or there might be another function for Windows.
[QUOTE=Darwin226;30525192]Could you give us code? I don't promise to help but it would be easier. [editline]17th June 2011[/editline] You should probably translate by -halfWidth, -halfHeight[/QUOTE] Right. I am using a Timer, to increase an int value, which determines the rotation of my rectangle, the code for that: [cpp] rectrotation = new Timer(100, new RectRotationHandler()); class RectRotationHandler implements ActionListener{ public void actionPerformed(ActionEvent e){ rotation += 5; } } [/cpp] Now, for the drawing, I use a BufferedImage, like this: [cpp] public void drawRectangle(){ Graphics2D b = buffer.createGraphics(); if(b instanceof Graphics2D){ b.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); b.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } int rectx = 80; int recty = 80; b.rotate(rotation * Math.PI / 180); b.setColor(Color.RED); b.drawRect(rectx,recty,40,40); }[/cpp] The rectangle is drawn with a simple drawRect(), and the rotation is done by doing b.rotate(), with as parameter the rotation int, which is being increased by the timer, so it rotates automatically. Now, I need to mess with the b.translate, so it doesn't rotate around the 0,0 axis of my level, but I have no idea how. [editline]17th June 2011[/editline] [QUOTE=Darwin226;30525192]Could you give us code? I don't promise to help but it would be easier. [editline]17th June 2011[/editline] You should probably translate by -halfWidth, -halfHeight[/QUOTE] Look at post #506
[QUOTE=Staneh;30525330][cpp] public void drawRectangle(){ Graphics2D b = buffer.createGraphics(); if(b instanceof Graphics2D){ b.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); b.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } int rectx = 80; int recty = 80; b.rotate(rotation * Math.PI / 180); b.setColor(Color.RED); b.drawRect(rectx,recty,40,40); }[/cpp][/QUOTE] [cpp] public void drawRectangle(){ Graphics2D b = buffer.createGraphics(); if(b instanceof Graphics2D){ b.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); b.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } int rectx = 80; int recty = 80; b.translate(20, 20); b.rotate(rotation * Math.PI / 180); b.translate(-20, -20); b.setColor(Color.RED); b.drawRect(rectx,recty,40,40); }[/cpp] I said after translating and rotating, translate back. If this doesn't work, change 20 to -20 and -20 to 20.
[QUOTE=WeltEnSTurm;30524819][code] ..\source\network\network_server.cpp:18:18: error: 'F_SETFL' was not declared in this scope ..\source\network\network_server.cpp:18:27: error: 'O_NONBLOCK' was not declared in this scope ..\source\network\network_server.cpp:18:37: error: 'fcntl' was not declared in this scope[/code] oh what the hell And yes, I included the headers. Using MinGW[/QUOTE] try ioctl
Never mind, I got it.
Sorry, you need to Log In to post a reply to this thread.