• What Do You Need Help With? V6
    7,544 replies, posted
I don't mind big walls of text :v: I'd rather have lots of details I can read over multiple times to get a better idea of it, than too little information and still not knowing what to do. Having said that, I'll go read over this several times and see if I can work something out. And I'll definitely check out that book, or rather the source code as the book is rather expensive. :v: [editline]derp[/editline] I just noticed something after implementing it, and reading back the text, I think I see the same happening there. Whenever I increase my maximum depth, the image gets brighter. Looking at your text, you say: [quote]The multiplication and division by pi cancels out, so it's really just the incoming light times 1.4 times the cosine term.[/quote] In the case that the cosine term is near 1, doesn't this mean there's an increasing amount of light? Would it help if I wrote some pseudo code showing what I'm doing right now, so someone may be able to figure out what's wrong? Or if someone happens to be bored, here's the [url=https://github.com/xThaWolfx/Tracer/tree/Test/CUDA%20Runtime]github project[/url]. The relevant code is in Raytracer2.h and Material.h
[QUOTE=xThaWolfx;46869497]I'll definitely check out that book, or rather the source code as the book is rather expensive. :v:[/QUOTE] Just be aware that the source code isn't well-commented by itself. The book's text provides all the explanatory stuff that you'd normally expect to find in comments. [QUOTE=xThaWolfx;46869497]Whenever I increase my maximum depth, the image gets brighter.[/QUOTE] That's normal, since you're including additional light paths that were previously ignored. In fact, if you have a fixed maximum depth (even a huge one), your rendering is biased, since there's no real-world limit to how many times light can bounce off objects before reaching your eye. But it's a diminishing effect: longer paths tend to carry less light than shorter ones, so each increase in maximum path length should have less of an effect on the image. With a high enough limit, the bias is small enough that it makes no discernible difference. [QUOTE=xThaWolfx;46869497]In the case that the cosine term is near 1, doesn't this mean there's an increasing amount of light?[/QUOTE] Not really, because [i]on average[/i] the cosine term will be small enough that multiplying it by 1.4 produces a value that's less than 1. When you're dealing with random variables, the [url=https://en.wikipedia.org/wiki/Expected_value]expected value[/url] is what really matters. Having a reflection factor that's greater than 1 for some directions just means that those directions are under-represented in the random sampling: the proportion of how often they're chosen (relative to other directions) is less than the proportion of how much light they reflect (relative to other directions). That's why it doesn't happen with the cosine-weighted sampling, where directions are chosen more often in direct proportion to how much light they reflect. Since the 1.4 came from multiplying the albedo (0.7) by the 2 from the hemisphere's 2*pi, it might help to provide another perspective on why you have to multiply by 2*pi. The "light" that you think of as traveling along a ray is in units of [i]radiance[/i], which basically represents the apparent brightness of an object. Radiance is a fancy name for power (i.e. watts), per unit area on the surface being illuminated, per unit solid angle above the surface. The "per unit solid angle" part is what I want to highlight here. [url=https://en.wikipedia.org/wiki/Solid_angle]Solid angle[/url] is basically the 2D equivalent of angle. Just as a radian is the angle that corresponds to an arc of length 1 on a unit circle, a steradian (the unit of solid angle) corresponds to an area of 1 on a unit sphere. Basically, solid angle represents how big an object appears from a point — how much of your field of view it covers. When you're calculating reflection on a surface, you're working with a point (which is infinitely small) and a ray (which is infinitely thin). The amount of energy (i.e. light) actually traveling along a ray to a point is also infinitely small, which is why radiance doesn't represent an [i]amount[/i], it represents a [i]density[/i]. If you have a point and a ray with an incoming radiance value of 47, it doesn't mean that there's 47 of something arriving at the point along the ray. It means that if a unit area on the surface (such as a 1x1 square) were illuminated by a light that's big enough or close enough to have an apparent size of 1 steradian, that region of the surface would be receiving 47 watts (joules per second) of energy from the light. Imagine you're looking at a fluorescent tube from a distance: it appears to be a certain brightness, which is roughly the same across its whole surface. Now imagine moving closer to the tube. It appears larger now since it's closer, and you're receiving more total light energy from it, but the tube's surface still appears to be the same brightness as when it was distant. The light's energy density hasn't changed; only its solid angle has. So, radiance that tells you about power per steradian, and when you integrate it over a hemisphere (which is 2*pi steradians), you're combining the density with an area to get an actual amount of power (per unit surface area, but that's a separate matter). If the radiance is constant over the hemisphere — that is, the incoming light is equally bright from all directions — then the integral is just the radiance value times 2*pi. And although the incoming light typically isn't [i]really[/i] equally bright from all directions, that's the approximation you make with Monte Carlo integration: sample one random direction and treat it as the value for all directions. [QUOTE=xThaWolfx;46869497]Would it help if I wrote some pseudo code showing what I'm doing right now, so someone may be able to figure out what's wrong? Or if someone happens to be bored, here's the [url=https://github.com/xThaWolfx/Tracer/tree/Test/CUDA%20Runtime]github project[/url].[/QUOTE] Pseudocode, sure, but I don't think I'll be of much help with actual code debugging. I'm not really familiar with CUDA (though I've read the OpenCL API docs), and I don't have CUDA development tools installed.
I'm having quite some trouble positioning text inside JSFML. Here's my code: [code]public Square setPos( Vector2f pos ) { Vector2f size = this.getSize(); //FloatRect txtBounds = number.getLocalBounds(); //number.setOrigin( txtBounds.width / 2, txtBounds.height / 2 ); number.setPosition( new Vector2f( pos.x + size.x / 2, pos.y + size.y / 2 ) ); this.setPosition( pos ); return this; } [/code] This, with the part where I set origin of the text commented out, gets me here: [t]https://dl.dropboxusercontent.com/u/46283290/txt_orOff.PNG[/t] With the setting origin part uncommented, it gets me here: [t]https://dl.dropboxusercontent.com/u/46283290/txt_orOn.PNG[/t] What am I doing wrong? Is there a way to get the text exactly in the middle of the square?
[QUOTE=Wyzard;46873050]Explanation[/QUOTE] Sadly, now that uni's started again, I've got less time left for my path tracer. I'll try and post some pseudo code over the coming days, probably in small parts to figure out if I'm doing everything correctly. By the way, those 2 files I mentioned contain no CUDA code at all, except for __device__ in front of all methods :v: I've contacted a professor at my uni who gave a Graphics course last year, hopefully I'll be able to meet up with him sometime soon. [QUOTE=HumbleTH;46875415]I'm having quite some trouble positioning text inside JSFML. Here's my code: [code]public Square setPos( Vector2f pos ) { Vector2f size = this.getSize(); //FloatRect txtBounds = number.getLocalBounds(); //number.setOrigin( txtBounds.width / 2, txtBounds.height / 2 ); number.setPosition( new Vector2f( pos.x + size.x / 2, pos.y + size.y / 2 ) ); this.setPosition( pos ); return this; } [/code] This, with the part where I set origin of the text commented out, gets me here: [t]https://dl.dropboxusercontent.com/u/46283290/txt_orOff.PNG[/t] With the setting origin part uncommented, it gets me here: [t]https://dl.dropboxusercontent.com/u/46283290/txt_orOn.PNG[/t] What am I doing wrong? Is there a way to get the text exactly in the middle of the square?[/QUOTE] If you don't set the origin, but instead subtract the txtBounds / 2 from the position, do you get the same result? I have no experience with JSFML, but perhaps that method is wrong/works differently from what you think?
Could someone translate this to something a programmer could understand please? [IMG]http://upload.wikimedia.org/math/c/4/a/c4a348cc528ee8386dd04950bdfed262.png[/IMG] [url]http://en.wikipedia.org/wiki/Drag_coefficient#Bluff_and_streamlined_body_flows[/url] [sp]It's like hieroglyphs to me.[/sp]
[QUOTE=xThaWolfx;46879176] If you don't set the origin, but instead subtract the txtBounds / 2 from the position, do you get the same result? I have no experience with JSFML, but perhaps that method is wrong/works differently from what you think?[/QUOTE] That's the way it's put on the wiki. After trying out adding the bounds' width and height, I get the exact same result as if I'd never set the origin. Same with both setting bounds and adding them.
[QUOTE=voodooattack;46884022]Could someone translate this to something a programmer could understand please? [IMG]http://upload.wikimedia.org/math/c/4/a/c4a348cc528ee8386dd04950bdfed262.png[/IMG] [url]http://en.wikipedia.org/wiki/Drag_coefficient#Bluff_and_streamlined_body_flows[/url] [sp]It's like hieroglyphs to me.[/sp][/QUOTE] Why do you need a physically accurate drag coefficient [editline]8th January 2015[/editline] Because unless you're actually trying to make some sorta aerodynamics simulator you could just try to use the approximates given in that article
[QUOTE=esalaka;46884259]Why do you need a physically accurate drag coefficient [editline]8th January 2015[/editline] Because unless you're actually trying to make some sorta aerodynamics simulator you could just try to use the approximates given in that article[/QUOTE] It's for an artificial life simulation. The organisms could (and actually do) cheat if I approximate.
Python 3.4.2 here. Why don't these two commands return the same result—as I'm taught and expect? [IMG]http://i.imgur.com/r7O4KX2.png[/IMG] Painfully obvious I'm in an intro class, I know.
[QUOTE=HumbleTH;46884142]That's the way it's put on the wiki. After trying out adding the bounds' width and height, I get the exact same result as if I'd never set the origin. Same with both setting bounds and adding them.[/QUOTE] Have you tried debugging the values you get with getSize, etc? Try drawing a rectangle with said size around the character, if that size is completely off then you know the problem lies with that method.
[QUOTE=danjee;46889314]Python 3.4.2 here. Why don't these two commands return the same result—as I'm taught and expect? [IMG]http://i.imgur.com/r7O4KX2.png[/IMG] Painfully obvious I'm in an intro class, I know.[/QUOTE] It kinda looks like that first one is printing a tuple? [editline]9th January 2015[/editline] I mean, are you sure that REPL you're using is Python 3 [editline]9th January 2015[/editline] Since in python2 print is a statement, print (a,b) prints the tuple (a,b), whereas in python3 it's a function so it prints the arguments a and b
I've never really compiled anything that wasn't an automatic make file or whatever, I'm trying to compile [url]http://www.netzob.org/[/url] because the premade windows installer is an older version and is buggy af. I tried just downloading it and running the setup.py, then fixing errors but couldn't figure it out. From the small amount I've used it without it breaking, it seems incredibly useful. If there's any similar tools, that works too, but I haven't found any. edit: talked to dev on irc and no one really uses it on windows, I'll just get my laptop in here for hosting the server on debian + netzob then, I should've done that a long time ago
Hi guys I've been trying to learn programming by myself for some time, but never understood how to use (as in: What can I do with these?) the functions such as if, len(), lists, dictionaries, etc etc So I found Codeacademy, and started learning Python. So far it has been a blast, no problems until I ran into this exercise: [CODE]shopping_list = ["banana", "orange", "apple"] stock = { "banana": 6, "apple": 0, "orange": 32, "pear": 15 } prices = { "banana": 4, "apple": 2, "orange": 1.5, "pear": 3 }[/CODE] And I was given the following instructions related to the previous code: [QUOTE]-Define a function compute_bill that takes one argument food as input. -In the function, create a variable total with an initial value of zero. -For each item in the food list, add the price of that item to total. -Finally, return the total. -Ignore whether or not the item you're billing for is in stock. [I]Note that your function should work for any food list.[/I][/QUOTE] My first solution was: [CODE]def compute_bill(food): total = 0 for item in food: total += prices[item] return total[/CODE] But it returned this error message when the code was ran: [CODE]Oops, try again. compute_bill(['banana', 'apple', 'orange', 'pear']) returned 4 instead of 10.5 [/CODE] So what I was doing wrong? From that error message, I understood that only 1 of the fruits was being put through the function (In this case, Banana, as its price is 4) So I noticed that last line....the "return total"....it had one more ind.block...thus I corrected it, leaving me with this: [CODE]def compute_bill(food): total = 0 for item in food: total += prices[item] return total[/CODE] Which worked! So I was left with a huge doubt, which I desperately need to clear: Why, pressing TAB one more time in the last line, makes the code go to hell? How does it affect the RETURN TOTAL? Thanks guys! It's a blast to learn how to code [editline]10th January 2015[/editline] [QUOTE=danjee;46889314]Python 3.4.2 here. Why don't these two commands return the same result—as I'm taught and expect? [IMG]http://i.imgur.com/r7O4KX2.png[/IMG] Painfully obvious I'm in an intro class, I know.[/QUOTE] Because you aren't concatenating them? It should be (If I'm not mistaken)= print ("Hello " + "world!")
[QUOTE=Cutthecrap;46895098]Why, pressing TAB one more time in the last line, makes the code go to hell? How does it affect the RETURN TOTAL?[/QUOTE] That extra level of indentation makes the return statement be part of the loop, instead of something that happens after the loop finishes. In other words, the function would do the following: * Initialize total to 0 * Add the price of the first item * Return the total * Add the price of the second item * Return the total * Add the price of the third item * Return the total * etc. …but of course, the first time it gets to a "return", it returns and the remaining steps don't happen. That's why you need the return to happen after the entire loop: * Initialize total to 0 * Add the price of the first item * Add the price of the second item * Add the price of the third item * etc. * Return the total
Does anyone know of a hexeditor that supports newlines, or splitting the file with a separator?
[QUOTE=Persious;46856754]It's nothing specific, I'm just wondering which ones are good out there if you want to teach yourself within the mobile world.[/QUOTE] I'm not sure I understand. Typically if you're interested in mobile application development you would just start by developing applications for whatever kind of phone you have already, ie I got started with Android because I owned an Android and that made it convenient to learn. Just Google "how to make _____ apps" and there should be plenty of resources that will walk you through the process of making various example apps.
Howdy! I am currently working on Sburb, a 2D Action-RPG platformer based on the webcomic Homestuck. Currently, the server host can load an image file and use it as the background. The game will automatically create collision boxes accordingly. Recently, I've been thinking about working with procedural generation, so here's my question for you folks: Is there any feasible way to generate image (.png) files, "draw landscapes" and place objects (other images) all around the place?
Anyone who uses UE4 blueprints. I am attempting to get the actor which is attached to a scenecomponent. How do I do this?
[QUOTE=cam64DD;46897629]Howdy! I am currently working on Sburb, a 2D Action-RPG platformer based on the webcomic Homestuck. Currently, the server host can load an image file and use it as the background. The game will automatically create collision boxes accordingly. Recently, I've been thinking about working with procedural generation, so here's my question for you folks: Is there any feasible way to generate image (.png) files, "draw landscapes" and place objects (other images) all around the place?[/QUOTE] [code] //prototype placeObject(int x, int y); ... image.placeObject( rand()* screenwidth, rand() * screenheight); [/code] pseudocode, no real language
Does anyone know how to fake gravity for some things when everything else doesn't have gravity? Like in a topdown 2D game where items could fall like this: [img]http://i.stack.imgur.com/z4BJ7.png[/img] I have a [URL=http://gamedev.stackexchange.com/questions/92003/unity2d-apply-gravity-to-some-items-when-everything-else-is-gravity-free/]question[/URL] on GDSH but it's not getting that much attention.
[QUOTE=war_man333;46903358]Does anyone know how to fake gravity for some things when everything else doesn't have gravity? Like in a topdown 2D game where items could fall like this: [img]http://i.stack.imgur.com/z4BJ7.png[/img] I have a [URL=http://gamedev.stackexchange.com/questions/92003/unity2d-apply-gravity-to-some-items-when-everything-else-is-gravity-free/]question[/URL] on GDSH but it's not getting that much attention.[/QUOTE] Every update, add some gravity constant to the object's Y-velocity. If you hit something, in order to make it bounce, just reverse its Y velocity multiplied by some factor so it loses energy and doesn't bounce forever. And maybe once the velocity is too low, just set it to 0 so it doesn't bounce with miniscule bounces after a while.
[QUOTE=xThaWolfx;46903443]Every update, add some gravity constant to the object's Y-velocity. If you hit something, in order to make it bounce, just reverse its Y velocity multiplied by some factor so it loses energy and doesn't bounce forever. And maybe once the velocity is too low, just set it to 0 so it doesn't bounce with miniscule bounces after a while.[/QUOTE] The problem is not collision-handling, it's collision-detection. When would we want to hit something? [img]http://i.imgur.com/VsJiIxZ.png[/img] Every tile is a floor. You can't just hit the floor, then it would hit instantly. Catch my drift?
[QUOTE=war_man333;46903507]The problem is not collision-handling, it's collision-detection. When would we want to hit something? -image- Every tile is a floor. You can't just hit the floor, then it would hit instantly. Catch my drift?[/QUOTE] So you want it to skitter along the floor, or "bounce" along the X/Y floor tiles? Something you could consider is some amalgamation of a "bounce" velocity vector, that contains (X,Y) coordinates of the direction it should skitter. You may want to attach a third value that serves as a sort of "bounce plasticity" (make it a Vector3 of X,Y,B maybe?) - every update, have the X,Y of the coordinates decrease toward zero, and when it reaches zero, decrease B by some value. Then, recompute X,Y, and derive it off the value of B such that as B gets smaller, so do X,Y. You can use some capping so that when B gets adequately close to zero (and so do X,Y) you just set B to zero and stop the bouncing. The visual result will be the object moving quickly along X,Y slowing down to a stop, then abruptly going fast again (though slower than last time) and slowing to a stop, each time moving slower than the last, until it finally comes to a stop. Take this suggestion with a mountain of salt, though. It's 3:07AM and I should have gone to bed a long time ago. :v:
[QUOTE=Gmod4ever;46903549]So you want it to skitter along the floor, or "bounce" along the X/Y floor tiles? Something you could consider is some amalgamation of a "bounce" velocity vector, that contains (X,Y) coordinates of the direction it should skitter. You may want to attach a third value that serves as a sort of "bounce plasticity" (make it a Vector3 of X,Y,B maybe?) - every update, have the X,Y of the coordinates decrease toward zero, and when it reaches zero, decrease B by some value. Then, recompute X,Y, and derive it off the value of B such that as B gets smaller, so do X,Y. You can use some capping so that when B gets adequately close to zero (and so do X,Y) you just set B to zero and stop the bouncing. The visual result will be the object moving quickly along X,Y slowing down to a stop, then abruptly going fast again (though slower than last time) and slowing to a stop, each time moving slower than the last, until it finally comes to a stop. Take this suggestion with a mountain of salt, though. It's 3:07AM and I should have gone to bed a long time ago. :v:[/QUOTE] That sounds as what I want. I just need to figure out how to either use Unity's physics to get projectile motion or simulate something similiar.
The most sane way would be to use a 3d physics engine. However i guess that isn't something you want to do. So should probably manually add a "height" variable to the entities you want to bounce. Keep the entities inside the physics engine at the same spot, just change where they are drawn based on the "height" variable (maybe also upscale them a little as they get closer to the camera). You can increase/decrease the height to simulate some kind of bouncing, you'll probably have to decrease the friction for the object, and if you want it to be able to bounce over objects, you'll have too somehow disable collision between stuff based on its height.
Yay. Here's the code, I might tweak the startPos.Y so all the coins don't stack on one line: [code] if(hasGravity) { if(rigidbody2D.transform.position.y <= startPosY && startForce.y > 1) { rigidbody2D.isKinematic = true; rigidbody2D.isKinematic = false; startForce.x *= 0.5f; startForce.y *= 0.5f; print (startForce.x + " - " + startForce.y); rigidbody2D.AddForce(startForce); } else if(startForce.y < 1) { rigidbody2D.isKinematic = true; rigidbody2D.isKinematic = false; rigidbody2D.gravityScale = 0; } } [/code]
I've finally got a nice project idea in mind and I'm excited to start working on it. I want to create a fast desktop application that functions as a communication system. I have a few features planned out, but I'm worried that all the functionality that I want to add will slow the program down. The only thing I'm struggling with is what language would be appropriate for this. I really want to use C++ because I'm familiar with it, and I've heard that it can be fast. Would C++ be an appropriate language for this sort of task? It is meant to be a very serious project and I don't want to get too far into it and realize I should have used another language.
[QUOTE=DerpHurr;46906334]I've finally got a nice project idea in mind and I'm excited to start working on it. I want to create a VERY fast desktop application that functions as a communication system. I have a few features planned out, but I'm worried that all the functionality that I want to add will slow the program down. The only thing I'm struggling with is what language would be appropriate for this. I really want to use C++ because I'm familiar with it, and I've heard that it can be fast. Would C++ be an appropriate language for this sort of task? It is meant to be a very serious project and I don't want to get too far into it and realize I should have used another language.[/QUOTE] If you have the patience and knowledge required to make use of C++, and the application you are developing indeed does require some heavy performance-intensive throughput, then I can only recommend HIGHLY that you stick with it.
[QUOTE=mastersrp;46906516]If you have the patience and knowledge required to make use of C++, and the application you are developing indeed does require some heavy performance-intensive throughput, then I can only recommend HIGHLY that you stick with it.[/QUOTE] I've heard of C++ having a reputation for being fast if you use it properly. The only thing I'm worried about is it has a lot of functionality and I'm not too great of a programmer yet, but its more of a project I want to work on for a while. I'm not too patient, but I guess this will help me in becoming more patient and a better programmer. EDIT: Another question - I want to use a GUI library for my application, but I eventually may want to use it commercially. Everyone keeps suggesting QT, but I think you can't use QT for commercial use without paying (or it is bound to certain conditions). Should I just start out with QT or use another GUI library?
[QUOTE=DerpHurr;46906334]I want to create a fast desktop application that functions as a communication system.[/QUOTE] You haven't provided much detail on what you want your application to do, but a communications application is likely to be [url=https://en.wikipedia.org/wiki/I/O_bound]I/O-bound[/url], not [url=https://en.wikipedia.org/wiki/CPU-bound]CPU-bound[/url]: your program will probably spend most of its time waiting for data from the network. Well-written C++ can be faster than code written in higher-level languages, but it's not guaranteed (you have to know what you're doing, and it may involve a lot of optimization work), and it's unlikely to make a noticeable difference for a program that isn't CPU-bound. Higher-level languages, on the other hand, can be easier to work with and may provide higher-level networking-abstractions out-of-the-box. (The C++ standard has no networking facilities, so you'll either have to find a third-party library or use platform-specific raw sockets, which is tedious.) Write your program in C++ if you like C++, but don't assume that you [i]need[/i] to use C++ or your program will be too slow. Plenty of successful network applications are written in Java, Python, and even JavaScript (to name a few). Go with whatever language will be most convenient and enjoyable to work with.
Sorry, you need to Log In to post a reply to this thread.