Skip to main content

Python Package made by Mhadhbi Issam .

Project description

DefoldSdk

♠ Install

pip install DefoldSdk

♠ Getting started

♠♠ Example createing new material and assign it to model :

from DefoldSdk import Project


x = Project()
x.new(name = "defoldproject" , path = ".")

modelMaterial= x.newMaterial(name = "pbr" , tags = ['model'])
modelMaterial.setvertex_constant(name='mtx_worldview',typ='Worldview')
modelMaterial.setvertex_constant(name='mtx_view',typ='View')
modelMaterial.setvertex_constant(name='mtx_proj',typ='Projection')
modelMaterial.setvertex_constant(name='mtx_normal',typ='Normal')
modelMaterial.setvertex_constant(name='light',typ='User')
modelMaterial.setfragment_constant(name = 'tint' , typ='User')
modelMaterial.setTexture(name='tex0')
modelMaterial.setvertex_space('local')
modelMaterial.vp = ''' 
    attribute highp vec4 position;
    attribute mediump vec2 texcoord0;
    attribute mediump vec3 normal;

    uniform mediump mat4 mtx_worldview;
    uniform mediump mat4 mtx_view;
    uniform mediump mat4 mtx_proj;
    uniform mediump mat4 mtx_normal;
    uniform mediump vec4 light;

    varying highp vec4 var_position;
    varying mediump vec3 var_normal;
    varying mediump vec2 var_texcoord0;
    varying mediump vec4 var_light;

    void main()
    {
        vec4 p = mtx_worldview * vec4(position.xyz, 1.0);
        var_light = mtx_view * vec4(light.xyz, 1.0);
        var_position = p;
        var_texcoord0 = texcoord0;
        var_normal = normalize((mtx_normal * vec4(normal, 0.0)).xyz);
        gl_Position = mtx_proj * p;
    }
    '''
modelMaterial.fp = ''' 
    varying highp vec4 var_position;
    varying mediump vec3 var_normal;
    varying mediump vec2 var_texcoord0;
    varying mediump vec4 var_light;

    uniform lowp sampler2D tex0;
    uniform lowp vec4 tint;

    void main()
    {
        // Pre-multiply alpha since all runtime textures already are
        vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
        vec4 color = texture2D(tex0, var_texcoord0.xy) ;

        // Diffuse light calculations
        vec3 ambient_light = vec3(0.2);
        vec3 diff_light = vec3(normalize(var_light.xyz - var_position.xyz));
        diff_light = max(dot(var_normal,diff_light), 0.0) + ambient_light;
        diff_light = clamp(diff_light, 0.0, 1.0);

        gl_FragColor = vec4(color.rgb*diff_light,1.0);
    }
    '''

x.update()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nimc-1.0.2.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

nimc-1.0.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file nimc-1.0.2.tar.gz.

File metadata

  • Download URL: nimc-1.0.2.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for nimc-1.0.2.tar.gz
Algorithm Hash digest
SHA256 07d4e82361192952fa87146a6c2b28fae3207bff7edf25cb60b27aa86ab5c8e8
MD5 61085114fb3b04c6061a2d5183bbde0f
BLAKE2b-256 5afbdafbe0eed993b14a3f98a688f9d11deca98b6e040c293699d8f5846fafbd

See more details on using hashes here.

File details

Details for the file nimc-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: nimc-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for nimc-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c64f68c392e136a94d2465fc358d670aac9bcb8f072deec043bc215fbeda9e0f
MD5 9138fed859e97d67d8a1277c985dfc73
BLAKE2b-256 f17ad89f097e6ad1acd2bd68ea69d31568ccba2d72c4913072c090f84704c4e1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page