Delgine 3D Tools & Content DeleD Community Edition
Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DeleD scripting plugin
Goto page 1, 2, 3  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Plugins
View previous topic :: View next topic  
Author Message
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Fri May 01, 2009 6:37 am    Post subject: DeleD scripting plugin Reply with quote

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 Smile
cheers,
Paul
_________________
Long live DeleD!

Hi ho...hi ho...it's off 3d modeling I go...
Back to top
View user's profile Send private message
chronozphere
DeleD PRO user


Joined: 20 Jun 2006
Posts: 1010
Location: Netherlands

PostPosted: Fri May 01, 2009 9:51 am    Post subject: Reply with quote

That is a great idea. Razz 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. Smile

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). Smile
Back to top
View user's profile Send private message
Mr.Fletcher
DeleD PRO user


Joined: 07 Aug 2004
Posts: 1772
Location: Germany

PostPosted: Fri May 01, 2009 11:04 am    Post subject: Reply with quote

Nice one, I'd vote for lua!
_________________
Behold! The DeleD Wiki! Please help us expanding it Smile
DeleD on IRC
Back to top
View user's profile Send private message
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Fri May 01, 2009 11:37 am    Post subject: Reply with quote

chronozphere wrote:
That is a great idea. Razz 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. Smile

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). Smile


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 Smile

cheers,
Paul
_________________
Long live DeleD!

Hi ho...hi ho...it's off 3d modeling I go...
Back to top
View user's profile Send private message
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Sun May 03, 2009 11:27 pm    Post subject: Reply with quote

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 Smile

Code:
function Execute()
    AddObject()
end


The object was a single triangle...I did say it was a proof of concept Wink


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
View user's profile Send private message
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Mon May 04, 2009 7:00 am    Post subject: Reply with quote

Here is a better example Smile

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
View user's profile Send private message
Jeroen
Site Admin


Joined: 07 Aug 2004
Posts: 5332
Location: The Netherlands

PostPosted: Mon May 04, 2009 7:35 am    Post subject: Reply with quote

Excellent! Very Happy
_________________
Check out Figuro, our online 3D app! More powerful 3D tools for free.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
chronozphere
DeleD PRO user


Joined: 20 Jun 2006
Posts: 1010
Location: Netherlands

PostPosted: Mon May 04, 2009 7:39 am    Post subject: Reply with quote

Great. Very Happy

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. Wink
Back to top
View user's profile Send private message
Grandmaster B
DeleD PRO user


Joined: 03 Jul 2007
Posts: 218

PostPosted: Mon May 04, 2009 7:47 am    Post subject: Reply with quote

Very cool!!!
Back to top
View user's profile Send private message
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Mon May 04, 2009 10:07 am    Post subject: Reply with quote

chronozphere wrote:
Great. Very Happy

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. Wink


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 Smile

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
View user's profile Send private message
ash
DeleD PRO user


Joined: 01 Sep 2006
Posts: 35
Location: amerika

PostPosted: Mon May 04, 2009 8:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Tue May 05, 2009 1:40 am    Post subject: Reply with quote

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 Smile

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
View user's profile Send private message
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Tue May 05, 2009 7:38 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Tue May 05, 2009 10:33 pm    Post subject: Reply with quote

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 Smile

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! Laughing

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 Smile

cheers,
Paul
_________________
Long live DeleD!

Hi ho...hi ho...it's off 3d modeling I go...
Back to top
View user's profile Send private message
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Wed May 06, 2009 7:21 pm    Post subject: Reply with quote

Well, "usable and practical" pretty much equals "great!" in my book!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Plugins All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
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