Author Topic: Someone wants to build some additional 3D Objects for me? :> It's easy!  (Read 24163 times)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
If you guys could spare a bit of time, some assistance with this will really help me, as it will let me try stacking objects together and test the re-usability of the engine.


How to:
(click to show/hide)


Full Template:
(click to show/hide)

The full template is currently set up to draw a simple cube.  You can change the function's name "DrawCube" to something else if appropriate... "DrawSpacecraft" would be excellent ^_^


Any questions, please ask!  If you make a cool 3D object, please post it and I'll go test it to see what it looks like.  :>

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Here's another example of a simple pyramid design:


(click to show/hide)


Even basic objects like squares and rectangles would be super-useful...  :>
« Last Edit: June 10, 2011, 08:48:47 PM by annikk.exe »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Ok, but maybe you can give us the code to visualize it?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Ok sure, attached.  :>  Once your objects are complete, you can paste the entire function into this level file and call the function in the appropriate place.  Then you'll be able to see the object you designed.  :>
The cube and pyramid functions are already in there.

If anyone is not sure how to put their own object design into the level, just post your design here and I will sort it for you.  :>

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
But I don't understand the edges fully, I'd love to make a small circle :D

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Is there any way to tweak the poisitions at runtime in the console?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Aino, use DrawSprite(int id, x,y, r,g,b,a, size) With these as the the IDs. You'd probably want 5, 6 or 7, though they wouldn't interact with the 3D stuff.

0            Point,
1            Spot,
2            Wing,
3            Background,
4            Noise,
5            CircleFill,
6            Ring,
7            ThickRing,
8            Atmosphere,
9            UIWindow,
10            UIButton,
11            UIButtonPressed,
12            UIButtonHighlight,
13            Pixel,

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Is there any way to tweak the poisitions at runtime in the console?

Code: [Select]
vertex3dXtransformed[0] = -100

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Uhmm... I'm just gonna make the point or?

And the edges ofcourse, but I meant a sphere :)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
But I don't understand the edges fully, I'd love to make a small circle :D

Edges join 2 vertices together.  :>
Alternatively, you can think of edges as lines that are drawn between one star and another star.


A circle would be very difficult to make as you can only use straight lines.  So you'd need a ton of vertices arranged in a roughly circular fashion, then you'd need an edge to connect each one to its neighbours.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Uhhm, I understood that fine, but the double bracket is confusing me :S

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
There is a way to rotate a point around an arbitrary axis, so you could use that to get the coordinates or the new points from a planar circle. (which you got from doing the same, just with a point.) Edges, though? They'd require a bit of work to do. No, they wouldn't.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
The double bracket means it's a matrix.

Don't worry, it's pretty simple; the first bracket should always have "i" in it.  The second bracket should contain the edge ID for that vertice; simple ascending numbers like 0, 1, 2, 3, 4, 5, 6, etc.

Code: [Select]
edge[i][0] =
edge[i][1] =
edge[i][2] =
edge[i][3] =
edge[i][4] =

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
And annikk, add an "ultimate" size, which determines the size of the drawing, cause if you want two of the same things, but at different size, you must rewrite the whole thing :/

Edit: unless it's already there, but I didn't see it :P

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
So the first number is where it sends from and the last is where it send the line to?

Edit: Realised it, I'm stupid :S

Explanation: The first is the vertex and the last is the number for that vertex, like the 4th edge for the first vertex :)
« Last Edit: June 10, 2011, 09:20:16 PM by Aino »

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Is there any way to reefer to the WHOLE of an array/matrix? Say I had the array

x = {0,1,2,3,4,5,6,7,8,9}

Can refer to the whole thing at once?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
it's edge[ID of the vertex we are drawing FROM][ID number of the edge] = ID of the vertex we are drawing TO

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Is there any way to reefer to the WHOLE of an array/matrix? Say I had the array

x = {0,1,2,3,4,5,6,7,8,9}

Can refer to the whole thing at once?

Not quite sure what you mean... yes, with a "For" loop.


Also someone mentioned an attribute that governs the overall size of an object.  I will implement this later, and it will be simple to convert objects over to the new system.

For now, all objects have a relative size of "1".  Later you will be able to change this, for example you would be able to change the modifier to 2, and that would result in an object double the original size.  Changing the modifier to 0.5 would result in an object half the original size, and so on.
That's not implemented yet, but as I say, it will be simple to do so when the time comes.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Regarding rotation of objects,

I have written code to do this.  However, I have not included it in this version of the engine, for some reason.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
If I'm testing, do I have to have edges? Or does the system survive without any edges set?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Good question, I'm not sure.  :>

edit - just tested removing the edges from my pyramid.  It worked fine.. :>

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
My sphere is soon done, now to get confused by the edges :D

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
I'll be very impressed if you make a good-looking sphere.. :>

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
This tool is awesome to work with :D

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
I am glad you think so.  ^_^  It's going to be a long time before I get round to designing a visual 3D object editor along the lines of Roidforge.. :>

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Done, and it looks amazing :D

Code: [Select]
function DrawSphere(xpos,ypos,zpos)

-- vertices
i = numberofvertices
firstvert = i

--0
--Ultimate 1
vertex3dX[i] = xpos + (math.cos(45*0/360*math.pi*2)*100)
vertex3dY[i] = ypos + (math.sin(45*0/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.sin(45*0/360*math.pi*2)*100)
i = i + 1

--1
vertex3dX[i] = xpos + (math.cos(45*1/360*math.pi*2)*100)
vertex3dY[i] = ypos + (math.sin(45*0/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.sin(45*1/360*math.pi*2)*100)
i = i + 1

--2
--Ultimate 2
vertex3dX[i] = xpos + (math.cos(45*2/360*math.pi*2)*100)
vertex3dY[i] = ypos + (math.sin(45*0/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.sin(45*2/360*math.pi*2)*100)
i = i + 1

--3
vertex3dX[i] = xpos + (math.cos(45*3/360*math.pi*2)*100)
vertex3dY[i] = ypos + (math.sin(45*0/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.sin(45*3/360*math.pi*2)*100)
i = i + 1

--4
--Ultimate 3
vertex3dX[i] = xpos + (math.cos(45*4/360*math.pi*2)*100)
vertex3dY[i] = ypos + (math.sin(45*0/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.sin(45*4/360*math.pi*2)*100)
i = i + 1

--5
vertex3dX[i] = xpos + (math.cos(45*5/360*math.pi*2)*100)
vertex3dY[i] = ypos + (math.sin(45*0/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.sin(45*5/360*math.pi*2)*100)
i = i + 1

--6
--Ultimate 4
vertex3dX[i] = xpos + (math.cos(45*6/360*math.pi*2)*100)
vertex3dY[i] = ypos + (math.sin(45*0/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.sin(45*6/360*math.pi*2)*100)
i = i + 1

--7
vertex3dX[i] = xpos + (math.cos(45*7/360*math.pi*2)*100)
vertex3dY[i] = ypos + (math.sin(45*0/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.sin(45*7/360*math.pi*2)*100)
i = i + 1

--8
vertex3dX[i] = xpos + (math.cos(45*1/360*math.pi*2)*100)
vertex3dY[i] = ypos + (math.sin(45*1/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.sin(45*0/360*math.pi*2)*100)
i = i + 1

--Ultimate 5
--9
vertex3dX[i] = xpos + (math.cos(45*2/360*math.pi*2)*100)
vertex3dY[i] = ypos + (math.sin(45*2/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.sin(45*0/360*math.pi*2)*100)
i = i + 1

--10
vertex3dX[i] = xpos + (math.cos(45*3/360*math.pi*2)*100)
vertex3dY[i] = ypos + (math.sin(45*3/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.sin(45*0/360*math.pi*2)*100)
i = i + 1

--11
vertex3dX[i] = xpos + (math.cos(45*5/360*math.pi*2)*100)
vertex3dY[i] = ypos + (math.sin(45*5/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.sin(45*0/360*math.pi*2)*100)
i = i + 1

--Ultimate 6
--12
vertex3dX[i] = xpos + (math.cos(45*6/360*math.pi*2)*100)
vertex3dY[i] = ypos + (math.sin(45*6/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.sin(45*0/360*math.pi*2)*100)
i = i + 1

--13
vertex3dX[i] = xpos + (math.cos(45*7/360*math.pi*2)*100)
vertex3dY[i] = ypos + (math.sin(45*7/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.sin(45*0/360*math.pi*2)*100)
i = i + 1

--14
vertex3dX[i] = xpos + 0
vertex3dY[i] = ypos + (math.sin(45*1/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.cos(45*1/360*math.pi*2)*100)
i = i + 1

--15
vertex3dX[i] = xpos + 0
vertex3dY[i] = ypos + (math.sin(45*3/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.cos(45*3/360*math.pi*2)*100)
i = i + 1

--16
vertex3dX[i] = xpos + 0
vertex3dY[i] = ypos + (math.sin(45*5/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.cos(45*5/360*math.pi*2)*100)
i = i + 1

--17
vertex3dX[i] = xpos + 0
vertex3dY[i] = ypos + (math.sin(45*7/360*math.pi*2)*100)
vertex3dZ[i] = zpos + (math.cos(45*7/360*math.pi*2)*100)
i = i + 1

numberofvertices = i

-- edges

i = vertexID

edge[i][0] = firstvert + 1
edge[i][1] = firstvert + 7
edge[i][2] = firstvert + 13
edge[i][3] = firstvert + 8
i = i + 1

edge[i][0] = firstvert + 0
edge[i][1] = firstvert + 2
edge[i][2] = firstvert + 13
edge[i][3] = firstvert + 8
edge[i][4] = firstvert + 14
edge[i][5] = firstvert + 17
i = i + 1

edge[i][0] = firstvert + 1
edge[i][1] = firstvert + 3
edge[i][2] = firstvert + 14
edge[i][3] = firstvert + 17
i = i + 1

edge[i][0] = firstvert + 2
edge[i][1] = firstvert + 4
edge[i][2] = firstvert + 14
edge[i][3] = firstvert + 17
edge[i][4] = firstvert + 10
edge[i][5] = firstvert + 11
i = i + 1

edge[i][0] = firstvert + 3
edge[i][1] = firstvert + 5
edge[i][2] = firstvert + 10
edge[i][3] = firstvert + 11
i = i + 1

edge[i][0] = firstvert + 4
edge[i][1] = firstvert + 6
edge[i][2] = firstvert + 10
edge[i][3] = firstvert + 11
edge[i][4] = firstvert + 16
edge[i][5] = firstvert + 15
i = i + 1

edge[i][0] = firstvert + 5
edge[i][1] = firstvert + 7
edge[i][2] = firstvert + 16
edge[i][3] = firstvert + 15
i = i + 1

edge[i][0] = firstvert + 6
edge[i][1] = firstvert + 0
edge[i][2] = firstvert + 16
edge[i][3] = firstvert + 15
edge[i][4] = firstvert + 13
edge[i][5] = firstvert + 8
i = i + 1

edge[i][0] = firstvert + 9
edge[i][1] = firstvert + 15
edge[i][2] = firstvert + 14
i = i + 1

edge[i][0] = firstvert + 15
edge[i][1] = firstvert + 14
edge[i][2] = firstvert + 10
i = i + 1

edge[i][0] = firstvert + 15
edge[i][1] = firstvert + 14
i = i + 1

edge[i][0] = firstvert + 12
edge[i][1] = firstvert + 16
edge[i][2] = firstvert + 17
i = i + 1

edge[i][0] = firstvert + 13
edge[i][1] = firstvert + 16
edge[i][2] = firstvert + 17
i = i + 1

edge[i][0] = firstvert + 16
edge[i][1] = firstvert + 17
i = i + 1

end

Full file also released though :)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Wow, that really does look good.. :>
You really seem to have a handle on things like Sin, Cos, and Pi.  I don't fully understand how you've done it but it's impressive to say the least. :>

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Also, I am super-stoked that I was able to just copy and paste your object in, and it worked without problems.  :D  Great success!

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Heh...

Well, after some time, me and the sphere learned alot of eachother... So in the end, the dges was really easy :)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
By the way annikk, gotta thank you alot for the matrix :)

Now my "Minecraft 2d" can be further improved :)

Edit: nahh, not needed I see... But thatnks anyways Annikk, now I know some more about lua which allows me to make more stuff :)

Edit 2:

Heres the code for the little Infinite exploration game :)

Code: [Select]
function LevelSetup()
Globals.G.Asteroids=0
Globals.G.EnemyFactionsMin=0
Globals.G.EnemyFactionsMax=0
SetBackdropColour(0,0,0)
AddAsteroid(0,0)
Globals.Flowers.Available = 0
Initialization()
BasicSaveFolder = "C:\\EufloriaSaves\\"
end

function LevelLogic()
GetAsteroid(0).Radius = 0
GetAsteroid(0):Hide(1)
GetAsteroid(0):SetVisible(1,false)
end

function LevelDraw()

if Limits == true then
SetBackdropColour(Br,Bg,Bb)
SetCameraZoomNow(PlayerSight/3.33)
end
GridSizeX = GetScreenWidth()/16
GridSizeY = GetScreenHeight()/16
if FreeCam == true then
PlayerX = GetCameraX()
PlayerY = GetCameraY()
else
CurrentXPos = GetCameraX()
CurrentYPos = GetCameraY()
if CurrentXPos ~= PlayerX then
local Way = CurrentXPos - PlayerX / math.abs(CurrentXPos - PlayerX)
if PlayerX/GridSizeX < math.ceil(PlayerX/GridSizeX) and PlayerX/GridSizeX > math.floor(PlayerX/GridSizeX) then
PlayerX = PlayerX + WalkingSpeed*Way

else
if BIs[In[math.floor(PlayerX/GridSizeX)+Way .. "," .. math.floor(PlayerY/GridSizeY)] ] ~= 1 then

else
PlayerX = PlayerX + WalkingSpeed*Way

end
end
end
if CurrentYPos ~= PlayerY then
local Way = CurrentYPos - PlayerY / math.abs(CurrentYPos - PlayerY)
if PlayerY/GridSizeY < math.ceil(PlayerY/GridSizeY) and PlayerY/GridSizeY > math.floor(PlayerY/GridSizeY) then
PlayerY = PlayerY + WalkingSpeed*Way

else
if BIs[In[math.floor(PlayerY/GridSizeY)+Way .. "," .. math.floor(PlayerY/GridSizeY)] ] ~= 1 then

else
PlayerY = PlayerY + WalkingSpeed*Way

end
end
end
CurrentXPos = PlayerX
CurrentYPos = PlayerY
SetCameraPosition(CurrentXPos, CurrentYPos)
end

for i = -PlayerSight,PlayerSight do

for j = -PlayerSight,PlayerSight do

if In[math.floor(PlayerX/GridSizeX)+i .. "," .. math.floor(PlayerY/GridSizeY)+j] == nil then

AddBlock(math.floor(PlayerX/GridSizeX)+i,math.floor(PlayerY/GridSizeY)+j)

end

local tempBlock = In[math.floor(PlayerX/GridSizeX)+i .. "," .. math.floor(PlayerY/GridSizeY)+j]
if tempBlock ~= nil and BIs[tempBlock] ~= nil and Bx[tempBlock] ~= nil and By[tempBlock] ~= nil then
if BIs[tempBlock] ~= 1 and math.abs(PlayerX-Bx[tempBlock]) < PlayerSight*GridSizeX and math.abs(PlayerY-By[tempBlock]) < PlayerSight*GridSizeY then
DrawBox(1,1,Bx[tempBlock],By[tempBlock],Bx[tempBlock]+GridSizeX,By[tempBlock]+GridSizeY,RedType[BIs[tempBlock]],GreenType[BIs[tempBlock]],BlueType[BIs[tempBlock]],1)
end
end
end
end
DrawSprite(1,PlayerX,PlayerY,1,0,0,1,5)
end

function Initialization()

GridSizeX = GetScreenWidth()/16
GridSizeY = GetScreenHeight()/16
MapDepth = 200

PlayerX = GridSizeX/2
PlayerY = GridSizeY/2
CurrentXPos = PlayerX
CurrentYPos = PlayerY
SetCameraPosition(CurrentXPos, CurrentYPos)
PlayerSight = 3
WalkingSpeed = 0.00001
Limits = true
FreeCam = true

Block = -1
Bx = {}
By = {}
BGravity = {}
BTowerRaze = {}
BIs = {}
In = {}
RedType = {0,127/255,0.33,0.45}
GreenType = {0,70/255,0.33,0.45}
BlueType = {0,0,0.33,0.33}

Br = 10
Bg = 125
Bb = 175
SetBackdropColour(Br,Bg,Bb)

end

function AddBlock(x,y)
Block = Block + 1
Bx[Block] = x*GridSizeX
By[Block] = y*GridSizeY
BGravity[Block] = true
BTowerRaze[Block] = true
In[x .. "," .. y] = Block
FindProperType(Block)
end

function FindProperType(Block)

local h = 1

local randomn = math.random()
if Bx[Block] == 0 and By[Block] == 0 then else
if randomn > 0.7 and h ~= 2 then

h = 2

elseif randomn < 0.7 and randomn > 0.1 then

h = 3

elseif randomn < 0.1 and randomn > 0.05 then

h = 4

end
end

BIs[Block] = h
end

It is also put under here :)
« Last Edit: June 10, 2011, 10:31:23 PM by Aino »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Yeah, matrices are a pretty advanced subject.  They aren't too hard to explain (think of a spreadsheet basically), but thinking of a simple demonstration of their use can be quite hard.  That kind of puts me off covering them in a guide... though I will eventually, I guess.  :>

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
But if you want an infinite nuber, yours reaches 1000, which is a decently number...

Back to infite... as you for example explore more, how do you increase the matrix number?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
The 1000 is the number of edges that can be created.  I don't think we'll be seeing 1000+ edged objects for a while yet.  It would be very costly on the CPU apart from anything else...

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Awww...I was working on a sphere and my comp crashed (bluescreens, I hate 'em). Then I had to go and revise for my maths exams. Than Aino got there first. Poo.

...

Now I'm gonna prefab Aino's sphere and make a bunch of semi-primitives.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Awesome!! :D


Sorry to hear about your crash though.  That must have been annoying. :/

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Is there any way of making more than one object? So, like:


A box over here



                                                                                                                                             And then another down here?



And have them both work as you would expect of two independent objects?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Is there any way of making more than one object? So, like:


A box over here



                                                                                                                                             And then another down here?



And have them both work as you would expect of two independent objects?

Yep!  Just call DrawCube (or whatever) twice, with different coordinates in the argument.  :>

EG:

Code: [Select]
DrawCube(200,200,200)
DrawCube(-500,-500,500)

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Oh, okay. Can you bind two objects together - such as creating a cube with a sphere growing out of its corner - and have the two behave as a single object?

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
In my experience with this, it would require some coding :P

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Oh, okay. I think I have have idea how to do this actually.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Yes, that would be possible.  There are two methods you could use to do this:

1) When moving/rotating objects, you refer to all the vertices over both objects at the same time for all your transforms.

2) (This option is better for transportability) You can combine the two object functions into a single object function.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Yeah, I'm working on a function to combine two objects, also on improving the wireframe engine you posted earlier (making it so you don't have to have loads of code in the level file)

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Is there any way to create an object outside of StarfieldInit? Like in ScreenDraw, or LevelDraw?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Not sure.. you could try calling the DrawCube() function from ScreenDraw() and see what happens I guess...  I think it will probably break though as it's not designed to do that currently.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
I never actually said why I did this, did I? Basically, I've edited the 3D Engine slightly to make the actual level file less messy.



Oh. Well, I'll just have to release what I have done, then. Is it ever likely to be edited to allow ScreenDraw and LevelDraw? For now, shapes have to be created still in StarfieldInit().

Your Resources/Maps folder should look something like this for every map that uses this variation of the 3D engine.

Maps
--Stuff
--Map using 3D Engine, based on Tidy Engine (e.g. AMap) The filepaths in this map should be something like C:\\Program Files\\steam\\steamapps\\common\\eufloria\\Resources\\Maps\\AMap\\3DEngine\\Engine.lua
--AMap (Folder)
--------3DEngine
------------Engine.lua
------------Shapes.lua (only if this is being used)
--More stuff
« Last Edit: June 11, 2011, 04:21:30 AM by Pilchard123 »

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Is there any way to reefer to the WHOLE of an array/matrix? Say I had the array

x = {0,1,2,3,4,5,6,7,8,9}

Can refer to the whole thing at once?

Yes, there is. If one was to use just the name of the array/matrix, in this case x, that will refer to the whole thing. Funny, I'm sure I tried that.

Also, may I enquire as to what the point of CaveMech is?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Now working on an editable sphere. I think I know how I'm going to go about it, but now I've got to learn how to use the engine.

Might do the same for cubes and pyramids, too.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Why have it split into so many files/folders?  Isn't it more convenient for players that download the maps if they only have to handle a single file?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Hm. Yeah, but it's not so messy for those that want to have a look at the code, and easier on the eyes at design time, too. Just thought I'd see what people thaought.

It also makes it more customisable - you can add custom shapes more neatly.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
I've managed to get shapes drawn in ScreenDraw, but it draws them every frame, and overlays the new on the old. This crashes, quickly.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
If there any way to add vertices in a for loop (using a different iteration varioable than i, obviously). I don't seem to be able to...

EDIT: After more experimentation, it seems that all the vertices bar the first are not drawn unless they have edges to/from them. Intended, or not?
« Last Edit: June 12, 2011, 12:03:30 AM by Pilchard123 »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
New method of adding edges.
I've converted the Cube over to the new method, but I haven't done the other objects.


Here's a sample of the Cube.  Heavily commented, so should be easy to see what's going on...


Code: [Select]
function DrawCube(xpos,ypos,zpos)

-- #### DO NOT REMOVE ####
i = numberofvertices
firstvert = i
-- #### DO NOT REMOVE ####



-- ##### VERTICES #####


-- near-side face
-- #0 top left vertex
vertex3dX[i] = xpos - 50
vertex3dY[i] = ypos - 50
vertex3dZ[i] = zpos - 50
i = i + 1

-- #1 top right vertex
vertex3dX[i] = xpos + 50
vertex3dY[i] = ypos - 50
vertex3dZ[i] = zpos - 50
i = i + 1

-- #2 bottom right vertex
vertex3dX[i] = xpos + 50
vertex3dY[i] = ypos + 50
vertex3dZ[i] = zpos - 50
i = i + 1

-- #3 bottom left vertex
vertex3dX[i] = xpos - 50
vertex3dY[i] = ypos + 50
vertex3dZ[i] = zpos - 50
i = i + 1

-- #4 far-side face
-- top left vertex
vertex3dX[i] = xpos - 50
vertex3dY[i] = ypos - 50
vertex3dZ[i] = zpos + 50
i = i + 1

-- #5 top right vertex
vertex3dX[i] = xpos + 50
vertex3dY[i] = ypos - 50
vertex3dZ[i] = zpos + 50
i = i + 1

-- #6 bottom right vertex
vertex3dX[i] = xpos + 50
vertex3dY[i] = ypos + 50
vertex3dZ[i] = zpos + 50
i = i + 1

-- #7 bottom left vertex
vertex3dX[i] = xpos - 50
vertex3dY[i] = xpos + 50
vertex3dZ[i] = xpos + 50
i = i + 1




-- #### DO NOT REMOVE ####
numberofvertices = i - 1
i = numberofedges
firstedge = i
-- #### DO NOT REMOVE ####






-- ##### EDGES #####


-- edgefrom[i] = ID of the vertice the edge should be drawn FROM
-- edgeto[i] = ID of the vertice the edge should be drawn TO
-- "i" is the ID of the edge.

-- near-side edges
-- #0 from near top left to near top right
edgefrom[i] = firstvert + 0
edgeto[i] = firstvert + 1
i = i + 1

-- #1 from near top right to near bottom right
edgefrom[i] = firstvert + 1
edgeto[i] = firstvert + 2
i = i + 1

-- #2 from near bottom right to near bottom left
edgefrom[i] = firstvert + 2
edgeto[i] = firstvert + 3
i = i + 1

-- #3 from near bottom left to near top top
edgefrom[i] = firstvert + 3
edgeto[i] = firstvert + 0
i = i + 1

-- far side edges

-- #4 from far top left to far top right
edgefrom[i] = firstvert + 4
edgeto[i] = firstvert + 5
i = i + 1

-- #5 from far top right to far bottom right
edgefrom[i] = firstvert + 5
edgeto[i] = firstvert + 6
i = i + 1

-- #6 from far bottom right to far bottom left
edgefrom[i] = firstvert + 6
edgeto[i] = firstvert + 7
i = i + 1

-- #7 from far bottom left to far top right
edgefrom[i] = firstvert + 7
edgeto[i] = firstvert + 4
i = i + 1


-- connecting edges

-- #8 from near top left to far top left
edgefrom[i] = firstvert + 0
edgeto[i] = firstvert + 4
i = i + 1

-- #9 from near top right to far top right
edgefrom[i] = firstvert + 1
edgeto[i] = firstvert + 5
i = i + 1

-- #10 from near bottom right to far bottom right
edgefrom[i] = firstvert + 2
edgeto[i] = firstvert + 6
i = i + 1

-- #11 from near bottom left to far bottom left
edgefrom[i] = firstvert + 3
edgeto[i] = firstvert + 7
i = i + 1



-- #### DO NOT REMOVE ####
numberofedges = i - 1
-- #### DO NOT REMOVE ####




end
« Last Edit: June 12, 2011, 09:34:41 AM by annikk.exe »