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
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.
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
Thank you, I'll give it a try
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?
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.
(06-03-2016, 01: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.
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
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