Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

130 Neutral

About coltdaniel

  • Rank
  1.   Thanks for the suggestion. The XY plane stuff worked as expected (normals always equal to (0,0,1)). But the unity sphere stuff show that there are problems. I took every point and divided by it's length relative to the origin to put them at a distance of 1 to the origin. The normals generated for these points are never equal to the points themselves, so something is wrong.   What I am talking about is related to what they are talking here: http://www.pointclouds.org/documentation/tutorials/normal_estimation.php
  2. This two points was an example that I choose to show that the result seemed strange to me. It has no practical use, nothing to do with a line, if I showed the real case with 243 points it would be harder to follow the problem. All I want to know is if I am understanding correctly what the procedure says. The idea is that if someone can read the procedure in the screenshot, it can make a quick check in my calculations and see if I did something wrong. In a conceptual way, like dividing by a number in each step of a summatory, instead only in the end, not in a arithmetic way.   For every point the in the set, it should create an approach of a normal. So it should be possible to "reach" the point by picking it and multiplying it by a constant. An example it is a point (6,8,0) that with an unitary normal of coordinates (0.6,0.8,0) would need a constant value of ten. But I am getting really weird values that can't be approximation errors, like a point with coordinates (-x,y,-z) and a normal for this point that it is (x,-y,-z), so that if I multiply it by a constant t or -t it can never reach the point I think it's fairly easy. It isn't for mesh generation, it's for generation normals for planes.
  3. Hello, I am doing some experiment with point cloud visualization, and found a procedure to generate normals from these point clouds. The idea is to use the points to generate the normal. The problem is that I may be misunderstanding what should be done. For instance, if I have two points with coordinates (0,0,5) and (0,0,10), so I expected the normal to be (0,0,1), in that way the point can be "reached" by taking the normal and multiplying it by a constant, but what I am getting it is a (1,0,0) or a (0,1,0) normal that can never "reach" neither of these points, so that's why I think I am doing something wrong. I attached an screenshot of the procedure, and here I will simulate my calculations done with these two points, so hopefully someone will be able to see a mistake.   Here is the screenshot:   [attachment=29452:Screenshot.png] Here is the simulation: H = [ || (0,0,5) - (0,0,5) || / 2 ] + [ || (0,0,10) - (0,0,5)|| / 2 ] H = 0 + 2.5 = 2.5 Wp (0,0,5) = e ^ [ (|| (0,0,5) - (0,0,5) ||) / 2.5² ] = e^0 = 1 Wp (0,0,10) = e ^ [ (|| (0,0,10) - (0,0,5) ||) / 2.5² ] = e^(5/6.25) = e^0.8 =~ 2.22 Mp = (Wp (0,0,5) * (0,0,5) + Wp (0,0,10) * (0,0,10)) / Wp (0,0,5) + Wp (0,0,10) = [1 * (0,0,5) + 3.22 * (0,0,10)] / 1 + 2,22 = (0,0,37.2) / 3.22 = (0,0,11.55) C = | (0,0,5) - (0,0,11.55) | = (0,0,-6.55) Inverse C = | (0,0) | | (0,0,10) - (0,0,11.55) | = (0,0,-1.55) | (0,0) | | (-6.55,-1.55) | Inverse C * C = |0 0 0 | eigenvalues = 0, 0, 45.307 |0 0 0 | |0 0 45.3| eigenvectors = (1,0,0) (0,1,0) (0,0,1) normal = (1,0,0) or (0,1,0)   Anyone saw anything wrong ?
  4. cowsarenotevil, yes that what I mean. Until a few moments before starting to write this thread, the "blackness" was giving me an impression of an artifact.   Ryan I can't see any faint circle on this image. My monitor doesn't have much brightness though. Any ideas of what I could do to see it?
  5. Hello, I am doing a Ray-tracer and I may be getting an visual artifact in a scene with a sphere projecting shadow on a plane. Here is:   As can be seen in the above screenshot, it is like the shadow is also projected in the bottom of the sphere in a reduced form. I checked all the calculations in a point located in this shadowed region to see if I could locate the source and my conclusions are this: The problem ain't during the first, direct bounce because the dot product between the light vector and normal is negative. This makes sense, since the light source is exactly above the sphere, aligned with it's center, so if the plane below the sphere wasn't reflective, all the bottom part of the sphere would be in the dark. Ok, then in the first reflection, the ray intersects the plane as expected, but the ray-sphere intersection algorithm says that a intersection happens, I checked the values one by one and everything seems fine. So where can be the error? After some thought I am starting to think that may not be one, that what this intersection means is that the ray hits the plane in a point where it is in the shadow due to the sphere, so none of it's red color hits the bottom of the sphere. But the image seems so unnatural that I am in doubt. What you guys think? Thanks for any suggestions.
  6. coltdaniel

    Reverse normal in ray-plane intersection

    Well, in my case I am just concerned about using planes to represent things like ground or sky, at least for the time being. So in this case I can ignore this reverse procedure, right ?
  7. 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? 
  8. 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?
  9. coltdaniel

    Problem with arrayList

    It ain't that. Note this code: [sourcelang="java"]points = positionList.get(3).getPoints() + this.tournamentManager.get(tournamentNumber).getQuarterFinalistPoints(); positionList.get(3).updatePoints(points); When the first tourament is executed, the fourth quarterfinalist gets its number of points, which should be zero, since the tournament just finished. Then these points are added to the number of points that a quarterfinalist of the tournamet should receive. The sum of zero with X points, is then updated to the player's constructor After the second tournament is executed, then the fourth quarterfinalist of the second event (whoever is), gets its X points from the previous tournament and sum it with the Y points that the quarterfinalist of the second event should receive. After that, the new amount of points is updated. So my code doesn't depend on the updatePoints method to make the calculation, this is done in the updatePontuation method, the updatePoints one is just a "setter" method. Any more ideas?
  10. 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) [sourcelang="java"] 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(); federation.controlActivities(); } public void controlActivities() { this.addTournament (this.createTournament("rolandGarros",200,140,90,50)); this.addTournament (this.createTournament("umag",30,20,15,10)); tournamentManager.get(0).playTournament(this.tournamentManager.get(0).getListPlayers()); this.updatePontuation(this.tournamentManager.get(0).getListPositions(), 0); tournamentManager.get(1).playTournament(this.tournamentManager.get(1).getListPlayers()); 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(); positionList.get(0).updatePoints(points); System.out.println (positionList.get(0).getName()); System.out.println (positionList.get(0).getPoints()); points = positionList.get(1).getPoints() + this.tournamentManager.get(tournamentNumber).getQuarterFinalistPoints(); positionList.get(1).updatePoints(points); System.out.println (positionList.get(1).getName()); System.out.println (positionList.get(1).getPoints()); points = positionList.get(2).getPoints() + this.tournamentManager.get(tournamentNumber).getQuarterFinalistPoints(); positionList.get(2).updatePoints(points); System.out.println (positionList.get(2).getName()); System.out.println (positionList.get(2).getPoints()); points = positionList.get(3).getPoints() + this.tournamentManager.get(tournamentNumber).getQuarterFinalistPoints(); positionList.get(3).updatePoints(points); System.out.println (positionList.get(3).getName()); System.out.println (positionList.get(3).getPoints()); points = positionList.get(4).getPoints() + this.tournamentManager.get(tournamentNumber).getSemiFinalistPoints(); positionList.get(4).updatePoints(points); System.out.println (positionList.get(4).getName()); System.out.println (positionList.get(4).getPoints()); points = positionList.get(5).getPoints() + this.tournamentManager.get(tournamentNumber).getSemiFinalistPoints(); positionList.get(5).updatePoints(points); System.out.println (positionList.get(5).getName()); System.out.println (positionList.get(5).getPoints()); points = positionList.get(6).getPoints() + this.tournamentManager.get(tournamentNumber).getViceChampionPoints(); positionList.get(6).updatePoints(points); System.out.println (positionList.get(6).getName()); System.out.println (positionList.get(6).getPoints()); points = positionList.get(7).getPoints() + this.tournamentManager.get(tournamentNumber).getChampionPoints(); positionList.get(7).updatePoints(points); 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,[sourcelang="java"] tournamentManager.get(1).playTournament(this.tournamentManager.get(1).getListPlayers()); 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: [sourcelang="java"] positionList.get(2).updatePoints(points); And this is the method: [sourcelang="java"] 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: [sourcelang="java"] 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) this.positionList.add(match.getLoser()); if (decide == 1) this.positionList.add(match.getWinner()); } I don't know why this is happening. Anyone have and idea? Thanks for the help
  11. coltdaniel

    Problem with array list in Java

    I think I am understanding right now, "federation" doesn't call System.out.println, and since it is called from inside controlActivities, which, by it's turn, is called by "federationn", in the end is "federationn" that is calling system.out. Due to it, tournamentManager tries to get it's tournament objects, but there is nothing there, they belong to the tournamentManager of "federation", because it was "federation" that created those tournaments and added them to it's "own" tournamentManager list. At least from a logical point of view this seems to make sense.
  12. coltdaniel

    Problem with array list in Java

    Quote:Original post by rip-off Well, your problem stems from having two Federation instances. You are adding elements to the vector in one and printing them from another. If you want to move code away from main() you need to create additional classes or functions that do what you want. But that is window dressing, the structure is pretty similar no matter where the code is. Try this: *** Source Snippet Removed *** Note that the use of the "this" reference is unnecessary, but is used mainly for illustration. It worked. I am somewhat confused about what really is going on. When "federationn" inside main calls controlActivities, all the objects created inside this method are going to belong to it? So the "federation" created inside controlActivities is part of "federationn"? I thought objects, created when an object call's a method that creates objects, didn`t belong to anybody, they just "existed". Or not? tournamentManager in my example is trying to get objects from where? Are there two copies of tournamentManager, one belonging to "federation" and other to "federationn"?
  13. coltdaniel

    Problem with array list in Java

    Quote:Original post by rip-off Why are you creating a new Federation instance in controlActivities? If you look at your code, you have 2 Federation instances, one created inside main() and another in controlActivities(). Because I don't want to control the program from inside the main method, so I created the first Federation just to it call controlActivities, and from there I do the Federation's management
  14. coltdaniel

    Problem with array list in Java

    Quote:Original post by rip-off *** Source Snippet Removed *** What class is this function in? You have a federation instance, which you add two Tournament instances to. But the last line references a "tournamentManager" directly. The instances are stored in the "tournamentManager" in "federation". In Federation. The tournamentManager is the arrayList to store the tournament instances. Here is the full code source for the Federation class import java.util.ArrayList; public class Federation { private ArrayList <Tournament> tournamentManager = new ArrayList<Tournament>(); public static void main(String[] args) { Federation federationn = new Federation(); federationn.controlActivities(); } public void controlActivities() { Federation federation = new Federation(); federation.addsTournaments (federation.createsTournaments("rolandGarros",200,140,90,50)); federation.addsTournaments (federation.createsTournaments("umag",30,20,15,10)); //System.out.println(tournamentManager.get(0).retrievesChampion()); } public Tournament createsTournaments(String name, int championPoints,int vice_championPoints, int semifinalistPoints, int quarterfinalistPoints) { Tournament tournament = new Tournament(name, championPoints, vice_championPoints, semifinalistPoints, quarterfinalistPoints); return tournament; } public void addsTournaments(Tournament tournament) { tournamentManager.add (tournament); } }
  15. coltdaniel

    Problem with array list in Java

    Quote:Original post by DevFred Quote:Original post by coltdaniel Although not related to this, there is a problem in adding lots of objects with the same name to an arrayList? Objects don't have names in Java. Show source code to clarify what you mean. public Tournament createsTournaments(String name, int championPoints,int vice_championPoints, int semifinalistPoints, int quarterfinalistPoints) { Tournament tournament = new Tournament(name, championPoints, vice_championPoints, semifinalistPoints, quarterfinalistPoints); return tournament; } As can be seen it creates objects always with the same name "tournament" with are returned to serve as the arguments of this method public void addsTournaments(Tournament tournament) { tournamentManager.add (tournament); } public void controlActivities() { Federation federation = new Federation(); federation.addsTournaments (federation.createsTournaments("rolandGarros",200,140,90,50)); federation.addsTournaments (federation.createsTournaments("umag",30,20,15,10)); //System.out.println(tournamentManager.get(0).retrievesChampion()); } The commented line is the one that generates the error message
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!