|
-
Feb 15th, 2005, 07:11 PM
#1
Thread Starter
Fanatic Member
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?
-
Feb 15th, 2005, 09:58 PM
#2
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.
ØØ
-
Feb 15th, 2005, 10:23 PM
#3
Thread Starter
Fanatic Member
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.
-
Feb 15th, 2005, 10:35 PM
#4
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?
ØØ
-
Feb 15th, 2005, 11:06 PM
#5
Thread Starter
Fanatic Member
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))
-
Feb 15th, 2005, 11:58 PM
#6
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.
ØØ
-
Feb 16th, 2005, 12:06 AM
#7
Thread Starter
Fanatic Member
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...
-
Feb 16th, 2005, 12:21 AM
#8
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);
}
}
-
Feb 16th, 2005, 02:08 PM
#9
Thread Starter
Fanatic Member
Re: how to get the color of a point in a vertex DX8.1
I cant figure it out. This sucks.
-
Mar 20th, 2005, 06:02 AM
#10
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|