1. Post #561
    ☂☂☂☂ ☂☂☂ ☂☂ _☂_
    Cuel's Avatar
    January 2005
    22,688 Posts
    Thanks bby.

    Edited:

    http://pastebin.com/Kg7FNP5S
    good/bad?

    What would be a good way to delete the folders if they are empty after deleting the files? - solved, added
    Code:
            if (file.isDirectory() && file != this.getDefaultDirectory()) {
                File[] itemsInFolder = file.listFiles();
                System.out.println(itemsInFolder.length);
                if (itemsInFolder.length == 0){
                    file.delete();
                }
            }
    at the bottom.
    anything else for error handling etc?
    Reply With Quote Edit / Delete Windows 7 Show Events

  2. Post #562
    Gold Member
    marvincmarvin's Avatar
    January 2011
    796 Posts
    I just did something similar last night and this is what I did..

    //Define event in your class
    public delegate void Connect(object sender, EventArgs args);
    public event Connect OnConnect; 
    
    void CallEvent() {
          if(this.OnConnect) 
                this.OnConnect(this, Eventargs.Empty);
    }
    
    Reply With Quote Edit / Delete Windows 7 United States Show Events Informative Informative x 1 (list)

  3. Post #563
    Reply With Quote Edit / Delete Windows XP Germany Show Events

  4. Post #564
    Sprite's Avatar
    October 2011
    294 Posts
    I need to write a simple program (because I don't know of one that exists) that allows me to create a tree of objects.

    >node1
    >>sub node1
    >>>subsub node1
    >>>subsub node2
    >>>subsub node3
    >>sub node2
    >>sub node3
    >>sub node4
    >node2

    I was thinking of writing it in visual basic (which I have forgotten) but perhaps there is something better to use.
    I'd go about HTML5 but I'm not sure how much data can be stored from a browser.

    I need this to write out ideas for my story. Superficial scope nodes are for general events that I need to detail later with deeper scope nodes.

    OH .... Silver Light?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  5. Post #565
    Capsup's Avatar
    April 2007
    823 Posts
    Working with WebGL using JavaScript and I've run into the weirdest error ever. I have this part:

    Code:
    				flatShader.VertexPositionAttribute = gl.getAttribLocation( flatShader, "v3VertexPosition" );
    				gl.enableVertexAttribArray( flatShader.VertexPositionAttribute );
    This works, no problems at all and the shader is used to draw some lines etc...

    However:
    Code:
    				textureShader.VertexPositionAttribute = gl.getAttribLocation( textureShader, "a_v3VertexPosition" );
    				gl.enableVertexAttribArray( textureShader.VertexPositionAttribute );
    The next piece of code only works if I comment out the gl.enableVertexAttribArray line, otherwise an error 1282 ( INVALID_OPERATION ) occurs.

    Code:
    				gl.useProgram( flatShader );
    				gl.bindBuffer( gl.ARRAY_BUFFER, buffer );
    
    				gl.vertexAttribPointer( flatShader.VertexPositionAttribute, 3, gl.FLOAT, false, 0, 0 );
    				gl.uniformMatrix4fv( flatShader.mvpMatrixUniform, false, mvpMatrix );
    				gl.drawArrays( gl.LINES, 0, 2 );
    
    				gl.bindBuffer( gl.ARRAY_BUFFER, null );
    
    				gl.useProgram( null );
    More specifically, gl.drawArrays errors out with that error. HOWEVER, the following does not generate the same error:

    Code:
    				textureShader.TextureCoordAttribute = gl.getAttribLocation( textureShader, "a_v2TextureCoord" );
    				gl.enableVertexAttribArray( textureShader.TextureCoordAttribute );
    So what the fuck is wrong with the VertexPosition variable!? I have checked, doublechecked and rechecked every single line and there is not a single mistype to spot. And it works as soon as I comment out that line. If I add a deliberate type error in there, such as:

    Code:
    				textureShader.VertexPositionAttribute = gl.getAttribLocation( textureShader, "a_v3VertexPosition" );
    				gl.enableVertexAttribArray( textureShader.NOSUCHVARIABLE )
    It keeps on going happily and enableVertex errors out with a INVALID_VALUE instead, however the lines are drawn.

    Why the fuck does that one line make glDrawArrays error out, when the next glEnableVertexAttribArray does not!?


    EDIT
    Figured out what was wrong. I was enabling the vertexarrays too early and unlike OpenGL, WebGL will error out on glDrawArrays / glDrawElements calls if a vertexarray is enabled on a buffer that is not populated. However after I fixed this, I still haven't been able to get my textured quad working yet... Would anybody care taking a look at my code and see if they can spot any issues that I might have missed?
    http://dl.dropbox.com/u/40398697/Web...bGLProject.rar
    Any help is appreciated. :)
    Reply With Quote Edit / Delete Windows 7 Denmark Show Events

  6. Post #566
    quincy18's Avatar
    September 2007
    1,018 Posts
    Could anybody take a look at this : http://gamedev.stackexchange.com/que...ith-2d-terrain
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  7. Post #567
    Gold Member

    March 2005
    3,028 Posts
    @capsup:
    Just out of curiosity, does it work if you replace gl.drawArrays with gl.drawElements, with an index buffer containing just "1, 2, 3, 4, 5, ..., n-1, n"?
    Reply With Quote Edit / Delete Windows 7 Show Events

  8. Post #568
    Gold Member
    WTF Nuke's Avatar
    March 2009
    4,470 Posts
    If you are seeing if a line intersects with another line, I'd use this article: http://paulbourke.net/geometry/lineline2d/
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  9. Post #569
    HQRSE FUCKER
    ief014's Avatar
    September 2009
    3,070 Posts
    A hacky way to do it would be to render the text into sf::RenderTexture and then render that onto you sf::RenderWindow.
    That's what I was hoping to not do, but it seems like my only option.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  10. Post #570
    Gold Member

    March 2005
    3,028 Posts
    To find which cell in the terrain to intersect with, think of it top-down as drawing a line in 2D.
    I'm going to use 'x[sub]0[/sub]' and 'x[sub]1[/sub]' to denote the minimum and maximum x-values of the current cell, respectively (same goes for y[sub]0[/sub], y[sub]1[/sub]). Likewise, z[sub]00[/sub] is going to denote corner with x=x[sub]0[/sub] and y=y[sub]0[/sub].

    Also, I'm going to use values <dx, dy, dz>, which represent the direction of the trace (they do not need to be normalized), and <x[sub]initial[/sub], y[sub]initial[/sub], z[sub]initial[/sub]> as the start of the trace.
    Start at the trace position, iterate by:
    x[sub]t[/sub] = dx < 0.0 ? x[sub]0[/sub] - x : x[sub]1[/sub] - x
    y[sub]t[/sub] = dy < 0.0 ? y[sub]0[/sub] - x : y[sub]1[/sub] - y
    t[sub]x[/sub] = x[sub]t[/sub] / dx;
    t[sub]y[/sub] = y[sub]t[/sub] / dy;
    t[sub]0[/sub] = (t[sub]x[/sub] < t[sub]y[/sub] ? t[sub]x[/sub] : t[sub]y[/sub]) + epsilon
    x += dx * t[sub]0[/sub];
    y += dy * t[sub]0[/sub];
    z += dz * t[sub]0[/sub];
    Now you have the current position (at the edge of the next nearest cell).

    Long story short, trying to solve from bilinear interpolation doesn't work out well. (The equation was like a full page).
    Instead, I'm going to define the surface of the polygon by its approximate partial-derivatives:
    z[sub]y[/sub] = (z[sub]1[/sub] - z[sub]0[/sub]) / (y[sub]1[/sub] - y[sub]0[/sub])
    z[sub]x[/sub] = (z[sub]1[/sub] - z[sub]0[/sub]) / (x[sub]1[/sub] - x[sub]0[/sub])
    So that:
    z = z[sub]y[/sub] * (y - y[sub]0[/sub]) + z[sub]x[/sub] * (x - x[sub]0[/sub]) + z[sub]00[/sub]

    The line is defined by:
    x = dx * t + x[sub]initial[/sub],
    y = dy * t + y[sub]initial[/sub],
    z = dz * t + z[sub]initial[/sub],


    Substituting the line equations back in:
    dz * t + z[sub]initial[/sub] = z[sub]y[/sub] * (dy * t + y[sub]initial[/sub] - y[sub]0[/sub]) + z[sub]x[/sub] * (dx * t + x[sub]initial[/sub] - x[sub]0[/sub]) + z[sub]00[/sub]
    Solving for t:
    t = (z[sub]y[/sub] * (y[sub]initial[/sub] - y[sub]0[/sub]) + z[sub]x[/sub] (x[sub]initial[/sub] - x[sub]0[/sub]) + z[sub]00[/sub] - z[sub]initial[/sub]) / (dz + dy * z[sub]y[/sub] + dx * z[sub]x[/sub])
    Substitute the value of t back into the line equation to get a point of intersection, check that point against the x- and y- bounds of the current cell.


    And oh dear god I hope that's right. I wrote it all off the top of my head, so verify the crap out of it.





    EFFFFFFFFFFFFFFFFFFFff. 2D terrain. Blargl.
    Reply With Quote Edit / Delete Windows 7 Show Events Informative Informative x 1 (list)

  11. Post #571
    DSG
    Gold Member
    Dennab
    October 2009
    5,953 Posts
    Can someone help me with why this isn't working? (programming in C)

    Code:
    #include <stdio.h>
    #include <math.h>
    #include <string.h>
    #include <ctype.h>
    char rot13char(char c)
    {
    	if(!isalpha(c))
    	{
    		return c;
    	}
    	else if(islower(c))
    	{
    		if(c > 'n')
    		{
    			return c -= 13;
    		}
    		else
    		{
    			return c += 13;
    		}
    	}
    	else
    	{
    		if(c > 'N')
    		{
    			return c -= 13;
    		}
    		else
    		{
    			return c += 13;
    		}
    	}
    }
    void rot13str(char str[])
    {
        int i;
    
        for(i=0; i != EOF; i++)
        {
            char c = getchar();
    
            str[i] = rot13char(c);
        }
    
    }
    int main(void)
    {
    64	char *s;
    	char c[101];
    
    	s = fgets(c, 101, stdin);
    
    	printf("Enter lines: ");
    
    71	while(s != EOF)
    	{
    		printf("%s", c);
    		s = fgets(c, 101, stdin);
    	}
    
    	return 0;
    }
    The purpose of the program is to take user input as a string, then convert the string by rot13 (a to n, b to o, c to p, etc.) and print it out. When compiling I receive the following errors:

    64: ISO C90 forbids mixed declarations and code
    71: comparison between pointer and integer

    I put 64 and 71 in the code to make it easier to find them. I'm not really sure how to fix these or why they're coming up.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  12. Post #572
    Gold Member
    Octave's Avatar
    January 2009
    2,530 Posts
    Can someone help me with why this isn't working? (programming in C)

    Code:
    #include <stdio.h>
    #include <math.h>
    #include <string.h>
    #include <ctype.h>
    char rot13char(char c)
    {
    	if(!isalpha(c))
    	{
    		return c;
    	}
    	else if(islower(c))
    	{
    		if(c > 'n')
    		{
    			return c -= 13;
    		}
    		else
    		{
    			return c += 13;
    		}
    	}
    	else
    	{
    		if(c > 'N')
    		{
    			return c -= 13;
    		}
    		else
    		{
    			return c += 13;
    		}
    	}
    }
    void rot13str(char str[])
    {
        int i;
    
        for(i=0; i != EOF; i++)
        {
            char c = getchar();
    
            str[i] = rot13char(c);
        }
    
    }
    int main(void)
    {
    64	char *s;
    	char c[101];
    
    	s = fgets(c, 101, stdin);
    
    	printf("Enter lines: ");
    
    71	while(s != EOF)
    	{
    		printf("%s", c);
    		s = fgets(c, 101, stdin);
    	}
    
    	return 0;
    }
    The purpose of the program is to take user input as a string, then convert the string by rot13 (a to n, b to o, c to p, etc.) and print it out. When compiling I receive the following errors:

    64: ISO C90 forbids mixed declarations and code
    71: comparison between pointer and integer

    I put 64 and 71 in the code to make it easier to find them. I'm not really sure how to fix these or why they're coming up.
    It should be
    Code:
    while (*s != EOF)
    
    or
    
    while (s != NULL)
    fgets returns a pointer to whatever is read. Also, in this case you are better off just using gets(), which automatically reads from stdin. I'm not sure why you're reading into two different strings at this point, just read into c or something.
    Reply With Quote Edit / Delete Linux United States Show Events

  13. Post #573
    olavst's Avatar
    November 2011
    76 Posts
    I need help deciding what scripting language to use for my Qt application. I want to give users the ability to write plugins. Similar to Sublime Text 2.
    QtScript and QtLua looks like two solutions. I prefer Lua, but it looks like QtScript is easier to integrate with existing QObject classes.

    Have anyone used either of these libraries? If so, what was your experience with it?
    Reply With Quote Edit / Delete Windows 7 Norway Show Events

  14. Post #574
    Gold Member
    Jookia's Avatar
    July 2007
    6,768 Posts
    Don't use gets or fgets.
    Reply With Quote Edit / Delete Linux Australia Show Events Agree Agree x 2 (list)

  15. Post #575
    Gold Member
    Sir Whoopsalot's Avatar
    August 2010
    23,104 Posts
    I'm in a bit of of what is medically known as a pickle. I'm making a small screen with a panel that takes a color and paints to a panel when the mouse is clicked and dragged. Problem is, I've hit a metaphorical wall, I don't really know how to get this done. How?

    Java btw.

    Oh, and here comes the wall of probably incredibly painful to look at code, ye be warned.

    Code:
    package swing2;
    
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    public class LayoutStuff extends JFrame implements AdjustmentListener,MouseListener
    
    {
    	
    	JPanel east = new JPanel();
    	JPanel bottom = new JPanel();
    	JPanel palette = new JPanel();
    	JButton button1 = new JButton("Red");
    	JButton button2 = new JButton("Blue");
    	JButton button3 = new JButton("Green");
    	JButton button4 = new JButton("Black");
    	JButton button5 = new JButton("Erase");
    	JScrollBar scrollbar1 = new JScrollBar (JScrollBar.HORIZONTAL, 0, 10, 0, 255);
    	JScrollBar scrollbar2 = new JScrollBar (JScrollBar.HORIZONTAL, 0, 10, 0, 255);
    	JScrollBar scrollbar3 = new JScrollBar (JScrollBar.HORIZONTAL, 0, 10, 0, 255);
    	
    	MyWindowListener myWindowListener;
    	JbuttonListener JbuttonListener;
    	
    	int muisx;
    	int muisy;
    	
    	PaintingStuff pstuff = new PaintingStuff();
    	
    	LayoutStuff()
    	{
    		setupUI();
    	}
    	
    	private void setupUI()
    	{
    		myWindowListener = new MyWindowListener();
    		addWindowListener(myWindowListener);
    		
    		Container c = getContentPane();
    		c.setLayout(new BorderLayout());
    		east.setLayout(new GridLayout(6,1));
    		
    		button1.setBackground(Color.RED);
    		button2.setBackground(Color.BLUE);
    		button3.setBackground(Color.GREEN);
    		button4.setBackground(Color.BLACK);
    		palette.setBackground(Color.BLACK);
    		
    		scrollbar1.setBackground(Color.RED);
    		scrollbar2.setBackground(Color.GREEN);
    		scrollbar3.setBackground(Color.BLUE);
    		scrollbar1.addAdjustmentListener(this);
    		scrollbar2.addAdjustmentListener(this);
    		scrollbar3.addAdjustmentListener(this);
    		
    		east.add(button1);
    		east.add(button2);
    		east.add(button3);
    		east.add(button4);
    		east.add(button5);
    		east.add(palette);
    		
    		JbuttonListener = new JbuttonListener();
    		button1.addActionListener(JbuttonListener);
    		button2.addActionListener(JbuttonListener);
    		button3.addActionListener(JbuttonListener);
    		button4.addActionListener(JbuttonListener);
    		button5.addActionListener(JbuttonListener);
    		bottom.setLayout(new GridLayout(3,1));
    		
    		bottom.add(scrollbar1);
    		bottom.add(scrollbar2);
    		bottom.add(scrollbar3);
    		pstuff.setBackground(Color.WHITE);
    		c.addMouseListener(this);
    		c.add(pstuff);
    		c.add(BorderLayout.EAST, east);
    		c.add(BorderLayout.SOUTH, bottom);
    		setSize(500,500);
    		setVisible(true);
    		
    	}
    	
    	public static void main(String[] args) {
    		
    	LayoutStuff layout = new LayoutStuff();
    	
    	}
    	
    	class JbuttonListener implements ActionListener
    	{
    		public void actionPerformed(ActionEvent e)
    		{
    			if(e.getActionCommand().equals("Red"))
    			{
    				palette.setBackground(Color.RED);
    			}
    			else
    				if (e.getActionCommand().equals("Blue"))
    				{
    					palette.setBackground(Color.BLUE);
    				}
    				else
    					if(e.getActionCommand().equals("Green"))
    					{
    						palette.setBackground(Color.GREEN);
    					}
    					else
    						if(e.getActionCommand().equals("Black"))
    						{
    							palette.setBackground(Color.BLACK);
    						}
    						else
    							if(e.getActionCommand().equals("Erase"))
    							{
    								palette.setBackground(Color.BLACK);
    								palette.repaint();
    								scrollbar1.setValue(0);
    								scrollbar2.setValue(0);
    								scrollbar3.setValue(0);
    							}
    		}
    	}
    
    	public void adjustmentValueChanged(AdjustmentEvent evt) 
    	{
    		int r = scrollbar1.getValue();
    	    int g = scrollbar2.getValue();
    	    int b = scrollbar3.getValue();
    	    
    	    palette.setBackground(new Color(r,g,b));
    	    palette.repaint();
    		
    	}
    	
    
    	public void drawPixel (Graphics g, int muisx, int muisy)
    	{
    		g.fillRect(muisx,muisy,1,1);
    	}
    		
    	public void mouseDragged(MouseEvent e)
    	{	
    	}
    	
    	public void mousePressed(MouseEvent e) {
    		
    	}
    
    	public void mouseClicked(MouseEvent e) {
    		muisx = e.getX();
    		muisy = e.getY();
    		System.out.println(muisx + "," + muisy);
    	}
    	
    	public void mouseEntered(MouseEvent e) {}
    
    	public void mouseExited(MouseEvent e) {}
    	
    	public void mouseReleased(MouseEvent e) {}
    
    	public void mouseMoved(MouseEvent e) {}
    		
    	}
    Reply With Quote Edit / Delete Linux Netherlands Show Events

  16. Post #576
    I gave enough money to buy a soda.
    Funley's Avatar
    May 2010
    1,426 Posts
    So how do i detect collisions between a Vector3 value and a huge (huge as in a list that could contain way over 15,000 vertices) list of vertices in XNA?

    Also, how do i draw 2D lines in XNA as well?

    Edited:

    Man this thread is slow.
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  17. Post #577
    DSG
    Gold Member
    Dennab
    October 2009
    5,953 Posts
    It should be
    Code:
    while (*s != EOF)
    
    or
    
    while (s != NULL)
    fgets returns a pointer to whatever is read. Also, in this case you are better off just using gets(), which automatically reads from stdin. I'm not sure why you're reading into two different strings at this point, just read into c or something.
    I'm in the process of learning C and I'm taking a class for it but when it comes to specific things like this we don't really go over these things. :\ Also I tried changing it to while (*s != EOF) and I still get the error on line 64 for "ISO C90 forbids mixed declarations and code."

    Don't use gets or fgets.
    Why not?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  18. Post #578
    Gold Member
    esalaka's Avatar
    July 2007
    10,249 Posts
    Why not?
    Buffer overflow. Someone gives you more data than you asked for and suddenly your program segfaults or has a potential exploit vector.
    Reply With Quote Edit / Delete Linux Finland Show Events Agree Agree x 1 (list)

  19. Post #579
    Gold Member
    Octave's Avatar
    January 2009
    2,530 Posts
    Buffer overflow. Someone gives you more data than you asked for and suddenly your program segfaults or has a potential exploit vector.
    As an alternative, getline() works fine if you have glibc.

    Edited:

    Also, "ISO C90 forbids mixed declarations and code." has to do with your compiler, what command/options are you compiling with? The results from searching this error told me that in K&R's original C standard, declarations can only be at the start of blocks. But in your case, both of your string declarations are right after the beginning of the main function's block, so I don't know. Maybe try changing your compiler settings if you can.
    Reply With Quote Edit / Delete Mac United States Show Events

  20. Post #580
    Gold Member
    ShaunOfTheLive's Avatar
    November 2007
    9,907 Posts
    Yeah, which compiler are you using DSG? It compiles fine for me using GCC v.4.6.2.

    EDIT: can you upload the actual file somewhere? It might be some weird encoding/line ending problem.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  21. Post #581
    DSG
    Gold Member
    Dennab
    October 2009
    5,953 Posts
    -ansi -Wall -pedantic are my required compiling commands, and it's C90, not C99, and I'm doing it in CodeBlocks. However, even when I try compiling with std=c99 instead of -ansi (which is C90) it'll compile, but not run properly at all. I'll just get a blank terminal window that doesn't print anything and doesn't seem to take any input or output anything as a result.

    Also, my teacher told us to use fgets for strings so I don't know what to really say to that one about the buffer overflow thing. What would I use instead otherwise?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  22. Post #582
    Gold Member
    Octave's Avatar
    January 2009
    2,530 Posts
    -ansi -Wall -pedantic are my required compiling commands, and it's C90, not C99, and I'm doing it in CodeBlocks. However, even when I try compiling with std=c99 instead of -ansi (which is C90) it'll compile, but not run properly at all. I'll just get a blank terminal window that doesn't print anything and doesn't seem to take any input or output anything as a result.

    Also, my teacher told us to use fgets for strings so I don't know what to really say to that one about the buffer overflow thing. What would I use instead otherwise?
    scanf("%s", buf);
    Reply With Quote Edit / Delete Linux United States Show Events

  23. Post #583
    DSG
    Gold Member
    Dennab
    October 2009
    5,953 Posts
    scanf("%s", buf);
    My teacher said scanf and gets were bad to use with strings... Any idea why he would say that?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  24. Post #584
    HQRSE FUCKER
    ief014's Avatar
    September 2009
    3,070 Posts
    My teacher said scanf and gets were bad to use with strings... Any idea why he would say that?
    He doesn't know how to use them. (aka don't listen to him on that)

    I swear, some programming teachers are some of the worst programmers.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Agree Agree x 4 (list)

  25. Post #585
    Gold Member
    WTF Nuke's Avatar
    March 2009
    4,470 Posts
    I have a list of monsters, and I have a map. Everytime the player moves they generate tiles they can see, and color them accordingly(however no list is made of those tiles). I want to make it so that when a player knows he can see a tile, all objects/monsters are revealed that are on that tile. What would be the best way to approach this problem? Make a list of visible tiles that gets discarded every turn, check through all the monsters/items to see if any are displayed on the tile, or something else?
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  26. Post #586
    Gold Member
    ShaunOfTheLive's Avatar
    November 2007
    9,907 Posts
    He doesn't know how to use them. (aka don't listen to him on that)

    I swear, some programming teachers are some of the worst programmers.
    If you can't do, teach. (This doesn't apply to all of them; some of my college professors are really good.)

    Edited:

    -ansi -Wall -pedantic are my required compiling commands,
    What the hell, I just compiled it again with those switches and it still compiles fine for me (it just gives me one warning about line 55).
    Reply With Quote Edit / Delete Windows 7 Canada Show Events Agree Agree x 2 (list)

  27. Post #587
    RUBY OVERLORD
    swift and shift's Avatar
    November 2011
    2,115 Posts
    If you can't do, teach.
    This will always be true until teachers start getting paid decently. Why would you take a teaching job when you can be paid so much more in a real programming job?
    Reply With Quote Edit / Delete Mac Australia Show Events Agree Agree x 6 (list)

  28. Post #588
    HQRSE FUCKER
    ief014's Avatar
    September 2009
    3,070 Posts
    This will always be true until teachers start getting paid decently. Why would you take a teaching job when you can be paid so much more in a real programming job?
    I don't understand it. Every programming teacher I've had were terrible.

    He doesn't know how to use them. (aka don't listen to him on that)

    I swear, some programming teachers are some of the worst programmers.
    To expand more on this;

    Firstly, your teacher should be explaining why they think it's not good to use.
    Secondly, they should be teaching you how to use it properly anyway.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  29. Post #589
    I gave enough money to buy a soda.
    Funley's Avatar
    May 2010
    1,426 Posts
    How do i do collisions with a Vector3 and a list of vertices in XNA?

    Third time's the charm :D
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  30. Post #590
    Gold Member
    Jookia's Avatar
    July 2007
    6,768 Posts
    Firstly, your teacher should be explaining why they think it's not good to use.
    Secondly, they should be teaching you how to use it properly anyway.
    Gets() cannot be used properly.
    Reply With Quote Edit / Delete Linux Australia Show Events

  31. Post #591
    Gold Member
    thomasfn's Avatar
    July 2008
    2,966 Posts
    How do i do collisions with a Vector3 and a list of vertices in XNA?

    Third time's the charm :D
    What does the list of vertices represent? A point cloud? Ordered vertices of a polygon?

    What does the Vector3 represent? A position? How do you want to "do collision"? Do you just want to know if the point is inside the polygon or not, or do you want to move it outside the polygon too?

    We need more information.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  32. Post #592
    Naarkie's Avatar
    September 2011
    320 Posts
    Hi, I need some help parsing/serialising the output from the Facepunch API. The output is in JSON, and I'm using C#.
    Example output
    Reply With Quote Edit / Delete Windows 7 South Africa Show Events

  33. Post #593
    I gave enough money to buy a soda.
    Funley's Avatar
    May 2010
    1,426 Posts
    What does the list of vertices represent? A point cloud? Ordered vertices of a polygon?

    What does the Vector3 represent? A position? How do you want to "do collision"? Do you just want to know if the point is inside the polygon or not, or do you want to move it outside the polygon too?

    We need more information.
    The Vector3 represents a 3D camera's position. The vertice list has VertexPositionNormalTexture objects, which are used to create polygons. The collision i want is to know when the Vector3 is a maybe 1-5 pixels away from a polygon.
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  34. Post #594
    Gold Member

    March 2005
    3,028 Posts
    This will always be true until teachers start getting paid decently. Why would you take a teaching job when you can be paid so much more in a real programming job?
    Because I don't have enough debt already.

    I'd be OK with them redistributing things, so that administration gets less and the professors get more (i.e. the way it should be), but the whole financial situation for students is stressful enough without them having to hike tuition.
    Reply With Quote Edit / Delete Windows 7 Show Events Agree Agree x 1 (list)

  35. Post #595
    Gold Member
    thomasfn's Avatar
    July 2008
    2,966 Posts
    The Vector3 represents a 3D camera's position. The vertice list has VertexPositionNormalTexture objects, which are used to create polygons. The collision i want is to know when the Vector3 is a maybe 1-5 pixels away from a polygon.
    The fast way out is use a physics engine, give the mesh to the physics engine and use the engine to determine if a point is inside of an object or not. If not this, you'll need to lookup and find/implement a "point inside 3d mesh" algorithm. Determining the smallest distance away from an object will be harder.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  36. Post #596

    November 2011
    6 Posts
    I got it now.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  37. Post #597
    evil-tedoz's Avatar
    October 2007
    129 Posts
    Is there someone that know where I could find a good tutorial explaining the magic tricks behind raycasting, I remember having seen one in the WAYWO threads and it got me interested. Thanks.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  38. Post #598
    laharlsblade's Avatar
    July 2009
    1,099 Posts
    In java, I have a JFormattedTextField with an ActionListener added to it and utilizing this simple Mask Formatter:
    format=new MaskFormatter("####");
    It works, but the ActionListener wont perform unless I've filled all four of the digits in the text field. I want it to take any integer with up to four digits, not only four. Anyone know how to do this? I've been looking around and it looks like I may just need a normal JTextField with a custom Document, but I don't yet know how to write one of those. So, if that is indeed the only solution, if anyone could give me a link(s) to a good resource(s) for writing documents for text fields I'd really appreciate it.

    And yes, I'm fairly new to Java, so please just bear that in mind.

    Edit: Oh, and now that I think about it, I'd also like to know how to activate an ActionListener whenever someone edits anything in a JTextField/Area, rather than when the user presses enter.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  39. Post #599
    Gold Member
    Lord Ned's Avatar
    April 2006
    3,702 Posts
    I apologize for this being a complex topic, but I've gotten overwhelmed with too many sources each doing it their own way and my brain is full of confusion now.

    I'm attempting to implement GPU-based skeletal animation. I understand the GPU side of things and already have my vertexes uploaded with boneWeights/boneIndexes.

    Here's my understanding of skeletal animation:
    Each Model contains a "Skeleton", which is composed of an array of "Joints" (or bones).
    Each joint stores a translation/rotation matrix (not sure what this is local to, I think the parent joint) - I don't why we store the INVERSE of this matrix (according to some ways).

    Once you have a skeleton in the model, when you load a basic animation you store the joints as a quaternion (rotation) and vector (translation), because when you go to interpolate later it's easier to work with than a Matrix.

    At the end of each frame, for each bone in the skeleton, you need to build it's final translation matrix.
    To do this you create a matrix based on it's animation, then walk up the chain multiplying by it's parent matrix each time... and by it's skeletal-bind animation too?

    Then these matrixes are uploaded to the GPU, you modify the vertex's position by each boneMatrix * it's weight.

    How far off am I?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  40. Post #600
    Clops with bisousbisous daily <3
    Mr. Smartass's Avatar
    December 2010
    9,188 Posts
    How do you change the center of rotation for a model in XNA?
    Reply With Quote Edit / Delete Windows 7 United States Show Events