Offseting sub-meshes - positioning submeshes

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Offseting sub-meshes - positioning submeshes

Post by robmar »

Anyone knows how to offset the position of sub-meshes?

I'd like to explode something by manipulating the position and rotation of the submeshes.
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: Offseting sub-meshes - positioning submeshes

Post by devsh »

You can't.... the reason is that you'd have to re-set the world transformation matrix for your shader/program or the thing that emulates it in fixed function pipeline.

In theory its possible but you'd need to do it before every draw call of a meshbuffer.
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Offseting sub-meshes - positioning submeshes

Post by robmar »

How about multiply the sub-mesh offset matrix by the original transform matrix, call SetTransform with that in the node's Render() proc, having passed the same offset matrix to the shader previously, and the following mesh or node render, reset the matrix... that should work, right? The GPU will simply recalc the vertices using the last matrix set. My shader code knows which sub-mesh is which, so that's covered...
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Offseting sub-meshes - positioning submeshes

Post by Mel »

What are you trying?
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Offseting sub-meshes - positioning submeshes

Post by robmar »

Just explode the model, it just requires a new transform for each submesh, the Irrlicht parent-child code does the same thing.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Offseting sub-meshes - positioning submeshes

Post by Mel »

How do you split the model? -separate it into submeshes- or is it already "exploded"? Perhaps you could create a particle system out of the model's triangles and move each triangle as a single particle randomly, or following any other method (if it doesn't have many triangles, namely 3000-5000 it may very well run completely on the CPU :)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
mant
Posts: 125
Joined: Sun Jan 27, 2013 3:38 pm

Re: Offseting sub-meshes - positioning submeshes

Post by mant »

Parent/child maybe the keyword for you to search for it.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Offseting sub-meshes - positioning submeshes

Post by Mel »

Skinning also does something similar. Each bone is in essence, a transformation matrix for a subset of the mesh, which holds parent/child relationships, so, you could use a sort of skinned mesh
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Post Reply