Render mechanism for collisionobject

I want to know render mechanism for collisionobject. After my experiment, the collisionobject rendered has nothing with camera , when I use ortho camera, bounds of collisionobject in model is incorrect.

I’m not sure I understand the problem, have you enabled debug rendering of physics to see where the collisions objects are?

Thank you, I am trying. I saw the position of collision object is not same with the model.

Can you Explain this situation ? The card model was rendered by ortho camera.

Is the debug graphics rendered with the same camera? What does the render script look like?

1 Like

It is not the same camera, the cards was rendered by ortho camera, debug camera is perspective camera.

    render.set_view(vmath.matrix4_look_at(vmath.vector3(0, 200, 125), vmath.vector3(0, 200, 125) + vmath.vector3(0, -0.85, -0.525), vmath.vector3(0, 0.525, -0.85)))
    render.set_projection(vmath.matrix4_orthographic(-200 * rendercam.window.x / 1920, 200 * rendercam.window.x / 1920, -112.5 * rendercam.window.y / 1080, 112.5 * rendercam.window.y / 1080, 20, 1000))
    render.draw(self.hand_card_collision_pred)
    
    -- Render 3D space
    -- Face culling and depth test should be enabled
    render.set_view(rendercam.calculate_view())
    render.set_projection(rendercam.calculate_proj())
    render.enable_state(render.STATE_CULL_FACE)
    render.set_cull_face(render.FACE_BACK)
    render.enable_state(render.STATE_DEPTH_TEST)
    render.set_depth_mask(true)
    render.disable_state(render.STATE_BLEND)

    render.draw(self.model_pred, self.model_constants)
   
    render.set_depth_mask(false)
    --rendercam.activate_camera(hash("/hand_cards_camera/HandCardCamera"))
    render.set_view(vmath.matrix4_look_at(vmath.vector3(0, 200, 125), vmath.vector3(0, 200, 125) + vmath.vector3(0, -0.85, -0.525), vmath.vector3(0, 0.525, -0.85)))
    render.set_projection(vmath.matrix4_orthographic(-200, 200, -112.5, 112.5, 20, 1000))
    --render.set_view(rendercam.calculate_view())
    --render.set_projection(rendercam.calculate_proj())
    render.draw(self.hand_card_pred, self.hand_card_constants)
    render.set_depth_mask(true)

Well, if the cards and debug lines are rendered using different projections then it’s no surprise that they don’t match up. Move the debug draw to the same place where you render the cards.

I do not understand how the collision object rendered, It looks unaffected by the camera matrix. How can I coincide the cards and the collision object, especially when the window size changes. My cards was rendered by orthogonal camera.

Where are you doing the debug drawing in your render script? I don’t see it in this sample. You need to call render.draw_debug3d(), after you draw your models, and before you change the view and projection matrices.

2 Likes