Mixing Vertex-based & Mesh-based Objects Rendering

Started by
2 comments, last by GKalman 16 years, 3 months ago
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.
Advertisement
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
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.
Thanks for the help from both of you.
Problem RESOLVED

This topic is closed to new replies.

Advertisement