Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 12 Jul 2009
Offline Last Active Dec 19 2014 06:54 PM

Topics I've Started

Reverse normal in ray-plane intersection

24 November 2014 - 12:10 AM

Hello, I am trying to do ray-plane intersection based on this siggraph material: http://www.siggraph.org/education/materials/HyperGraph/raytrace/rayplane_intersection.htm and there the tutorial says that if the dot product between the ray direction and the plane normal is greater than zero then it usually should be reversed.

Why? Since I don't know yet the reason, I also don't know if I can reverse it soon after the first intersection test for the first pixel and then forget about it, or if I can reverse it once only for the intersection rays (I am using orthographic projection, so the ray's direction is always 0,0,1) and then for reflection/refraction rays should I do the dot product test everytime?

Someone could do the favor of clarify that out for me? 

Changing color background

03 February 2013 - 10:39 PM

There is a way to do this? The white background is very irritating to the eyes when I am in a fairly dark environment (which is all the cases of myself acessing it). There is a way to use the old blue background?

Problem with arrayList

23 November 2009 - 03:40 PM

I Have this program: It creates a federation that controls a series of tournaments, which are disputed and the points should go to the players according to their position in the tournament. I use an arraylist in which the players are positioned there based in the round of the tournament in which they lose. The loser of the first quarterfinal is putted in position 0, the one that loses in the second quarterfinal in position 1, and so on until the champion in the eight position. Here is part of code of this program: (this is most of the main class)
import java.util.ArrayList;

public class Federation {
	private int tournamentNumber;
	private ArrayList <Tournament> tournamentManager = new ArrayList<Tournament>();
	public static void main(String[] args) {
		Federation federation = new Federation();	
    public void controlActivities() {
    	this.addTournament (this.createTournament("rolandGarros",200,140,90,50));
    	this.addTournament (this.createTournament("umag",30,20,15,10));
    	this.updatePontuation(this.tournamentManager.get(0).getListPositions(), 0);
    	this.updatePontuation(this.tournamentManager.get(1).getListPositions(), 1);
    private void updatePontuation(ArrayList <Player> positionList, int tournamentNumber) {
    	int points;
    	System.out.println (positionList.get(0).getPoints());
    	System.out.println (positionList.get(1).getPoints());
    	System.out.println (positionList.get(2).getPoints());
    	System.out.println (positionList.get(3).getPoints());
    	System.out.println (positionList.get(4).getPoints());
    	System.out.println (positionList.get(5).getPoints());
    	System.out.println (positionList.get(6).getPoints());
    	System.out.println (positionList.get(7).getPoints());
    	System.out.println (tournamentManager.get(0).getSemiFinalistPoints());
    	System.out.println (tournamentManager.get(1).getSemiFinalistPoints());
		points = positionList.get(0).getPoints() + this.tournamentManager.get(tournamentNumber).getQuarterFinalistPoints();
		System.out.println (positionList.get(0).getName());
		System.out.println (positionList.get(0).getPoints());
		points = positionList.get(1).getPoints() + this.tournamentManager.get(tournamentNumber).getQuarterFinalistPoints();
		System.out.println (positionList.get(1).getName());
		System.out.println (positionList.get(1).getPoints());
		points = positionList.get(2).getPoints() + this.tournamentManager.get(tournamentNumber).getQuarterFinalistPoints();
		System.out.println (positionList.get(2).getName());
		System.out.println (positionList.get(2).getPoints());
		points = positionList.get(3).getPoints() + this.tournamentManager.get(tournamentNumber).getQuarterFinalistPoints();
		System.out.println (positionList.get(3).getName());
		System.out.println (positionList.get(3).getPoints());
		points = positionList.get(4).getPoints() + this.tournamentManager.get(tournamentNumber).getSemiFinalistPoints();
		System.out.println (positionList.get(4).getName());
		System.out.println (positionList.get(4).getPoints());
		points = positionList.get(5).getPoints() + this.tournamentManager.get(tournamentNumber).getSemiFinalistPoints();
		System.out.println (positionList.get(5).getName());
		System.out.println (positionList.get(5).getPoints());
		points = positionList.get(6).getPoints() + this.tournamentManager.get(tournamentNumber).getViceChampionPoints();
		System.out.println (positionList.get(6).getName());
		System.out.println (positionList.get(6).getPoints());
		points = positionList.get(7).getPoints() + this.tournamentManager.get(tournamentNumber).getChampionPoints();
		System.out.println (positionList.get(7).getName());
		System.out.println (positionList.get(7).getPoints());

    public void addTournament(Tournament tournament) {
    	tournamentManager.add (tournament);

When I execute the first tournament, everything goes just fine, the players are putted in there as they should be and the points are distributed correctly. But when I put the code to execute the second event,
this.updatePontuation(this.tournamentManager.get(1).getListPositions(), 1); 

it simply does not sum the points that a player got from the new tournament to its old ones. This is a call to the method that updates the points of a certain player in its constructor:

And this is the method:
public void updatePoints(int points) {
		this.points = points;

In fact, the points of the old one are erased. Here is the source code from another class that deals with the positioning of a player based on whether he wins the match or nott:
                   private ArrayList <Player> positionList = new ArrayList<Player>(); 
                   Match match7 = new Match(match5.getWinner(), match6.getWinner());
		   match7.decideMatch ();
		   match7.showWinner  ();
		   this.updatePositionList (0, match7);
		   this.updatePositionList (1, match7);
	public void updatePositionList (int decide, Match match) {
		if (decide == 0)
		if (decide == 1)

I don't know why this is happening. Anyone have and idea? Thanks for the help

Problem with array list in Java

12 July 2009 - 08:32 AM

I am trying to add a bunch of objects to an arrayList and them to print the values of one of the fields of these objects through a System.out.println. Inside System.out, the arrayList uses get to obtain its object number 0, and them send the object to use a getter method of its class to obtain the value of one of its fields, the value that should be printed But then I receive: Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.RangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) What can be? Although not related to this, there is a problem in adding lots of objects with the same name to an arrayList? I guess not, since every time I invoke the method responsible for adding the objects to the arrayList, its gonna add them to sequential positions, but I wanna be sure

How I can post code?

12 July 2009 - 07:58 AM

Normally I use
to enter code in another foruns, but here it doesnt work and I dont have any visible option to manipulate text when I post a message. What can I do?