Sign in to follow this  
GKalman

Mixing Vertex-based & Mesh-based Objects Rendering

Recommended Posts

I have 2 simple applications (only for testing a concept). NB: I use VB 6.0 (I know it's not the most efficient language) App #1: Creates and renders lines along the x-y-z axes (statically) App #2: Creates a SPHERE [via: g_d3dx.CreateSphere(...) as a D3DXMesh object] and applies a translation matrix, say, along the y-axis in an oscillating (sinusoidal) fashion. BOTH appliactions work correctly as SEPARATE applications. However, when I try to combine them via '----- Public sub renderAxes(...) ... end sub '---- Public sub renderSphere(...) ... end sub '------- Public sub Render() ... renderAxes renderSphere setupProjection 'this includes the translation along the y axes!!!! ... end sub '===================== then my problem is that the translation now applies to BOTH the axes AND the sphere!!! Please note: the axes are rendered via the sub: xxx.DrawPrimitive(), while the sphere is renderd via the sub: yyy.DrawSubset(). Question: How do I separate the two renderings, so that the (vertex-based) axes remain stationary, while the (mesh-based) sphere moves along the y-axis? If both the sphere and the axes were vertex-based I could have used a vertex-list.

Share this post


Link to post
Share on other sites
Each object you render must have its own transformation matrix. Your code should look something like this.

Public sub renderAxes(...)
// Set transform for axes
// draw the axes
end sub

Public sub renderSphere(...)
// Set transform for sphere
// draw the sphere
end sub

Share this post


Link to post
Share on other sites
What neneboricua19 said is correct. One addition:

Internally there's almost no difference in how DrawPrimitives(xxx) and DrawSubset(xxx) work - DrawSubset() will also call DrawPrimitives() internally (and additionally set some other render states, vertex declarations etc).
So the problem is not HOW you draw the objects and what type they have, but that their transformation matrices are not set independently of each other.

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