Plane special coloring

Started by
6 comments, last by nedemon 18 years, 6 months ago
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.
Advertisement
Couldn't you simply apply a texture to your plane ?
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Sorry, gentleman, i should've told ths earlier - no textures!
native cpp, dx9. Component? Well, d3d or d3dx, i guess.
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.
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?
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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

This topic is closed to new replies.

Advertisement