### Author Topic: Limitations of the 3D Starfield Engine  (Read 86346 times)

0 Members and 1 Guest are viewing this topic.

#### Aino

• Ent
• Thank You
• -Given: 5
• Posts: 1,526
• They'll eat you next!
• Eufloria: Yes
##### Re: Limitations of the 3D Starfield Engine
« Reply #15 on: June 02, 2011, 05:12:11 AM »
Jus ttell, we might get use for it later

#### Sniped50

• Sapling
• Thank You
• -Given: 0
• Posts: 97
##### Re: Limitations of the 3D Starfield Engine
« Reply #16 on: June 02, 2011, 07:43:12 AM »
Alright then.

Instead of having the engine check if vertex 1 is connected to vertex 2, drawing the line, and then doing it again the opposite way, why don't you just check if one vertex ID is smaller than the other, and then not drawing the connecting line at all if it returns true?

For instance, the square annikk had earlier. Vertex 0 is the first to be checked, so the lines connecting it to vertices 1 and 3 are drawn. Simple enough. Then vertex 1 is checked, and when the engine checks the line connecting it to vertex 0, it sees it is already drawn because the subject vertex ID (1) is larger than the checked vertex ID (0), so another line isn't drawn. It then checks the line connecting it to vertex 2, and because 1 < 2, it is then drawn. The process continues until it has checked all the vertices and drawn all the lines.

If you also include checks against lines between specific vertices, you only have to do it once (an if statement prevents a line between vertex 0 and vertex 2, and vertex 2 doesn't connect to vertex 0 anyways because of the higher ID number) to get a desired shape.

So there you go. If you already thought of that/a much cooler way of doing it, then all I can say is...

"Sometimes, the simplest solutions work the best."
- Mythbusters

"But the complex solutions look prettier."
- Me

#### annikk.exe

• Achiever
• Ent
• Thank You
• -Given: 0
• Posts: 1,809
##### Re: Limitations of the 3D Starfield Engine
« Reply #17 on: June 02, 2011, 05:53:16 PM »
Sweet, that's a pretty smart idea. :>

#### annikk.exe

• Achiever
• Ent
• Thank You
• -Given: 0
• Posts: 1,809
##### Re: Limitations of the 3D Starfield Engine
« Reply #18 on: June 02, 2011, 10:51:02 PM »
Modified to include the approach detailed in the posts immediately above.  Thanks Sniped!

Code: [Select]
` -- for each point, draw all its lines for i = 0,numberofpoints do -- we need to calculate how many lines this point is part of linenumber = -1 for numberoflinescheck = 0,100 do if lines[i][linenumber] ~= nil then linenumber = linenumber + 1 else break end end -- we now know this point is connected to "linenumber" other points by lines for j = 0,linenumber do -- Only draw the line if the opposing vertex's ID is greater than this vertex's ID if lines[i][j] > i then -- now we take each of the other points... destinationpoint = lines[i][j] -- and retrieve the coordinates of that point destX = pointX[destinationpoint] destY = pointY[destinationpoint] -- then we draw the line from the current point to the stored point. DrawLine(pointX[i], pointY[i], destX, destY, 1,1,1,1,1,1,1,1,10) end end end`

#### annikk.exe

• Achiever
• Ent
• Thank You
• -Given: 0
• Posts: 1,809
##### Re: Limitations of the 3D Starfield Engine
« Reply #19 on: June 02, 2011, 11:01:32 PM »
If anyone can spot any problems or improvements to the efficiency of that code, let me know!  It's all still at a very formative stage, nothing is final.

#### Pilchard123

• Tester
• Old Oak
• Thank You
• -Given: 4
• Posts: 930
• Eufloria: Yes
##### Re: Limitations of the 3D Starfield Engine
« Reply #20 on: June 02, 2011, 11:47:36 PM »
This might help, along with load of other stuff about graph theory:

Just beware: It can get very boring if it's anything like the exam I had to sit in the subject.

#### annikk.exe

• Achiever
• Ent
• Thank You
• -Given: 0
• Posts: 1,809
##### Re: Limitations of the 3D Starfield Engine
« Reply #21 on: June 03, 2011, 07:44:48 PM »
Made some progress with this.  Take a look at this demo map.

I've decided to keep the vertices having a "size" property, so they can be displayed on-screen and developers can see where they are.  I've learned from experience this morning that manually entering the data for even a simple object like this one is very time-consuming and not really workable for more complicated objects, so it seems like a 3D Designer level will be necessary so that objects can be created visually in an editor, then output so they can be used elsewhere.

Lots to think about.. :>  Going to do some more tidying of this code, and then I'll have a go at rotating one of the vertices around a point.

#### annikk.exe

• Achiever
• Ent
• Thank You
• -Given: 0
• Posts: 1,809
##### Re: Limitations of the 3D Starfield Engine
« Reply #22 on: June 03, 2011, 07:47:50 PM »
Hmm I take screenshot :>

#### annikk.exe

• Achiever
• Ent
• Thank You
• -Given: 0
• Posts: 1,809
##### Re: Limitations of the 3D Starfield Engine
« Reply #23 on: June 03, 2011, 08:54:24 PM »
More progress, got it rotating around the Z axis now, and it rotates around a specific point.
Going to get the X and Y rotations done next.  :>

#### annikk.exe

• Achiever
• Ent
• Thank You
• -Given: 0
• Posts: 1,809
##### Re: Limitations of the 3D Starfield Engine
« Reply #24 on: June 03, 2011, 09:14:59 PM »
Can rotate around all axis now.

However, there is a problem.  After each rotation, the cube gets slightly smaller in both the axis that are NOT being rotated around.  The cube swiftly becomes rectangular.

I have an idea of how to fix it.  Will require some reorganising.  In the mean time, check it out... if you want to.. :>

#### Aino

• Ent
• Thank You
• -Given: 5
• Posts: 1,526
• They'll eat you next!
• Eufloria: Yes
##### Re: Limitations of the 3D Starfield Engine
« Reply #25 on: June 04, 2011, 08:04:00 PM »
Nice to see progress

Have been in Sweden, Gõteborg in Liseberg(an Amusements park ...

So I haven't got to check the forum, but I am back now

#### Aino

• Ent
• Thank You
• -Given: 5
• Posts: 1,526
• They'll eat you next!
• Eufloria: Yes
##### Re: Limitations of the 3D Starfield Engine
« Reply #26 on: June 06, 2011, 01:55:25 AM »
Wait... just realized that you can do the opposite of the parralax effect on the dots closest, but not fully 3D as it will just stretch further out...

#### annikk.exe

• Achiever
• Ent
• Thank You
• -Given: 0
• Posts: 1,809
##### Re: Limitations of the 3D Starfield Engine
« Reply #27 on: June 06, 2011, 05:21:43 PM »
Not sure what you mean..  Things that are in the foreground (ie have a negative Z coordinate) can be "behind" the camera, that's in keeping with true 3D..

Not done any further work on this.  Might get some done today.

#### Aino

• Ent
• Thank You
• -Given: 5
• Posts: 1,526
• They'll eat you next!
• Eufloria: Yes
##### Re: Limitations of the 3D Starfield Engine
« Reply #28 on: June 06, 2011, 09:10:09 PM »
When you drag your screen, the points behind gets dragged too, so if you also count with the one closest to the screen will be dragged the opoosite way of the one currently being dragged...

Screen Dragged --->

Furthest away points <--
Closest to screen -->

• Achiever
• Ent
• Thank You
• -Given: 0