• What Do You Need Help With? V7
    4,993 replies, posted
  • [QUOTE=srobins;49783087]Out of curiosity I just did a little reading and found this: [url]https://stackoverflow.com/questions/34981878/deferred-shading-anti-aliasing[/url] [...] I'm trying to wrap my head around it lol, so what he's saying is that because the G-Buffer is multisampled, the lighting pass will have to go in and calculate lighting for each sample (rather than a single pixel), which exponentially increases overhead, and if you were to just calculate single-sampled lighting on a multi-sampled G-Buffer, the lighting wouldn't properly match-up with the G-Buffer?[/QUOTE] Yes, though this isn't the normal "enable and forget" MSAA you can just switch on with a flag. You have to set up the buffers a bit differently and write shaders that support it manually in this case (in addition to the proportional overhead. It's not exponential but it [I]is[/I] a lot more expensive).
  • Ok guys I hope you can help me. My program has to tell what the last char is of a string that someone inputs during the program. This is what I have so far [CODE]import java.util.Scanner; public class q1 { public static void main(String[] args) { System.out.println("Type a word, if you want to exit type done"); Scanner keyboard = new Scanner(System.in); String word; word = keyboard.next(); while (!"DONE".equalsIgnoreCase(word)) { System.out.println(word); word = keyboard.nextLine(); char achar = word.charAt(0); System.out.println(achar); } System.out.println("Exiting"); System.exit(0); } } [/CODE] So in that while loop if I had typed hello I should see hello h o and then it loops again for another word till done is typed So if anyone can help me figure out how I will get it to output the last char I would really appreciate it. Also I know someone asked if I was this thing with java or another I have no idea I think its java script what ever eclipse uses thats what kind of java I'm working on.
  • Just get the position of the last string character and use it as an index to access it in the character array: [code] String word = "Hello"; System.out.println(word.charAt(0)); System.out.println(word.charAt(word.length() - 1)); [/code]
  • [QUOTE=Edvinas;49784634]Just get the position of the last string character and use it as an index to access it in the character array: [code] String word = "Hello"; System.out.println(word.charAt(0)); System.out.println(word.charAt(word.length() - 1)); [/code][/QUOTE] But how do I know what the position will be cause you can type any word into the program?
  • [QUOTE=Jacob_sword;49784728]But how do I know what the position will be cause you can type any word into the program?[/QUOTE] That's why he uses 'word.length() - 1'. If the word is, say, 5 characters long, then the last character is at position 4 (5 - 1).
  • It's also worth mentioning that Java and JavaScript are two completely different languages. You're using Java here.
  • ok so when I use the word.length I get this error Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(Unknown Source) at q1.main(q1.java:14) [editline]21st February 2016[/editline] Does Java have some kind of wildcard thing that I can put as the value? [editline]21st February 2016[/editline] never mind guys I got it. So it was being caused by the keyboard.nextline for some reason? But this is what my code looks now if any was curious [code]import java.util.Scanner; public class q1 { public static void main(String[] args) { System.out.println("Type a word, if you want to exit type done"); Scanner keyboard = new Scanner(System.in); String word; word = keyboard.next(); while (!"DONE".equalsIgnoreCase(word)) { System.out.println(word); char achar = word.charAt(0); System.out.println(achar); System.out.println(word.charAt(word.length() - 1)); word = keyboard.next(); } System.out.println("Exiting"); System.exit(0); } } [/code]
  • [QUOTE=Jacob_sword;49784870]ok so when I use the word.length I get this error Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(Unknown Source) at q1.main(q1.java:14) [editline]21st February 2016[/editline] Does Java have some kind of wildcard thing that I can put as the value?[/QUOTE] 'String Index Out Of Bounds' means that you tried to index a character of the string that does not exist. An index of 0 throwing this error implies to me that your string's length is zero, meaning it has no characters; it is an empty string.
  • So I have a transform class which has a parent/child system. To replicate the behavior that you find in modeling applications and engines, I'd like the following: When you have a parent with a world position (2, 3) and a child with a world position with (5, 0), the child's position (that is, relative to the parent) is (3, -3). This is simple enough by doing (worldPosition - parent.worldPosition) This works fine for positions, but I need to do the same with rotations. When a child should be rotated (0, 0, 0) to the world axis, but the parent is rotated (0, 30, 0) in the world, the child's actual rotation should be (0, -30, 0). How do I do this? And then the same for scale. If I have a child scaled to (1, 1, 1) in the world, and a parent scaled (0.5, 0.5, 0.5) in the world, the child should have a scale of (2, 2, 2). How do I do this too? If it is any help, here's my transform class. If there are any glaring mistakes, let me know. [URL]https://github.com/CptAsgard/Potion/blob/master/PotionEngine/Rendering/Transform.cpp[/URL] Not that the position part works with parent/child. I apply this behaviour in the function SetParent(). The rotation and scale parts don't work, for obvious reasons. The question is, how can I make it work? Simulating this in Unity: Parent world space: [IMG]https://i.imgur.com/bZxbZdz.png[/IMG] Child world space: [IMG]https://i.imgur.com/Z6ezvVl.png[/IMG] Child's self space once it's childed to the parent: [IMG]https://i.imgur.com/V6YJi96.png[/IMG] Doing the same exercise in Unreal results in these values for the child: [img]https://i.imgur.com/wJCpANZ.png[/img]
  • Ok I have another question about Java how do I make a random number and set it so it doesn't go any higher then 1000? Also Thank you guys for helping me with my last question.
  • [QUOTE=Jacob_sword;49786250]Ok I have another question about Java how do I make a random number and set it so it doesn't go any higher then 1000? Also Thank you guys for helping me with my last question.[/QUOTE] Modulo it by 1000
  • [QUOTE=Jacob_sword;49786250]Ok I have another question about Java how do I make a random number and set it so it doesn't go any higher then 1000? Also Thank you guys for helping me with my last question.[/QUOTE] Don't you have from/to range for random number generator?
  • ok I got the random number thing. It was [code]Random rand = new Random(); code = rand.nextInt(10000) + 1;[/code] But now I'm trying to take that code int and turn it into a string so I can pull each digit out as a char but when I try to make it a string I get some kind of syntax error. so this is the line I have right now. [code]String a; code.toString(a);[/code]
  • [QUOTE=Jacob_sword;49788223]ok I got the random number thing. It was [code]Random rand = new Random(); code = rand.nextInt(10000) + 1;[/code] But now I'm trying to take that code int and turn it into a string so I can pull each digit out as a char but when I try to make it a string I get some kind of syntax error. so this is the line I have right now. [code]String a; code.toString(a);[/code][/QUOTE] I have no experience with Java but shouldn't it be this instead? [code]String a = code.toString();[/code]
  • You want the number as a string? [code] int code = rand.nextInt(10000) + 1; // Multiple ways to do it, pick one. String a = Integer.toString(code); a = "" + code; a = String.format("%d", code); // And more! [/code] Welcome to programming; use google and in general stack overflow results are good. Guaranteed you aren't the first person to ask these questions! [URL]http://stackoverflow.com/questions/4105331/how-to-convert-from-int-to-string[/URL] [editline]21st February 2016[/editline] [QUOTE=Alice3173;49788479]I have no experience with Java but shouldn't it be this instead? [code]String a = code.toString();[/code][/QUOTE] In Java it depends on what type code is. If code is a primitive type then no (int, float, double, etc). But if its one of the wrapper classes (Integer, Float, Double), then yes.
  • [QUOTE=thrawn2787;49788488]You want the number as a string? [code] int code = rand.nextInt(10000) + 1; // Multiple ways to do it, pick one. String a = Integer.toString(code); a = "" + code; a = String.format("%d", code); // And more! [/code] Welcome to programming; use google and in general stack overflow results are good. Guaranteed you aren't the first person to ask these questions! [URL]http://stackoverflow.com/questions/4105331/how-to-convert-from-int-to-string[/URL] [editline]21st February 2016[/editline] In Java it depends on what type code is. If code is a primitive type then no (int, float, double, etc). But if its one of the wrapper classes (Integer, Float, Double), then yes.[/QUOTE] I've been looking at google but can't seem to find anything that I understand but you guys are really being helpful so thank you again!
  • Is there any way, in C++, to get the compiler to interpret something enclosed in brackets as, well, not being enclosed in brackets? For example, if I wanted to do something like this: [code]#define RunCode( c ) c; // some conversion to make c not enclosed in brackets int main() { RunCode( "std::cout << 'hi'" ); }[/code]
  • I think I see what you want to accomplish but no, you can't run a string as code. Unless you actually do mean just string literals like in your example, but then I would have to ask why? The problem in your code is the quotes, not the brackets. It works without the quotes. Actually scratch that it doesn't since 'hi' is not a character.
  • Say you have an array of 44.000 floats, let's say it looks like { 0.1, 0.2, 0.3 ... n }. The array represents an audioclip. You want to change the speed (tempo+pitch) to half of that, so now you have an array of 88.000 floats and it looks like { 0.1, 0.1, 0.2, 0.2, 0.3, 0.3 ... n }, I suppose (?) How would you do this for non-trivial factors like changing the speed to 60%, or 143%?
  • Something like [code]NewLen = Len * (1 / (Percentage / 100))[/code] For 60%, you'd get 73333.33.., you'd obviously need to round that to something like 73333.0 [editline]23rd February 2016[/editline] For 143% you'd get 30769.23..
  • Ok so that's how you allocate how many slots there are in the array, but how do you distribute the 44.000 floats in that new array? :)
  • [QUOTE=war_man333;49798300]Ok so that's how you allocate how many slots there are in the array, but how do you distribute the 44.000 floats in that new array? :)[/QUOTE] You interpolate in some way. In this case it's upsampling [URL="https://en.wikipedia.org/wiki/Upsampling"]which Wikipedia seems to have a decent article on[/URL][URL="https://archive.is/uOEGf"],[/URL] or downsampling which is linked from there. The higher-quality alternative would be to manipulate the sound file to have a different sample rate setting, if possible :v:
  • [QUOTE=Tamschi;49798380]You interpolate in some way. In this case it's upsampling [URL="https://en.wikipedia.org/wiki/Upsampling"]which Wikipedia seems to have a decent article on[/URL][URL="https://archive.is/uOEGf"],[/URL] or downsampling which is linked from there. The higher-quality alternative would be to manipulate the sound file to have a different sample rate setting, if possible :v:[/QUOTE] I can alter the sample rate but then you can't change the speed in the middle of the sound clip. Thanks for the link! Wait how the heck can I "Smooth out the discontinuities with a lowpass filter, which replaces the zeros." in C#? :v:
  • You can change speed in the middle of the sound clip, it's complex but it's doable. Also, in C# (or any other language) , FIRs filters (Finite Impulse Response) are done with sliding dot product over sound sample/stream. Sliding dot product is cross-correlation: [url]https://en.wikipedia.org/wiki/Cross-correlation[/url] Simplest lowpass filter is moving average also most efficient to implement. Those can work in real time too. There exist also IIR, more efficient filters but harder to manage (can be unstable - hence the name Infinite Impulse Response)
  • [QUOTE=Fourier;49798646]You can change speed in the middle of the sound clip, it's complex but it's doable. Also, in C# (or any other language) , FIRs filters (Finite Impulse Response) are done with sliding dot product over sound sample/stream. Sliding dot product is cross-correlation: [url]https://en.wikipedia.org/wiki/Cross-correlation[/url] Simplest lowpass filter is moving average also most efficient to implement. Those can work in real time too. There exist also IIR, more efficient filters but harder to manage (can be unstable - hence the name Infinite Impulse Response)[/QUOTE] I think the easiest here would be moving average but I don't even know how that works in code. I'm not looking for anything super efficient, just something that's easy to implement. This produces some... interesting... results. [code] public float[] ChangeSpeed(float[] frames, int begin, int end, float factor) { #region Sequence int changedFramesLength = (end - begin) * (int)(1 / factor); float[] changedFrames = new float[changedFramesLength]; float[] snippet = new float[end - begin]; int j = 0; for (int i = begin; i < end; i++) { snippet[j] = frames[i]; j++; } j=0; int modulu = (int)(1 / factor); for (int i = 0; i < changedFramesLength; i++) { if(i%modulu == 0) { changedFrames[i] = snippet[j]; j++; } } #endregion #region MovingAvg float knownValue = 0; for (int i = 0; i < changedFramesLength; i++) { if(changedFrames[i] != 0) { knownValue = changedFrames[i]; } else { changedFrames[i] = knownValue; } } #endregion return changedFrames; } [/code] Obviously I'm not doing moving average because I can't figure out how.
  • If I want to make a grid in a c++ console, what is the best way? So far I have a loop for columns and then a loop inside that for rows, inside that I'm GridControl[GridPos] = "*" with GridPos being a number that keeps track of the loop number This works fine and it displays the asterisk fine but doesn't feel very efficient I've also got a while loop to randomly replace a picked asterisk with another character and that works fine, but I'm having trouble displaying it. If I loop through my array and cout the contents in the wile loop, it repeatedly draws it. I know why that is but even using Console's clear() in the same loop which I thought would've worked
  • [QUOTE=Fourier;49804096]Hey umm... why are you mixing filtering and speed changing?[/QUOTE] If you're asking me... I am not entirely sure what I'm doing.
  • I have a boost MPL set, and I want to convert each element in the set to be wrapped in some container. How would I do this? Here is an example of what I'd like: [cpp]using mySet = mpl::set<int, float, double>; using myNewSet = /*insert magic here*/; //myNewSet == mpl::set<container<int>, container<float>, container<double>>[/cpp]
  • [QUOTE=war_man333;49804179]If you're asking me... I am not entirely sure what I'm doing.[/QUOTE] Might be helpful to learn the maths behind what you're trying to do first, with pen and paper. Or just use a DSP library, surely there's one for .NET.