Euflorium: The Eufloria Community

Eufloria => Eufloria Classic => Eufloria Classic Mods => Topic started by: annikk.exe on June 10, 2011, 08:00:49 PM

Title: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 08:00:49 PM
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.  :>
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 08:45:39 PM
Here's another example of a simple pyramid design:


(click to show/hide)


Even basic objects like squares and rectangles would be super-useful...  :>
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Aino on June 10, 2011, 08:49:57 PM
Ok, but maybe you can give us the code to visualize it?
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 08:53:30 PM
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.  :>
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Aino on June 10, 2011, 08:56:25 PM
But I don't understand the edges fully, I'd love to make a small circle :D
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 10, 2011, 08:56:52 PM
Is there any way to tweak the poisitions at runtime in the console?
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 10, 2011, 08:58:54 PM
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,
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 09:07:45 PM
Is there any way to tweak the poisitions at runtime in the console?

Code: [Select]
vertex3dXtransformed[0] = -100
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Aino on June 10, 2011, 09:08:35 PM
Uhmm... I'm just gonna make the point or?

And the edges ofcourse, but I meant a sphere :)
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 09:09:50 PM
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.
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Aino on June 10, 2011, 09:11:02 PM
Uhhm, I understood that fine, but the double bracket is confusing me :S
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 10, 2011, 09:13:23 PM
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.
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 09:15:39 PM
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] =
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Aino on June 10, 2011, 09:16:23 PM
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
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Aino on June 10, 2011, 09:17:07 PM
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 :)
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 10, 2011, 09:18:43 PM
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?
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 09:22:43 PM
it's edge[ID of the vertex we are drawing FROM][ID number of the edge] = ID of the vertex we are drawing TO
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 09:26:01 PM
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.
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 09:29:41 PM
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.
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Aino on June 10, 2011, 09:31:18 PM
If I'm testing, do I have to have edges? Or does the system survive without any edges set?
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 09:31:53 PM
Good question, I'm not sure.  :>

edit - just tested removing the edges from my pyramid.  It worked fine.. :>
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Aino on June 10, 2011, 09:36:16 PM
My sphere is soon done, now to get confused by the edges :D
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 09:38:01 PM
I'll be very impressed if you make a good-looking sphere.. :>
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Aino on June 10, 2011, 09:40:33 PM
This tool is awesome to work with :D
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 09:45:46 PM
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.. :>
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Aino on June 10, 2011, 10:04:12 PM
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 :)
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 10:07:37 PM
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. :>
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 10:08:50 PM
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!
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Aino on June 10, 2011, 10:09:22 PM
Heh...

Well, after some time, me and the sphere learned alot of eachother... So in the end, the dges was really easy :)
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Aino on June 10, 2011, 10:11:38 PM
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 :)
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 10:17:55 PM
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.  :>
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Aino on June 10, 2011, 10:27:51 PM
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?
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 10:47:10 PM
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...
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 10, 2011, 11:21:20 PM
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.
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 11:22:23 PM
Awesome!! :D


Sorry to hear about your crash though.  That must have been annoying. :/
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 10, 2011, 11:42:42 PM
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?
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 10, 2011, 11:44:59 PM
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)
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 10, 2011, 11:49:20 PM
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?
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Aino on June 10, 2011, 11:50:43 PM
In my experience with this, it would require some coding :P
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 10, 2011, 11:53:18 PM
Oh, okay. I think I have have idea how to do this actually.
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 11, 2011, 12:14:14 AM
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.
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 11, 2011, 12:40:34 AM
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)
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 11, 2011, 03:06:15 AM
Is there any way to create an object outside of StarfieldInit? Like in ScreenDraw, or LevelDraw?
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 11, 2011, 03:50:48 AM
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.
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 11, 2011, 03:54:18 AM
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
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 11, 2011, 04:52:50 AM
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?
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 11, 2011, 05:31:21 AM
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.
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 11, 2011, 06:09:44 AM
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?
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 11, 2011, 06:49:12 AM
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.
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 11, 2011, 09:16:47 PM
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.
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: Pilchard123 on June 11, 2011, 11:07:05 PM
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?
Title: Re: Someone wants to build some additional 3D Objects for me? :> It's easy!
Post by: annikk.exe on June 12, 2011, 09:09:24 AM
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