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

missing face in Magnum::Primitives::cylinderSolid with texture coords #386

Closed
affa0 opened this issue Nov 5, 2019 · 2 comments

Comments

@affa0
Copy link

@affa0 affa0 commented Nov 5, 2019

if CylinderFlag::GenerateTextureCoords and CylinderFlag::CapEnds is used with cylinderSolid a face is missing.

Can be reproduced with this adapted python example:
removing the primitives.CylinderFlags.GENERATE_TEXTURE_COORDS flag fixes it

from magnum import *
from magnum import gl, meshtools, primitives, shaders
from magnum.platform.sdl2 import Application

class PrimitivesExample(Application):
    def __init__(self):
        configuration = self.Configuration()
        configuration.title = "Magnum Python Primitives Example"
        Application.__init__(self, configuration)

        gl.Renderer.enable(gl.Renderer.Feature.DEPTH_TEST)
        gl.Renderer.enable(gl.Renderer.Feature.FACE_CULLING)

        #with this one face is missing
        self._mesh = meshtools.compile(primitives.cylinder_solid(1,16,0.5, primitives.CylinderFlags.CAP_ENDS | primitives.CylinderFlags.GENERATE_TEXTURE_COORDS))
        #without GENERATE_TEXTURE_COORDS it seems to work
        #self._mesh = meshtools.compile(primitives.cylinder_solid(1,16,0.5, primitives.CylinderFlags.CAP_ENDS))

        self._shader = shaders.Phong()

        self._transformation = (
            Matrix4.rotation_x(Deg(30.0))@
            Matrix4.rotation_y(Deg(40.0)))
        self._projection = (
            Matrix4.perspective_projection(
                fov=Deg(35.0), aspect_ratio=1.33333, near=0.01, far=100.0)@
            Matrix4.translation(Vector3.z_axis(-10.0)))
        self._color = Color3.from_hsv(Deg(35.0), 1.0, 1.0)
        self._previous_mouse_position = Vector2i()

    def draw_event(self):
        gl.default_framebuffer.clear(gl.FramebufferClear.COLOR|
                                     gl.FramebufferClear.DEPTH)

        self._shader.light_positions = [(7.0, 5.0, 2.5)]
        self._shader.light_colors = [Color3(1.0)]
        self._shader.diffuse_color = self._color
        self._shader.ambient_color = Color3.from_hsv(self._color.hue(), 1.0, 0.3)
        self._shader.transformation_matrix = self._transformation
        self._shader.normal_matrix = self._transformation.rotation_scaling()
        self._shader.projection_matrix = self._projection

        self._mesh.draw(self._shader)
        self.swap_buffers()

    def mouse_release_event(self, event: Application.MouseEvent):
        self._color = Color3.from_hsv(self._color.hue() + Deg(50.0), 1.0, 1.0)
        self.redraw()

    def mouse_move_event(self, event: Application.MouseMoveEvent):
        if event.buttons & self.MouseMoveEvent.Buttons.LEFT:
            delta = 1.0*(
                Vector2(event.position - self._previous_mouse_position)/
                Vector2(self.window_size))
            self._transformation = (
                Matrix4.rotation_x(Rad(delta.y))@
                self._transformation@
                Matrix4.rotation_y(Rad(delta.x)))
            self.redraw()

        self._previous_mouse_position = event.position

exit(PrimitivesExample().exec())```
@mosra mosra added this to the 2019.1c milestone Nov 5, 2019
@mosra mosra added this to TODO in Debugging and prototyping via automation Nov 5, 2019
@mosra mosra self-assigned this Nov 5, 2019
@mosra

This comment has been minimized.

Copy link
Owner

@mosra mosra commented Nov 5, 2019

Oh ... not again 😆 (see #220, #197, ...). I wonder how is it possible that this keeps happening, sorry about that. Will fix that right away.

Btw., thanks for the quick python repro -- I like this way of reproducing issues! 👍

@mosra

This comment has been minimized.

Copy link
Owner

@mosra mosra commented Nov 5, 2019

Fixed in 96ea050, with more extensive test cases added in 8c902be.

Thanks for the report!

@mosra mosra closed this Nov 5, 2019
Debugging and prototyping automation moved this from TODO to Done Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
2 participants
You can’t perform that action at this time.