Plane special coloring

This topic is 4733 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Greetings to everyone. Now i got a problem to solve: Let's say i created a plane of some color. I want to draw a shooting target on that plane that would be colored like a rainbow, i.e. red in the middle, next ring is yellow and the most outside ring is violiet(or whatever:))). The only way to solve this problem seems to me pretty complicated: I get to draw a number of rings with a pretty complicated algorithm for each. Are there any other ways to solve this problem? Thanx.

Share on other sites
Couldn't you simply apply a texture to your plane ?

Share on other sites
Firstly, a couple of basic questions:

1. Which API are you using (DX7, DX8, DX9...) and which component (D3D?)
2. Which language/platform (Managed C#, Native C++ ?)

I think you might have realised a fundamental "problem" with using geometry for this sort of job - it just becomes too complex [smile]

The basic trick is to create a simple rectangle/square plane (the bounding area of your target for example) and then apply a texture to it that contains the more detailed colour representation of your target.

If you need more help with basic texturing, or if I've misinterpretted your question, post back with more details [smile]

hth
Jack

Share on other sites
Sorry, gentleman, i should've told ths earlier - no textures!
native cpp, dx9. Component? Well, d3d or d3dx, i guess.

Share on other sites
ouch !
Well ... without texture, the only way to if probably to create those rings with geometry ... maybe with HLSL, but that would be more complicated and I'm not sure of the result.

(do you mind telling us why you don't want to use textures ?)

For the algo to create the rings, it's really not that complicated :

int nbVertices = 0;for (float x = 0.0f; x < 3.14f; x += 0.017f)    for (float y = 0.0f; y < 3.14f; y += 0.017f)    {        vertices[nbVertices]._color      = 0xFFFF0000;        vertices[nbVertices++]._position = D3DXVECTOR3(cos(x) * outerRadius, sin(y) * outerRadius, 0.0f);        vertices[nbVertices]._color      = 0xFFFF0000;        vertices[nbVertices++]._position = D3DXVECTOR3(cos(x) * innerRadius, sin(y) * innerRadius, 0.0f);    }

That'll create a flat ring (triangle strips) on the xy plane. The 0.017f is 1 degre in radians (from memory, so it may be wrong ^^) so here, there will be 360 slices for 1 ring. You can increase or decrease the step to have a more or less detailed ring.

Share on other sites
I don't at all. It's just a task. Student's task. I must demonstrate my deep knowledge with this.:)))
Actually, i recently thought of another way: Is that possible to achieve this by placing a transparent light source directly above the plane? Maybe a couple of lights?

Share on other sites
As a homework-style assignment, I suppose you'll probably have to do it the hard way [grin]

Quote:
 Is that possible to achieve this by placing a transparent light source directly above the plane? Maybe a couple of lights?

You might well be able to get the effect you want by using a few light sources on a highly tesselated grid of geometry. I don't think it'd be much (if at all) easier than the obvious one of creating the patterns in geometry.

Can you use vertex shaders/HLSL? if so, you can probably generate the colour rings mathemagically using a shader that runs over a grid of vertices. For example, the shader computes the distance of the current vertex from the center of the grid and then picks the appropriate "ring" colour.

hth
Jack

Share on other sites
No shaders too.:)) Not too much of ways to do it then, i guess.
Thanx for help.

1. 1
2. 2
3. 3
Rutin
17
4. 4
5. 5
JoeJ
13

• 9
• 14
• 10
• 25
• 9
• Forum Statistics

• Total Topics
632645
• Total Posts
3007629
• Who's Online (See full list)

There are no registered users currently online

×