Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
3rd party dll's
06-02-2016, 04:57 AM
Post: #1
3rd party dll's
I've been looking at the Kerkythea plugin with the view of modifying it for Thea, it actually works "as is" to some degree, engine choice and materials would need work but its all do able for an Erlang novice like me.
My question is will Erlang handle 3rd party dll's?.. on the basic leave I could use a C# server dll which sends and receives messages to Thea, this is basically how the Thea4Blender plugin works
or there's the Thea SDK way which has various Swig wrappers, I know C#, Python and Java work and obviously the C++ original

I'm just thinking out loud really, I've done the Wings environment working and building, I've started work on the Thea plugin

The server idea is probably the easiest as it doesn't need the sdk at all, if it was python its only about 10 lines of code to make the client, C# was a lot more
Reply
06-02-2016, 09:22 PM
Post: #2
RE: 3rd party dll's
What is server and what is client here, and what messages are we taking about here, tcp/ip?

Writing socket comunication is easy in erlang, thought there are no examples in wings.
But it is what most use erlang for so it should be easy to find example code.
Reply
06-02-2016, 10:37 PM
Post: #3
RE: 3rd party dll's
I'll show the Python Client to give you an idea
Code:
from ctypes import *
import traceback
import sys
import socket
import struct
from os import path

port=6300 #port
host='127.0.0.1'#ip address

def sendSocketMsg(host, port, message):  #client code
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect((host, int(port)))
        
        msg = struct.pack('<l',len(message))+struct.pack('<l',0)+message

        s.sendall(msg)
        data = s.recv(1024)
        
        s.close()
        print (data.decode("utf-8"))
        return data.decode("utf-8")
    except:
        return 'ERROR'
    next
#get studio version
message = b'version'
sendSocketMsg(host, port, message)
#load a scene
message = b"message \"Load C:\\Temp\\scene.scn.thea\""
sendSocketMsg(host, port, message)
#get active camera
message =b"get \"./Scenes/Active/Cameras/Active\""
sendSocketMsg(host, port, message)
#get time limit
message = b'get \"./Scenes/Active/Render/Time Limit\"'
sendSocketMsg(host, port, message)
#get samples
message = b'get \"./Scenes/Active/Render/Sample Limit\"'
sendSocketMsg(host, port, message)
#render scene
message = b"message \"Render\""
sendSocketMsg(host, port, message)
############################################
#while loop would go here looping until data is Idle
##command in the loop
message = b'status'
sendSocketMsg(host, port, message)
##end loop
###########################################

##then save
#message = b"message 'SaveImage C:\\Temp\\scenex.png'"
sendSocketMsg(host, port, message)

Thea has a built in remote server which you can start from the command line ie
thea -noshow -remoteserver

then basically you just past commands and wait for a reply, like in the example you can get scene information and change it.
Its only really any good for loading a scene getting information, engine cores, rendering settings, display (iso, fnumber) It can't do a lists of commands so you couldn't get the materials or change them, the only way I found was to write and xml material file and use merge to replace the original
Reply
06-02-2016, 10:46 PM
Post: #4
RE: 3rd party dll's
Ok that should be easy in erlang as well, so that is what I would do.

http://erlang.org/doc/man/gen_tcp.html
Reply
06-02-2016, 11:49 PM
Post: #5
RE: 3rd party dll's
Thank you, I'll give it a try Smile
Reply
06-03-2016, 09:54 PM
Post: #6
RE: 3rd party dll's
Well it kinda works, its connecting but the data format wrong,
Code:
msg = struct.pack('<l',len(message))+struct.pack('<l',0)+message
is what I need to figure out

Out of interest is erlport worth looking into?
Reply
06-03-2016, 11:13 PM
Post: #7
RE: 3rd party dll's
I don't know python so you will have to be more specific.

i.e. struct.pack?
Maybe
Data = io_lib:format("<1~w<10~s", [length(Message), Message]),

Have no idea what erlport is, but no you should not need anything else.
Reply
06-04-2016, 02:20 AM
Post: #8
RE: 3rd party dll's
(06-03-2016 11:13 PM)dgud Wrote:  Have no idea what erlport is
It's a library that intend to allow us to connect Erlang to other languages.
http://erlport.org/

I read about it some time ago when I though we could use something like this to reuse Python code made for Blender plugins and make some of them available to Wings3d.

My Wings3D Collection at G+
Reply
06-04-2016, 02:53 AM
Post: #9
RE: 3rd party dll's
I had a quick try with erlport and it does work to run the python code I posted earlier, Thea is doing stuff apart from the return messages.
It does seem like it could be useful, even if its just a way to show people what I'm trying to do, in theory I could use Thea's sdk Python wrappers with erlport but I can see it going badly wrong lol

Thanks for the example, I'll give it a try now
Reply
06-07-2016, 02:17 AM
Post: #10
RE: 3rd party dll's
Quick test with ErlPort, this is actually using the Thea SDK Swig Python not the server I haven't managed to get an Erlang one working yet..

Its a shame that most of the links are dead for various help topics Sad


Attached File(s) Thumbnail(s)
   
Reply


Forum Jump:


User(s) browsing this thread: 1 Guest(s)