Volumetric texture arrows axes

Started by
12 comments, last by Jason Z 11 years, 2 months ago
Hi,
I'm trying to render XYZ axes arrows using textures and Sprite.Draw(...) method.
I'm using Matrix.RotationYawPitchRoll(...) for rotation the rendered object around the axes and I want my axes arrows to rotate around it's own origin point in the same direction as the object.
So, my question is, how to make volume XYZ axes arrows texture for further its rotation ?
Something like this:[attachment=13581:axes.png]
Advertisement

I am afraid I don't understand your question - can you give a little more detail about what you are trying to do? You want to add a texture onto your axes, or something else? Or do you mean you are trying to use a texture to apply the words 'x-axis', 'y-axis', and 'z-axis' to your rendering??

I am afraid I don't understand your question - can you give a little more detail about what you are trying to do? You want to add a texture onto your axes, or something else? Or do you mean you are trying to use a texture to apply the words 'x-axis', 'y-axis', and 'z-axis' to your rendering??

I want to visualize the current XYZ orientation by rendering the coordinate axes as three arrows. The arrows should rotate as I rotate the model. I want to render the arrows in a fixed size in the bottom left corner like cylinder geometries, not just lines. I think using a 3d texture with cylinder arrows will be nice solution, but, I may be wrong.

Thanks

Ahh ok - now I understand. In that case, you want to create a 3d model just like you would any other model, but with the axes pointing in their respective directions in object space. Then, whatever transformation you apply to your model when you render it, you would just do the same for the axes model.

Using a 3D texture is possible, but it would be horribly inefficient because 3D textures use tons of memory. In this case, it is better to just go with a regular polygonal mesh.

Ahh ok - now I understand. In that case, you want to create a 3d model just like you would any other model, but with the axes pointing in their respective directions in object space. Then, whatever transformation you apply to your model when you render it, you would just do the same for the axes model.

Using a 3D texture is possible, but it would be horribly inefficient because 3D textures use tons of memory. In this case, it is better to just go with a regular polygonal mesh.

If you say so... But it must have a static position (left bottom corner) and do not change it while i change lookAtVector etc. Also, it must rotate around it's own origin point, not around of the model. To achive this, I use sprites for drawing static elements (I have few of those) and vertices (VertexBuffer) to draw model.

Maybe you have some code samples of this, couse I don't know how to build cylinders like a polygonal mesh? Will be very appreciate

Ahh ok - now I understand. In that case, you want to create a 3d model just like you would any other model, but with the axes pointing in their respective directions in object space. Then, whatever transformation you apply to your model when you render it, you would just do the same for the axes model.

Using a 3D texture is possible, but it would be horribly inefficient because 3D textures use tons of memory. In this case, it is better to just go with a regular polygonal mesh.

If you say so... But it must have a static position (left bottom corner) and do not change it while i change lookAtVector etc. Also, it must rotate around it's own origin point, not around of the model. To achive this, I use sprites for drawing static elements (I have few of those) and vertices (VertexBuffer) to draw model.

Maybe you have some code samples of this, couse I don't know how to build cylinders like a polygonal mesh? Will be very appreciate

Ok - I didn't realize that you wanted it to stay in one location on the screen. In that case, you should apply the rotation from your model to the axes, and use a fixed translation component for putting it into the location you want it. Keep in mind that the position should be relative to the view position if you want it to follow the camera around as it moves. Or you could set the view matrix to be the identity when you go to render the axes, allowing you to choose a fixed translation and leave it there.

For examples about building cylinders and cones, you can find lots of resources around the net. I have some of these operations implemented in my engine, Hieroglyph3, which you can download and use under the MIT license.

And is it possible to use sprites for it?

The point is that I'm already using sprites and it will be better for me to keep working with them. I can apply world changes to sprite and set origin point of it, so problem with position and rotation are solved. But, I don't know is it possible to draw something else exept 2D texture rectangle or text with help of sprite. If there are some other primitives, which can be drawn with sprites?

Here is part of code with sprite:


sprite.Begin(SpriteFlags.AlphaBlend);

//other static sprite figures (which mustn't move)

sprite.Transform = rotation;
sprite.Draw(texture1, new ColorBGRA(0.0f, 0.9f, 1.0f, 1.0f), 
new Rectangle(0, 0, 50, 50), new Vector3(25,25,0), new Vector3(0, 0, 0));
sprite.Transform = Matrix.Identity;

sprite.End();

In addition to what Jason mentioned in his posts, you should not try to achieve any kind of 3D modelling using sprites, unless you want to make things really hard and inefficient for yourself. Some challenges are worth not taking. wink.png

FYI, it's generally the other way round i.e. sprites are created out of 3D models.

For your particular requirement, it's better you go with polygonal mesh.

I'm not really familiar with the sprite functionality that you are using, but if you can apply 3d transforms to the sprite's rectangle vertices then you could do a rough approximation using a billboard style rendering. This would work ok for times when you aren't viewing the axis head on, but it would disappear when you are viewing it head on...

However, if you already have 3D models in your scene, then this should be quite similar. You can either programmatically draw the geometry with cylinders and cones, or you can use your modelling package to create the geometry and just import it like any other mesh. This is really the better way to approach the problem - I don't think you will be happy with the results when using sprites for this functionality!

So, sprites are bad idea... Get it)

I understand what you are telling me and I even have an idea how to make it with primitives, BUT, here is another problem: how to mark axes with text (x axis, yaxis... like in picture above). Those lines will be moving all the time, how to make axis marks (text) to move with their axis arrows?

Didn't thought that usual axial arrows will deal so much problems to me smile.png But I have concrete task and I must solve it.

Thanks all for helping

This topic is closed to new replies.

Advertisement