Gracias Gracias:  0
Resultados 1 al 1 de 1

Tema: Mr Blender’s Web Services

  1. #1
    Administrador y fundador. Avatar de 3dpoder
    Fecha de ingreso
    Apr 2002

    Mr. Blender’s Web Services

    Mr. Blender’s Web Services
    By - Hamed Zaghaghi

    In this article you can learn how to use web services with Blender to make games or walk-throughs that are able to interact with resources on the Internet. I'll assume that you have some background of XML, Python, and PHP.

    Bellow you can read my interview with Mr: Blender.

    Me: Hello Mr: Blender!
    Mr: Blender: Hey YOU!
    Me: - I'm thinking about making a game or walkthrough that interacts with others on the Internet.
    Mr: Blender: OK, what's the problemí You can do it using python scripting.
    Me: Yes I know that I can do it, but... I don't know how!
    Mr: Blender: Do you know about web services?
    Me: Web servicesí!
    Mr: Blender: Yes. It's about exchanging data between a web server and a client.
    Me: Hmmm. Can you explain more about web services?
    Mr: Blender: Web services are methods you write or see in programs. Both are called with local programs, but the difference is that methods in local programs run locally and use local system resources, while methods in web services run on servers and use server resources. This isn't a complete definition of a web service, but it's close enough.
    Me: Can you give me some examples of using a web service in Blender?
    Mr: Blender: Okay. For example, you might want:

    • Users of your game to register on your web site and then login into the game using their user name and password (you can see this in almost all online games).
    • Your game to chek for a newer versión when starting and prompts the user to update.
    • To make a 3D presentation of a house for sale and users can chat with the house owner and asque him/her some questions, or many other examples.

    Me: Oh, well, I thinque that when users must register their user name and password, I should have a database that contains user data, but what is the relation between Blender, Python, Web Service, and a Database?

    Mr: Blender: Have a look at the following picture; I thinque that it will help you find the answer.


    Blender! & Web Services

    Me: OK, can you go step by step to make a complete example?
    Mr: Blender: Yes. Let's make a game with versión checker, step by step.
    Me: OK. :)
    Mr: Blender: First of all we need a game. You can use your previous games, or make a simple game, or simply use the standard Blender scene with a cube at the center as a game and continue.
    Me: OK, I'll use a new Blender scene.
    Mr: Blender: First we add an Always sensor, and unchek both True and False pulse mode.
    Me: Ok.


    Mr: Blender: Now make a new file in the Text Editor and name it "check_versión" without quotes, then add a Python controller and set Script parameter to "check_versión" without quotes again, then connect the Always Sensor to the Python Controller.
    Me: And then?


    Mr: Blender: Before doing anything else in Blender, we need to configure our web service server. I use Apache as my web server, PHP for writing web services, the XML-RPC protocol for my web service, and Keith Devens' implementation of XML-RPC on PHP. You can find XML-RPC implementations in other programming languages at
    Me: Oh, and then?
    Mr: Blender: For setting the web service up, first download Keith Devens' implementation from, then upload it somewhere to your web server.
    Me: OK, I'm downloading it and uploading to
    Mr: Blender: Then write this code in a text editor and save it as a php file in the same directory that you uploaded the XML-RPC implementation. Let's call it server.php.

    <?php #1)Include Keith Devens implementation include("kd_xmlrpc.php"); #2)Web Service Methods $xmlrpc_methods = array(); $xmlrpc_methods['CurrentVersion'] = 'getCurrentVersion'; $xmlrpc_methods['method_not_found'] = 'XMLRPC_method_not_found';
    #3)Web Service Server
    $xmlrpc_request = XMLRPC_parse($HTTP_RAW_POST_DATA);
    $methodName =
    $params = XMLRPC_getParams($xmlrpc_request);
    #4)Web Service Methods Implementation
    function getCurrentVersion($params){
    $returnversión['versión'] = 3.60;
    function XMLRPC_method_not_found($methodName){
    XMLRPC_error("2", "The method you requested,
    '$methodName', was not found.");
    Me: I can do it, but I don't know what the code is for.

    Mr: Blender: This code setups an XML-RPC server using Keith Devens' implementation, with two methods, "getCurrentVersion" and "method_not_found." The first method is the one we want to call from blender, and the second one is for requested methods that this server doesn't support. In the first section of code we include the XML_RPC implementation, and in the second section we setup an array that is used with the server code to find an implementation of the requested method. For example when in line 2 section 2, we say that if a method named "CurrentVersion" exists, the requested server should run the "getCurrentVersion" method implemented in section 4.

    Then, in the third section, parse the request and extract the requested method name and its parameters. Finally, chek if the requested method name was implemented, and if not, run "method_not_found" instead.

    Me: Oh. I thinque that after we write this code and save it on server.php, we can then send a request method name and its parameters to server.php, and this code will run the requested method and respond with its value.

    Mr: Blender: Yes, that's right. As a short explanation, the "getCurrentVersion" method responds with a structure of three fields - versión, minor and major. Every time my program gets updated we change those numbers. In these methods, we can connect to databases and get some information from them.

    Me: And then from python send a request to server.php to run getCurrentVersion. But how can we do it in python?

    Mr: Blender: This section is easier than the previous one. Python has a library named "xmlrpclib," and we can use it to send requests and receive responses. To see what this library can do, paste this code in the python text editor of Blender, then press P.

    import xmlrpclib
    this_versión = 1.3
    server =
    current_versión = server.getCurrentVersion()
    if(current_versión['versión'] > this_versión):
    print "Go to program web site and download updated
    print "program is updated."
    Me: I'll do it, but where I can see the resultsí

    Mr: Blender: You can see the printed line in the terminal/command prompt of blender.

    Me: Thanque you, Mr. Blender, for your time.

    Mr: Blender: You're welcome!

    Interviewer - Hamed Zaghaghi,
    MSc. Student of Algorithms and Computation,
    Engineering Science Department, University of Tehran
    Email -

    Miniaturas adjuntadas Miniaturas adjuntadas -1.jpg   -paginas-desdeblenderart_jan08_issue14.pdf-adobe-acrobat-pro-extended_pagina_1_imagen_0006.jpg   -paginas-desdeblenderart_jan08_issue14.pdf-adobe-acrobat-pro-extended_pagina_1_imagen_0007.jpg  
    Si vas a subir un trabajo al foro, hazlo adjuntando la imagen, archivo, vídeo o lo que sea, no publicando enlaces de otros sitios.

    |Agradecer cuando alguien te ayuda es de ser agradecido|

Temas similares

  1. Nuevo libro sobre Blender: Creacion de personajes con Blender 2 69
    Por CaminanteBinario en el foro Quien eres tu - Aqui puedes presentarte
    Respuestas: 5
    Último mensaje: 21-12-2013, 01:52
  2. Blender Demora cuando seleccionas un objeto en Blender Posible Blender Bug
    Por KAEIKO en el foro Problemas con Programas
    Respuestas: 8
    Último mensaje: 30-08-2011, 00:57
  3. Respuestas: 1
    Último mensaje: 30-04-2010, 03:46
  4. 3D Visualization services
    Por covono en el foro Demandas de Empleo / Curriculum
    Respuestas: 0
    Último mensaje: 08-09-2008, 07:33
  5. Problema al instalar Services Packs en 3DS Max 8
    Por thenewmoran en el foro Problemas con Programas
    Respuestas: 2
    Último mensaje: 07-11-2007, 16:59

Actualmente estos son sus permisos de publicación en el foro.

  • -No puedes crear nuevos temas al no estar registrado o no haber iniciado sesión en el foro.
  • -No puedes responder temas al no estar registrado o no haber iniciado sesión en el foro.
  • -No puedes subir archivos adjuntos al no estar registrado o no haber iniciado sesión en el foro.
  • -No puedes editar tus mensajes al no estar registrado o no haber iniciado sesión en el foro.