2
$\begingroup$

I try to attach a PyOpenGL Shader to an object using the setCustomMaterial() command but It raises an error: 'KX_BlenderMaterial' object has no attribute 'setCustomMaterial. So I need to retrieve the KX_PolygonMaterial component of my object instead of the KX_BlenderMaterial but the function for getting each one of those is the same

obj = bge.logic.GetCurrentController().owner    
mat = obj.meshes[0].materials

The corresponding api page describes the object KX_MeshProxy and its function materials saying: "list of KX_BlenderMaterial or KX_PolygonMaterial types"

How can convert the BlenderMaterial to PolygonMaterial ?

This code should return a PolyMaterial yet it still gives me a BlenderMaterial back; ALso I tryed checking "texture face" but it doesn't solve the problem

mesh = bge.logic.getCurrentController().owner.meshes[0]
poly = mesh.numPolygons
for p in range (poly):
    P = mesh.getPolygon(p)
    PolyMat = P.material
    PolyMat.setCustomMaterial(Material()) 
$\endgroup$
1
  • $\begingroup$ In the current version API the return is KX_BlenderMaterial, there is no more KX_PolygonMaterial. $\endgroup$ Oct 18 '17 at 14:19
1
$\begingroup$

Apparently KX_PolygonMaterial doesn't exist anymore.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.