How to allow an object to have a mesh

Not favoritedFavorited Favorited 0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi all!

    I'm trying to make a drawing plugin using the addon SDK v1. I want to be able to modify the mesh of the instances of my object type at runtime. To do this, i created a mesh using wi.CreateMesh(2,2).

    When this method is called, i receive the error "object does not support mesh". Digging a bit into the worldinfo.js code i find this:

    CreateMesh(t, e) {
     if (t = Math.floor(t),
     e = Math.floor(e),
     !this.GetInstance().GetPlugin().SupportsMesh())
     throw new Error("object does not support mesh");
     this.ReleaseMesh(),
     this._meshInfo = {
     sourceMesh: C3.New(C3.Gfx.Mesh, t, e),
     transformedMesh: C3.New(C3.Gfx.Mesh, t, e),
     meshPoly: null
     }
     }
    

    So it seems that the plugin itself has a flag that tells Construct if its objects support mesh or not. However, i can't find anything in the docs related to this. Is it possible to allow a custom object type to use meshes?

    Doing the same thing using a behavior on a sprite works since the sprite object by defaults allows the usage of meshes, so I wonder how i can achieve the same thing, but without a behavior and on a custom drawing plugin.

  • Not all objects support meshes. You can pick an instance then {instancePicked}.plugin.supportsMesh.

    construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/object-interfaces/iplugin

    The documentation can be hard to navigate on what regards to addons, you will have to look into the scripting documentation to complement the addon docs.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Good to know, thank you. I guess that means that there isn't a way to manually allow a certain plugin to use meshes for now (e.g.: by specifiying some plugin _info) (?)

  • Correct. If the plugin doesn't support meshes, there's nothing you can do to force it. I'm not aware of any exposed api to create a mesh on a custom plugin. But you can explore inheritance... could work.

  • weird I would have assumed we can set it supports mesh via ipluginInfo, but it doesn't seem to be there

    https://www.construct.net/en/make-games/manuals/addon-sdk/reference/iplugininfo

    I hope this can be addded, maybe for sdk v2, but I also see how this can have many issue if you do complex custom drawing

  • Honestly I needed this to have control over the UVs of each point, since as far as I know the built-in mesh is the only way to specify the sampling coordinates of the texture.

    It would be nice to be able to specify UVs when rendering quads or convex polygons, but that doesn't seem to be supported.

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)