0 votes

I'm trying to get Quad in imported scene, but my Plane in Blender imports to Godot as mesh. How can I change it? Is it even possible? Thanks!

P.S. i'm trying to add dynamically created texture to plane from scene, it's possible with quad object but i'm unable to do same with mesh. If you know how to bind texture to plane mesh, it would be useful too.

That how I bind the texture:

get_node("Quad").get_material_override().set_texture(FixedMaterial.PARAM_DIFFUSE, tex)
in Engine by (12 points)
edited by

1 Answer

0 votes

Completely untested code, but if I read the documentation correct this should work;

var material=FixedMaterial.new()
material.set_texture(FixedMaterial.PARAM_DIFFUSE, tex)

get_node("Mesh").surface_set_material(0,material)

Rellevant documentation;
http://docs.godotengine.org/en/stable/classes/class_mesh.html?highlight=mesh#class-mesh-surface-set-material
http://docs.godotengine.org/en/stable/classes/class_fixedmaterial.html#class-fixedmaterial-set-texture

the surface number should be 0 because you only have a quad in your mesh, if that fails
print get_surface_count() from the mesh and work your way through them ;)

by (366 points)
edited by

A little fix for your code, It should be

get_node("Mesh").get_mesh().surface_set_material(0,material)

And anyway that doesn't work. Also i'm still waiting answer for main question. Maybe I should use some specific object or flag like here

Ah sorry forgot about the first bit.

I'm fairly sure that godot will always import as a mesh regardless of the number of vertices.

Now you could use the blend4web exporter which exports to json and then import and parse that into a quad your self -but at that point it would be easier to just create it by hand.

One thing you should note tho is that sine the node "Mesh" is apparently a mesh instance;

The documentation for the get_mesh() function says;

Mesh get_mesh ( ) const

I'm still new to gdscript but I take that to mean it's not a reference, so you would need to call set_mesh() with the copy you received for it to take effect

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.