Jump to content

  • Log In with Google      Sign In   
  • Create Account


Volumetric texture arrows axes


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
13 replies to this topic

#1 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 11 February 2013 - 06:25 AM

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:axes.png

Edited by Yura, 11 February 2013 - 06:39 AM.


Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 4700

Like
1Likes
Like

Posted 11 February 2013 - 06:43 AM

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??



#3 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 11 February 2013 - 07:07 AM

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



#4 Jason Z   Crossbones+   -  Reputation: 4700

Like
2Likes
Like

Posted 11 February 2013 - 07:35 AM

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.



#5 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 11 February 2013 - 07:57 AM

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


Edited by Yura, 11 February 2013 - 08:33 AM.


#6 Jason Z   Crossbones+   -  Reputation: 4700

Like
2Likes
Like

Posted 11 February 2013 - 01:39 PM

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.



#7 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 12 February 2013 - 05:03 AM

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();


#8 NewDisplayName   Members   -  Reputation: 351

Like
1Likes
Like

Posted 12 February 2013 - 10:05 AM

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.



#9 Jason Z   Crossbones+   -  Reputation: 4700

Like
1Likes
Like

Posted 12 February 2013 - 10:05 AM

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!



#10 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 13 February 2013 - 02:07 AM

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



#11 Jason Z   Crossbones+   -  Reputation: 4700

Like
1Likes
Like

Posted 13 February 2013 - 12:56 PM

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?

This is normally done by defining a point in object space of your axes model that you want the text to be located at.  Then you can use your transformation and projection matrices to find that location in screen space.  Once you have the location in screen space, then you can use your normal text rendering system to put the text in the appropriate place.  If you haven't done any manual projection of vertices before, you can check out a 'picking' tutorial for the details, as it uses much the same technique.

 

I hope that helps!



#12 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 15 February 2013 - 03:55 AM

Yes, you were right.

It helped!

Thanks for help

happy.png



#13 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 15 February 2013 - 06:49 AM

On more question:

How to make those arrows always in front? When model is moving on it, the arrows are hiden behind the model. Playing with Z-coordinate gives nothing, only changing world position.. Maybe you have some ideas?



#14 Jason Z   Crossbones+   -  Reputation: 4700

Like
1Likes
Like

Posted 15 February 2013 - 05:28 PM

You could render the model first, followed by the axes.  When you render the axes, simply disable depth writes and depth test for that draw call.  This will ensure that the axes are drawn over the model regardless of the shape of the model.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS