• What do you need help with? Version 1
    5,001 replies, posted
Hey. So here's the deal, at my house we have 3 laptops and 2 desktops, all of them holding data that needs to be backed up at least once a month. So far, my dad and I (my mom doesn't know anything about IT so we handle it for her) just plug an external hdd to each of the machines at a time and copy over whatever, but that's a tedious and human-error prone method, not to mention that it's a bitch to manage conflicts between files altered on different machines. So, since we're moving soon and the PCs will be further away in the house, but we'll have a LAN all trough out, what I wanna do is setup a synchronization system. Basically, one server machine with loads of storage that has permission to access the individual PCs and copy over to its disk whatever files are different from the server's copy. Besides all the security, passive vs. active, "omg large files might be a problem", [I]et al [/I]discussion, I have 2 questions: 1) my idea for file comparison was to recursively generate a SHA1 hash from the root directory down, and compare hashes pre-sync to know what needs to be copied. (a bit like git does) Is this a good idea? Are there any other choices? SHA1 vs. MD5 vs. anything else? 2) I'm thinking of writing the server and client software in c++. Are there better choices? Final note: we run a mix of linux and windows on the laptops and desktops. The sync/data server will be running linux. Thanks in advance. ps: should this be in its own post?
[QUOTE=Wishfallen;21137624]Are you making DisplayObject inherit GameComponent? Should look something like this [cpp] public class DisplayObject : GameComponent { SpriteBatch spriteBatch; public DisplayObject(Game game) : base(game) { // constructor stuff } public override void Initialize() { spriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch)); } public override void Update(GameTime timing) { // update stuff base.Update(timing); } } [/cpp] If you need draw, make the first line: [cpp] public class DisplayObject : GameComponent, IDrawable [/cpp] and then implement the interface (VS does this for you if you click the name of the interface, mouse over the dropdown box, click and then select Implement Interface)[/QUOTE] Or you can inherit DrawableGameComponent.
This is showing me an exception at line 30 (person = new GOval). I think it has something to do with the 'random.nextInt' methods I'm calling. [cpp] /* This program creates a crowd of randomly placed circles * which move and bounce off each other and the walls of the window. */ import acm.program.*; import acm.util.*; import acm.graphics.*; public class Crowd extends GraphicsProgram { public static final int APP_WIDTH = 800; public static final int APP_HEIGHT = 600; public static final int NUM_PEOPLE = 15; public static final int SIZE_PEOPLE = 20; private RandomGenerator random; private GOval person; public void run() { setup(); //startMoving(); } /* Creates the circles, one by one, at random positions, filled with random colors.*/ private void setup() { setSize(APP_WIDTH,APP_HEIGHT); for (int i = 1; i < NUM_PEOPLE; i++) { person = new GOval (random.nextInt(SIZE_PEOPLE,(APP_WIDTH - SIZE_PEOPLE)), random.nextInt(SIZE_PEOPLE,(APP_HEIGHT - SIZE_PEOPLE)), SIZE_PEOPLE,SIZE_PEOPLE); person.setFilled(true); person.setFillColor(random.nextColor()); add(person); } } } [/cpp]
Draw (vector drawing like lines, dots, circles) in XNA is pretty much out of the question right? I mean, I wanted to draw a pixel and the way people recommended is to use 1x1 sized pictures... If I could draw a pixel I could easily make my draw line function.
Stupid question here... [cpp]main() { printf("Hello World\n"); char* Str; while(1) { scanf("%s", Str); if(!strcmp(Str, "Say hi")) { printf("Hi!\n"); } else if(!strcmp(Str, "exit")) { return 0; } } return 0; }[/cpp] For some reason, when I run it, Win7 tells me that the program has stopped working, and then the command prompt ends up with this: [code] Hello world! Say hi [/code]
[QUOTE=Nikita;21170409]Stupid question here... main() { printf("Hello World\n"); char* Str; while(1) { scanf("%s", Str); if(!strcmp(Str, "Say hi")) { printf("Hi!\n"); } else if(!strcmp(Str, "exit")) { return 0; } } return 0; } For some reason, when I run it, Win7 tells me that the program has stopped working, and then the command prompt ends up with this: [code] Hello world! Say hi [/code][/QUOTE] You're trying to scanf into an invalid pointer. char* doesn't magically become a string, it's just a pointer to string.
Ok.. it does not crash with char Str[64]; but for some reason it still lags for 30 secs before even displaying anything.
Looking for clarification on Box2D. Does the position set in a b2BodyDef apply to the centre of the body rather than the corner? I think it does but I'm not sure. Also what is the best way of creating a body that won't move? [editline]Edited:[/editline] The source for b2Body.h shows that there is a static flag but I can find no way of setting it.. :confused:
Yea center
Thanks null. And, success! I made a static object, sort of. I used b2World::GetGroundBody and used that to create a shape.
I'm not 100% sure but I think setting the mass/density to 0 was for making a body static. [editline]07:18PM[/editline] That or Box2D had some sort of enum/class difference for dynamic vs. static bodies. Just check the docs.
[QUOTE=nullsquared;21173911]I'm not 100% sure but I think setting the mass/density to 0 was for making a body static. [editline]07:18PM[/editline] That or Box2D had some sort of enum/class difference for dynamic vs. static bodies. Just check the docs.[/QUOTE] I'll have a play tomorrow with the density and mass. The manual appears to be out of date (or I'm out of date :v:), it talks about creating fixtures but I have no such methods in my Box2D.
[QUOTE=nullsquared;21173911]I'm not 100% sure but I think setting the mass/density to 0 was for making a body static. [editline]07:18PM[/editline] That or Box2D had some sort of enum/class difference for dynamic vs. static bodies. Just check the docs.[/QUOTE] This is correct, setting the density to 0 makes the shape static (don't forget to call SetMassFromShapes() on the body). [QUOTE=Turd92;21174545]I'll have a play tomorrow with the density and mass. The manual appears to be out of date (or I'm out of date :v:), it talks about creating fixtures but I have no such methods in my Box2D.[/QUOTE] Fixtures are used in the Flash (AS3) port of Box2D, is that what you're using? [editline]01:46PM[/editline] Oh, I'm a little outdated, turns out the C++ version has been updated and is now using fixtures too, my bad.
[QUOTE=Z_guy;21174547]This is correct, setting the density to 0 makes the shape static (don't forget to call SetMassFromShapes() on the body).[/QUOTE] Alright, thanks both of you, gave you tools. They aren't appearing for me though :v: [editline]Edited:[/editline] No, C++ version. That might be why I was getting confused then!
[QUOTE=Turd92;21174610]Alright, thanks both of you, gave you tools. They aren't appearing for me though :v:[/QUOTE] I think 2 people need to rate someone the same thing, or blues can't rate. Can't remember.
[QUOTE=Turd92;21174610]No, C++ version. That might be why I was getting confused then![/QUOTE] Are you using the latest version? Because fixtures was added in the latest version (released two days ago). The latest version also has a flag for making the body static, instead of setting the density to zero.
[QUOTE=Z_guy;21174810]Are you using the latest version? Because fixtures was added in the latest version (released two days ago). The latest version also has a flag for making the body static, instead of setting the density to zero.[/QUOTE] I don't think I have it, I'll update it now. Thanks!
I thought about how to draw pixels in XNA and got an idea, tell me if it's a good option. So I make a Texture2D the size of the window, i use t2D.getData to fill an array with pixel data. Then make my own function for changing specific pixels in that array to colors I wanted and then use setData to apply the changes to the texture This seems to be a pretty fast method of doing it except for the setData part so I'm wondering how long it would took to take and if it could be done every tick.
It's a really slow way to do it, when you get the texture you will be copying all the pixels from the graphics card to the main memory, then when you finish your slow edits on the cpu you will upload it slowly to the gpu again. Much much better to use shaders.
Simply, I'm trying to read three, four byte floats from a file. The problem is eight bytes are read for each float, trashing the loading sequence. I'm using Fedora 12 and Qt 4.6.2. pcfStream is a QDataStream. If pFloat is changed to a double, the floating point accuracy increases, but the same number of bytes are read. [code]case ATTRIBUTE_FLOAT: { float *pFloat = new float; pcfStream >> *pFloat; return pFloat; }[/code] The three floats in hex: [quote]00 00 20 C1 00 00 20 C1 00 00 20 C1[/quote] The three floats in base ten: [quote]-10 -10 -10[/quote] The three floats when incorrectly read: [quote]-524288 0 0[/quote] Size sample: [quote]Sizeof() Int: 4 Long: 4 Float: 4 Double: 8[/quote] So, the best I can figure a double is read, then cast to a float. Any idea what's causing this behaviour? Fixed. Apparently that was exactly what was happening. [quote]void QDataStream::setFloatingPointPrecision ( FloatingPointPrecision precision ) Sets the floating point precision of the data stream to precision. If the floating point precision is DoublePrecision and the version of the data stream is Qt_4_6 or higher, all floating point numbers will be written and read with 64-bit precision. If the floating point precision is SinglePrecision and the version is Qt_4_6 or higher, all floating point numbers will be written and read with 32-bit precision. For versions prior to Qt_4_6, the precision of floating point numbers in the data stream depends on the stream operator called. The default is DoublePrecision. Warning: This property must be set to the same value on the object that writes and the object that reads the data stream. This function was introduced in Qt 4.6.[/quote]
So I decided to make a mandelbrot renderer (yeah yeah, rate me clocks) I managed to screw it up though: [img]http://imgkk.com/i/v3hu.png[/img] help?
Let's have a looksee at your code
[code] public Bitmap DrawMandel(int w, int h, Complex min, Complex max) { Bitmap img = new Bitmap(w, h); var lb = img.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); unsafe { LinSpace xvals = new LinSpace(min.Re, max.Re, w); LinSpace yvals = new LinSpace(min.Im, max.Im, h); int i = 0; byte* p = (byte*)lb.Scan0; foreach (var y in yvals) { foreach (var x in xvals) { var mx = x; var my = y; int iter = 0; while (mx * mx + my * my < (2 * 2) && iter < maxiters) { var xtemp = mx * mx - my * my + mx; my = 2 * mx * my + my; mx = xtemp; iter++; } byte c; if (iter == maxiters) c = 0; else c = (byte)(255 - iter); p[i++] = c; p[i++] = c; p[i++] = c; } } } img.UnlockBits(lb); return img; } [/code]
I have no idea how to use shaders or how to implement the in my program.
[QUOTE=Darwin226;21184611]I have no idea how to use shaders or how to implement the in my program.[/QUOTE] [url]http://creators.xna.com/en-US/article/shader_primer[/url] Tutorials for shaders and XNA
[QUOTE=turb_;21183780][code]<Mandelbrot code>[/code][/QUOTE] I don't fully understand your code, but [code]var xtemp = mx * mx - my * my + mx; my = 2 * mx * my + my;[/code] Looks wrong to me somehow... are you sure you have the equation correct?
I'm using SFML.NET, and when I create a big amount of Bullets (the class Bullet is a class that contains a Sprite) at the same time, there is a big slowdown. However, after they're created, the FPS is stable and very high. What can I do to prevent this slowdown?
Pre-create them, but don't draw them until you want them to.
[QUOTE=ZeekyHBomb;21188669]Pre-create them, but don't draw them until you want them to.[/QUOTE] What do you mean? Having a List full of bullets, and when I need some I pick them from the List and change their X,Y,Graphic, etc?
Exactly. I think that the FPS breaks down due to allocating the memory. So if you already allocate it in load-time, the slowdown in run-time should be much less noticeable.
Sorry, you need to Log In to post a reply to this thread.