• What do you need help with? V. 3.0
    4,884 replies, posted
[QUOTE=Anonim;32213723]This works for '[a:b]', but for '[a:b, c]' it ends up grouping ', c' together with 'b': [code]>>> r = r'\[(.+):(.+)(,\s*(.+))?\]' >>> re.search(r,'[0:10, 2]').groups() ('0', '10, 2', None, None) >>> re.search(r,'[0:10,2]').groups() ('0', '10,2', None, None)[/code][/QUOTE] Well, I think this happens because of your ".+" as it is greedy and swallows just everything coming. Replace it with your actual regex to match your numbers.
[QUOTE=Dienes;32213780]Well, I think this happens because of your ".+" as it is greedy and swallows just everything coming. Replace it with your actual regex to match your numbers.[/QUOTE] Yeah, this makes sense. [code]>>> r = r'\[' + rnum + ':' + rnum + r'(,\s*' + rnum + r')?\]' >>> re.search(r,'[0:10]').groups() ('0', '10', None, None) >>> re.search(r,'[0:10, 2]').groups() ('0', '10', ', 2', '2')[/code] Now to figure out how to avoid grouping the comma.
[QUOTE=Anonim;32213893]Yeah, this makes sense. [code]>>> r = r'\[' + rnum + ':' + rnum + r'(,\s*' + rnum + r')?\]' >>> re.search(r,'[0:10]').groups() ('0', '10', None, None) >>> re.search(r,'[0:10, 2]').groups() ('0', '10', ', 2', '2')[/code] Now to figure out how to avoid grouping the comma.[/QUOTE] Apparently, "(?:bla)" is a non-capturing group in Python. So, try: [CODE]r'\[' + rnum + ':' + rnum + r'(?:,\s*' + rnum + r')?\]'[/CODE]
[QUOTE=Samuka97;32197215]I'm working on a todo-list program, and I want to make it so when you tick a task, instead of it just popping away, I want it to fade out and then the tasks below it slowly move up. The question is, is there a formula you guys use for smooth movement? Like when you drag a slider, and instead of it just jumping to your mouse's position, it smoothly makes it way to it, accelerating and decelerating before it's end position.[/QUOTE] Garry posted a thing on his blog or something about this. I think the topic you are referring to is interpolation. [URL="http://paulbourke.net/miscellaneous/interpolation/"]http://paulbourke.net/miscellaneous/interpolation/[/URL] Linear interpolation is the most common form, and is known as Lerp in some libraries. I imagine if you have some kind of math utility library or class you may find pre-built methods there to handle different kinds of interpolation.
[QUOTE=Dienes;32213950]Apparently, "(?:bla)" is a non-capturing group in Python. So, try: [CODE]r'\[' + rnum + ':' + rnum + r'(?:,\s*' + rnum + r')?\]'[/CODE][/QUOTE] Strange, I tried this earlier and got an error, yet it works now. Must've made a typo. Either way, it does what it's supposed to do now. Thanks for the help.
I don't understand opengl view projections, how would I move the camera around and angle it? Thats the part I always have trouble with, drawing 3D and 2D objects at the same time, aswell
I try to make a script that changes the name between two files, how do I do that? What code should I use and stuff?
[QUOTE=Confuzzed Otto;32218988]I try to make a script that changes the name between two files, how do I do that? What code should I use and stuff?[/QUOTE] [CODE]rename a.jar temp.jar rename b.jar a.jar rename temp.jar b.jar[/CODE] ...and the other way around? What exactly do you need help with?
I have no idea how to do it :( I'll try that script thingy. This will make it much easier to change from 1.8 beta to 1.7.3 :D
[QUOTE=Map in a box;32218600]I don't understand opengl view projections, how would I move the camera around and angle it? Thats the part I always have trouble with, drawing 3D and 2D objects at the same time, aswell[/QUOTE] In modern OpenGL, you make your own projection and view matrix, and multiply that with every vertex's position.
I'm trying to get sound to play in this windows forum application I'm making, and I can't figure it out. [csharp] using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Media; namespace Whack_a_mole { public partial class Form1 : Form { double timerDouble; string Music = "E:\\documents\\programming resources\\OhgodwhatRemix.mp3"; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } public void playaudio(string s) { SoundPlayer mplayer = new SoundPlayer(); mplayer.SoundLocation = s; mplayer.Play(); } private void timer1_Tick(object sender, EventArgs e) { HitArea1.ForeColor = Color.Black; HitArea2.ForeColor = Color.Black; HitArea3.ForeColor = Color.Black; HitArea4.ForeColor = Color.Black; HitArea5.ForeColor = Color.Black; HitArea6.ForeColor = Color.Black; HitArea7.ForeColor = Color.Black; HitArea8.ForeColor = Color.Black; HitArea9.ForeColor = Color.Black; HitArea10.ForeColor = Color.Black; HitArea11.ForeColor = Color.Black; HitArea12.ForeColor = Color.Black; HitArea1.Text = ""; HitArea2.Text = ""; HitArea3.Text = ""; HitArea4.Text = ""; HitArea5.Text = ""; HitArea6.Text = ""; HitArea7.Text = ""; HitArea8.Text = ""; HitArea9.Text = ""; HitArea10.Text = ""; HitArea11.Text = ""; HitArea12.Text = ""; Random random = new Random(); int positionChosenInt = random.Next(0, 12); switch (positionChosenInt) { case 1: HitArea1.ForeColor = Color.Red; HitArea1.Text = "☺"; break; case 2: HitArea2.ForeColor = Color.Red; HitArea2.Text = "☺"; break; case 3: HitArea3.ForeColor = Color.Red; HitArea3.Text = "☺"; break; case 4: HitArea4.ForeColor = Color.Red; HitArea4.Text = "☺"; break; case 5: HitArea5.ForeColor = Color.Red; HitArea5.Text = "☺"; break; case 6: HitArea6.ForeColor = Color.Red; HitArea6.Text = "☺"; break; case 7: HitArea7.ForeColor = Color.Red; HitArea7.Text = "☺"; break; case 8: HitArea8.ForeColor = Color.Red; HitArea8.Text = "☺"; break; case 9: HitArea9.ForeColor = Color.Red; HitArea9.Text = "☺"; break; case 10: HitArea10.ForeColor = Color.Red; HitArea10.Text = "☺"; break; case 11: HitArea11.ForeColor = Color.Red; HitArea11.Text = "☺"; break; case 12: HitArea12.ForeColor = Color.Red; HitArea12.Text = "☺"; break; } } private void timeleft_timer_Tick(object sender, EventArgs e) { timerDouble -= 0.01; } private void startButton_Click(object sender, EventArgs e) { moleTimer.Enabled = true; playaudio(Music); } } } [/csharp] The error returned is [code] System.IO.FileNotFoundException was unhandled Message=Please be sure a sound file exists at the specified location. [/code] so for some reason it can't access the audio file. What am I doing wrong?
You need to encase [code] E:\\documents\\programming resources\\OhgodwhatRemix.mp3 [/code] in its own set of quotes, since there is a space in the path name, thus making that line: [code] string Music = "\"E:\\documents\\programming resources\\OhgodwhatRemix.mp3\""; [/code] Otherwise, it's looking for "E:\Documents\Programming" I think anyway, don't kill me if I'm wrong.
[QUOTE=Forumaster;32225410]You need to encase [code] E:\\documents\\programming resources\\OhgodwhatRemix.mp3 [/code] in its own set of quotes, since there is a space in the path name, thus making that line: [code] string Music = "\"E:\\documents\\programming resources\\OhgodwhatRemix.mp3\""; [/code] Otherwise, it's looking for "E:\Documents\Programming" I think anyway, don't kill me if I'm wrong.[/QUOTE] Thanks. It's still having issues, but I think I can work them out.
Is there any proper debugger for C++ in linux? My program builds fine but I run it and it just crashes, codeblocks says nothing and the console just says exited with -1
[QUOTE=Richy19;32225900]Is there any proper debugger for C++ in linux? My program builds fine but I run it and it just crashes, codeblocks says nothing and the console just says exited with -1[/QUOTE] gdb
[QUOTE=thf;32220826]In modern OpenGL, you make your own projection and view matrix, and multiply that with every vertex's position.[/QUOTE] A matrix allows you to offset vertices? :confused:
matrices are confusing, either learn them or assume that a matrix can transform vertices as a fact. If you want to have some idea of how, it's multiplying a 4x4 matrix by your vertex as if it were a 1x4 matrix. And by the way it multiplies, the top left 3x3 matrix represents both rotation and scaling of the vertex, the top right 1x3 represents offset, the bottom left 3x1 has something to do with perspective - I don't know much about it, the bottom right value is called the homogeneous coordinate, it also has something to do with perspective, but you should almost always keep it as 1 - again, not really too sure why.
[QUOTE=robmaister12;32228844]matrices are confusing, either learn them or assume that a matrix can transform vertices as a fact. If you want to have some idea of how, it's multiplying a 4x4 matrix by your vertex as if it were a 1x4 matrix. And by the way it multiplies, the top left 3x3 matrix represents both rotation and scaling of the vertex, the top right 1x3 represents offset, the bottom left 3x1 has something to do with perspective - I don't know much about it, the bottom right value is called the homogeneous coordinate, it also has something to do with perspective, but you should almost always keep it as 1 - again, not really too sure why.[/QUOTE] The four rows of the matrix correspond to the four components of the output vector, and the four columns correspond to the components of the input vector. The bottom row is usually all zero with a one in the rightmost cell, which leaves the w-component unmodified. In perspective projection, a value is entered in the third column of the bottom row, making w proportional to z (or depth). The actual process of perspective division is done in a separate step (a matrix on its own cannot produce perspective). The x- and y- coordinates are divided by w (which is now proportional to z), resulting in different scales at different distances. The whole process goes: object coordinates -> model matrix -> world coordinates -> view matrix -> eye coordinates -> perspective matrix -> clip coordinates -> perspective division -> normalized device coordinates Note that all these transformations are just by convention, and not mandatory. In a programmable pipeline you are free to use whatever coordinate systems or transformations are necessary to produce the result you want. However, when you finally output a position from a vertex shader with gl_Position, it is assumed to be in clip coordinates.
I have matrices down pretty well myself, but to a lot of people they're confusing. The w coordinate stuff still confuses me a bit, but I still have a vague idea of what's going on. Two other very common matrices you'll see: normal matrix for lighting, TBN matrix for normal mapping.
[code] gdb ./Gaem GNU gdb (GDB) Fedora (7.3-41.fc15) Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-redhat-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /home/richy/Documents/codeblocks/Gaem/bin/Debug/Gaem...done. (gdb) run Starting program: /home/richy/Documents/codeblocks/Gaem/bin/Debug/Gaem [Thread debugging using libthread_db enabled] Using OpenGL 2.1 Using GLEW 1.5.8 [Inferior 1 (process 6082) exited with code 01] [/code] No shit sherlock!! How the hell do I debug this shit? [code] valgrind ./Gaem ==6121== Memcheck, a memory error detector ==6121== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al. ==6121== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info ==6121== Command: ./Gaem ==6121== ==6121== Invalid read of size 4 ==6121== at 0x463998A: _mesa_make_extension_string (extensions.c:911) ==6121== by 0x4617437: _mesa_make_current (context.c:1514) ==6121== by 0x4597997: intelMakeCurrent (intel_context.c:974) ==6121== by 0x458BAD7: driBindContext (dri_util.c:196) ==6121== by 0x45853ECC: dri2_bind_context (dri2_glx.c:151) ==6121== by 0x4582D050: MakeContextCurrent (glxcurrent.c:269) ==6121== by 0x4582D1D3: glXMakeCurrent (glxcurrent.c:303) ==6121== by 0x804EF49: main (Main.cpp:18) ==6121== Address 0x4205db8 is 0 bytes inside a block of size 1 alloc'd ==6121== at 0x4005447: calloc (vg_replace_malloc.c:467) ==6121== by 0x4639B57: _mesa_make_extension_string (extensions.c:775) ==6121== by 0x4617437: _mesa_make_current (context.c:1514) ==6121== by 0x4597997: intelMakeCurrent (intel_context.c:974) ==6121== by 0x458BAD7: driBindContext (dri_util.c:196) ==6121== by 0x45853ECC: dri2_bind_context (dri2_glx.c:151) ==6121== by 0x4582D050: MakeContextCurrent (glxcurrent.c:269) ==6121== by 0x4582D1D3: glXMakeCurrent (glxcurrent.c:303) ==6121== by 0x804EF49: main (Main.cpp:18) ==6121== Using OpenGL 2.1 Using GLEW 1.5.8 ==6121== Conditional jump or move depends on uninitialised value(s) ==6121== at 0x404EDFA: sf::Renderer::SetShader(sf::Shader const*) (in /usr/local/lib/libsfml-graphics.so.2.0) ==6121== by 0x4395FFFF: ??? ==6121== ==6121== Conditional jump or move depends on uninitialised value(s) ==6121== at 0x404EC28: sf::Renderer::SetBlendMode(sf::Blend::Mode) (in /usr/local/lib/libsfml-graphics.so.2.0) ==6121== by 0x4395FFFF: ??? ==6121== ==6121== Conditional jump or move depends on uninitialised value(s) ==6121== at 0x404ED48: sf::Renderer::SetTexture(sf::Texture const*) (in /usr/local/lib/libsfml-graphics.so.2.0) ==6121== by 0x4054191: sf::Sprite::Render(sf::RenderTarget&, sf::Renderer&) const (in /usr/local/lib/libsfml-graphics.so.2.0) ==6121== by 0x4038F57: sf::Drawable::Draw(sf::RenderTarget&, sf::Renderer&) const (in /usr/local/lib/libsfml-graphics.so.2.0) ==6121== by 0x4395FFFF: ??? ==6121== ==6121== ==6121== HEAP SUMMARY: ==6121== in use at exit: 77,104,616 bytes in 3,609 blocks ==6121== total heap usage: 9,110 allocs, 5,501 frees, 87,886,690 bytes allocated ==6121== ==6121== LEAK SUMMARY: ==6121== definitely lost: 1,240 bytes in 10 blocks ==6121== indirectly lost: 0 bytes in 0 blocks ==6121== possibly lost: 22,336,741 bytes in 16 blocks ==6121== still reachable: 54,766,635 bytes in 3,583 blocks ==6121== suppressed: 0 bytes in 0 blocks ==6121== Rerun with --leak-check=full to see details of leaked memory ==6121== ==6121== For counts of detected and suppressed errors, rerun with: -v ==6121== Use --track-origins=yes to see where uninitialised values come from ==6121== ERROR SUMMARY: 6 errors from 4 contexts (suppressed: 66 from 14) [/code] This better not just be because I have intel Graphics card
[code] gluLookAt((float)Math.sin(pitch)*0.5f, (float)Math.cos(yaw)*0.5f, 5.0f, /* eye is at (0,0,5) */ 0.0f, 0.0f, 0.0f, /* center is at (0,0,0) */ 0.0f, 1.0f, 0.0f); [/code] I am not doing it right am I. I know you shouldnt use gluLookAt, I just dont know what else to use.
[QUOTE=Richy19;32242052]How the hell do I debug this shit?[/QUOTE] Your program didn't crash, so GDB has no reason to suspend it unless you set some breakpoints. If you have no idea where the problem is, a good start would be to set a breakpoint on main() and step through from there.
[QUOTE=Wyzard;32243576]Your program didn't crash, so GDB has no reason to suspend it unless you set some breakpoints. If you have no idea where the problem is, a good start would be to set a breakpoint on main() and step through from there.[/QUOTE] But it does crash, it crashes at renderWindow.Display()
No, it exited cleanly with a nonzero exit status. That's different than crashing (e.g. a segfault). The program didn't do what you expected, but as far as the OS is concerned, it ran to completion.
[QUOTE=Wyzard;32243912]No, it exited cleanly with a nonzero exit status. That's different than crashing (e.g. a segfault). The program didn't do what you expected, but as far as the OS is concerned, it ran to completion.[/QUOTE] Wouldn't linux tell you if it was a segfault aswell? [editline]11th September 2011[/editline] Since I still haven't got an answer, heres something new for you guys to tackle: Can I get an example of how to play a sound in Bass? There are examples but are way over complicated for what I need.
[QUOTE=Wyzard;32243912]No, it exited cleanly with a nonzero exit status. That's different than crashing (e.g. a segfault). The program didn't do what you expected, but as far as the OS is concerned, it ran to completion.[/QUOTE] So is there anything I can do?, SFML doesnt add any exit(1) neither do I so its something codeblocks must be adding. Things like this make me miss managed languages
I'd start disabling parts of the program ("#if 0" is good for that) until the problem goes away, then add things back to figure out what's triggering it.
[QUOTE=Wyzard;32244537]I'd start disabling parts of the program ("#if 0" is good for that) until the problem goes away, then add things back to figure out what's triggering it.[/QUOTE] Its when I use Display within an openGL context with Drawables (sprite/text)
[QUOTE=Map in a box;32242079][code] gluLookAt((float)Math.sin(pitch)*0.5f, (float)Math.cos(yaw)*0.5f, 5.0f, /* eye is at (0,0,5) */ 0.0f, 0.0f, 0.0f, /* center is at (0,0,0) */ 0.0f, 1.0f, 0.0f); [/code] I am not doing it right am I. I know you shouldnt use gluLookAt, I just dont know what else to use.[/QUOTE] What version of OpenGL are you targetting? gluLookAt only works within the fixed-function pipeline. If you're using anything newer than OpenGL 1.X (perhaps 2.X if you don't use shaders), you'll have to provide your own matrix math routines (either with a library or programming it from scratch). In OpenGL, there really is no such thing as a 'camera'. The projection matrix, if you use one, should [i]only[/i] be used for projection. The convention is to use the view or model-view matrix to handle orientation/position transformations. You must keep in mind that you are actually operating on the individual vertices, not on the 'camera' (which, again, does not exist!), so it is generally easiest to think of the transformations as [i]moving/rotating the world around the viewer[/i] instead of moving the viewer within the world. This means your view transformations will all be 'backwards' if you choose to think of it from a 'camera' perspective. These resources might be helpful: [url=http://www.songho.ca/opengl/gl_projectionmatrix.html]A derivation of the OpenGL projection matrix[/url] The wikipedia articles on [url=http://en.wikipedia.org/wiki/Rotation_matrix]matrix rotations[/url] and [url=http://en.wikipedia.org/wiki/Translation_matrix]translation[/url], which will compose your view and model matrices.
I decided to stick with working on me and my friends engine, thanks for that though I'll use it for reference
Sorry, you need to Log In to post a reply to this thread.