Results 1 to 10 of 10

Thread: how to get the color of a point in a vertex DX8.1

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2003
    Posts
    601

    how to get the color of a point in a vertex DX8.1

    how can you get the color of a point within a vertex with transparent texture.


    Say the following image is a black rock with pink has transprancy. and I want to get the color of a point in the vertex to find out if the color is black or pink. with pink being transparent i cant use getpixel cause it will only show whats displayed so how could i get the color pink or black instead?

  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: how to get the color of a point in a vertex DX8.1

    Vertex? Lets say you have a triangle that is blue in one end, and red in one, and yellow in the third. Do you want the color in the edges of that triangle?


    What are you going to use it for, maybe there is a better way.


    PS: What confuses me is that you say you want the color of a point within a vertex. And that is more like saying: "Getting the coloro of a point in a point". Becasuse a vertex is a point, with aditional info like texture coordinates.

    ØØ

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2003
    Posts
    601

    Re: how to get the color of a point in a vertex DX8.1

    ok. say I render this picture with pink being transparent.




    How can I determine what color the mouse is over. I want to be able to tell if im over the tree or not. with the pink being transparent, I'll get the color under the transparency, so is there a way to tell if im over the invisible pink or over the tree.

    hope that clears things up.

  4. #4
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: how to get the color of a point in a vertex DX8.1

    So you are talking about a surface or a texture or something? And not a vertex? How do you render it BTW?



    ØØ

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2003
    Posts
    601

    Re: how to get the color of a point in a vertex DX8.1

    the texture.

    D3DDevice.SetTexture 0, Textures(TheTextures1(TheCounter)) D3DDevice.DrawPrimitiveUP D3DPT_TRIANGLESTRIP, 2, TilesLayer1((TheCounter * 4)), Len(TilesLayer1(TheCounter))

  6. #6
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: how to get the color of a point in a vertex DX8.1

    Well I guess you have to lock the whole surface using IDirect3DSurface8::LockRect(...).

    Then find the position you want to check (easiest if you are in screen coordinates, but since this sounds like a 2D game, I guess you are)

    Position = y * pitch + x * BytesPerPixel

    THen read from that pixel (pBits parameter) in the loced rect.

    Remeber to unlock the surface again.


    ØØ

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2003
    Posts
    601

    Re: how to get the color of a point in a vertex DX8.1

    could you give me an exmaple.

    Ive tried

    Dim DirectSurface As D3DLOCKED_RECT

    then i tried

    Position = y * DirectSurface.pitch + x * DirectSurface.pbits

    i keep getting zero...

  8. #8
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: how to get the color of a point in a vertex DX8.1

    Did you lock the surface before you tried to get the info on the pixel. Sorry but I have NO idea on how the syntax looks in VB. But if it helps. Here is a sample on how to read to pixels in C++.


    Code:
    IDirect3DTexture8 *Texture=NULL;
    D3DLOCKED_RECT LR;
    Graphics.D3DDevice->CreateTexture(128,128,0,D3DUSAGE_RENDERTARGET,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,&Texture);	
    Texture->LockRect(0,&LR,NULL,D3DLOCK_NOSYSLOCK );
    	for (int y=0;y<128;y++)	{
    		for (int x=0;x<128;x++)		{
    			((unsigned long*)LR.pBits)[x + ((y*LR.Pitch)>>2)]=D3DCOLOR_RGBA(255,0,0,255);
    		}
    	}

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2003
    Posts
    601

    Re: how to get the color of a point in a vertex DX8.1

    I cant figure it out. This sucks.

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2003
    Posts
    601

    Re: how to get the color of a point in a vertex DX8.1

    noteme, think you could make an example with that image I showed. It would be very helpfull in many ways.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width