Skip to content

How to draw hex from basic shapes #1165

Answered by DJMcNab
Anav0 asked this question in Q&A
Discussion options

You must be logged in to vote

You would need to use one of the existing shapes as your base, then generate the hexagon mesh yourself. I'm going to assume that you want to draw a planar hexagon. https://github.com/Quantumplation/bevy-hex-example is an example of third party code, which generates a bevelled hexagon.

I have made a small function

fn hex_mesh() -> Mesh {
    // generate mesh
    // full code is in the details pane below.
}

to generate such a mesh. This can be used in a full project:

Code hidden for future readers
use std::f32::consts::PI;

use bevy::{
    prelude::*,
    render::{mesh::Indices, pipeline::PrimitiveTopology},
};

fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .add_…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tatref
Comment options

Answer selected by Anav0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants