Author Topic: 3D Object Editor  (Read 5784 times)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
3D Object Editor
« on: May 21, 2012, 10:45:54 PM »
I might be getting a little ahead of myself here, but the engine isn't all that far off being finished and I'm going to need an object editor..

So time to start planning out.


So what's needed for an object editor?

It needs to view the world in 3D.
Vertices should be added in a point-and-click manner similar to roidforge.  They need to be removed in the same way, with a "remove vertex" tool.

Edges can be declared by clicking the Edge button, then selecting 2 vertices, then clicking confirm.
Edges should be selectable from a list, and they should change colour onscreen when selected.  From here they can be deleted if necessary.

Faces need to be added by clicking the Add Face tool, then selecting a bunch of the edges from the list (they will highlight as they are added).
They should be removed by looking through a list of the currently existing faces..  as each face is highlighted, so its comprising edges should be coloured in the game field to show which edges are involved in that face.

Adjusting the positions of vertices should be done with sliders.  More sliders should be available to rotate the object, as well as "continuous rotate".

Ideally, vertices and edges should be selectable in-game.

Finally, the object should be built within the confines of -1,-1,-1 and 1,1,1.  IE a cube would occupy the maximum space possible in this area, and would have dimensions 2x2x2.
All objects should be built in this way to create a predictable scaling mechanism later on.

Hmm... lots to think about.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: 3D Object Editor
« Reply #1 on: May 21, 2012, 11:13:29 PM »
It must be possible to select multiple vertices and perform move or rotate options on all of them at the same time..

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Re: 3D Object Editor
« Reply #2 on: May 22, 2012, 03:10:12 AM »
So, you're gonna make a Eufloria-based interactive mouse-driven editor, capable of creating transformable multi-sided even and uneven real-time rotatable 3D Polygons with perspective. This editor will then save the necessary data into a text file. This data can then be pasted into a playable map which would include a 3D engine capable of rendering the polygon at a chosen scale. Is that an accurate description? I'm just trying to understand your intentions.

So, in your description, the polygon would be created by clicking points on the screen using the eye-ball method. A small sphere will appear indicating the placement of the vertex. Then, by clicking on two vertices in succession, you create an edge which is then rendered between those vertices. This edge then appears in a growing list somewhere on the screen as "1-2" for example. Then, after creating multiple edges (at least three) which are recognized as being connected, you "select" these three edges from the list and by clicking somewhere else (a "generate face" button?) you create a face defined by the selected edges.

Then, by using slider controls, the "object" can be rotated to facilitate placement of additional vertices and edges and faces. Delete buttons are also available for editing. Once the object is satisfactory, any necessary information is "saved" in a file later to be used by the 3D engine.

I....don't... know... what... to think about all this. So many hurdles and questions. My head hurts.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: 3D Object Editor
« Reply #3 on: May 22, 2012, 03:29:54 AM »
Pretty much :>

Apart from this bit:

Quote
This data can then be pasted into a playable map which would include a 3D engine capable of rendering the polygon at a chosen scale. Is that an accurate description? I'm just trying to understand your intentions.

Not polygons exactly... that would imply a 2D part of an object.  I'm talking about building an editor that you can use, ingame, to visually create complex objects, such as a banana.
(well, something shaped like one, anyway...)


The problem with creating a complex object arises from the way its shape is specified.
It's hugely complex and not intuitive to understand.  To give an example, here's the code required to produce a simple primitive, the cube:

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

-- #### DO NOT REMOVE ####
i = numberofvertices
if vertex3dX[i] ~= nil then
i = i + 1
end
firstvert = i
-- #### DO NOT REMOVE ####



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


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

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

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

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

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

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

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

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




-- #### DO NOT REMOVE ####
numberofvertices = i - 1
i = numberofedges
if edgefrom[i] ~= nil then
i = i + 1
end
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 left
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 ####




-- ##### FACES #####

-- face[ID of the face][numbered] = ID of the edge

-- #### DO NOT REMOVE ####
i = numberoffaces
i = i + 1
-- #### DO NOT REMOVE ####

-- #0 nearside face
face[i][0] = firstedge + 0
face[i][1] = firstedge + 1
face[i][2] = firstedge + 2
face[i][3] = firstedge + 3
i = i + 1


-- #1 farside face
face[i][0] = firstedge + 4
face[i][1] = firstedge + 5
face[i][2] = firstedge + 6
face[i][3] = firstedge + 7
i = i + 1

-- #2 top face
face[i][0] = firstedge + 0
face[i][1] = firstedge + 4
face[i][2] = firstedge + 8
face[i][3] = firstedge + 9
i = i + 1

-- #3 bottom face
face[i][0] = firstedge + 2
face[i][1] = firstedge + 6
face[i][2] = firstedge + 10
face[i][3] = firstedge + 11
i = i + 1

-- #4 left face
face[i][0] = firstedge + 3
face[i][1] = firstedge + 7
face[i][2] = firstedge + 8
face[i][3] = firstedge + 11
i = i + 1

-- #5 right face
face[i][0] = firstedge + 1
face[i][1] = firstedge + 5
face[i][2] = firstedge + 9
face[i][3] = firstedge + 10
i = i + 1


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

end

Now elite hax0r coders such as Aino might be able to put together formulas that create a 21-vertex sphere, and with some significant effort I managed to visualise how a cube is connected up and write up the coordinates required, but most artistic types are not like that.  They need to see what they are working on.  So entering coordinates and such manually is hardly ideal for this.

Hence the requirement for an object editor.
It actually won't be that difficult, I think.  It's basically just RoidForge all over again, but with slightly different requirements.  I wrote RoidForge in one day... I'm hoping a month will be enough for a basic 3D object editor.


I'm hoping to finish the last of the coding for the 3D engine this week.  Then it's bug testing time..

Lost Seedling

  • Shrub
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 30
  • Posts: 205
Re: 3D Object Editor
« Reply #4 on: May 22, 2012, 05:07:31 AM »
I just looked up the meaning of "hax0r" at the urban dictionary..........ummmm, never mind.

Yes I meant "3D Object". Well, I'll be following your progress as closely as I can. Roid Forge seems like it would be a piece-of-cake compared to this beast, if indeed it will look and function as I'm imagining.

 


annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: 3D Object Editor
« Reply #5 on: May 24, 2012, 08:06:54 PM »
Aino, you remember you created that sphere before?

Would you be able to build a new sphere, but this one would have a lot more vertices?  EG 50-100 vertices instead of 21..

Let me know if you're up for it.  I don't know what maths you used for the last one but it looked great. :>

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: 3D Object Editor
« Reply #6 on: May 24, 2012, 08:08:15 PM »
The method for declaring objects is the same as it was last time.