1. Post #2961
    Gold Member
    Tamschi's Avatar
    December 2009
    8,611 Posts
    Sorry for quoting you twice but I can't see why this isn't working:

    Code:
    [...]
            IntPtr filePointer = api.Open("C:\\Users\\Mathias Siig\\Documents\\yamaha.wav", LibsndfileMode.Rdwr, ref info);
    [...]
    Reading works fine, I have access to write, but it's like the frames/samples are not committed to the file. Am I missing some kind of call?
    Small note: Windows and .NET support / in paths just fine (and even mixed strings), so I suggest using that everywhere.
    Otherwise you could write it as
    Code:
    @"C:\Users\Mathias Siig\Documents\yamaha.wav"
    too, when pasting from Windows Explorer.

    Edited:

    Reduce the angle first

    Code:
    float Reduce(float Ang) {
        while (Ang > 360)
            Ang -= 360;
        while (Ang < 0)
            Ang += 360;
    }
    But obviously use math to do that

    Edited:

    Code:
    AngReduced = Ang - 360.0f * Math.Floor(Ang / 360.0f)
    The modulo operator works fine with floats, iirc.

    Edited:

    See maybe I'm wrong. I just read that as being the downside of deffered shading.
    It doesn't work with the default/almost perfect anti-aliasing mode available via blend functions, since that convolutes the buffers/doesn't preserve distinct normals or depth information on a pixel, or anything else that doesn't preserve it like SSAA.
    (It would instead give you the average visible colour and normal, the nearest visible depth, and likely completely mess up material flags.)

    What does work are downsampling of the final image and screen space solutions (e.g. FXAA), since they preserve or don't need the additional information, respectively.
    It would also be possible to use depth peeling to gather the necessary data only for where transparent overlaps exist (I think. I haven't read into it thoroughly yet).
    Reply With Quote Edit / Delete Windows 10 Firefox Germany Show Events

  2. Post #2962
    Gold Member
    war_man333's Avatar
    May 2006
    7,850 Posts
    Hey no stress, you don't have to help random strangers online!

    For whatever reason, this works.
    Code:
        void TestApi()
        {
            LibsndfileApi api = new LibsndfileApi();
            LibsndfileInfo info = new LibsndfileInfo();
            IntPtr filePointer = api.Open("C:/Users/Mathias Siig/Documents/yamaha.wav", LibsndfileMode.Read, ref info);
            float[] frames = new float[info.Frames*info.Channels];
            api.ReadFrames(filePointer, frames, info.Frames);
            for (int i = 0; i < frames.Length; i++)
                frames[i] = i/(float)frames.Length;
            api.Close(filePointer);
    
            long amountOfFrames = info.Frames;
            filePointer = api.Open("C:/Users/Mathias Siig/Documents/yamaha.wav", LibsndfileMode.Write, ref info);
            long framesWritten = api.WriteFrames(filePointer, frames, amountOfFrames);
            api.WriteSync(filePointer);
            api.Close(filePointer);
        }
    also thanks for the tip Tamschi
    Reply With Quote Edit / Delete Windows 10 Chrome Finland Show Events

  3. Post #2963
    Gold Member
    alien_guy's Avatar
    June 2009
    4,742 Posts
    Can someone explain why deffered rendering makes it impossible to have anti-aliasing?
    The normal buffer would be incorrect if you tried to anti-alias it.
    Reply With Quote Edit / Delete Windows 7 Firefox United Kingdom Show Events Informative Informative x 1 (list)

  4. Post #2964
    Gold Member
    cartman300's Avatar
    April 2011
    3,199 Posts
    The modulo operator works fine with floats, iirc.
    They're not the same

    https://ideone.com/TQ4LS8
    Reply With Quote Edit / Delete Windows 10 Firefox Croatia Show Events Useful Useful x 1 (list)

  5. Post #2965
    Dennab
    December 2014
    4,794 Posts
    See maybe I'm wrong. I just read that as being the downside of deffered shading.
    Can someone explain why deffered rendering makes it impossible to have anti-aliasing?
    When people refer to a lack of anti-aliasing in deferred rendering, they're usually talking about MSAA I think. I don't honestly know the details of how MSAA works, but I know that in a forward renderer, you can basically just enable MSAA in DirectX/OpenGL and have it work. In deferred rendering, the use of all those buffers throws it off anti-aliasing the normal buffer will mess up your lighting calculations and you'll need to implement a post-processed anti-aliasing method. So you can get anti-aliasing in deferred renderers, it's just more expensive and takes a bit more effort.
    Reply With Quote Edit / Delete Windows 10 Chrome United States Show Events Agree Agree x 1 (list)

  6. Post #2966
    Gold Member
    WTF Nuke's Avatar
    March 2009
    5,247 Posts
    Ah this makes sense. I guess it's not possible to ignore the normal buffer when you perform MSAA? Actually never mind, I can see how that can screw up lighting since you are in reality altering the output image but if you don't alter the normals as well you would get lighting on the wrong pixels.
    Reply With Quote Edit / Delete Windows 10 Firefox Canada Show Events

  7. Post #2967
    Gold Member
    Tamschi's Avatar
    December 2009
    8,611 Posts
    Oh right, that behaves differently with negative numbers.
    It would work with a branch but the floor formula is most likely faster.
    Reply With Quote Edit / Delete Windows 10 Firefox Germany Show Events

  8. Post #2968
    Dennab
    December 2014
    4,794 Posts
    Ah this makes sense. I guess it's not possible to ignore the normal buffer when you perform MSAA? Actually never mind, I can see how that can screw up lighting since you are in reality altering the output image but if you don't alter the normals as well you would get lighting on the wrong pixels.
    What I don't understand is why you can't just apply MSAA to the final frame before pushing it to the screen, but then again I'd probably understand that if I knew how MSAA works lol
    Reply With Quote Edit / Delete Windows 10 Chrome United States Show Events

  9. Post #2969
    Gold Member
    Tamschi's Avatar
    December 2009
    8,611 Posts
    What I don't understand is why you can't just apply MSAA to the final frame before pushing it to the screen, but then again I'd probably understand that if I knew how MSAA works lol
    MSAA doesn't use large intermediary buffers afaik, but multisamples and convolutes pixels immediately.

    Edited:

    It also (normally) requires geometry to be available, so if you only process a previous buffer that doesn't work.
    Reply With Quote Edit / Delete Windows 10 Firefox Germany Show Events Agree Agree x 1 (list)

  10. Post #2970
    Dennab
    December 2014
    4,794 Posts
    Out of curiosity I just did a little reading and found this: https://stackoverflow.com/questions/...-anti-aliasing

    Multisampling is based on the general idea that you only need to execute the fragment shader once for all of the samples covered by a particular triangle's rasterization within that pixel. So while you do write to multiple samples (like with super sampling), you only execute the fragment shader once, thus saving lots of texture accesses. The same value is written across the samples in the multisample image.

    That is still doable with deferred rendering. The geometry pass still makes sense under multisampling rules. Or at least, as much sense as it ever has.

    The problem is what you have to do during your lighting pass.

    Because your geometry pass was multisampled, your lighting pass must read multisampled data. You cannot do a multisample resolve of the geometry buffers (that would be the "nonsensical" part Wikipedia was talking about); your lighting pass must read each sample and process it. Per light. So if you did an 8x multisample operation, your fragment shader will have to run eight times for each pixel. Per light.
    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?
    Reply With Quote Edit / Delete Windows 10 Chrome United States Show Events Agree Agree x 2 (list)

  11. Post #2971
    Gold Member
    Tamschi's Avatar
    December 2009
    8,611 Posts
    Out of curiosity I just did a little reading and found this: https://stackoverflow.com/questions/...-anti-aliasing

    [...]

    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?
    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 is a lot more expensive).
    Reply With Quote Edit / Delete Windows 10 Firefox Germany Show Events Agree Agree x 1Informative Informative x 1 (list)

  12. Post #2972
    Gold Member
    Jacob_sword's Avatar
    September 2010
    1,638 Posts
    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);
    	}
    }
    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.
    Reply With Quote Edit / Delete Windows 10 Chrome United States Show Events

  13. Post #2973
    Edvinas's Avatar
    August 2010
    871 Posts
    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));
    Reply With Quote Edit / Delete Windows 10 Firefox Lithuania Show Events

  14. Post #2974
    Gold Member
    Jacob_sword's Avatar
    September 2010
    1,638 Posts
    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));
    But how do I know what the position will be cause you can type any word into the program?
    Reply With Quote Edit / Delete Windows 10 Chrome United States Show Events Dumb Dumb x 2 (list)

  15. Post #2975
    Gold Member
    BackwardSpy's Avatar
    May 2008
    6,521 Posts
    But how do I know what the position will be cause you can type any word into the program?
    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).
    Reply With Quote Edit / Delete Windows 10 Firefox United Kingdom Show Events Agree Agree x 3 (list)

  16. Post #2976
    fauxpark's Avatar
    November 2010
    248 Posts
    It's also worth mentioning that Java and JavaScript are two completely different languages. You're using Java here.
    Reply With Quote Edit / Delete Android Chrome Australia Show Events Agree Agree x 4 (list)

  17. Post #2977
    Gold Member
    Jacob_sword's Avatar
    September 2010
    1,638 Posts
    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)

    Edited:

    Does Java have some kind of wildcard thing that I can put as the value?

    Edited:

    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);
    	}
    }
    Reply With Quote Edit / Delete Windows 10 Chrome United States Show Events

  18. Post #2978
    Gold Member
    BackwardSpy's Avatar
    May 2008
    6,521 Posts
    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)

    Edited:

    Does Java have some kind of wildcard thing that I can put as the value?
    '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.
    Reply With Quote Edit / Delete Windows 10 Firefox United Kingdom Show Events Agree Agree x 3 (list)

  19. Post #2979
    Gold Member
    Asgard's Avatar
    July 2010
    4,281 Posts
    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.

    https://github.com/CptAsgard/Potion/.../Transform.cpp

    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:


    Child world space:


    Child's self space once it's childed to the parent:


    Doing the same exercise in Unreal results in these values for the child:
    Reply With Quote Edit / Delete Windows 10 Chrome Netherlands Show Events

  20. Post #2980
    Gold Member
    Jacob_sword's Avatar
    September 2010
    1,638 Posts
    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.
    Reply With Quote Edit / Delete Windows 10 Chrome United States Show Events

  21. Post #2981
    Trebgarta's Avatar
    March 2014
    6,512 Posts
    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.
    Modulo it by 1000
    Reply With Quote Edit / Delete Android Chrome Germany Show Events

  22. Post #2982
    Fourier's Avatar
    July 2014
    4,001 Posts
    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.
    Don't you have from/to range for random number generator?
    Reply With Quote Edit / Delete Windows 8 Chrome Slovenia Show Events Agree Agree x 1 (list)

  23. Post #2983
    Gold Member
    Jacob_sword's Avatar
    September 2010
    1,638 Posts
    ok I got the random number thing. It was
    Code:
    Random rand = new Random();
    		code = rand.nextInt(10000) + 1;
    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);
    Reply With Quote Edit / Delete Windows 10 Chrome United States Show Events

  24. Post #2984
    Ask me about
    the stick
    up my ass
    Alice3173's Avatar
    April 2010
    11,451 Posts
    ok I got the random number thing. It was
    Code:
    Random rand = new Random();
    		code = rand.nextInt(10000) + 1;
    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);
    I have no experience with Java but shouldn't it be this instead?
    Code:
    String a = code.toString();
    Reply With Quote Edit / Delete Windows 10 Firefox United States Show Events Disagree Disagree x 1Programming King Programming King x 1Agree Agree x 1 (list)

  25. Post #2985
    HEY GUYS, DID YOU KNOW THAT THERE'S A NEW STEAMGROUP FOR PLAYING HALF-LIFE 1 AND 2 DEATHMATCH WITH OTHER FACEPUNCHERS?? WE USUALLY PLAY GAMES A COUPLE TIMES A WEEK AND IF YOU JOIN OUR STEAM GROUP WE'LL LET YOU KNOW WHEN WE'RE PLAYING!! CLICK HERE TO JOIN!
    Dennab
    April 2007
    10,941 Posts
    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!
    Welcome to programming; use google and in general stack overflow results are good. Guaranteed you aren't the first person to ask these questions!

    http://stackoverflow.com/questions/4...-int-to-string

    Edited:

    I have no experience with Java but shouldn't it be this instead?
    Code:
    String a = code.toString();
    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.
    Reply With Quote Edit / Delete Windows 7 Firefox United States Show Events Informative Informative x 1 (list)

  26. Post #2986
    Gold Member
    Jacob_sword's Avatar
    September 2010
    1,638 Posts
    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!
    Welcome to programming; use google and in general stack overflow results are good. Guaranteed you aren't the first person to ask these questions!

    http://stackoverflow.com/questions/4...-int-to-string

    Edited:



    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.
    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!
    Reply With Quote Edit / Delete Windows 10 Chrome United States Show Events

  27. Post #2987
    Dennab
    September 2015
    1,487 Posts
    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'" ); }
    Reply With Quote Edit / Delete Linux Chrome Canada Show Events Informative Informative x 1 (list)

  28. Post #2988
    Gold Member
    WTF Nuke's Avatar
    March 2009
    5,247 Posts
    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.
    Reply With Quote Edit / Delete Windows 10 Firefox Canada Show Events

  29. Post #2989
    Gold Member
    war_man333's Avatar
    May 2006
    7,850 Posts
    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%?
    Reply With Quote Edit / Delete Windows 10 Chrome Finland Show Events

  30. Post #2990
    Gold Member
    cartman300's Avatar
    April 2011
    3,199 Posts
    Something like

    Code:
    NewLen = Len * (1 / (Percentage / 100))
    For 60%, you'd get 73333.33.., you'd obviously need to round that to something like 73333.0

    Edited:

    For 143% you'd get 30769.23..
    Reply With Quote Edit / Delete Windows 8 Chrome Croatia Show Events

  31. Post #2991
    Gold Member
    war_man333's Avatar
    May 2006
    7,850 Posts
    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? :)
    Reply With Quote Edit / Delete Windows 10 Chrome Finland Show Events

  32. Post #2992
    Gold Member
    Tamschi's Avatar
    December 2009
    8,611 Posts
    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? :)
    You interpolate in some way. In this case it's upsampling which Wikipedia seems to have a decent article on, 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
    Reply With Quote Edit / Delete Windows 10 Firefox Germany Show Events Agree Agree x 1 (list)

  33. Post #2993
    Gold Member
    war_man333's Avatar
    May 2006
    7,850 Posts
    You interpolate in some way. In this case it's upsampling which Wikipedia seems to have a decent article on, 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
    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#?
    Reply With Quote Edit / Delete Windows 10 Chrome Finland Show Events Friendly Friendly x 1 (list)

  34. Post #2994
    Fourier's Avatar
    July 2014
    4,001 Posts
    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:

    https://en.wikipedia.org/wiki/Cross-correlation

    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)
    Reply With Quote Edit / Delete Windows 8 Chrome Slovenia Show Events

  35. Post #2995
    Gold Member
    war_man333's Avatar
    May 2006
    7,850 Posts
    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:

    https://en.wikipedia.org/wiki/Cross-correlation

    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)
    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;
        }
    Obviously I'm not doing moving average because I can't figure out how.
    Reply With Quote Edit / Delete Windows 10 Chrome Finland Show Events

  36. Post #2996
    Fourier's Avatar
    July 2014
    4,001 Posts
    Hey umm... why are you mixing filtering and speed changing?
    Reply With Quote Edit / Delete Windows 8 Chrome Slovenia Show Events

  37. Post #2997
    Gold Member
    war_man333's Avatar
    May 2006
    7,850 Posts
    Hey umm... why are you mixing filtering and speed changing?
    If you're asking me... I am not entirely sure what I'm doing.
    Reply With Quote Edit / Delete Windows 10 Chrome Finland Show Events Funny Funny x 3 (list)

  38. Post #2998
    Gold Member
    WTF Nuke's Avatar
    March 2009
    5,247 Posts
    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:
    using mySet = mpl::set<int, float, double>;
    using myNewSet = /*insert magic here*/;
    //myNewSet == mpl::set<container<int>, container<float>, container<double>>
    Reply With Quote Edit / Delete Windows 10 Firefox Canada Show Events

  39. Post #2999
    Gold Member
    DrTaxi's Avatar
    September 2009
    5,598 Posts
    If you're asking me... I am not entirely sure what I'm doing.
    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.
    Reply With Quote Edit / Delete Windows 10 Vivaldi Germany Show Events Agree Agree x 2 (list)

  40. Post #3000

    October 2014
    19 Posts
    I have the Problem that i cant create an Array of my Class Tank and i dont know why.

    This is the tank header
    Code:
    #ifndef TANK_H
    #define TANK_H
    
    #include <Windows.h>
    #include "GameManager.h"
    
    class Tank
    {
    public:
    	Tank();
    	Tank(int posX, int posY, char icon);
    
    	void Shoot();
    	void ShootTimer();
    	void Update();
    	void GetInput();
    
    	~Tank();
    
    private:
    	int ShootDelay;
    	int ShootTimerInt;
    	bool canShoot;
    	
    	int *posX;
    	int *posY;
    	char *icon;
    };
    #endif
    and this the cpp
    Code:
    #include "Tank.h"
    
    Tank::Tank()
    {
    }
    
    Tank::Tank(int posX, int posY, char icon)
    {
    	this->icon = new char(icon);
    	this->posX = new int(posX);
    	this->posY = new int(posY);
    	//this->canShoot = true;
    }
    
    void Tank::Shoot()
    {
    
    }
    
    void Tank::ShootTimer()
    {
    	/*if (!canShoot)
    	{
    		ShootTimerInt += 1;
    
    		if (ShootTimerInt >= ShootDelay)
    		{
    			canShoot = true;
    			ShootTimerInt = 0;
    		}
    	}*/
    }
    
    void Tank::Update()
    {
    	GetInput();
    	ShootTimer();
    }
    
    void Tank::GetInput()
    {
    	//if (GetAsyncKeyState(VK_SPACE) && this->canShoot)
    	//	Shoot();
    }
    
    
    Tank::~Tank()
    {
    	delete this->icon;
    	delete this->posX;
    	delete this->posY;
    }
    here i try to implement the Array
    Code:
    #ifndef GM_H
    #define GM_H
    
    #include "Tank.h"
    #include "Enemy.h"
    #include <list>
    #include <thread>
    #include <chrono>
    
    class GameManager
    {
    public:
    	GameManager(int millisecondsSleepTime);
    	GameManager();
    	~GameManager();
    
    	Tank *Tanks[3];
    
    	Enemy *Enemys[3];
    
    	bool Playing = true;
    	int *SleepTime;
    
    	void GameLoop();
    };
    #endif
    it throws me Syntaxerrors in the line i created the tank Array and C++ compiler error c4430 “c++ doesnt support default int”

    but a line later the same thing works just fine with the Enemy Array.
    Reply With Quote Edit / Delete Windows 8.1 Chrome Germany Show Events