GPWiki.org
GPWiki.org
It is currently Sun May 19, 2013 6:18 pm

All times are UTC




Post new topic Reply to topic  [ 39 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Coordinate rotation
PostPosted: Wed Feb 15, 2012 11:46 am 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3805
Location: Ferriday, LA, US
I seriously have to be the most inept sorry excuse for a programmer on the face of the freaking planet.

I've been banging on the FOV crap for about two weeks, and still haven't achieved acceptable results. My latest excursion: I was ready to bash Sirisian's line segment intersection testing function for being too rigid... the function would give me strange results at times. For example, if a was testing my vision ray against a wall (all wall lines are straight -- if the line has differing X coordinates, the Y coordinates must be the same, and vice versa -- no diagonals in any sense), I would get different results depending on whether the wall was going positive X vs. negative X (my wall paths are traversed so that the Southern faces always go in the positive X direction, while North-facing wall sides are plotted in the negative X direction). I would also get different results just by swapping the order of the line segments (in other words, if I used the FOV-ray as the first parameter and the wall line as the second parameter, I would get results very different from what I would had I passed the wall line as the first argument and the vision ray as the second parameter)...

I thought it was an issue with the function Sirisian wrote, so I mocked up a demo where I could easily test different situations (such as swapping the X or Y coordinates of lines, or swapping the order in which they are fed to the intersection-testing function). Well, surely enough, everything worked just fine. Just the way one would expect.

So, evidently, I have something else going on in my own crappily written garbage. I seriously don't know why I put up with this mess. My code doesn't work, I ask for help, I get help, and then I can't use that help because my code is so horribly laid out that it doesn't work correctly under *any* circumstances.

Someone please shoot me.

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Wed Feb 15, 2012 12:23 pm 
Funky Monkey

Joined: Thu Sep 09, 2004 1:17 pm
Posts: 1541
Location: burrowed
Heh, don't get frustrated about it. Everyone has problems with some sneaky bug that at some point interferes with code in a way that you cannot fathom. It took me about 6 months (not actively working on it, but working on it every now and then) to get a decent 2d sphere to wall collision. (Then i lost the code at some point :P)

One thing i'd like to check is the method you're using. LineVSLine is something different than LineSegmentVSLineSegment. But you're probably aware of that. (Also there is rayVSline, and rayVSlineSegment, which might be even more fitting for your purpose)

So when the algorithm is working, your input values probably are off, but i assume you doublechecked if the values for your walls are actually returning the correct ones, and the ray's you're shooting are in the same space.

Well, this is about the only suggestions i can make without looking at some code.

_________________
Long pork is people!

wzl's burrow


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Wed Feb 15, 2012 2:26 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6704
Location: Lincoln, Englandshire
rotInMilc wrote:
I seriously have to be the most inept sorry excuse for a programmer on the face of the freaking planet.


Hey! There's a line here, get to the back! ;)

Seriously, it happens to me all the time. When I wrote the CBFG code and plugged it into my GUI code, all the text was upside down. I'd written the GUI code with Y zero at the top of the screen and the CBFG with the more traditional OpenGL scheme of Y zero at the bottom of the screen. I had to rewrite the render functions for one of the classes, but which one? I was going against logic on the one hand and against established practice on the other.
Happy days. :confused

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Wed Feb 15, 2012 8:13 pm 
Bytewise

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 276
Location: Here (where else?)
@rotInMilc:
I seriously doubt that the worst programmer at this planet would recognize his own short-comings.

I normally put such a problem aside, and after some time at an unexpected moment, you realize why it fails, and/or it starts itching again to try again with a different approach.

I have one problem that I work on every now and then for the last decade with different amounts of success :)
Want to swap? :D

_________________
My project: Messing about in FreeRCT, dev blog, and IRC #freerct at oftc.net


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 5:41 pm 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
Well, I will try a step-by-step way, to make an easy full picture. The final part is not finished yet.
Instead of cast a ray every angle, just look for the vertices, and cast a ray to them.
STEP 01 - Schematic view.
Image
Note: All shadable objects MUST be contained in the same list.
Pl = player;
Wall is a shadable object;

STEP 02 - The basic structure of things.
Code:
class TPointFloat
{
  X, Y : float;
};

class TLine
{
  XStart, YStart : float;
  XEnd, YEnd : float;
  Angle : double; // I'm not sure if double(C++ and C#) is the one used for angles.
};

class TPlayer
{
  FCenterPosition : TPointFloat;
};

class TObjectShadable
{
  VerticesList : List of TPointFloat; // for security and flexibility, let's say that this list is dynamic.
  FListOfProcessingLines : List of TLine
  FListPolygonShadows : List of TLine;
};

class TDarkArea
{
  FLine1, FLine2, FLine3, FLine4 : TLine;
};

class TWall (TObjectShadable)
{
  VerticesList : List of TPointFloat; // it is just the same list of TObjectShadable.
  MyWallSprite : CBitmap;
};

class TMap
{
  FObjectsList : list of TObjectShadable; // what includes TWall.
};

Your wall, for example, is like this(1 bmp, 4 vertices):
Image

Global declarations:
Code:
FThePlayer : TPlayer;
FTheMap : TMap;
FListOfProcessingLines : List of TLine

STEP 03 - The beginning of the algorithm.
What we must know is that there are 2 loops. One inside the other. You could put this code inside a function in the class TMap, for example.
The outer loop make a scanning from the first shadable object to the last:

Code:
SOIndex : Integer;

for SOIndex := 0 to (FObjectsList.count - 1) do
{
  // The second loop here;
};

the variable count is the number of elements inside FObjectsList, since the loop begins from 0, the final index must be the count - 1

The second loop will scan every vertex of the object indicated by SOIndex:
Code:
SOIndex : Integer;
VerticeIndex : Integer;

for SOIndex := 0 to (FObjectsList.count - 1) do
{
  // FObjectsList.item[SOIndex] is the current object.

  for VerticeIndex := 0 to (FObjectsList.item[SOIndex].VerticesList.count -1) do
  {
    // Now we will store the lines that begins from the player center and ends at the vertices of the object.
    BTheNewLine : TRLineS;
    BTheNewLine.XStart := FThePlayer.FCenterPosition.X;
    BTheNewLine.YStart := FThePlayer.FCenterPosition.Y;
    BTheNewLine.XEnd := FObjectsList.item[SOIndex].VerticesList.item[VerticeIndex].X;
    BTheNewLine.YEnd := FObjectsList.item[SOIndex].VerticesList.item[VerticeIndex].Y;
    BTheNewLine.Angle := GetAngle(BTheNewLine.XStart, BTheNewLine.YStart, BTheNewLine.XEnd, BTheNewLine.YEnd); // I'm still looking for a good implementation.
    FObjectsList.item[SOIndex].FListOfProcessingLines.add(BTheNewLine); // now we add the new line to the list of processing;
  };
};


IMPLEMENTATION!
We want to scan only objects inside the scene, so:
Code:
SOIndex : Integer;
VerticeIndex : Integer;

for SOIndex := 0 to (FObjectsList.count - 1) do
{
  // FObjectsList.item[SOIndex] is the current object.
  // If any of the vertices of the object is inside the scene, proceed.
  if VerticesInsideTheScene(FObjectsList.item[SOIndex].VerticesList) then
  {
    for VerticeIndex := 0 to (FObjectsList.item[SOIndex].VerticesList.count -1) do
    {
      // Now we will store the lines that begins from the player center and ends at the vertices of the object.
      BTheNewLine : TLine;
      BTheNewLine.XStart := FThePlayer.FCenterPosition.X;
      BTheNewLine.YStart := FThePlayer.FCenterPosition.Y;
      BTheNewLine.XEnd := FObjectsList.item[SOIndex].VerticesList.item[VerticeIndex].X;
      BTheNewLine.YEnd := FObjectsList.item[SOIndex].VerticesList.item[VerticeIndex].Y;
      BTheNewLine.Angle := GetAngle(BTheNewLine.XStart, BTheNewLine.YStart, BTheNewLine.XEnd, BTheNewLine.YEnd); // I'm still looking for a good implementation.
      FObjectsList.item[SOIndex].FListOfProcessingLines.add(BTheNewLine); // now we add the new line to the list of processing;
    };
  };
};


Let's see what this code does:
Image
The objects containing vertices(in yellow).

Image
This is how the loop see the list of objects, beginning from 0.

Image Image
This is what the code inside the loops does. The RLineS-01 is the first resulting line from scanning added in the list of lines wich will be processed. In the second image you see the resulting lines taken from the scanning of the second object and its vertices.

Note: the resulting lines from scanning are not the lines wich will make the shadow polygon.

STEP 04 - Creating the shadow polygons.
Now, we will create the new global variable:
Code:
FListPolygonShadows : list of TLine;

This is a step-by-step scheme:
Image
We are in the step 3 inside "Create shadow polygon".

Look the following picture:
Image
The pink area is the outside of the screen. Outside of the screen we have 4 vertices, a square rounding the screen.

Now we create a loop, that creates a new shadow line for each resulting line we got before:
Code:
for SOIndex := 0 to (FObjectsList.count - 1) do
{
  for BLineIndex := 0 to FListOfProcessingLines.count -1 do
  {
    //Create the new shadow line:
    BTheNewShadowLine : TLine;
 
    // The following code says that the shadow line start where the resulting line ends, and get its angle:
    BTheNewShadowLine.XStart := FListOfProcessingLines.item[BLineIndex].XEnd;
    BTheNewShadowLine.YStart := FListOfProcessingLines.item[BLineIndex].YEnd;
    BTheNewShadowLine.Angle := FListOfProcessingLines.item[BLineIndex].Angle;
 
    // Now we call a raster functions, that increases the end value of the shadow line until it find the outsidescreen square:
    ProcessEndPointOfShadowLine(BTheNewShadowLine);
    // The increment process uses the angle to know the direction to increase the line.
 
    // Add the new shadow line to the list of shadow lines:
    FObjectsList.item[SOIndex]..FListPolygonShadows.add(BTheNewShadowLine);
  };
};


This is what happens in the first index of the loop:
Image Image

STEP 05 - How the function ProcessEndPointOfShadowLine knows if the end point collided with the outside square.
Well, the functions ProcessEndPointOfShadowLine will check( for each increment ) if there is a intersection between the shadow line and the lines of the square. This process may be slow if we make a small incrementation, then, we must make a median or high incrementation.

Note - Check Line Intersection Function examples:
http://www.ucancode.net/faq/C-Line-Inte ... rawing.htm
http://www.i-logic.com/utilities/trig.htm

The result of the high incrementation may be something like this:
Image

Now, I'm studying how to merge the vertices to create the polygon. :rofl

Links I used to make the concept:
http://flassari.is/2008/11/line-line-in ... cplusplus/
http://cboard.cprogramming.com/contests ... tions.html
http:// paulbourke. net/geometry/insidepoly/
http:// forums.tigsource. com/index.php?topic=8803.0
http:// en.wikipedia. org/wiki/General_Polygon_Clipper [HAVE YOU SEEN THIS?!]
http:// http://www.saltgames. com/2011/2d-shadow-effects/

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Last edited by FelipeFS on Fri Feb 17, 2012 10:26 pm, edited 4 times in total.

Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 5:50 pm 
Super-dooper pooper scooper
User avatar

Joined: Tue Oct 11, 2011 8:08 pm
Posts: 170
Well, that seems complicated. ;)


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 5:52 pm 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
Lexusjjss wrote:
Well, that seems complicated. ;)

:rofl It is not, it is just... large.

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Last edited by FelipeFS on Fri Feb 17, 2012 5:54 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 5:54 pm 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
I don't even know if "shadable" is a real word! :lol
I have not found either in the dictionary either in the Google Translator.

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 8:23 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3805
Location: Ferriday, LA, US
Holy frickincrap, Felipe -- I think I get the basic idea of how you're proceeding about things, and it seems like it would be MUCH less error-prone than my current ray-casting method!

I will have to find a little time to try this out. But, I think it will work nicely (assuming there aren't any other latent bugs in my code, waiting for an opportunity to pounce :rolleyes). Thank you!

FelipeFS wrote:
Code:
      // Now we will store the lines that begins from the player center and ends at the vertices of the object.
      BTheNewLine : TLine;
      BTheNewLine.XStart := FThePlayer.FCenterPosition.X;
      BTheNewLine.YStart := FThePlayer.FCenterPosition.Y;
      BTheNewLine.XEnd := FObjectsList.item[SOIndex].VerticesList.item[VerticeIndex].X;
      BTheNewLine.YEnd := FObjectsList.item[SOIndex].VerticesList.item[VerticeIndex].Y;
      BTheNewLine.Angle := GetAngle(BTheNewLine.XStart, BTheNewLine.YStart, BTheNewLine.XEnd, BTheNewLine.YEnd); // I'm still looking for a good implementation.


Would the following work?

Code:
BTheNewLine.XStart = FThePlayer.FCenterPosition.X;
BTheNewLine.YStart = FThePlayer.FCenterPosition.Y;
BTheNewLine.XDelta = FObjectsList.item[SOIndex].VerticesList.item[VerticeIndex].X - FThePlayer.FCenterPosition.X;
BTheNewLine.YDelta = FObjectsList.item[SOIndex].VerticesList.item[VerticeIndex].Y - FThePlayer.FCenterPosition.Y;
BTheNewLine.CompositeDelta = Math.sqrt(BTheNewLine.XDelta * BTheNewLine.XDelta + BTheNewLine.YDelta * BTheNewLine.YDelta);
BTheNewLine.Angle = Math.atan2(BTheNewLine.YDelta, BTheNewLine.XDelta);
BTheNewLine.XEnd = FThePlayer.FCenterPosition.X + Math.cos(BTheNewLine.Angle) * BTheNewLine.CompositeDelta;
BTheNewLine.YEnd = FThePlayer.FCenterPosition.Y + Math.sin(BTheNewLine.Angle) * BTheNewLine.CompositeDelta;


Of course, that said, I wouldn't need to make lines with regard to the player's location to form the polygon I would use as my clipping plane. The way Canvas works, I can just send it a list of X/Y points, and simply plot lines between each of those X/Y points to create an arbitrary polygon. Then, when I've traced the "outline" of the polygon, I tell my Canvas context to use it as a clip plane -- which is a quick way to ensure that anything outside of the polygon is not rendered.

In other words, I would only want the end points of the lines (which would all be along a wall) to create the polygon to be used for clipping.

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 8:53 pm 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
What would be CompositeDelta? Is that the increment that will be used for find the end point of BTheNewShadowLine?
By the way, remember that the lines wich will became the polygon of shadow are "BTheNewShadowLine", not "BTheNewLine";

BTheNewLine are just an auxiliary storage, they store the angle that the vertex is related to the PlayerCenter.
BTheNewShadowLine will be the lines of the shadow polygon.

I'm saying this because in the code you posted, you are finding the XEnd and YEnd of the BTheNewLine, but the XEnd and YEnd we don't have are from the BTheNewShadowLine.

By the way, I have already figured out the last part of the concept. I will make some schemes and pseudo-codes.

UPDATE ABOUT THE CODE I POSTED: Before the loops start, you MUST clear the list FListOfProcessingLines and FListPolygonShadows. If yo do not do it, when the player moves, new shadows will be created, but the shadows from the last player position will keep(and we don't want this).

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 9:15 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3805
Location: Ferriday, LA, US
FelipeFS wrote:
What would be CompositeDelta? Is that the increment that will be used for find the end point of BTheNewShadowLine?

CompositeDelta is the total distance between the player's location and the end point of the line.

Say you want to find a line between two sets of X/Y coordinates, but need to do it manually (i.e. without some sort of "lineTo" function or whatnot). You basically start off with this:

Code:
DeltaX = TargetX - OriginX;
DeltaY = TargetY - OriginY;


OK, so you know where the target is in relation to the origin... to find the distance between those two points, however, we would use the following:

Code:
CompositeDelta = Math.sqrt(DeltaX * DeltaX + DeltaY * DeltaY);


Which basically means "Add the square of DeltaX to the square of DeltaY together, and then get the square-root of the result." This is the actual distance between our target and our origin. Now, to actually find the line, we figure out the angle between the target and origin coordinates:

Code:
Angle = Math.atan2(DeltaY, DeltaX);


...and multiply the angle's X/Y components by the distance between the target and origin:

Code:
LineStartX = OriginX;
LineStartY = OriginY;
LineEndX = LineStartX + Math.cos(Angle) * CompositeDelta;
LineEndY = LineStartY + Math.sin(Angle) * CompositeDelta;


And that gives you the relative position of the coordinate sets, as well as the distance from both points, and the angle between them. When you combine these elements together, magic happens.

FelipeFS wrote:
By the way, remember that the lines wich will became the polygon of shadow are "BTheNewShadowLine", not "BTheNewLine";

BTheNewLine are just an auxiliary storage, they store the angle that the vertex is related to the PlayerCenter.
BTheNewShadowLine will be the lines of the shadow polygon.

I'm saying this because in the code you posted, you are finding the XEnd and YEnd of the BTheNewLine, but the XEnd and YEnd we don't have are from the BTheNewShadowLine.

Yeah, I gotcha -- I went over it kind of quickly initially, and my mind was jumping all over the place (not that this is unusual for me). I was more or less trying to, in my head, adapt your code to fit into my situation. So I may have confused the terminology a bit. :)

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 9:17 pm 
Super-dooper pooper scooper
User avatar

Joined: Tue Oct 11, 2011 8:08 pm
Posts: 170
Could you put that on the wiki? Even without the code, that's quite a useful post.


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 9:24 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3805
Location: Ferriday, LA, US
Lexusjjss wrote:
Could you put that on the wiki? Even without the code, that's quite a useful post.

To which author, and to which post, do you refer?

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 9:38 pm 
Super-dooper pooper scooper
User avatar

Joined: Tue Oct 11, 2011 8:08 pm
Posts: 170
rotInMilc wrote:
Lexusjjss wrote:
Could you put that on the wiki? Even without the code, that's quite a useful post.

To which author, and to which post, do you refer?


Felipe's page long list of ray casting code.


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 9:45 pm 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
Just wait a moment, folks, I'm almost finishing the last part.

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 10:08 pm 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
Well, the last part is done! It is easier than I imagined, because complex polygons are not need.
ALL polygons that will shape the shadows will be compound of 4 lines.
Let's see:
ImageImage

and the points of each shadow line:
Image
But, there is a question. Like you see above, there are only 2 shadow lines.
We will consider the origin and the end of each shadow line the 2 lines lacking. One is equivalent to the wall There they are:
Image

To make possible paint this area, let's create a new class:
Code:
class TDarkArea
{
  FLine1, FLine2, FLine3, FLine4 : TLine;
};


We will create these darkarea objects inside a new loop for - But before a modification:

In the previous post, I put FListPolygonShadows and FListOfProcessingLines as a global variable, instead of this, put these variables inside the class TObjectShadable, that means that each object will have its own list of shadows lines and resulting lines from scanning, and means that a object can have more than one shadow. (I will update the previous post, changing how the objects TDarkArea will be added for its respective objects). This is how the calss must look now:
Code:
class TObjectShadable
{
  VerticesList : List of TPointFloat; // for security and flexibility, let's say that this list is dynamic.
  FListOfProcessingLines : List of TLine
  FListPolygonShadows : List of TLine;
};


Code:
FListShadowsAreas : List of TDarkArea;

for BIndex := 0 to FObjectsList.item.count -1 do
{
  //Create the new shadow line:
  BTheNewShadowArea : TDarkArea;
 
  //First Line of shadow area - The one that is equivalent to the wall:
  BTheNewShadowArea.FLine1.StartX := FObjectsList.item[BIndex].VerticesList.item[0].X;
  BTheNewShadowArea.FLine1.StartY := FObjectsList.item[BIndex].VerticesList.item[0].Y;
  BTheNewShadowArea.FLine1.EndX := FObjectsList.item[BIndex].VerticesList.item[0].X;
  BTheNewShadowArea.FLine1.EndY := FObjectsList.item[BIndex].VerticesList.item[0].Y;
 
  BTheNewShadowArea.FLine2 := FObjectsList.item[BIndex].FListPolygonShadows.Item[0];
  BTheNewShadowArea.FLine3 := FObjectsList.item[BIndex].FListPolygonShadows.Item[1];
 
  //The last line use the EndX and EndY of each shadow line;
  BTheNewShadowArea.FLine4.StartX := FObjectsList.item[BIndex].FListPolygonShadows.Item[0].EndX;
  BTheNewShadowArea.FLine4.StartY := FObjectsList.item[BIndex].FListPolygonShadows.Item[0].EndY;
  BTheNewShadowArea.FLine4.EndX := FObjectsList.item[BIndex].FListPolygonShadows.Item[1].EndX;
  BTheNewShadowArea.FLine4.EndY := FObjectsList.item[BIndex].FListPolygonShadows.Item[1].EndY;
 

  // Now we call a raster functions, that increases the end value of the shadow line until it find the outsidescreen square:
  ProcessEndPointOfShadowLine(BTheNewShadowArea);
  // The increment process uses the angle to know the direction to increase the line.
 
  // Add the new shadow line to the list of shadow lines:
  FListShadowsAreas .add(BTheNewShadowArea);
}


After this loop, the next loop - yeah, the last one!!! - will be like this:

Code:
for BIndex := 0 to FObjectsList.item.count -1 do
{
  DrawFourSideArea(FObjectsList.item[BIndex], rgb(0, 0, 0));
};


Now we have the dark area!

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 10:27 pm 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
Since I changed the list of shadow lines and resulting lines from scanning from global to local(inside the TObjectShadable), I have changed a little bit the first code I posted.

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 11:04 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3805
Location: Ferriday, LA, US
Felipe, I haven't figured out if you've addressed this particular issue yet, but does this routine take into account walls partially behind other walls?

Sorry if this question is dense, I haven't yet had a chance to sit down and give your code a proper poring-over.

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
 Post subject: Re: Coordinate rotation
PostPosted: Fri Feb 17, 2012 11:40 pm 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
No, it is still considering the walls behind other walls.

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 39 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group