• Advertisement
Sign in to follow this  

Positioning a model always infront of a camera

This topic is 3347 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm wondering what's wrong with my code: I'm trying to fix a model to the front of a camera such that it's always visible no-matter what orientation or position the camera is at. The effect i'm trying to achieve is a 3D cockpit. I have created the inside of a cockpit using blender and imported it into my scene engine. The model is in local coordinates - centered at the origin. In a shader (which is where is fails to display), I simply transform the incoming cockpit vertex into clipspace using the camera's projection matrix. I do not apply any camera view matrix as this should be unnecessary - I'm sure this process is correct - yet do not see the model. I've tried to add a small displacement to the model to push it away from the origin a bit before applying the projection matrix - no luck. Anyone able to comment...

Share this post


Link to post
Share on other sites
Advertisement
If you position the cockpit correctly in Blender, you don't need to do anything.
Just set modelview to identity before rendering the cockpit.

Share this post


Link to post
Share on other sites
Thanks v-man, at least you have confirmed that I am doing everything right.
I've setup a prototype in render monkey also have the same issue as my rendering engine. Using the shader the following code should do the trick:

// incoming vertex + a small displacement to aid visuals/debug
float4 l_posWS = float4 (IN.Position.xyz + float3(0,0,-5), 1.0);
float4 l_posCS = mul (glstate.matrix.projection, l_posWS);

Since, I'm using a shader the fixed function camera's modelview matrix is ignored - so its strange that I don't get the expected results.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement