| |

VerySource

 Forgot password?
 Register
Search
View: 2452|Reply: 15

Existing data is stored in three arrays of x [], y [], z []. How to draw three-dimensional graphics on the screen using

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-5 11:40:01
| Show all posts |Read mode
Existing data is stored in three arrays of x [], y [], and z []. How to draw three-dimensional graphics on the screen using vc programming, no need to talk about the principle of projection, just provide vc source code (not opengl). Thanks in advance.
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-5 17:18:01
| Show all posts
Too exaggerated? ? ? Generally, as long as the basic principles are implemented by themselves, who wants the source code but not the principle? ? ? Is it due for homework? ? It seems that no one except me posted it.
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-6 13:00:01
| Show all posts
As soon as the principle is grasped, it depends on how the program is implemented. How to deal with horizontal and vertical angles of view? The coordinate origin needs to be displayed in the middle of the screen (inverted T-shape), and it is directly encoded by VC without involving OPENGL.
    Don't talk big upstairs, take a paragraph example to see.
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-7 03:06:01
| Show all posts
Use the "similar triangle" principle to "planarize" points in space to a plane. (LZ already knows it well, why ask?)
Reply

Use magic Report

0

Threads

55

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-1-10 23:09:01
| Show all posts
Without talking about projection, how to use 3D display?
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-21 22:27:01
| Show all posts
To put it plainly: the calculation procedure of 3 points to 2 points. That is: A [] = f (x [], y [], z []) and B [] = f (x [], y [], z []). Write the code of the relevant function (and consider the variables of flat view, top view, and rotation).
The principle of projection is definitely needed, but it is not described here. Just want to see the source code here.
Too much is said in class, not much is done. I think it should be reversed here.
Reply

Use magic Report

0

Threads

18

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-24 11:54:01
| Show all posts
Just do it yourself
Reply

Use magic Report

0

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-24 17:18:01
| Show all posts
Ha ha, you are so funny, my teacher ’s master thesis was this thing. The VC shows three-dimensional terrain. You have 100 points to get the source code, and you do n’t talk about the principle, huh.
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-26 09:00:02
| Show all posts
Pseudocode:
// in deed you must need normal transition to change
// but i did not know !!
while (some express) {
pos_x_projected [index] = x [index] / z [index];
pos_y_projected [index] = y [inedx] / z [index];
index ++;
}
// world Cartesian coordinate and viewport to windows in Windows coordinate
// i give you some formula, some stupid don't understand
(w_pos_x-WINDOWS_CDC_LEFT) / (WINDOWS_CDC_RIGHT-WINDOWS_CDC_LEFT) = (pos_x_projected-VIEWPORT_LEFT) / (VIEWPORT_RIGHT-VIEWPORT_LEFT);
(w_pos_y-WINDOWS_CDC_TOP) / (WINDOWS_CDC_BOTTOM-WINDOWS_CDC_TOP) = (pos_x_projected-VIEWPORT_BOTTOM) / (VIEWPORT_TOP-VIEWPORT_BOTTOM);
// compute the w_pos_x and w_pos_y
// but i don't where's viewport in camera ??? !! 1

// get DC of windows
while (some express) {
dc.LineTo (w_pos_x [index], w_pos_y [index])
// some other process to draw a whole primary
}

Because we don't know the initial position of the primitives, we don't know where the camera is, and we don't know whether to crop, so this pipeline is hard to make mistakes! !! Only when it (x [], y [], x []) are already in the transformed position, but it is unlikely to exist in the actual situation! !! !! Please do n’t push the law in the future, this way you ca n’t get a foothold in verysource!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-3 12:15:01
| Show all posts
I have a similar code, the key is to change the 3D to the 2D coordinates of the screen, to give a few examples, without OpenGl and other things.
realP[3] is your original 3D data point coordinates, scrP is the 2D screen coordinates, after generating 2D points, can you Lineto? But my program has not realized the conversion of any angle, as for the interspersed zoom The offset algorithm is not shown here.

switch(ViewType)
{
case VIEWTYPE_FUS://top view
scrP->x = realP[0];
scrP->y = realP[1];
break;

case VIEWTYPE_ZHS://Front view
scrP->x = realP[0];
scrP->y = realP[2];
break;

case VIEWTYPE_YOS://right view
scrP->x = realP[1];
scrP->y = realP[2];
break;

case VIEWTYPE_ZD0://isometric view of southwest
scrP->x = (realP[0]-realP[1])*COS_30;
scrP->y = (realP[0]+realP[1])*SIN_30+realP[2];
break;

case VIEWTYPE_ZD1://southeast isometric
scrP->x = (realP[0]+realP[1])*COS_30;
scrP->y = (realP[1]-realP[0])*SIN_30+realP[2];
break;

...

default:
scrP->x = 0;
scrP->y = 0;
break;
}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list