|
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: Fri May 01, 2009 6:37 am Post subject: DeleD scripting plugin |
|
|
Hi all,
I am toying with the idea to write a simple scripting plugin that will allow you to manipulate a DeleD scene using 1 or more script files via a single plugin DLL.
This would allow for the easy creation of procedural geometory, etc.
I have two ideas on the language to use in the script files:
1 use Lua (www.lua.org) - I have already used Lua in my own Delphi projects and it shouldn't be too difficult to whip something up so I can make the script files in Lua.
I can already simulate simple classes in Lua scripts that would make objects a bit easier/cleaner to create/modify.
possible example code
Code: |
Scene = DeleD.GetCurrentScene(<whatever parameters>)
for i = 0,Scene.PrimitiveCount - 1 do
{
Primitive = Scene.GetPrimitive(i)
Primitive.Vertices....
}
|
Pros: quicker to get something up and running, and supports classes.
Cons: language is not Delphi/Pascal
2 use my own Pascal-like scripting language - I did already make a pascal like scripting language a while back and I could update that so I can use it in this project.
Pros: is a Pascal-like language so might be a bit nicer to use.
Cons: currently doesn't support any sort of classes (emulated, or otherwise).
possible example code
Code: |
Scene := DeleD_GetCurrentScene(<parameters>);
For i := 0 To Scene_GetPrimitiveCount(Scene) - 1 Do
Begin
Primitive := Scene_GetPrimitive(Scene,i);
{....}
End; |
I appreciate your thoughts
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 01, 2009 9:51 am Post subject: |
|
|
That is a great idea. I'd go for lua. No, It isn't pascal, but it's still easy to use AFAIK and I like classes instead of long function names.
Maybe It's time to request some new plugin features. It would be great if plugins could be nicely integrated into DeleD. A plugin must be able to retrieve the current selection for example (Selected vertices, polygons etc). |
|
Back to top |
|
|
Mr.Fletcher DeleD PRO user
Joined: 07 Aug 2004 Posts: 1772 Location: Germany
|
Posted: Fri May 01, 2009 11:04 am Post subject: |
|
|
Nice one, I'd vote for lua! _________________ Behold! The DeleD Wiki! Please help us expanding it
DeleD on IRC |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Fri May 01, 2009 11:37 am Post subject: |
|
|
chronozphere wrote: |
That is a great idea. I'd go for lua. No, It isn't pascal, but it's still easy to use AFAIK and I like classes instead of long function names.
Maybe It's time to request some new plugin features. It would be great if plugins could be nicely integrated into DeleD. A plugin must be able to retrieve the current selection for example (Selected vertices, polygons etc). |
I completely agree it would be better if plugins could control DeleD more completely, and also about things like selected vertices, polygons, etc.
Ok, I will give Lua a whirl
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: Sun May 03, 2009 11:27 pm Post subject: |
|
|
I know it isn't very exciting, but as a proof of concept, I have managed to get some Lua code to create an object in DeleD
Code: |
function Execute()
AddObject()
end |
The object was a single triangle...I did say it was a proof of concept
Now I can move onto bigger and better things...litterally!! haha!
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: Mon May 04, 2009 7:00 am Post subject: |
|
|
Here is a better example
Code: |
function Execute()
-- places 3 icosahedrons at (x,y,z) with radius r
-- AddIcosahedron(x,y,z,r)
AddIcosahedron(-100,0,0,50)
AddIcosahedron(0,0,0,60)
AddIcosahedron(100,0,0,70)
end
|
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
Jeroen Site Admin
Joined: 07 Aug 2004 Posts: 5332 Location: The Netherlands
|
Posted: Mon May 04, 2009 7:35 am Post subject: |
|
|
Excellent! _________________ Check out Figuro, our online 3D app! More powerful 3D tools for free. |
|
Back to top |
|
|
chronozphere DeleD PRO user
Joined: 20 Jun 2006 Posts: 1010 Location: Netherlands
|
Posted: Mon May 04, 2009 7:39 am Post subject: |
|
|
Great.
Are you going to add a little math library to it? That seems neccesary to me if you want to do more advanced stuff. And is it only meant for object-creation or can you manipulate existing geometry aswell?
Keep it up. |
|
Back to top |
|
|
Grandmaster B DeleD PRO user
Joined: 03 Jul 2007 Posts: 218
|
Posted: Mon May 04, 2009 7:47 am Post subject: |
|
|
Very cool!!! |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Mon May 04, 2009 10:07 am Post subject: |
|
|
chronozphere wrote: |
Great.
Are you going to add a little math library to it? That seems neccesary to me if you want to do more advanced stuff. And is it only meant for object-creation or can you manipulate existing geometry aswell?
Keep it up. |
I will definitely be adding Scene and mesh classes for starters, and you will be able to use loops & other things (and math stuff), etc. to create geometry and other things
I will also make it so you can alter existing objects too.
I was just testing a single Delphi routine that is called from the Lua Script Wink
PS, has anyone updated the Delphi units for reading/writing DeleD files that Mr.Fletcher made in 2007? to include the new DeleD things (joints, etc)?
It might be necessary for me be able to access joints and other new stuff too otherwise it may stuff up models, etc. if I update the scene and the new DeleD 2.0 bits are missing.
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
ash DeleD PRO user
Joined: 01 Sep 2006 Posts: 35 Location: amerika
|
Posted: Mon May 04, 2009 8:13 pm Post subject: |
|
|
IOm really interested in Lua scripting for DeleD, I think maybe sometime in a year or two when I am little bit better programmer, I would like to maker a simple procedural plant script, or one for some stones, etc
Lua looks to be a nice language to use, I am hoping I enjoy it more than python, I do not like intermezzo code style one bit :/ _________________ quid quid latine dictum sit
DeleD PRO User |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Tue May 05, 2009 1:40 am Post subject: |
|
|
I have started adding in some Delphi classes that can be accessed via Lua now.
EDIT: I have updated the code below
Example code:
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)
-- show vertex in the form "x,y,z"
-- ".." concatenates values together as strings
ShowMessage(x..","..y..","..z)
end
end
end |
This code will get the current DeleD scene, iterate through all the primitives, and for each primitive, display each vertex in that primitive
The code shows one of the neat Lua features - returing multiple values from one function!
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Tue May 05, 2009 7:38 pm Post subject: |
|
|
Excellent stuff. And I agree that tuples are very cool (but only for scripting-purposes, I am very glad mainstream compiled languages enforce predefined structures for result values).
As a sidenote, perhaps you should try contacting Il Buzzo, because he took his lua plugin system quite far at the time. Perhaps a bit too far (was working on including an IDE and testing framework), as the project hasn't been updated for over a year. He is a great guy, so perhaps you guys can share experiences? |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Tue May 05, 2009 10:33 pm Post subject: |
|
|
Paul-Jan wrote: |
Excellent stuff. And I agree that tuples are very cool (but only for scripting-purposes, I am very glad mainstream compiled languages enforce predefined structures for result values).
As a sidenote, perhaps you should try contacting Il Buzzo, because he took his lua plugin system quite far at the time. Perhaps a bit too far (was working on including an IDE and testing framework), as the project hasn't been updated for over a year. He is a great guy, so perhaps you guys can share experiences? |
Thanks for the info and link Paul-Jan
I find it ironic that I thought of doing this project and I hadn't even heard of Il Buzzo or his Lua script plugin!
I will take a look and perhaps contact him.
PS. I was never planning on taking it as far as he obviously did though, just to a usable and practical stage
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Wed May 06, 2009 7:21 pm Post subject: |
|
|
Well, "usable and practical" pretty much equals "great!" in my book! |
|
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
|
|