Author Topic: 3D Concepts  (Read 4136 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 #60 on: May 20, 2012, 01:18:53 PM »
No, absolutely nothing at all like fl0w :p

It will be able to display 3D objects made up of points and straight lines, and move/rotate them.  There won't be any textures or lighting effects or anything like that.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
  • First iOS modder :D
Re: 3D Concepts
« Reply #61 on: May 20, 2012, 01:34:41 PM »
I'm a bit confused now, But, get on with it :D

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: 3D Concepts
« Reply #62 on: May 20, 2012, 02:45:31 PM »
You could make it like fl0w, but it would take a lot of time and CPU power...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: 3D Concepts
« Reply #63 on: May 20, 2012, 04:13:51 PM »
No, I really couldn't...  that would require textures and all sorts of things that aren't supported and never will be, due to constraints of Eufloria itself.

I could make gameplay like fl0w perhaps, but it will never look the same way.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
  • First iOS modder :D
Re: 3D Concepts
« Reply #64 on: May 20, 2012, 04:19:54 PM »
Could you control the seedling? As in like a car? :p

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 1,483
  • They'll eat you next!
  • Eufloria: Yes
Re: 3D Concepts
« Reply #65 on: May 20, 2012, 04:27:26 PM »
No, I really couldn't...  that would require textures and all sorts of things that aren't supported and never will be, due to constraints of Eufloria itself.

I could make gameplay like fl0w perhaps, but it will never look the same way.

Textures consist of? Pixels... you can make that happen, but as I said it'd require a lot of time and CPU power...

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
  • First iOS modder :D
Re: 3D Concepts
« Reply #66 on: May 20, 2012, 05:09:10 PM »
I didn't mean the looks of it, I mean an asteroid that has layers :D

So say that

Code: [Select]
depth = 0
which if we was looking at a house, would be the ground floor.

Code: [Select]
depth = -1[/code

which if we was looking at a house, would be the basement.

[code]depth = 1

which if we was looking at a house, would be the second level above ground floor.

Something like that could be done with Asteroids? but only some type of asteroids allow you to switch between depths? But I know you can't hide asteroids can you, as in fullly. So really, the Asteroids would have to be very small, and depending on the depth layer, some asteroids would come back to normal size

Code: [Select]
if depth = 0

GetAsteroid(0):SetRadius(3000)
GetAsteroid(1):SetRadius(1)
GetAsteroid(2):SetRadius(1)

etc...[/code]

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: 3D Concepts
« Reply #67 on: May 21, 2012, 10:26:41 AM »
You can temporarily shrink the size of an asteroid to a radius of 0, causing it to effectively disappear, however trees and seeds will then struggle to interact with it properly.

Another option is to use MoveTo to temporarily move the asteroid off the screen.. :>

I would probably tackle a problem like that from a different angle, other than the 3D engine.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: 3D Concepts
« Reply #68 on: May 21, 2012, 11:05:07 AM »
Now, I have pseudovertices being generated and stored in arrays like this:

pseudovertexX[edgeID][pseudovertexID]
pseudovertexY[edgeID][pseudovertexID]

Lets take an example edge, edge 5.

pseudovertexX[5][pseudovertexID]
pseudovertexY[5][pseudovertexID]

This will contain a number of different points that occur along the edge.
Suppose the edge has the equation y = 2x + 3
So some sample points would be:
0, 3
-1.5, 0
2, 7
4, 11
-3, -3

Prior to sorting, they might appear like this:

pseudovertexX[5][pseudovertexID] = { 0, -1.5, 2, 4, -3 }
pseudovertexY[5][pseudovertexID] = { 3, 0, 7, 11, -3 }

Each contains 5 elements.

When I use table.sort or similar to sort these elements into the right order, they would be sorted independently.  However because we are dealing with a straight line, this should not matter; they should naturally stay in sync with each other

pseudovertexX[5][pseudovertexID] = { -3, -1.5, 0, 2, 4 }
pseudovertexY[5][pseudovertexID] = { -3, 0, 3, 7, 11 }

So the elements then line up like this:

-3, -3
-1.5, 0
0, 3
2, 7
4, 11

So even though they were sorted independently, they didn't get mixed up.
This is always true for all possible lines in the engine.

It's even true of a horizontal or vertical.

Consider the line y = 4, which is horizontal.

A possible set:

pseudovertexX[5][pseudovertexID] = { 0, -1.5, 2, 4, -3 }
pseudovertexY[5][pseudovertexID] = { 4, 4, 4, 4, 4}

Sorted, becomes:
pseudovertexX[5][pseudovertexID] = { -3, -1.5, 0, 2, 4 }
pseudovertexY[5][pseudovertexID] = { 4, 4, 4, 4, 4}

In such a case, all the Y values are identical... so it doesn't matter that this situation mixes their indexes up.



Now, the question arises... can I sort pseudovertexY[edgeID][pseudovertexID] and only sort the pseudovertex ID's?  Hmm, I suspect I will have to copy it to a seperate array first...


So that would be done in this way:


Code: [Select]
function SortVertices()

for edgeID = 0, numberofedges do
-- calculate number of pseudovertices in this edge

numverts = -1
sortedX = {}
sortedY = {}
for pvID = 0,100 do -- maybe change 100 to maxpseudovertices or whatever that variable is called... i set it in StarfieldInit()

if pseudovertexX[edgeID][pvID] ~= nil then

sortedX[pvID] = pseudovertexX[edgeID][pvID]
sortedY[pvID] = pseudovertexY[edgeID][pvID]
numverts = numverts + 1

else

break

end

end
-- numverts is now equal to the number of pseudovertices
-- ie if numverts = 0, there is one pseudovertex
-- if numverts = 1, there are two pseudovertices, etc

-- first check that there is at least two pseudovertices - if there are 1 or 0, there's nothing to sort.
if numverts > 0 then

table.sort(sortedX)
table.sort(sortedY)

for pvID = 0, numverts do

pseudovertexX[edgeID][pvID] = sortedX[pvID]
pseudovertexY[edgeID][pvID] = sortedY[pvID]

end

end

end

end

And that should sort the pseudovertices... hopefully..? :>
« Last Edit: May 21, 2012, 11:25:17 AM by annikk.exe »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: 3D Concepts
« Reply #69 on: May 21, 2012, 11:26:41 AM »
In terms of advanced graphics for this engine, it would be possible to implement face alpha (transparency), and also face reflections.  However I will focus on the basic engine first.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: 3D Concepts
« Reply #70 on: May 22, 2012, 10:08:38 AM »
Pseudovertex generator isn't quite perfect yet, it's displaying some erroneous pseudovertices.  It displays the correct ones too though.

Erroneous vertices appear on a single rotating cube.  I'm not sure why yet.  It has taken a fair bit of studying and trying to understand what I'm seeing to realise they are erroneous in the first place.  I'll study them a bit more and maybe figure out what part of the code I ought to be checking again..

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: 3D Concepts
« Reply #71 on: July 29, 2012, 11:23:59 AM »
Here's the problem.

In a 2D field, two lines intersect.

I can see what proportion of Line A is to the left of Line B, and I can measure this amount.

I'll express this amount as a number like 0.45
If the amount was 1, it would be the entire length of the line.

So 0.45 means the intersection happens 45% of the way along line A.


Now here's the crazy bit.  Those 2D lines, are actually 3D lines; but they look 2D because they're on a flat monitor screen.

The 3D lines exist in 3D space, and their 2D coordinates are being calculated independently in the background.


Here's the thing though - those lines still intersect 45% of the way along in 3D space.

Or wait... maybe they don't...

No wait, THEY DO intersect when viewed from the angle of the camera.  That's the whole point.

So yes, when viewed from the angle of the camera, they do intersect at 45% and that's the value we're interested in.


So, given the following:

Line A, formed by:

Vertex1X
Vertex1Y
Vertex1Z

Vertex2X
Vertex2Y
Vertex2Z


Line B, formed by:

Vertex3X
Vertex3Y
Vertex3Z

Vertex4X
Vertex4Y
Vertex4Z

And in function form,
Code: [Select]
function Calculate3Dintersection(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4)
-- code goes here
-- calculate intersectX, intersectY, and intersectZ
end

How do I calculate intersectX, intersectY, and intersectZ?


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.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: 3D Concepts
« Reply #72 on: July 29, 2012, 11:28:52 AM »
I got this bro!

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: 3D Concepts
« Reply #73 on: July 30, 2012, 12:53:09 PM »
seed guys, I think this might be it. Not seeing any other obstacles.. After all these months, I think I am on the verge of completing the engine.

Tasks left to do:
1. Code up the linear interpolation depth check (should be easy)
2. Test it.. Pseudovertices should all be correct at this point.
3. Code a function to draw edges with respect to pseudovertices.
4. Test it..
5. Victory dance!

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: 3D Concepts
« Reply #74 on: July 31, 2012, 08:12:14 AM »
Problems with step 1. :P
Oh well.

Take a look at this!

« Last Edit: July 31, 2012, 08:20:15 AM by annikk.exe »