Author Topic: 3D Concepts  (Read 4135 times)

0 Members and 1 Guest are viewing this topic.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: 3D Concepts
« Reply #75 on: August 01, 2012, 10:45:48 AM »
I can see the pseudovertices...  whenever the lines cross, a pseudovertex is created.  So next step is we take the 2D X and Y coordinates, and add Z = 0 to create a 3D coordinate.  Next we take the camera position as another 3D coordinate.  Now we draw a line along those two points... I shall call it the CamSect line, because it's formed from the camera and the 2D intersection point.  This 3D CamSect line will intersect with both of the edges that are crossing to create the pseudovertex.

1.  Find sect1, the 3D coordinates of the intersection point between CamSect and Line 1.
2.  Find sect2, the 3D coordinates of the intersection point between CamSect and Line 2.

3.  Calculate the distance from the camera to sect1, call this dist1.
4.  Calculate the distance from the camera to sect2, call this dist2.
5.  Which distance is furthest?  Call that distance 3Ddist. Whichever is furthest away is the edge that will receive the pseudovertex, for which we have just calculated 3D coordinates.  Call the 3D pseudovertex Pseu, with coordinates PseuX, PseuY, and PseuZ.

6.  Next we must check the coordinates PseuX, PseuY, PseuZ against all faces, to see if there are any faces in front of them:
7.  Does this vertex appear inside any faces in 2D?
8.  If it appears inside in 2D, check that face in 3D.  Calculate the coordinates where the plane formed by the face is intersected by the CamSect line.  Call that point CamPlaneSect.

9.  Calculate the distance between CamPlaneSect and the camera.  Call this distance CamPlaneSectDist.
10. Compare CamPlaneSectDist with 3DDist from step 5.  If 3DDist is greater than CamPlaneSectDist, this pseudovertex is behind a face.  If it is, hide it.  If it isn't, don't hide it (yet) and return to step 6 and check the rest of the faces.
« Last Edit: August 01, 2012, 01:15:05 PM by annikk.exe »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: 3D Concepts
« Reply #76 on: August 06, 2012, 04:34:41 PM »
Here's the solution.
We use linear interpolation to travel a portion of the way along the 3d edge. To do this, we need the proportional multiplier. It's called t and has a value between 0 and 1. We calculate t from the 2d lines. Then we travel t proportion of the distance across the edge and arrive at the 3d intersection.. We can calculate each component (x, y, z) separately.

This solution won't work!

To see why, consider this image of a 3D scene:



Look at the line that forms the edge of the sidewalk.
Note how it extends into the distance.  How long is this line in 3D, perhaps a mile?

Now consider that same line, but as 2D.  Find a point halfway along it.  How far away is that in 3D?  Perhaps 15 metres.  No way is it half a mile!

This approach WILL NOT WORK.


So instead I need to find a different way to calculate the intersection point of two 3D lines.


The new method is currently this:


Code: [Select]
function Calculate3DIntersectionPoint(Ax1, Ay1, Az1, Ax2, Ay2, Az2, Bx1, By1, Bz1, Bx2, By2, Bz2)

t = (Ax1 - Bx1) / (Ax1 - Ax2 - Bx1 + Bx2) )

intersectX3d =  Ax1 + ((Ax2 - Ax1) * t)
intersectY3d =  Ay1 + ((Ay2 - Ay1) * t)
intersectZ3d =  Az1 + ((Az2 - Az1) * t)

end

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: 3D Concepts
« Reply #77 on: August 06, 2012, 07:48:29 PM »
Updated the code with this new method of calculating line intersections.  As expected, it still works correctly, but some vertices still flicker.

Damn flickering!  Currently the to-do list is: Fix the flickering, spend an hour throwing together some draw code, and finish.


EDIT.  Actually, wait...  this doesn't work after all.  It's giving some crazy values for the intersection point...
Sigh..
« Last Edit: August 06, 2012, 07:59:39 PM by annikk.exe »

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 899
  • Eufloria: Yes
Re: 3D Concepts
« Reply #78 on: August 06, 2012, 09:04:36 PM »
I'll get that explanation finished at some point tomorrow hopefully.

SweetCandyGrimm

  • Grimm
  • Shoot
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 23
    • My Juggalobook.com Profile.
Re: 3D Concepts
« Reply #79 on: September 04, 2012, 01:14:04 PM »
It's hard to tell how many people actually read things on this forum, or appreciate the efforts of the map-makers, since so few seem to actually post comments. For what it's worth, I, for one, find this thread fascinating and look forward to seeing these concepts developed further. Keep it coming!

IM READING IM READING!!!!! and learning.. i think this is giving me the drive to let math stick.. ;) ty for this wicked game... and a way for us to stick our hands in too :P

oh yea was playing around with window's attempt at iOS's selective screenshots.. then threw it in an editor.. thought it would be cool for bgs and facebook timelines ect ect
my lil gift to all :P ;D
~SCG~