Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I decide which diagonal to use ? #97

Open
paganaye opened this issue Sep 18, 2021 · 4 comments
Open

How can I decide which diagonal to use ? #97

paganaye opened this issue Sep 18, 2021 · 4 comments

Comments

@paganaye
Copy link

With pixi-projection we use square sprite, then inside the application transform it into two triangles.
In my game half the time it looks all right and half the time it looks bad.
How can I fix that.
image

@paganaye
Copy link
Author

I fixed it (badly) using this code.
The question becomes: Is there a better way?

        const rightDiagonal = Math.abs(this.elevations.topRight - this.elevations.bottomLeft)
            <= Math.abs(this.elevations.topLeft - this.elevations.bottomRight);
        if (!rightDiagonal) {
            let tempX = vertexData2d[0];
            let tempY = vertexData2d[1];
            let tempZ = vertexData2d[2];
            vertexData2d[0] = vertexData2d[3];
            vertexData2d[1] = vertexData2d[4];
            vertexData2d[2] = vertexData2d[5];
            vertexData2d[3] = vertexData2d[6];
            vertexData2d[4] = vertexData2d[7];
            vertexData2d[5] = vertexData2d[8];
            vertexData2d[6] = vertexData2d[9];
            vertexData2d[7] = vertexData2d[10];
            vertexData2d[8] = vertexData2d[11];
            vertexData2d[9] = tempX;
            vertexData2d[10] = tempY;
            vertexData2d[11] = tempZ;
            this.rotation = - Math.PI / 2;
        } else {
            this.rotation = 0;
        }

@ivanpopelyshev
Copy link
Collaborator

The question is a bit wrong, we have to make actual quads, not triangles :) The whole point of Sprite2d is how to make weights ([2], [5], [8], [11]) so it actually becomes a projective quad and not two triangles.

@paganaye
Copy link
Author

You're telling me I am a sprite abuser.
Well you might be right, but I do with what I have.
Perhaps I need a triangle primitive.
This would allow me to have a different tint for each triangle.
image

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Sep 19, 2021

hm, interesting. Yeah, we might need mesh like this. Seriously, that's a mesh problem, mesh with 3 coords per vertex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants