|
I'm sorry but I still don't understand. You say you've got a triangle and you list the following numbers:
0,10,200,200
But what do these numbers mean? A triangle has three points and each point takes two numbers to describe - so that means we should have 6 numbers - you've only go 4. If they are side lengths we've got one too many.
I assume you want to distort the rendering to simulate perspective?
Steve
|
|
|
|
|
Oh man, i woke up on the wrong side today hehehehe
for each triangle word i refered above , replace it with a square
now do you see my point?
help?
thanks
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
I think so, although the list of numbers still stumps me: a square would require 8 numbers.
Anyway, I think when you said rotation, you meant around the x-axis or the y-axis and not around z. If this is what you want you can't do it using GDI. GDI is 2D: SetWorldTransform can only do translation, rotation, shearing, stretching and mirroring. Basically only affine transformations in 2D.
Steve
-- modified at 4:00 Sunday 23rd April, 2006
|
|
|
|
|
Stephen Hewitt wrote: If this is what you want you can do it using GDI.
How? code snippet?
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
I just modified my post. I meant to write you "can't do it". GDI is only for 2D.
Steve
|
|
|
|
|
look at the parameters of PlgBlt
it take an array of points, which means it can divert the shape you are drawing in the Z axis as well.....
Like i said, i've managed to diver the rectangle in 30 degrees in the Z axis, but the old drawing were remained....(of the original position of the rectangle)...
I'm sure this can be done...
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
I still don't believe you can do what I think you're after using simple GDI calls. If you do manage it I would be interested in seeing how you did it.
Good luck.
Steve
-- modified at 7:28 Sunday 23rd April, 2006
|
|
|
|
|
Can you give me an email so i can send to you my small sample?
In the sample, if you press the button, the rectangle diverts in a certain angle and it and the text inside it appears as in 3D, trouble is how to erase the preiovus rectangle drawings....
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Did you get my sample via email?
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
|
I've played with your example and I can't get it to do what you want (as I suspected). The destination rectangle is always a "parallelogram" (quoted text from MSDN): that's a square or rectangle which is squashed to one side so that the two opposing sides are parallel. To simulate perspective you need a trapezium.
Steve
|
|
|
|
|
not sure i understand you reply...
Stephen Hewitt wrote: that's a square or rectangle which is squashed to one side so that the two opposing sides are parallel. To simulate perspective you need a trapezium.
????
can you explain it in more simple words.
thanks
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
A parallelogram looks like this:
-----
\ \
\ \
-----
But a trapezium looks like this:
---
/ \
/ \
-------
PlgBlt is short for parallelogram_Bit_Blit. The following is a quote from MSDN:
"Pointer to an array of three points in logical space that identify three corners of the destination parallelogram".
Notice it has three points not four - This ensures it is impossible to even ask for a shape that isn't a parallelogram: No matter which three points you give to it a third is calculated such that the resulting shape is a parallelogram.
To simulate perspective you need something that looks like a trapezium.
Steve
|
|
|
|
|
I know the difference between a trapezium and parallelogram.
since the rectangle is diverted and represented in 3D environment, i do need to preserve its coordinates so the outcome result of what is need is a parallelogram and not trapezium.
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
What do you mean, "since the rectangle is diverted and represented in 3D environment"? PlgBlt performs a 2D mapping from a rectangle to a parallelogram. A far as I can see that's a show stopper for you. I think to get it to work the way you want you’d have to use DirectX or OpenGL or create your own code to calculate a transformation for every pixel – No simple GDI call that I know of can do what you want as it’s designed for 2D work.
Steve
|
|
|
|
|
|
I can't see anything that will help you in there.
Steve
-- modified at 7:26 Sunday 23rd April, 2006
|
|
|
|
|
Look at the reply by Pravin Kumar (the second one) ,
he mentioned several steps:
(i) You have to create a polygon region from the rotated vertices of the rectangle,
(ii) get its bounding rectangle using CRgn:: GetClipBox function,
(iii) create a compatible bitmap and attach it to a compatible memory DC,
(iv) paint the memory DC with the background colour of the window,
(v) draw region on memory DC using FillRgn and FrameRgn functions and finally
(vi) BitBlt the memory DC to the window DC. Detaching the bitmap from memory DC and deleting bitmap and DC go without saying
and the trick could be to create a polygon of the outcome rectangle, then copy it to memory dc after you clip it using RGB, then draw the memory dc back to window using bitblt....
this code be something right?
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
I can't see how this procedure does what you want. I think what you want is rotation around the x or y axis with perspective. This is beyond abilities of GDI.
Steve
|
|
|
|
|
ok then let's conclude this debate
Bottom line is that i need to use Open GL or DirectX to do so....
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Yeah, I don't think were progressing the issue. Good luck.
Steve
|
|
|
|
|
I've sent you an oher sample in the mail, did u get it?
this time it does what i need but i have a drawing problem...
maybe u can help?
thanks
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Hi ,
I am infancy to socket programming .I need to connect to an external device through terminalserver4 and i should be able to send command & receive output. Using the following code, i am able to send data to the external device from the two send functions and able to receive data from only the first recv function.
The program is blocking at the second recv function. Please check the following code and help me if anywhere went wrong.
#define DEST_IP "10.10.1.1"
#define DEST_PORT 2001
void CSocktestDlg::process()
{
WSADATA wsaData;
if(WSAStartup(MAKEWORD(1,1),&wsaData)!=0)
{
AfxMessageBox("WSAStartup failed",MB_OK);
exit(1);
}
else
{
//AfxMessageBox("WSAStartup succeeded",MB_OK);
}
int sockfd;
struct sockaddr_in dest_addr;
//Establishing socket
sockfd=socket(AF_INET,SOCK_STREAM,0);
dest_addr.sin_family=AF_INET;
dest_addr.sin_port=htons(DEST_PORT);
dest_addr.sin_addr.s_addr=inet_addr(DEST_IP);
memset(&(dest_addr.sin_zero),'\0',8);
//For connecting
if(connect(sockfd,(struct sockaddr *)&dest_addr,sizeof(struct sockaddr))==0)
{
//AfxMessageBox("Connected to remote system successfully",MB_OK);
}
else
{
AfxMessageBox("Unable to connect to remote machine",MB_OK);
}
//For sending data
CString code= "2,76,69,68,77,73,44,73,77,68,69,73,77,68,69,0,217,105,3";
int len,bytes_sent,n,i;
CTokenEx CtlArraySpliter;
CStringArray strArray;
CtlArraySpliter.Split(code,",",strArray,TRUE);
for(i = 0; i < strArray.GetSize(); i++ )
{
//len=strArray.GetAt(i).GetLength();
n = atoi(strArray.GetAt(i));
bytes_sent=send(sockfd,(char *) &n,sizeof(int),0);
}
strArray.RemoveAll();
AfxMessageBox("Sent message through socket to remote IP",MB_OK);
Sleep(5000);
//For receiving data
char buf[50];
int p=recv(sockfd,buf,50,0);
CString s,readbuffer,soutput;
readbuffer=(CString)buf;
soutput = "";
for(i = 0;i < p;i++)
{
if (soutput == "")
{
s.Format("%d", (int)((unsigned char)readbuffer.GetAt(i)));
soutput = soutput + s;
}
else
{
s.Format("%d", (int)((unsigned char)readbuffer.GetAt(i)));
soutput = soutput + "," + s;
}
}
AfxMessageBox(soutput,MB_OK);
//second time sending......................
CtlArraySpliter.Split(code,",",strArray,TRUE);
for(i = 0; i < strArray.GetSize(); i++ )
{
//len=strArray.GetAt(i).GetLength();
n = atoi(strArray.GetAt(i));
bytes_sent=send(sockfd,(char *) &n,sizeof(int),0);
//m_myPortController.Write((char *) &n,0,0);
}
strArray.RemoveAll();
Sleep(5000);
char buf1[50];
int q=recv(sockfd,buf1,50,0);
readbuffer=(CString)buf1;
soutput = "";
for(i = 0;i < q;i++)
{
if (soutput == "")
{
s.Format("%d", (int)((unsigned char)readbuffer.GetAt(i)));
soutput = soutput + s;
}
else
{
s.Format("%d", (int)((unsigned char)readbuffer.GetAt(i)));
soutput = soutput + "," + s;
}
}
AfxMessageBox(soutput+" first port second time",MB_OK);
if (p == SOCKET_ERROR)
{
p = WSAGetLastError();
WSACleanup();
}
else
{
AfxMessageBox("Received data successfully",MB_OK);
}
//For shutting down the socket
int r=shutdown(sockfd,2);
WSACleanup();
if (r==0)
{
//AfxMessageBox("socket closed successfully",MB_OK);
}
if (r==-1)
{
AfxMessageBox("Unable to close the socket",MB_OK);
}
}
The program is blocking at the second recv() function.
Pl help me.
Thanks in advance!!
|
|
|
|
|
in general, each waiting function (such as recv()) should be put in a thread, because u don't know if or when other-side sends message to you.
so create threads for your waiting functions.
A special image tool for C++ programmers, don't miss it!
The world unique Software Label Maker is here for you and me ...
A nice hyper tool for optimizing your MS html-help contents.
|
|
|
|
|
here, i think there is no waiting problem.Because the external device sends message immediately after sending command code. Is there any other wrong in my code? For the first time it is responding immediately. For the second time not.
|
|
|
|
|