|
DeleD Community Edition Forums
|
View previous topic :: View next topic |
Author |
Message |
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Wed May 06, 2009 8:35 pm Post subject: |
|
|
Paul-Jan wrote: |
Well, "usable and practical" pretty much equals "great!" in my book! |
LOL! nicely said
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Wed May 06, 2009 11:43 pm Post subject: |
|
|
Well after a small rewrite, I can now finally alter vertices of primitives AND update DeleD with the updated primitives
Code: |
function Execute()
Scene = DeleD.GetCurrentScene()
-- iterate p from 0 to Scene.PrimitiveCount - 1
for p = 0,Scene.PrimitiveCount - 1 do
prim = Scene.GetPrimitive(p)
-- iterate v from 0 to prim.VertexCount - 1
for v = 0,prim.VertexCount - 1 do
x,y,z = prim.GetVertex(v)
x = x * 2
y = y * 2
z = z * 2
prim.SetVertex(v,x,y,z)
end
prim.SendToDeleD()
end
end |
The code above scales every primitive in the current scene by 2 times in each dimension.
I can also add primitives too, but I can't add/alter polygons in primitives yet so I need to add that functionality before this becomes useful
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
chronozphere DeleD PRO user
Joined: 20 Jun 2006 Posts: 1010 Location: Netherlands
|
Posted: Thu May 07, 2009 7:56 am Post subject: |
|
|
This is very cool.
You're making quite some progress here. Are you expecting it to be finished any time soon?
Keep it up. |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Thu May 07, 2009 9:34 am Post subject: |
|
|
chronozphere wrote: |
This is very cool.
You're making quite some progress here. Are you expecting it to be finished any time soon?
Keep it up. |
I'm working out how to do the polygon bit of the primitives using indices pointing to the vertices, and directly using vertices.
possible example:
Code: |
prim = Scene.AddPrimitive()
prim.AddVertex(1,3,4)
prim.AddVertex(-1.4,-10,3)
prim.AddVertex(1.4,10,3)
prim.AddPolygonIndices(0,1,2)
|
or
Code: |
prim = Scene.AddPrimitive()
prim.AddPolygonVertices({1,3,4},{-1.4,-10,3},{1.4,10,3})
|
I might also have to do a rewrite on the internal DeleD classes I am using to make things a bit easier to use in the long run, but I will try and put that off till I get a working version that I can publish first
Hopefully the plugin will be working enough by the end of next week (juggling around work and family), but could be sooner - touch wood
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
fik Member
Joined: 11 Oct 2006 Posts: 303
|
Posted: Sat May 09, 2009 11:25 pm Post subject: |
|
|
This is looking really promising and usefull |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Tue May 12, 2009 12:57 am Post subject: |
|
|
Hi all,
after a bit of debugging and fiddling, I can now do some geometry generation via Lua script as vertices, etc.
Code: |
function Execute()
-- Icosahedron data
r = 200
X = 0.525731112119133606
Z = 0.850650808352039932
ICOS_Vertices = {
{-X, 0.0, Z,1}, {X, 0.0, Z,1}, {-X, 0.0, -Z,1}, {X, 0.0, -Z,1},
{0.0, Z, X,1}, {0.0, Z, -X,1}, {0.0, -Z, X,1}, {0.0, -Z, -X,1},
{Z, X, 0.0,1}, {-Z, X, 0.0,1}, {Z, -X, 0.0,1}, {-Z, -X, 0.0,1}
}
ICOS_Indices = {
{0,4,1}, {0,9,4}, {9,5,4}, {4,5,8}, {4,8,1},
{8,10,1}, {8,3,10},{5,3,8}, {5,2,3}, {2,7,3},
{7,10,3}, {7,6,10}, {7,11,6}, {11,0,6}, {0,1,6},
{6,1,10}, {9,0,11}, {9,11,2}, {9,2,5}, {7,2,11}
}
Scene = DeleD.GetCurrentScene()
prim = Scene.AddPrimitive()
-- add vertices
for i = 1,12 do
x = ICOS_Vertices[i][1]
y = ICOS_Vertices[i][2]
z = ICOS_Vertices[i][3]
prim.AddVertex(x,y,z)
end
-- add polygons using vertex indices
for i = 1,20 do
i1 = ICOS_Indices[i][1]
i2 = ICOS_Indices[i][2]
i3 = ICOS_Indices[i][3]
prim.AddPolygonIndices(i1,i2,i3)
end
prim.Scale(r)
prim.Translate(100,0,0)
prim.SendToDeleD()
end |
The above code will create an Icosahedron using the vertices and indices data supplied, scale it by 200, translate it to (100,0,0), and then send the primitive to DeleD
Hopefully there will be a BETA version that I can release by the end of the week...
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Tue May 12, 2009 1:53 am Post subject: |
|
|
and here is another example (using random this time)
Code: |
function Execute()
-- Icosahedron data
X = 0.525731112119133606
Z = 0.850650808352039932
ICOS_Vertices = {
{-X, 0.0, Z,1}, {X, 0.0, Z,1}, {-X, 0.0, -Z,1}, {X, 0.0, -Z,1},
{0.0, Z, X,1}, {0.0, Z, -X,1}, {0.0, -Z, X,1}, {0.0, -Z, -X,1},
{Z, X, 0.0,1}, {-Z, X, 0.0,1}, {Z, -X, 0.0,1}, {-Z, -X, 0.0,1}
}
ICOS_Indices = {
{0,4,1}, {0,9,4}, {9,5,4}, {4,5,8}, {4,8,1},
{8,10,1}, {8,3,10},{5,3,8}, {5,2,3}, {2,7,3},
{7,10,3}, {7,6,10}, {7,11,6}, {11,0,6}, {0,1,6},
{6,1,10}, {9,0,11}, {9,11,2}, {9,2,5}, {7,2,11}
}
Scene = DeleD.GetCurrentScene()
math.randomseed(100)
for p = 1,10 do
prim = Scene.AddPrimitive()
-- add vertices
for i = 1,12 do
x = ICOS_Vertices[i][1]
y = ICOS_Vertices[i][2]
z = ICOS_Vertices[i][3]
prim.AddVertex(x,y,z)
end
-- add polygons using vertex indices
for i = 1,20 do
i1 = ICOS_Indices[i][1]
i2 = ICOS_Indices[i][2]
i3 = ICOS_Indices[i][3]
prim.AddPolygonIndices(i1,i2,i3)
end
prim.Scale(math.random(50,200))
prim.Translate(math.random(-500,500),0,math.random(-500,500))
prim.SendToDeleD()
end
end |
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
chronozphere DeleD PRO user
Joined: 20 Jun 2006 Posts: 1010 Location: Netherlands
|
Posted: Tue May 12, 2009 7:16 am Post subject: |
|
|
Oh men, this is going to be very usefull. Can't wait to play around with it myself. |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Wed May 13, 2009 3:46 am Post subject: |
|
|
If anyone wants to have a play with the current version (before release), you can find a zip file here:
http://fpc4gp2x.eonclash.com/downloads/DeleDScript.zip
It contains the lua and plugin dlls + some example scripts.
Both dlls need to go in the Plugins folder as per usual.
You may notice that the lua dll doesn't have a dll extension, this is so DeleD doesn't try and load it as a plugin.
It shouldn't be too hard to workout what the scripts do.
If you need help with the scripting language, Lua, then you can find the manual online here:
http://www.lua.org/manual/5.1/manual.html
PS.There is no documentation yet, and some bits may change by release, but you can still have fun
NOTE!!: the plugin allows you to load/save script text files, and when the load/save dialog box is shown, it appears on a different monitor on my system unless I move it to my primary monitor...
Can you please check this and get back to me?
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
fik Member
Joined: 11 Oct 2006 Posts: 303
|
Posted: Wed May 13, 2009 10:15 pm Post subject: |
|
|
Downloaded and looks good. Having a little play with, all seems to work ok so far.
Good work |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Thu May 14, 2009 7:17 am Post subject: |
|
|
Primitives now can be rotated (around the model origin and world origin), scaled, cloned and even imported from RAW format files
Code: |
vertex vertex vertex...
...
vertex vertex vertex
|
Image of RAW asteroid file imported, scaled and rotated around origin
http://img254.imageshack.us/img254/9475/scriptscreenshot.png
Code: |
function Execute()
n = 10
Scene = DeleD.GetCurrentScene()
prim = Scene.AddPrimitive()
-- Import_RAW() will use a dialog box if no file name is specified
-- file names can use \\ or / as path delimiters
-- prim.Import_RAW("C:\\Documents and Settings\\paul.nicholls\\Desktop\\To be burned to cd\\a_steroidv06\\a_steroidv06\\src\\data\\ast.raw")
prim.Import_RAW("C:/Documents and Settings/paul.nicholls/Desktop/To be burned to cd/a_steroidv06/a_steroidv06/src/data/ast.raw")
prim.SetName("Asteroid")
for i = 0,n do
-- make copy of imported primitive
cprim = prim.Clone()
cprim.Scale(math.random(50,100),math.random(50,100),math.random(50,100))
cprim.Translate(math.random(150,300),0,0)
-- rotates model around world origin (Rotate_ModelOrigin uses the model origin instead)
-- Rotate(a,x,y,z)
-- a = angle (degrees), (x,y,z) = axis of rotation (doesn't have to be normalized)
cprim.Rotate(360 * i / n,0,1,0)
cprim.SendToDeleD()
end
end
|
I have also uploaded the latest version so you can play
It includes a sample RAW file (the asteroid)
http://fpc4gp2x.eonclash.com/downloads/DeleDScript.zip
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
chronozphere DeleD PRO user
Joined: 20 Jun 2006 Posts: 1010 Location: Netherlands
|
Posted: Thu May 14, 2009 1:28 pm Post subject: |
|
|
It doens't seem to work.
I tried your scaling-example but it didn't have any effect. No errors, just nothing.
The scripts that generate geometry didn't work either. "AddPolygonIndices" seems to be an invalid operation/function.
I just copied/pasted the scripts from this page.
Hope you are able to fix this. I don't have a clue what's going on. |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Thu May 14, 2009 8:52 pm Post subject: |
|
|
chronozphere wrote: |
It doens't seem to work.
I tried your scaling-example but it didn't have any effect. No errors, just nothing.
The scripts that generate geometry didn't work either. "AddPolygonIndices" seems to be an invalid operation/function.
I just copied/pasted the scripts from this page.
Hope you are able to fix this. I don't have a clue what's going on. |
Just to check, can you try one or more of the script files that I supplied instead?
the scaling example needs primitives in a scene to exist first.
Sorry, but AddPolygonIndices is now AddPolygonAsIndices (and there is also AddPolygonAsVertices)...
Some supplied examples are below.
Create some geometry
Code: |
function Execute()
-- add primitives to existing scene (use DeleD.CreateNewScene() to clear any existing scenes first)
Scene = DeleD.GetCurrentScene()
prim = Scene.AddPrimitive()
prim.AddPolygonAsVertices(
{-1000,0,-1000},
{1000,0,-1000},
{1000,0, 1000},
{-1000,0, 1000}
)
prim.SetName("Ground")
prim.SendToDeleD()
end |
Code: |
function Execute()
Scene = DeleD.GetCurrentScene()
prim = Scene.AddPrimitive()
prim.AddVertex(-1000,0, 1000)
prim.AddVertex( 1000,0, 1000)
prim.AddVertex( 1000,0,-1000)
prim.AddVertex(-1000,0,-1000)
prim.AddPolygonAsIndices(3,2,1,0)
prim.SetName("Ground")
prim.SendToDeleD()
end |
scale example (primitives must already exist)
Code: |
function Execute()
Scene = DeleD.GetCurrentScene()
-- iterate p from 0 to Scene.GetPrimitiveCount() - 1
for p = 0,Scene.GetPrimitiveCount() - 1 do
prim = Scene.GetPrimitive(p)
-- iterate v from 0 to prim.GetVertexCount() - 1
for v = 0,prim.GetVertexCount() - 1 do
x,y,z = prim.GetVertex(v)
x = x * 2
y = y * 2
z = z * 2
prim.SetVertex(v,x,y,z)
end
prim.SendToDeleD()
end
end |
Import RAW file and rotate example (change path to where you have the RAW file instead, or supply no path to use a open file dialog box)
Code: |
function Execute()
n = 10
Scene = DeleD.GetCurrentScene()
prim = Scene.AddPrimitive()
prim.Import_RAW("C:\\Documents and Settings\\paul.nicholls\\Desktop\\To be burned to cd\\a_steroidv06\\a_steroidv06\\src\\data\\ast.raw")
prim.SetName("Asteroid")
for i = 0,n do
cprim = prim.Clone()
cprim.Scale(math.random(50,100),math.random(50,100),math.random(50,100))
cprim.Translate(math.random(150,300),0,0)
cprim.Rotate(360 * i / n,0,1,0)
cprim.SendToDeleD()
end
end |
Hope this helps
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
chronozphere DeleD PRO user
Joined: 20 Jun 2006 Posts: 1010 Location: Netherlands
|
Posted: Fri May 15, 2009 7:31 am Post subject: |
|
|
Okay.. I did some testing for you.
I ran the scale-script with a few cylinders in it but hitting the execute button didn't have any effect.
The geometry-generation scripts seem to work now. Don't know why, but it's good.
The RAW-example creates objects without visible geometry. It might be that all vertices are located at the origin or that the primitives don't have vertices at all.
I tried your icosahedron code again, but it didn't work. Here it is:
Code: |
function Execute()
-- Icosahedron data
X = 0.525731112119133606
Z = 0.850650808352039932
ICOS_Vertices = {
{-X, 0.0, Z,1}, {X, 0.0, Z,1}, {-X, 0.0, -Z,1}, {X, 0.0, -Z,1},
{0.0, Z, X,1}, {0.0, Z, -X,1}, {0.0, -Z, X,1}, {0.0, -Z, -X,1},
{Z, X, 0.0,1}, {-Z, X, 0.0,1}, {Z, -X, 0.0,1}, {-Z, -X, 0.0,1}
}
ICOS_Indices = {
{0,4,1}, {0,9,4}, {9,5,4}, {4,5,8}, {4,8,1},
{8,10,1}, {8,3,10},{5,3,8}, {5,2,3}, {2,7,3},
{7,10,3}, {7,6,10}, {7,11,6}, {11,0,6}, {0,1,6},
{6,1,10}, {9,0,11}, {9,11,2}, {9,2,5}, {7,2,11}
}
Scene = DeleD.GetCurrentScene()
math.randomseed(100)
for p = 1,10 do
prim = Scene.AddPrimitive()
-- add vertices
for i = 1,12 do
x = ICOS_Vertices[i][1]
y = ICOS_Vertices[i][2]
z = ICOS_Vertices[i][3]
prim.AddVertex(x,y,z)
end
-- add polygons using vertex indices
for i = 1,20 do
i1 = ICOS_Indices[i][1]
i2 = ICOS_Indices[i][2]
i3 = ICOS_Indices[i][3]
prim.AddPolygonAsIndices(i1,i2,i3)
end
prim.Scale(math.random(50,200))
prim.Translate(math.random(-500,500),0,math.random(-500,500))
prim.SendToDeleD()
end
end
|
First it showed me the following error:
Code: |
[string "function Execute()..."]:40: bad argument #2 to 'Scale' (number expected, got no value)
|
When i outcommented the Scale routine. DeleD showed me the following message a couple of times, after i hit the "execute" button:
---------------------------
Error
---------------------------
CallBackProc: TPluginManager.SetData: '-489,525726318359' is not a valid floating point value
---------------------------
OK
---------------------------
Then i tried changing the line to:
Code: |
prim.Scale(1, 1, 1)
|
But DeleD showed the same errors again. The same happens when you remove any the translate-method.
Furthermore, I have a few requests.
> Ctrl-A should select all text in the script-memo, but it beeps instead. Can you make it work?
> You might want to use a slightly more advanced memo-component. It would be nice to have line-numbers in a gutter on the left side. Syntax-highlighting would be awesome, but it's not neccesary. You could take a look at this: http://synedit.sourceforge.net/
> It might be nice to let the plugin remember the last script you were working on. It often happens that you need to get back to DeleD to check something. It would be nice if you could start tweaking the script you were working on, instead of having to copy/paste/save/load it (This is a nitpick though. )
Allthough the plugin doesn't completely work here, I really like it. Keep up the good work. |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Fri May 15, 2009 12:13 pm Post subject: |
|
|
chronozphere wrote: |
Okay.. I did some testing for you.
I ran the scale-script with a few cylinders in it but hitting the execute button didn't have any effect.
The geometry-generation scripts seem to work now. Don't know why, but it's good.
The RAW-example creates objects without visible geometry. It might be that all vertices are located at the origin or that the primitives don't have vertices at all.
I tried your icosahedron code again, but it didn't work. Here it is:
Code: |
function Execute()
-- Icosahedron data
X = 0.525731112119133606
Z = 0.850650808352039932
ICOS_Vertices = {
{-X, 0.0, Z,1}, {X, 0.0, Z,1}, {-X, 0.0, -Z,1}, {X, 0.0, -Z,1},
{0.0, Z, X,1}, {0.0, Z, -X,1}, {0.0, -Z, X,1}, {0.0, -Z, -X,1},
{Z, X, 0.0,1}, {-Z, X, 0.0,1}, {Z, -X, 0.0,1}, {-Z, -X, 0.0,1}
}
ICOS_Indices = {
{0,4,1}, {0,9,4}, {9,5,4}, {4,5,8}, {4,8,1},
{8,10,1}, {8,3,10},{5,3,8}, {5,2,3}, {2,7,3},
{7,10,3}, {7,6,10}, {7,11,6}, {11,0,6}, {0,1,6},
{6,1,10}, {9,0,11}, {9,11,2}, {9,2,5}, {7,2,11}
}
Scene = DeleD.GetCurrentScene()
math.randomseed(100)
for p = 1,10 do
prim = Scene.AddPrimitive()
-- add vertices
for i = 1,12 do
x = ICOS_Vertices[i][1]
y = ICOS_Vertices[i][2]
z = ICOS_Vertices[i][3]
prim.AddVertex(x,y,z)
end
-- add polygons using vertex indices
for i = 1,20 do
i1 = ICOS_Indices[i][1]
i2 = ICOS_Indices[i][2]
i3 = ICOS_Indices[i][3]
prim.AddPolygonAsIndices(i1,i2,i3)
end
prim.Scale(math.random(50,200))
prim.Translate(math.random(-500,500),0,math.random(-500,500))
prim.SendToDeleD()
end
end
|
First it showed me the following error:
Code: |
[string "function Execute()..."]:40: bad argument #2 to 'Scale' (number expected, got no value)
|
When i outcommented the Scale routine. DeleD showed me the following message a couple of times, after i hit the "execute" button:
---------------------------
Error
---------------------------
CallBackProc: TPluginManager.SetData: '-489,525726318359' is not a valid floating point value
---------------------------
OK
---------------------------
Then i tried changing the line to:
Code: |
prim.Scale(1, 1, 1)
|
But DeleD showed the same errors again. The same happens when you remove any the translate-method.
Furthermore, I have a few requests.
> Ctrl-A should select all text in the script-memo, but it beeps instead. Can you make it work?
> You might want to use a slightly more advanced memo-component. It would be nice to have line-numbers in a gutter on the left side. Syntax-highlighting would be awesome, but it's not neccesary. You could take a look at this: http://synedit.sourceforge.net/
> It might be nice to let the plugin remember the last script you were working on. It often happens that you need to get back to DeleD to check something. It would be nice if you could start tweaking the script you were working on, instead of having to copy/paste/save/load it (This is a nitpick though. )
Allthough the plugin doesn't completely work here, I really like it. Keep up the good work. |
Hi chronozphere,
Thanks for testing
It's funny you should mention using a better editor component like SynEdit...I upgraded it today already before I read this post - it now uses SynEdit WITH Lua syntax highlighting!! yay!!
I tried the same script as you showed above, and as you noticed, the Scale() command now takes 3 parameters instead of what I wrote back then
When I commented out that line like you did I didn't get a DeleD crash...I must have changed something in the meantime...
I have now personally checked all the scripts that I have included in the zip file and they all do what they are supposed to.
I have also added a basic help dialog box (F1) that loads a .rtf 'help' file (needs to be put into the Plugins folder too).
It now also remembers the last script that you had loaded/saved when you quit DeleDScript
It just doesn't do the CTRL+A thing yet
So get the updated version hot off the presses <G>
http://fpc4gp2x.eonclash.com/downloads/DeleDScript.zip
NOTE: just for fun, I am going to add a .plg 3d model file importer too
See here for some examples:
http://www.martinreddy.net/ukvrsig/rend386.html
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|