|
@@ -811,6 +811,7 @@ void tnspost_World(tnsWorld *w){
|
|
tnsRefreshMaterialLibraries();
|
|
tnsRefreshMaterialLibraries();
|
|
}
|
|
}
|
|
void tnspost_Material(tnsMaterial *m){
|
|
void tnspost_Material(tnsMaterial *m){
|
|
|
|
+ tns_RefreshMaterial2D(m);
|
|
//if(m->AsLibrary){ tnsRefreshMaterialLibraries(); return; }
|
|
//if(m->AsLibrary){ tnsRefreshMaterialLibraries(); return; }
|
|
//tnsEnsureMaterialShader(m,1);
|
|
//tnsEnsureMaterialShader(m,1);
|
|
}
|
|
}
|
|
@@ -896,8 +897,27 @@ void tns_InvalidateMeshWithMaterial(tnsMaterial* m){
|
|
}
|
|
}
|
|
}
|
|
}
|
|
void tnsset_MaterialColor(tnsMaterial* m, real* c){
|
|
void tnsset_MaterialColor(tnsMaterial* m, real* c){
|
|
- tnsVectorCopy4d(c,m->Color); tns_InvalidateMeshWithMaterial(m); laNotifyUsers("tns.world");
|
|
|
|
|
|
+ tnsVectorCopy4d(c,m->Color); tns_InvalidateMeshWithMaterial(m); tns_RefreshMaterial2D(m); laNotifyUsers("tns.world");
|
|
|
|
+}
|
|
|
|
+void tns_RefreshMaterial2D(tnsMaterial* m){
|
|
|
|
+ NVGcontext* vg=MAIN.CurrentWindow->nvg;
|
|
|
|
+ if(m->GradientMode==TNS_GRADIENT_MODE_LINEAR){
|
|
|
|
+ m->Paint=nvgLinearGradient(vg,m->GradientCenter[0],m->GradientCenter[1],m->GradientSize[0],m->GradientSize[1],
|
|
|
|
+ nvgRGBAf(LA_COLOR4(m->Color)),nvgRGBAf(LA_COLOR4(m->Color2)));
|
|
|
|
+ }elif(m->GradientMode==TNS_GRADIENT_MODE_BOX){
|
|
|
|
+ m->Paint=nvgBoxGradient(vg,m->GradientCenter[0],m->GradientCenter[1],m->GradientSize[0],m->GradientSize[1],
|
|
|
|
+ m->GradientBoxR,m->GradientBoxF,nvgRGBAf(LA_COLOR4(m->Color)),nvgRGBAf(LA_COLOR4(m->Color2)));
|
|
|
|
+ }elif(m->GradientMode==TNS_GRADIENT_MODE_RADIAL){
|
|
|
|
+ m->Paint=nvgRadialGradient(vg,m->GradientCenter[0],m->GradientCenter[1],m->GradientSize[0],m->GradientSize[1],
|
|
|
|
+ nvgRGBAf(LA_COLOR4(m->Color)),nvgRGBAf(LA_COLOR4(m->Color2)));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+void tnsset_MaterialColor2(tnsMaterial* m, real* c){ tnsVectorCopy4d(c,m->Color2); tns_RefreshMaterial2D(m); laNotifyUsers("tns.world"); }
|
|
|
|
+void tnsset_MaterialGradientMode(tnsMaterial* m, int Mode){ m->GradientMode=Mode; tns_RefreshMaterial2D(m); laNotifyUsers("tns.world"); }
|
|
|
|
+void tnsset_MaterialGradientCenter(tnsMaterial* m, real* c){ tnsVectorCopy2d(c,m->GradientCenter); tns_RefreshMaterial2D(m); laNotifyUsers("tns.world"); }
|
|
|
|
+void tnsset_MaterialGradientSize(tnsMaterial* m, real* c){ tnsVectorCopy2d(c,m->GradientSize); tns_RefreshMaterial2D(m); laNotifyUsers("tns.world"); }
|
|
|
|
+void tnsset_MaterialGradientF(tnsMaterial* m, real c){ m->GradientBoxF=c; tns_RefreshMaterial2D(m); laNotifyUsers("tns.world"); }
|
|
|
|
+void tnsset_MaterialGradientR(tnsMaterial* m, real c){ m->GradientBoxR=c; tns_RefreshMaterial2D(m); laNotifyUsers("tns.world"); }
|
|
void tnsget_MaterialSlotname(tnsMaterialSlot* ms, char *result, char** here){
|
|
void tnsget_MaterialSlotname(tnsMaterialSlot* ms, char *result, char** here){
|
|
if(!ms){ strcpy(result,"?"); return; }
|
|
if(!ms){ strcpy(result,"?"); return; }
|
|
if(ms->Material&&ms->Material->Name&&ms->Material->Name->Ptr){
|
|
if(ms->Material&&ms->Material->Name&&ms->Material->Name->Ptr){
|
|
@@ -1131,7 +1151,8 @@ void la_RegisterTNSProps(){
|
|
p = laAddPropertyContainer("tns_material", "Material" "Object material", 0,0,0,sizeof(tnsMaterial),tnspost_Material,0,2);{
|
|
p = laAddPropertyContainer("tns_material", "Material" "Object material", 0,0,0,sizeof(tnsMaterial),tnspost_Material,0,2);{
|
|
TNS_PC_MATERIAL=p;
|
|
TNS_PC_MATERIAL=p;
|
|
laAddStringProperty(p, "name", "Material Name", "The name ff the material", 0,0,0,0,1, offsetof(tnsMaterial, Name), 0,0,0,0,LA_AS_IDENTIFIER);
|
|
laAddStringProperty(p, "name", "Material Name", "The name ff the material", 0,0,0,0,1, offsetof(tnsMaterial, Name), 0,0,0,0,LA_AS_IDENTIFIER);
|
|
- laAddFloatProperty(p, "color", "Color", "Base color of the material", LA_WIDGET_FLOAT_COLOR, "R,G,B,A", 0,1,0,0.025, 1, 0,offsetof(tnsMaterial, Color), 0,0,4, 0,0,0,0,tnsset_MaterialColor, 0,0,0);
|
|
|
|
|
|
+ laAddFloatProperty(p, "color", "Color", "Base color of the material", LA_WIDGET_FLOAT_COLOR, "R,G,B,A", 0,1,0,0.025, 1, 0,offsetof(tnsMaterial, Color), 0,0,4, 0,0,0,0,tnsset_MaterialColor,0,0,0);
|
|
|
|
+ laAddFloatProperty(p, "color2", "Color 2", "Gradient end color of the material", LA_WIDGET_FLOAT_COLOR, "R,G,B,A", 0,1,0,0.025, 1, 0,offsetof(tnsMaterial, Color2), 0,0,4, 0,0,0,0,tnsset_MaterialColor2,0,0,0);
|
|
ep = laAddEnumProperty(p, "colorful", "Colorful", "Use colorful display", 0,0,0,0,0,offsetof(tnsMaterial, Colorful), 0,0,0,0,0,0,0,0,0,0);{
|
|
ep = laAddEnumProperty(p, "colorful", "Colorful", "Use colorful display", 0,0,0,0,0,offsetof(tnsMaterial, Colorful), 0,0,0,0,0,0,0,0,0,0);{
|
|
laAddEnumItemAs(ep, "NONE", "None", "Display materials normally",0,0);
|
|
laAddEnumItemAs(ep, "NONE", "None", "Display materials normally",0,0);
|
|
laAddEnumItemAs(ep, "COLORFUL", "Colorful", "Display material with colorful halftone",1,0);
|
|
laAddEnumItemAs(ep, "COLORFUL", "Colorful", "Display material with colorful halftone",1,0);
|
|
@@ -1140,6 +1161,15 @@ void la_RegisterTNSProps(){
|
|
laAddEnumItemAs(ep, "NONE", "None", "Use as normal material",0,0);
|
|
laAddEnumItemAs(ep, "NONE", "None", "Use as normal material",0,0);
|
|
laAddEnumItemAs(ep, "LIBRARY", "LIBRARY", "As commom library",1,0);
|
|
laAddEnumItemAs(ep, "LIBRARY", "LIBRARY", "As commom library",1,0);
|
|
}
|
|
}
|
|
|
|
+ ep=laAddEnumProperty(p,"gradient_mode","Gradient Mode","2D Gradient mode of shapes",0,0,0,0,0,offsetof(tnsMaterial,GradientMode),0,tnsset_MaterialGradientMode,0,0,0,0,0,0,0,0);
|
|
|
|
+ laAddEnumItemAs(ep,"NONE","None","Don't do any gradient",0,0);
|
|
|
|
+ laAddEnumItemAs(ep,"LINEAR","Linear","Do linear gradient",TNS_GRADIENT_MODE_LINEAR,0);
|
|
|
|
+ laAddEnumItemAs(ep,"BOX","Box","Do box gradient",TNS_GRADIENT_MODE_BOX,0);
|
|
|
|
+ laAddEnumItemAs(ep,"RADIAL","Radial","Do radial gradient",TNS_GRADIENT_MODE_RADIAL,0);
|
|
|
|
+ laAddFloatProperty(p,"gradient_center","Gradient Center","Starting point of the gradient",0,0,0,0,0,0,0,0,offsetof(tnsMaterial,GradientCenter),0,0,2,0,0,0,0,tnsset_MaterialGradientCenter,0,0,0);
|
|
|
|
+ laAddFloatProperty(p,"gradient_size","Gradient Size","Size of the gradient",0,0,0,0,0,0,0,0,offsetof(tnsMaterial,GradientSize),0,0,2,0,0,0,0,tnsset_MaterialGradientSize,0,0,0);
|
|
|
|
+ laAddFloatProperty(p,"gradient_box_r","Corner","Corner radius of the box gradient",0,0,0,0,0,0,0,0,offsetof(tnsMaterial,GradientBoxR),0,tnsset_MaterialGradientR,0,0,0,0,0,0,0,0,0);
|
|
|
|
+ laAddFloatProperty(p,"gradient_box_f","Feather","Feather distance of the box gradient",0,0,0,0,0,0,0,0,offsetof(tnsMaterial,GradientBoxF),0,tnsset_MaterialGradientF,0,0,0,0,0,0,0,0,0);
|
|
laAddSubGroup(p, "shader_page", "Shader Page", "Shader page of this material","la_rack_page",0,0,0,offsetof(tnsMaterial,Page),0,0,0,0,0,0,0,LA_UDF_SINGLE|LA_HIDE_IN_SAVE);
|
|
laAddSubGroup(p, "shader_page", "Shader Page", "Shader page of this material","la_rack_page",0,0,0,offsetof(tnsMaterial,Page),0,0,0,0,0,0,0,LA_UDF_SINGLE|LA_HIDE_IN_SAVE);
|
|
laAddOperatorProperty(p,"refresh","Refresh","Refresh material shader","M_refresh_material_shader",L'🗘',0);
|
|
laAddOperatorProperty(p,"refresh","Refresh","Refresh material shader","M_refresh_material_shader",L'🗘',0);
|
|
laAddOperatorProperty(p,"remove","Remove","Remove this material","M_remove_material",L'🗴',0);
|
|
laAddOperatorProperty(p,"remove","Remove","Remove this material","M_remove_material",L'🗴',0);
|