Sign in to follow this  
Keisni

Position 3D mesh in 2D tile based map, need help!

Recommended Posts

I have matView2D and matProj2D to render the tile based map, and I have different matView3D and matProj3D to render mesh characters. For example, to place my character in (400, 300) screen coordinates, I need to translate this 2D offset to 3D offset and I thought matWorld2D * matView2D * matProj2D = matWorld3D * matView3D * matProj3D matOffset = matView2D * matProj2D * Inverse(matProj3D)* Inverse(matView3D) Now every time I have a 2D translation matTranslate2D matTranslate3D = matTranslate2D * matOffset Then I use matWorld3D = matScale3D * matRotate3D * matTranslate3D to move my character. But, this doesn`t work. ?????????????????????????????????

Share this post


Link to post
Share on other sites
Two things to try.

1. Use an orthographic projection, and draw your meshes and "terrain" (read: tiles) in the same model-space.

2. Draw your terrain, and render your meshes to an off-screen buffer. Project the origin of your mesh into 2D space to find the "origin" of the off-screen buffer, and then blit the off-screen image to the screen at the correct location.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this