Need help with two steps rendering of character and background
I rendered a character 2.0 tall. She is starting from y:1 to y:-1. I did it that way to be able to get better precision to deal with petter panning/shadow acne(i think such is the best, correct me if i am wrong..) And now i want to render the room the character will walk through. My initial idea was to render first the room and then render the character on front. But now i am having trouble imagining the set-up. I imagine they render 5km wide open world scenes a similar way. I dont need 5km open world. I need my character to walk through a building.
I need you to point me in a good direction with the names of the techniques to search for them on Google or links to tutorials. Basically i am not sure how to sincronize the perspective for the room and the character. I am codding it all in js and webgl. So i need a more programming oriented tutorials. Using a library is not an option.
I do not understand what you are asking about. What problem behavior is your program showing?
If you render the character and the room using the same view and projection matrices then the character should appear in the room naturally.
There are ten kinds of people in this world: those who understand binary and those who don't.
Why do you need to fit an entire building inside the rendering box? Surely parts of it could be visible at different points in time?
I think what you are looking for is the correct World View Projection transformation.
You can find a detailed example here http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/.
The general idea is that your objects are transformed into different coordinate spaces for the final rendering. Initially your meshes will be in object space with the coordinate system at the center of each object.
To this you apply the world matrix to get them into world space which has all the objects positioned relative to each other. In your example the parts of the building will have a different world matrix than the character. To move the character around you would only need to change its world matrix.
After the world matrix you apply the view transform. This is a coordinate system where the origin is the camera position and the forward vector is aligned with the cameras forward vector.
Finally you apply the projection matrix which does a perspective or orthographic projection into homogeneous coordinates where the scene from the camera is projected onto a cube with (-1,1). This is the -1 +1 range you are talking about.
one thing you need to do at the beginning of any project is determine the scale used. IE 1 unit in your 3D system = how many meters in the real world? then you just make everything to scale and it all works out automatically. people are the right size, houses are the right size, all meshes and models are the right size.
Norm Barrows
Rockland Software Productions
"Building PC games since 1989"
PLAY CAVEMAN NOW!
http://rocklandsoftware.net/beta.php