简体   繁体   中英

How to fix the invalid mesh construction?

There is a sample here: http://amegas.github.io/gera/custom.geometry

It shows the rotating swords, which are represented as the custom loaded geometry which is mapped with the UV-texture.

As I can see this sample uses only a part of the texture with ignoring other parts of image. I want to load other models using the the sample from github, but the last attempt was unsuccessful. The result is shown here:

在此处输入图片说明

I rather don't understand how to solve my problem. As I have learned the information about the library which is used in sample. I must prepare some vertex/texture coordinates for rendering the custom 3D model. Also I thought to try to use some other WebGL drawing mode ( TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN and etc.. ), because the library from sample provides an optional way to set the custom draw mode for each mesh:

var mesh = new Gera.Mesh({
    geometry: new Gera.Geometry({
        type: Gera.Geometry.Type.Custom,
        vertices: object3d.jsonModel.vertices,
        indices: object3d.jsonModel.indices,
        uvCoordinates: object3d.jsonModel.uvCoordinates
    }),
    material: new Gera.Material( object3d.texture ),
    drawMode: Gera.Renderer.DrawMode.TriangleStrip
});

But also no success. I'm thinking that I've prepared the model of cat not correctly. I've used obj2json mesh file converter from other github project. The result is shown above.

What should I do to solve my problem?

Seems to be that obj2json parser works bad. I've tried to convert several Wavefront models using that parser and I must say, that it doesn't make the correct triangulation for the complex models. If a 3d model is some kind of box or something similar, then obj2json triangulates correctly the export model. But if to use some models of cats, dragons and other stuff - there will be problems.

Also, I want to give a piece of advice to you, not to use custom drawing mode when you work with Gera library, because 3D models often use only two modes: triangles (1) and lines (2) in addition to wireframe mode. There are only a few situations when you should start to use custom drawing mode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM