Crystal Space
9052 Posts in 2047 Topics by 73677 Members
Latest Member: Danielsallia117
 Pages: [1] 2
Jr. Member

Posts: 81

 « on: February 16, 2009, 09:14:45 am »

Hi, I am new in CS.
I have some problems about coordinate Transformation.
Assuming that there is an polygon in the world map. Now I want to get the polygon vertices' object space coordinates, world space coordinates and screen coordinates. which function can i use?
And how to get the transform which will transform object space of the polygon to world space? How to get the transform which will transform world space of the polygon to screen ?

 Logged
jorrit
Hero Member

Posts: 1706

 « Reply #1 on: February 16, 2009, 09:21:57 am »

Hi, I am new in CS.
I have some problems about coordinate Transformation.
Assuming that there is an polygon in the world map. Now I want to get the polygon vertices' object space coordinates, world space coordinates and screen coordinates. which function can i use?
And how to get the transform which will transform object space of the polygon to world space? How to get the transform which will transform world space of the polygon to screen ?

The object to world transform can be found in the movable of the object. So if you have a pointer to the mesh that contains the polygon you can do mesh->GetMovable()->GetFullTransform(). This transform represents the transformation from object space to world space. Calling This2Other() on this transform would convert a vector from object space to world space. Calling Other2This() would do the reverse.

The transform to get from world space to screen is in the camera that you use. You can use camera->GetTransform() to get that. Doing Other2This() on this transform will transform from world to camera space.

Camera space is still 3D space. So if you want to get screen coordinates you have to do perspective projection too. The camera has a function for that. You can call camera->Perspective() to convert a 3D camera space vector to a 2D screen location.

Hope this helps,

Greetings,
 Logged
Jr. Member

Posts: 81

 « Reply #2 on: February 16, 2009, 09:36:41 am »

Is the result which I use " camera->Perspective()" to get have the same large to screen  , or I need to do some clip after that?
 Logged
jorrit
Hero Member

Posts: 1706

 « Reply #3 on: February 16, 2009, 09:41:16 am »

Is the result which I use " camera->Perspective()" to get have the same large to screen  , or I need to do some clip after that?

The result is not clipped. Even worse. Before giving vertices to the Perspective() function you must make sure that it is actually in front of the camera or the function will not be correct (i.e. vertex.z > 0 to test if it is in front of the camera). Note that this can be complicated. For example, a polygon might be partially in front of the camera and partially behind it. In that case you need to clip the polygon in 3D space to the Z=0 plane so that only the part of the polygon in front of the camera remains.

Greetings,
 Logged
Jr. Member

Posts: 81

 « Reply #4 on: February 16, 2009, 09:54:25 am »

I know the meaning what you said to me . But I have no idea about how to implement it in CS.  --_--||
 Logged
jorrit
Hero Member

Posts: 1706

 « Reply #5 on: February 16, 2009, 09:57:01 am »

You can use the csPlane3.ClipPolygon() routine.

Greetings,
 Logged
Jr. Member

Posts: 81

 « Reply #6 on: February 16, 2009, 10:12:55 am »

o, I know it now!!
I have another questions.
The description of the function "iGraphics2D->Blit (int x, int y, int width, int height, unsigned char const *data)" is " Blit a memory block. Format of the image is RGBA in bytes. Row by row. " I don't understand its meaning. Does it mean to copy the const data to the memory block?
Is it the same as blitter in DirectDraw?
 Logged
jorrit
Hero Member

Posts: 1706

 « Reply #7 on: February 16, 2009, 10:13:44 am »

It will copy the data to the screen.

Greetings,
 Logged
Jr. Member

Posts: 81

 « Reply #8 on: February 16, 2009, 10:17:39 am »

o, got it!

Thank you very much!!!!
 Logged
Jr. Member

Posts: 81

 « Reply #9 on: February 17, 2009, 08:23:32 am »

Now I can get the 2d vertices in screen coordinate of the visible part of ploygon,  but how can I get the RGB value which of the 2d vertices?
 Logged
jorrit
Hero Member

Posts: 1706

 « Reply #10 on: February 17, 2009, 08:35:22 am »

That's a bit harder. What exactly are you trying to do? What's the problem that you want to solve in general?

Greetings,
 Logged
Jr. Member

Posts: 81

 « Reply #11 on: February 17, 2009, 09:06:08 am »

The picture shows two rooms and using portal to connect them. Through the portal I can see another room. Now I want to get the RGB value of the part which i use red square to encircle. And show them in another place.
 Logged
jorrit
Hero Member

Posts: 1706

 « Reply #12 on: February 17, 2009, 09:07:36 am »

Ok, but you didn't tell me what you are trying to do. You are only telling me the technical thing you are trying to do but not why. What is the effect you are trying to achieve?

Reading RGB values from the 3D card is very very slow. It sounds to me as if you are going about this the wrong way. But first I need to  know what it is that you want to do.

Greetings,
 Logged
Jr. Member

Posts: 81

 « Reply #13 on: February 17, 2009, 09:41:34 am »

This is a long story, I don't know how to explain.
If I get the RGB data and use them in the same program, and  it also very slow?
 Logged
jorrit
Hero Member

Posts: 1706

 « Reply #14 on: February 17, 2009, 09:45:48 am »

Yes, reading any information from a 3D card is slow since communication between 3D card and computer is designed so that it is only fast from the computer to the card. Not the other way around.

If you want to copy part of the screen somewhere else I think you should use other functions. Without really knowing what you want to do I guess that you can probably get a lot further by simply rendering the contents of the portal to a texture (I told you this before). And then you can render that texture anywhere you want on the screen.

Greetings,
 Logged
 Pages: [1] 2