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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
defoldsdk-1.2.7.tar.gz
(10.6 kB
view details)
Built Distribution
defoldsdk-1.2.7-py3-none-any.whl
(12.6 kB
view details)
File details
Details for the file defoldsdk-1.2.7.tar.gz
.
File metadata
- Download URL: defoldsdk-1.2.7.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c760284e804be00557b09d75cf4f62aff6d57343aa5e3508dd563c52dc4d5ad |
|
MD5 | 7d19d5b7b1d872821d674c527f5e3d7a |
|
BLAKE2b-256 | 5e2ed9a921ce8b5f44f3b79217f80c5c7c694ab61737c3252112a2869f071116 |
File details
Details for the file defoldsdk-1.2.7-py3-none-any.whl
.
File metadata
- Download URL: defoldsdk-1.2.7-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7db2e351aacadcf0650489a65e7edd835a3dd718303385a51835b489878d969 |
|
MD5 | 382d7059a1b6b0d96b38e95d4bb0eeff |
|
BLAKE2b-256 | 034a26ab74b162fb5a480acd8f72981b31f4152af17694a65d451f83ae72846e |