Coloring a 3D Surface
  Home FAQ Contact Sign in
microsoft.public.win32.programmer.directx.graphics only
 
Advanced search
POPULAR GROUPS

more...

microsoft ... graphics Profile…
 Up
Coloring a 3D Surface         


Author: TFM
Date: Aug 15, 2007 12:50

I have a 3D like the following:
http://tabishfayyaz.googlepages.com/blackGraph.JPG

How do I color them to give a picture like the following:
http://tabishfayyaz.googlepages.com/colorGraph.JPG

I create a mesh from a list of vertices. I heard coloring has
something to do with normals but haven't been able to get my head
working around that.
15 Comments
Re: Coloring a 3D Surface         


Author: Geoffrey Summerhayes
Date: Aug 15, 2007 13:58

On Aug 15, 3:50 pm, TFM gmail.com> wrote:
> I have a 3D like the following:http://tabishfayyaz.googlepages.com/blackGraph.JPG
>
> How do I color them to give a picture like the following:http://tabishfayyaz.googlepages.com/colorGraph.JPG
>
> I create a mesh from a list of vertices. I heard coloring has
> something to do with normals but haven't been able to get my head
> working around that.

Forget about normals for now. One of the easier ways to
do this is to declare your vertex with colour information.
Assuming Y is up, just set each vertex's colour based on
its x-z position.

Look in the sdk samples at "Tutorial 2: Vertices" (or
'Rendering Vertices' depending on which version of the
sdk you have and where you are looking). It shows how
a triangle with colour information is rendered.

---
Geoff
no comments
Re: Coloring a 3D Surface         


Author: TFM
Date: Aug 16, 2007 06:38

On Aug 15, 4:58 pm, Geoffrey Summerhayes gmail.com> wrote:
> On Aug 15, 3:50 pm, TFM gmail.com> wrote:
>
>
>> How do I color them to give a picture like the following:http://tabishfayyaz.googlepages.com/colorGraph.JPG
>
>> I create a mesh from a list of vertices. I heard coloring has
>> something to do with normals but haven't been able to get my head
>> working around that.
>
> Forget about normals for now. One of the easier ways to
> do this is to declare your vertex with colour information.
> Assuming Y is up, just set each vertex's colour based on
> its x-z position.
>
> Look in the sdk samples at "Tutorial 2: Vertices" (or
> 'Rendering Vertices' depending on which version of the
> sdk you have and where you are looking). It shows how
> a triangle with colour information is rendered. ...
Show full article (2.01Kb)
no comments
Re: Coloring a 3D Surface         


Author: Geoffrey Summerhayes
Date: Aug 16, 2007 09:25

On Aug 16, 9:38 am, TFM gmail.com> wrote:
>
> Yes I know how to set color of each vertex but I can't figure out how
> to give this color interpolation over a 3D surface
>
> I've tried the following with different results:
>
> http://tabishfayyaz.googlepages.com/strictlyColoredGraph.JPG
>
> The code which is used is this:
>
> if(x<0 && y<0)
> vertexPosColor = new CustomVertex.PositionColored(x, y, (float)z,
> Color.Blue.ToArgb() * Color.Magenta.ToArgb());
> else if(x<0 && y>0)
> vertexPosColor = new CustomVertex.PositionColored(x, y, (float)z,
> Color.Blue.ToArgb() * Color.Pink.ToArgb());
> else if(x>0 && y<0)
> vertexPosColor = new CustomVertex.PositionColored(x, y, (float)z,
> Color.Green.ToArgb() * Color.Yellow.ToArgb()); ...
Show full article (2.10Kb)
no comments
Re: Coloring a 3D Surface         


Author: TFM
Date: Aug 16, 2007 12:33

On Aug 16, 12:25 pm, Geoffrey Summerhayes gmail.com> wrote:
> On Aug 16, 9:38 am, TFM gmail.com> wrote:
>
>
>
>
>
>> Yes I know how to set color of each vertex but I can't figure out how
>> to give this color interpolation over a 3D surface
>
>> I've tried the following with different results:
>
>
>> The code which is used is this:
>
>> if(x<0 && y<0)
>> vertexPosColor = new CustomVertex.PositionColored(x, y, (float)z,
>> Color.Blue.ToArgb() * Color.Magenta.ToArgb());
>> else if(x<0 && y>0) ...
Show full article (2.48Kb)
no comments
Re: Coloring a 3D Surface         


Author: Geoffrey Summerhayes
Date: Aug 16, 2007 12:44

On Aug 16, 3:33 pm, TFM gmail.com> wrote:
> On Aug 16, 12:25 pm, Geoffrey Summerhayes gmail.com> wrote:
>
>
>
>
>
>> On Aug 16, 9:38 am, TFM gmail.com> wrote:
>
>>> Yes I know how to set color of each vertex but I can't figure out how
>>> to give this color interpolation over a 3D surface
>
>>> I've tried the following with different results:
>
>
>>> The code which is used is this:
>
>>> if(x<0 && y<0)
>>> vertexPosColor = new CustomVertex.PositionColored(x, y, (float)z, ...
Show full article (4.61Kb)
no comments
Re: Coloring a 3D Surface         


Author: TFM
Date: Aug 16, 2007 16:15

On Aug 16, 3:44 pm, Geoffrey Summerhayes gmail.com> wrote:
> On Aug 16, 3:33 pm, TFM gmail.com> wrote:
>
>
>
>> On Aug 16, 12:25 pm, Geoffrey Summerhayes gmail.com> wrote:
>
>>> On Aug 16, 9:38 am, TFM gmail.com> wrote:
>
>>>> Yes I know how to set color of each vertex but I can't figure out how
>>>> to give this color interpolation over a 3D surface
>
>>>> I've tried the following with different results:
>
>
>>>> The code which is used is this:
>
>>>> if(x<0 && y<0)
>>>> vertexPosColor = new CustomVertex.PositionColored(x, y, (float)z, ...
Show full article (5.06Kb)
no comments
Re: Coloring a 3D Surface         


Author: Geoffrey Summerhayes
Date: Aug 16, 2007 20:51

On Aug 16, 7:15 pm, TFM gmail.com> wrote:
>
> No I mean to say 4 corners of what ? I don't have square, I have a
> traingle, each square has 2 triangle.

Each what, what was that? Did I hear each SQUARE?

http://tabishfayyaz.googlepages.com/strictlyColoredGraph.JPG

Look, 4 corners.

http://tabishfayyaz.googlepages.com/colorGraph.JPG

I'm guessing about 25x25 or 625 vertices.
With the corners coloured yellow, blue, green, and magenta.
> I'm using Managed DirectX, I don't understand your code. What is
> C1,C2....... ?

In this case they'd be yellow, blue,...

Untested...
Show full article (1.10Kb)
no comments
Re: Coloring a 3D Surface         


Author: TFM
Date: Aug 17, 2007 09:08

On Aug 16, 11:51 pm, Geoffrey Summerhayes gmail.com> wrote:
> On Aug 16, 7:15 pm, TFM gmail.com> wrote:
>
>
>
>> No I mean to say 4 corners of what ? I don't have square, I have a
>> traingle, each square has 2 triangle.
>
> Each what, what was that? Did I hear each SQUARE?
>
> http://tabishfayyaz.googlepages.com/strictlyColoredGraph.JPG
>
> Look, 4 corners.
>
> http://tabishfayyaz.googlepages.com/colorGraph.JPG
>
> I'm guessing about 25x25 or 625 vertices.
> With the corners coloured yellow, blue, green, and magenta.
>
>> I'm using Managed DirectX, I don't understand your code. What is ...
Show full article (2.22Kb)
no comments
Re: Coloring a 3D Surface         


Author: Geoffrey Summerhayes
Date: Aug 17, 2007 10:33

On Aug 17, 12:08 pm, TFM gmail.com> wrote:
>
> oh you were talking about the 1 big square I thought you were talking
> about the little squares the whole graph is made up of :)
> Yes its 25x25.
>
> There seems to be a little problem with the casting stuff. I've
> changed r,g,b to float. Here is my code:
>
> float r, g, b;
> float a = (float)(4.0 * (1.0 - realX / 24.0) * (1.0 - realY / 24.0));
> float bb = (float)(4.0 * (realX / 24.0) * (1.0 - realY / 24.0));
> float c = (float)(4.0 * (1.0 - x / 24.0) * (y / 24.0));
> float d = (float)(4.0 * (realX / 24.0) * (realY / 24.0));
> r = (c1.R * a + c2.R * bb + c3.R * c + c4.R * d) / 4.0f;
> g = (c1.G * a + c2.G * bb + c3.G * c + c4.G * d) / 4.0f;
> b = (c1.B * a + c2.B * bb + c3.B * c + c4.B * d) / 4.0f;
>
> Color vColor = r*65536+g*256+b;
> vertexPosColor = new CustomVertex.PositionColored(realX,realY ,realZ, ...
Show full article (1.25Kb)
no comments

RELATED THREADS
SubjectArticles qty Group
FS: Avon BEYOND COLOR Line Softening Mousse Foundation Color Toffee - Item #: 235512 via auctionalt.forsale ·
1 2