CN101477701A - Built-in real tri-dimension rendering process oriented to AutoCAD and 3DS MAX - Google Patents

Built-in real tri-dimension rendering process oriented to AutoCAD and 3DS MAX Download PDF

Info

Publication number
CN101477701A
CN101477701A CNA200910025518XA CN200910025518A CN101477701A CN 101477701 A CN101477701 A CN 101477701A CN A200910025518X A CNA200910025518X A CN A200910025518XA CN 200910025518 A CN200910025518 A CN 200910025518A CN 101477701 A CN101477701 A CN 101477701A
Authority
CN
China
Prior art keywords
dimensional
function
stereo
api
matrix
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CNA200910025518XA
Other languages
Chinese (zh)
Other versions
CN101477701B (en
Inventor
闾国年
温永宁
盛业华
吴明光
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing Normal University
Original Assignee
Nanjing Normal University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing Normal University filed Critical Nanjing Normal University
Priority to CN200910025518XA priority Critical patent/CN101477701B/en
Publication of CN101477701A publication Critical patent/CN101477701A/en
Application granted granted Critical
Publication of CN101477701B publication Critical patent/CN101477701B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Processing Or Creating Images (AREA)
  • Image Generation (AREA)

Abstract

The invention discloses a method for realizing true 3D display. The method is oriented to AutoCAD and 3 DS MAX and comprises the following steps: an implanted rendering data interception technology is adopted between invoking of a 3D API of software and display by a display card to capture an original single channel color signal, a depth signal, a 3D scene transformation matrix and a projection transformation matrix; rasterized 3D data is reconstructed by parsing the information; on the basis of the stereo vision principle, the scene is re-transformed to two different viewpoint positions in a self-adapting manner, so that a binocular vision stereopair to be displayed in a 3D form is formed, and the display card is driven to output the binocular vision stereopair in a 3D form; and polarization, a pair of red and green or blinking glasses, and the like are adopted for true 3D display and observation. The invention can realize true 3D scene display of the prior software such as AutoCAD and 3 DS MAX without changing programs and operation modes thereof.

Description

Implantation type true three-dimensional stereo rendering method towards AutoCAD and 3DS MAX software
Technical field
The present invention relates to the three-dimensional visualization technique field, be specifically related to a kind of implantation type true three-dimensional stereo rendering method towards AutoCAD and 3DS MAX software.
Background technology
Along with development of computer, stereo display has become fields such as environmental simulation, simulated training and planning and design technological means commonly used, even beginning combines the generation three-dimensional film with film, computer game etc. and true 3d gaming incorporates daily life.Computer aided design software AutoCAD and 3 d modeling software 3DS MAX that AutoDesk company releases are two kinds of important three-dimensional applications softwares.
Realize that in three-dimensional applications stereoscopic vision is a kind of trend, on single display equipment, observe three-dimensional scenery, the image that images of left and right eyes is seen independently need be separated separately, make right and left eyes see that different images passes through the physiological action formation stereoscopic vision of brain by specific external device then.Traditional stereo display needs the equipment of specialty to carry out stereo display, comprises the video card of supporting left and right sides buffer memory and supports the stereoscopic display device that binary channels shows.Based on above-mentioned technology, produced widely popular virtual reality technology, obtained in fields such as machine emulation, battlefield simulations using widely.But, owing to need professional equipment, with high costs, also limited the application of stereo display technique, so the application of stereo display can not obtain promoting, a large amount of three-dimensional programs still adopts the single channel technology to show, lack stereoscopic sensation, lost the due stereo display characteristic of three-dimensional program.Simultaneously, because stereo display needs specialised hardware, special art of programming, also caused a large amount of programs when exploitation, not consider the stereo display characteristic, in program, do not realize supporting the function of stereo display, even make these programs can not show solid having on the hardware of three-dimensional display function.These programs have occupied the overwhelming majority of present 3-D display program, AutoCAD and 3DS MAX do not break through above-mentioned restriction yet, and it is in modeling process, and the user still can only see single pass perspective three dimensional, very three-dimensional stereo display can not be realized, best effect can not be reached.
Summary of the invention
Problem to be solved by this invention is to overcome the deficiency that AutoCAD and 3DS MAX software exist in 3-D display, realize that the real tri-dimension that former software is not added modification shows.Core of the present invention is to utilize the ultimate principle of three-dimensional rendering, by color data and depth data in the interception video card result frame image, resolve the projective transformation matrix that generates the result frame image, the ultimate principle that applying three-dimensional is played up and the three-dimensional scenic of reconstructing grid, on this scene basis, use principle of stereoscopic vision, generate stereogram, based on different stereo display patterns, drive video card and carry out solid output.
The technical foundation that the present invention relies on is about the basic model of three-dimensional rendering in the computer graphics, be the basic model of the three-dimensional rendering of the 3D API that uses of AutoCAD and 3DS MAX (current under Windows two kinds of softwares under hardware-accelerated driving, all use OpenGL), comprise the transformation pipeline, Z buffer zone algorithm on three-dimensional rendering streamline, summit etc.Realize that according to being OpenGL API and video card both all are based on this basic model and carry out work.The present invention makes this computer software realize the three-dimensional true 3-D display and the observation of binocular vision under the situation of not changing AutoCAD and 3DS MAX source code, binary code or computer hardware structure.
The ultimate principle that Computerized three-dimensional shows is with after three-dimensional scenic process geometric transformation and photo-irradiation treatment and the rasterizing, generates a width of cloth two-dimensional grid image and exports on output device.Comprise a series of three dimensional object in the three-dimensional scenic, three dimensional object is to be combined by the geometric graphic element (comprising some line and triangle) that a series of summits constitute.The summit is one and comprises three-dimensional space position and the corresponding coordinate points of playing up parameter thereof.At first vertex data is carried out perspective grid conversion and photo-irradiation treatment.In the coordinate transform stage, the summit of describing geometry of objects is transformed under the coordinate system that viewpoint is the center, carries out color and brightness that illumination calculation determines that each summit should have again.The basic display unit of computer graphics is a pixel, and these geometric objects are tiled into pixel, and it is medium to be shown that these pixels are sent to frame buffer at last, as shown in Figure 2.
In three-dimensional picture is played up, exist a series of coordinate transform, at last the coordinate transform of object itself is become the pixel coordinate on the two-dimensional screen.These coordinate transforms all with the previous step transformation results as output, constitute the streamline of an apex coordinate conversion, as shown in Figure 3.The coordinate of all three dimensional objects has all been arrived under the same coordinate system by unified, forms normalized coordinate through projection and cutting, forms image pixel by the rasterizing conversion.
Z buffer zone algorithm claims depth buffered algorithm again.Because the two dimensional surface coordinate can corresponding unlimited a plurality of three-dimensional coordinates under perspective projection.So what the geometric object of rasterizing had comprised each pixel correspondence is called the parameter of depth value to viewpoint, if the depth value of rasterizing geometric object pixel is less than original pixel, just replace the value of origin-location with the value of this pixel, this has just guaranteed that always nearest apart from viewpoint pixel is saved.
At above principle, realize that the technical scheme of the object of the invention is:
Towards the implantation type true three-dimensional stereo rendering method of AutoCAD and 3DS MAX software, this method may further comprise the steps:
Data interception is monitored and played up to step (1) at the 3D API OpenGL of AutoCAD and 3DS MAX use;
Step (2) is utilized scene change matrix and projective transformation matrix reconstructing grid three-dimensional data;
Step (3) self-adaptation screen resolution and people's eye cardinal distance is set two different viewpoint positions and is generated stereogram;
Step (4) is carried out true three-dimensional observation at different stereoscopy equipment.
The concrete available the following step of method of the present invention realizes, the following step in no particular order:
A. the function of 3-D display environment is created in monitoring, in this function, add system's detection function function of calling 3D API, obtain system's stereo display characteristic, according to corresponding stereo display characteristic, stereo display pattern in the display environment of change original start, on the hardware of supporting stereo display, open real tri-dimension and show support, on the hardware of not supporting stereo display, sign is set so that carry out red green stereo display.
B. monitoring beginning one frame is drawn function, and the adding code obtains the viewport size when the pre-plot frame in this function, is that stereogram is created interim buffer zone according to the pixel format of playing up.
C. monitoring changes current drafting matrix function, in this function, add code to obtain of the change of three-dimensional applications software, by the projection type of matrix parameter identification scene rendering, when being perspective projection to current drafting matrix, write down this matrix, as the key parameter of three-dimensional scenic reconstruct;
D. monitor the function that frame buffer is outputed to display device, add code to obtain each color of pixel and depth data in the entire frame at the monitoring function, the projective transformation matrix information of obtaining based on step c, the three-dimensional coordinate of each pixel of inverse under eye coordinates system reconstructs the three-dimensional scenic based on the rasterizing of pixel; According to the stereoscopic vision model of eye, generation can be for the stereogram of stereo display.
In the described step (1) monitoring of OpenGL API with play up data interception and further comprise: utilize API interception technology, obtain the output of 3 D rendering correlation matrix and three-dimensional rendering data, extract the wide height of projection matrix, viewport of realizing the three-dimensional perspective conversion, as the key parameter of three-dimensional scenic reconstruct; Utilize the specific function of OpenGL API, the output of interception three-dimensional rendering is extracted color and depth data in the video card frame buffer, as the basis of three-dimensional scenic reconstruct.
3D API interception is meant and utilizes computer programming, the OpenGL api function that AutoCAD and 3DS MAX are used calls to be monitored, and the data of playing up that OpenGL API produces are tackled and insert self-defined code therein, reach the purpose that original API is monitored or realizes again.API tackles technology maturation and is widely used, as screen word-selecting software, anti-viral software, network firewall or the like.The OpenGL API of indication of the present invention plays up the some crucial OpenGL api function that interception is meant the interception specific function.
Also further comprise the concrete steps that realize the interception of 3D api function at it in the described step (1): at the 3D API (OpenGL) of AutoCAD and 3DS MAX use, inject or/and the Hook Function technology is write specific hook procedure by code, in the data load stage of three-dimensional visualization program, 3D API hook procedure is loaded in the process of three-dimensional visualization program, thus interception and monitoring 3D API Calls.The crucial function of the 3D API that indication of the present invention need be tackled is as follows:
(21) 3D API creates the function of 3-D display environment;
(22) 3D API begins the function of a frame scene rendering;
(23) 3D API changes the current function of playing up matrix;
(24) 3D API finishes the function of a frame scene rendering;
(25) 3D API will play up data and output to function on the current screen.
Described step (2) further comprises utilizes OpenGL API to output to color and depth data in the video card frame buffer, and the projective parameter that obtains in conjunction with interception OpenGL API Calls is resolved the three-dimensional spatial information that generates color image and depth data.Promptly, by generating the projection matrix and the wide height of viewport of three-dimensional rendering output, calculate the color and the depth data of the output of three-dimensional rendering key control parameter (viewpoint position, hither plane, far plane) and three-dimensional rendering, and then calculate the three-dimensional coordinate of each pixel in the visual space and corresponding color characteristics, the three-dimensional scenic data of rasterizing under the reconstruct visual space.It specifically can comprise following steps:
I. the identification of perspective projection transformation matrix.In the render process of a frame scene, three-dimensional applications software may repeatedly be changed projective transformation matrix, has only perspective transformation matrix just can produce the perspective three dimensional effect.Be without loss of generality, suppose that the perspective projection transformation matrix is consistent in the render process of a frame, perspective projection matrix is tackled, the eigenwert in the matrix as criterion, is judged whether the matrix of current interception is perspective projection matrix.
II. setting up viewpoint is the three dimensional space coordinate system (being called for short eye coordinates system) of true origin.The perspective projection transformation matrix of intercepting and capturing with step I is a parameter, foundation is the view coordinate system of true origin with the power pin: the Z axle passes the center of hither plane, the X-axis of the Y-axis of hither plane and X-direction and this coordinate system, the Y direction unanimity, hither plane is positioned on the scale of Z axle of hither plane value correspondence.The codomain of X is [width/2, width/2] on the hither plane, and the codomain of Y is [height/2, height/2].In this coordinate system, (X, Y Z) can be tried to achieve by the perspective projection matrix conversion with the coordinate figure P ' of the intersection point of hither plane (X ', Y ', Z ') arbitrary coordinate point P, and wherein Z ' is corresponding to the depth value in the frame depth buffer.Can get: X ' equals width/2*X/Z; Y ' equals height/2*Y/Z; Z ' equals (z-zNear)/z*zFar/ (zFar-zNear), and wherein Z ' is corresponding to the value in the depth buffer.
III. the reconstruct of rasterizing three-dimensional scenic data.If the width of viewport is width ', highly is height ' to be obtained by OpenGL API related function.By the proportionate relationship of viewport and the hither plane coordinate P of three-dimensional rendering two field picture pixel " ' (X " ' arbitrarily as can be known, Y " ') corresponding to the three-dimensional coordinate Pn on the hither plane (xn, yn, zn); xn=(X " '-width '/2) * width/2 wherein, yn=(Y " '-height '/2) * height/2.Value Z ' in the corresponding depth buffer, by Step II as can be known, corresponding eye coordinates system Z value down is Z ' * (zFar-zNear)/zFar+zNear, can get the coordinate P of pixel under eye coordinates system (X, Y, Z), wherein X equals xNear/zNear*Z, and Y equals yNear/zNear*Z.
By calling color buffer district function and the depth buffer function in the video card of reading of OpenGL API, utilize coordinate system and the above-mentioned relation set up in the Step II, can obtain the eye coordinates system three-dimensional coordinate of all pixels down.All three-dimensional coordinates are coupled together with triangle surface, just constituted a three-dimensional surface that can carry out three-dimensional rendering, is playing up under the visual angle arbitrarily by the three-dimensional flow waterline on this surface.
" setting two different viewpoint positions and generate stereogram " in the described step (3) is the three-dimensional scenic that utilizes step (2) reconstruct, generates two width of cloth images, forms stereogram.The present invention proposes the stereo display model based on the three-dimensional scenic of " voxel ", so-called voxel is meant the three-dimensional coordinate of each pixel of the three-dimensional scenic of step (2) reconstruct and its corresponding view space composition sequence [(X together, Y, Z), (R, G, B)], a voxel space of formation.At each pixel in this space,, calculate its location of pixels point in new viewpoint according to the perspective transform principle.
Generate stereogram and can adopt following two kinds of methods:
Method one. call 3D API, play up the contextual data that obtains in the step (2), original image as left visual point image situation under, generate right visual point image; Original image as right visual point image situation under, generate left visual point image; Do not preserving under the original image situation, generating left and right sides visual point image, thereby realizing that stereogram generates.
Method two. adopt rasterizing three-dimensional scenic data, make up the mapping relations of pixel under original visual space and the target visual space, the pixel under the original visual space is converted directly under the target visual space.Original image as left visual point image situation under, generate right visual point image; Original image as right visual point image situation under, generate left visual point image; Do not preserving under the original image situation, generating left and right sides visual point image, thereby realizing that stereogram generates fast.Wherein:
The viewpoint horizontal-shift is meant the change amount D of the new viewpoint original viewpoint of distance on X-direction x
The viewpoint vertical shift is meant the change amount D of the new viewpoint original viewpoint of distance on Z-direction z
Image pixel is offset, and is meant the additional offset D of the image pixel horizontal direction of generation Pixel
Then under another eye coordinates system, (the coordinate X that pixel Z) is marked under the left viewpoint is Width ' * (X-Dx)/(Z-Dz)+D for X, Y to primitive frame image mid point P Pixel, Y is Height ' * Y/ (Z-Dz).This pixel is under for right eye coordinates being, coordinate calculates according to the method described above, but Dx, Dz gets negative sign.
Each color of pixel is copied to the target location.Thereby two viewpoints are all used this method obtain stereogram.This method has without graphics pipeline, and program composition is simple, optimizes advantages such as easy.
" carry out true three-dimensional observation " in the described step (4) and be meant stereogram that step (3) is generated, by display device output and carry out stereoscopy at different stereoscopy equipment.The stereogram that the present invention generates is carried out true 3-D display in the following way:
X. the binocular solid of video card support shows.As supporting under the OpenGL API ring border of stereo display, creating the stereo display pattern that the equipment handle stage starts OpenGL API, about being transported to respectively, the stereogram that generates in two buffer zones, realizes stereo display.
Y. on the video card of not supporting stereo display, stereogram is synthesized a width of cloth red and green complementary color stereo-picture, and an image from the stereogram of the left and right sides extracts red channel, extracts green and blue channel in another image, the passage that extracts is merged, form the stereo-picture of a complementary colors.And send original image buffer back to and carry out stereo display and observation.
Z. stereo-picture or picture are supported on the stereoscopic display device being transported to other.
The present invention is intended to solve the problem that AutoCAD and 3DS MAX program can not be supported stereo display, relies on ripe code interception technical intercept to carry out layout again at AutoCAD and 3DS MAX for calling of OpenGL API.By the monitoring projection matrix, obtain the key parameter of inverse three-dimensional scenic, by color image and the depth image of drawing,, and pixel value is mapped on the position of correspondence by counter its three-dimensional coordinate of asking of pixel, form stereogram.Carry out stereo display by various display modes, the present invention also provides a feasible approach for the direct three-dimensional of existing a large amount of three-dimensional programs.The present invention has following characteristic:
(1) solved the problem that to carry out stereo display at AutoCAD and 3DS MAX, promoted mutual and user experience at AutoCAD and 3DS MAX.
(2) the algorithm novelty of Shi Xianing is redistributed the formation stereogram by color image data in the frame buffer zone and depth data process, and algorithm principle is simple, and programming realizes convenient.
(3) made full use of existing technical resource,, had good adaptability, do not had specific (special) requirements for video card owing to develop based on the OpenGL API of industrial standard.Support plurality of display modes, can realize stereo display under the display environment arbitrarily.
Description of drawings
The method flow diagram of Fig. 1 embodiment of the invention 1
The basic model of the three-dimensional rendering that Fig. 2 the present invention adopts
The coordinate transform streamline of the three-dimensional picture that Fig. 3 the present invention adopts
The perspective projection of Fig. 4 embodiment of the invention 1 and perspective transformation matrix
Fig. 5 embodiment of the invention 1 be the coordinate system at center with the viewpoint
The quick generation method figure of the stereogram of Fig. 6 embodiment of the invention 1
Embodiment
Below in conjunction with drawings and Examples the present invention is described in further details.
Embodiment 1
As shown in Figures 2 and 3 owing to all use OpenGL API as three-dimensional rendering API at modelling phase AutoCAD and 3DS MAX, so present embodiment based on OpenGL API as objective for implementation, operating system platform is implemented for Windows XP.
The interception of OpenGL API is developed based on Micorsoft Detours SDK with monitoring.Detours is the kit that a cover that Microsoft provides carries out the API Calls interception under the windows platform, supports all platforms of Win32.
As shown in Figure 1, towards the implantation type true three-dimensional stereo rendering method of AutoCAD and 3DS MAX software, this method may further comprise the steps:
Data interception is monitored and played up to step (1) at the OpenGL API of AutoCAD and 3DS MAX use;
Step (2) is utilized scene change matrix and projective transformation matrix reconstructing grid three-dimensional data;
Step (3) self-adaptation screen resolution and people's eye cardinal distance is set two different viewpoint positions and is generated stereogram;
Step (4) is carried out true three-dimensional observation at different stereoscopy equipment.
In the step (1) interception of OpenGL API with obtain the scene rendering data and further comprise: utilize 3D API interception technology, obtain 3 D rendering correlation matrix and three-dimensional rendering data, extract the wide height of projection matrix, viewport of realizing the three-dimensional perspective conversion, as the key parameter of three-dimensional scenic reconstruct; Utilize the specific function of 3D API, the output of interception three-dimensional rendering is extracted color and depth data in the video card frame buffer, as the basis of three-dimensional scenic reconstruct.
Step (2) further comprises utilizes OpenGL API to output to color and depth data in the video card frame buffer, and the projective parameter that obtains in conjunction with interception OpenGL API Calls is resolved the three-dimensional spatial information that generates color image and depth data.It further comprises following steps:
I. the identification of perspective projection transformation matrix.In the render process of a frame scene, three-dimensional applications software may repeatedly be changed projective transformation matrix, has only perspective transformation matrix just can produce the perspective three dimensional effect.Be without loss of generality, suppose that the perspective projection transformation matrix is consistent in the render process of a frame.Every controlled variable of perspective projection is seen shown in the accompanying drawing 4 with corresponding matrix relationship.Perspective projection matrix is tackled, the eigenwert in the matrix as criterion, is judged whether the matrix of current interception is perspective projection matrix.
II. setting up viewpoint is the three dimensional space coordinate system (being called for short eye coordinates system) of true origin.The perspective projection transformation matrix of intercepting and capturing with a is a parameter, foundation is the view coordinate system of true origin with the power pin: the Z axle passes the center of hither plane, the X-axis of the Y-axis of hither plane and X-direction and this coordinate system, the Y direction unanimity, hither plane is positioned on the scale of Z axle of hither plane value correspondence.The codomain of X is [width/2, width/2] on the hither plane, and the codomain of Y is [height/2, height/2].In this coordinate system, (X, Y Z) can be tried to achieve by the perspective projection matrix conversion with the coordinate figure P ' of the intersection point of hither plane (X ', Y ', Z ') arbitrary coordinate point P, and wherein Z ' is corresponding to the depth value in the frame depth buffer, as shown in Figure 5.Can get: X ' equals width/2*X/Z; Y ' equals height/2*Y/Z; Z ' equals (z-zNear)/z*zFar/ (zFar-zNear), and wherein Z ' is corresponding to the value in the depth buffer.
III. the reconstruct of rasterizing three-dimensional scenic data.If the width of viewport is width ', highly is height ' to be obtained by OpenGL API related function.By the proportionate relationship of viewport and the hither plane coordinate P of three-dimensional rendering two field picture pixel " ' (X " ' arbitrarily as can be known, Y " ') corresponding to the three-dimensional coordinate Pn on the hither plane (xn, yn, zn); xn=(X " '-width '/2) * width/2 wherein, yn=(Y " '-height '/2) * height/2.Value Z ' in the corresponding depth buffer, by b as can be known, corresponding eye coordinates system Z value down is Z ' * (zFar-zNear)/zFar+zNear, can get the coordinate P of pixel under eye coordinates system (X, Y, Z), wherein X equals xNear/zNear*Z, and Y equals yNear/zNear*Z.
By calling color buffer district function and the depth buffer function in the video card of reading of OpenGL API, utilize coordinate system and the above-mentioned relation set up in the Step II, can obtain the eye coordinates system three-dimensional coordinate of all pixels down.All three-dimensional coordinates are coupled together with triangle surface, just constituted a three-dimensional surface that can carry out three-dimensional rendering, is playing up under the visual angle arbitrarily by the three-dimensional flow waterline on this surface.
Step (3) is utilized the three-dimensional scenic of step (2) reconstruct, generates two width of cloth images, forms stereogram.Generate stereogram and can adopt following two kinds of methods:
Method one. call 3D API, play up the contextual data that obtains in the step (2), original image as left visual point image situation under, generate right visual point image; Original image as right visual point image situation under, generate left visual point image; Do not preserving under the original image situation, generating left and right sides visual point image, thereby realizing that stereogram generates.
Method two. adopt rasterizing three-dimensional scenic data, make up the mapping relations of pixel under original visual space and the target visual space, the pixel under the original visual space is converted directly under the target visual space.Original image as left visual point image situation under, generate right visual point image; Original image as right visual point image situation under, generate left visual point image; Do not preserving under the original image situation, generating left and right sides visual point image, thereby realizing that stereogram generates fast.Wherein:
The viewpoint horizontal-shift is meant the change amount D of the new viewpoint original viewpoint of distance on X-direction x
The viewpoint vertical shift is meant the change amount D of the new viewpoint original viewpoint of distance on Z-direction z
Image pixel is offset, and is meant the additional offset D of the visual pixel level direction of generation Pixel
Then under another eye coordinates system, (the coordinate X that pixel Z) is marked under the left viewpoint is Width ' * (X-Dx)/(Z-Dz)+D for X, Y to primitive frame image mid point P Pixel, Y is Height ' * Y/ (Z-Dz).This pixel is under for right eye coordinates being, coordinate calculates according to the method described above, but Dx, Dz gets negative sign.
Each color of pixel is copied to the target location.Thereby two viewpoints are all used this method obtain stereogram.This method has without graphics pipeline, and program composition is simple, optimizes advantages such as easy.
The stereogram that step (4) generates step (3) is by display device output and carry out stereoscopy.The stereogram that the present invention generates is carried out true 3-D display in the following way:
X. the binocular solid of video card support shows.As supporting under the OpenGL environment of stereo display, creating the stereo display pattern that the equipment handle stage starts OpenGL, about being transported to respectively, the stereogram that generates in two buffer zones, realizes stereo display.Or
Y. on the video card of not supporting stereo display, stereogram is synthesized a width of cloth red and green complementary color stereo-picture, and an image from the stereogram of the left and right sides extracts red channel, extracts green and blue channel in another image, the passage that extracts is merged, form the stereo-picture of a complementary colors.And send original image buffer back to and carry out stereo display and observation.Or
Z. stereo-picture or picture are supported on the stereoscopic display device being transported to other.
Embodiment 2
A kind of implantation type true three-dimensional stereo rendering method towards AutoCAD and 3DS MAX software comprises the interception with minor function:
A. create the function of 3-D display environment, monitor this function, in the monitoring function, add system's detection function function of calling 3D API, obtain system's stereo display characteristic, according to corresponding stereo display characteristic, the stereo display pattern in the display environment of change original start is opened real tri-dimension and is shown support on the hardware of supporting stereo display, on the hardware of not supporting stereo display, sign is set so that carry out red green stereo display.
B. begin a frame and draw function, monitor this function, the adding code obtains the viewport size when the pre-plot frame in the monitoring function, is that stereogram is created interim buffer zone according to the pixel format of playing up.
D. frame buffer is outputed to the function of display device, monitor this function, add code to obtain each color of pixel and depth data in the entire frame at the monitoring function, the projective transformation matrix information of obtaining based on c, the three-dimensional coordinate of each pixel of inverse under eye coordinates system reconstructs the three-dimensional scenic based on the rasterizing of pixel;
E. the projection matrix information of obtaining based on c, the parameters of perspective projection in the inverse 3 D rendering, according to these parameters, rebuild the three-dimensional scenic of rasterizing, according to the stereoscopic vision model of eye, generation can be for the stereogram of stereo display.
Following implementation process is the concrete software decoding process of said method.
1. based on Detours API, under Windows XP platform based on Visual Studio 2005 set up based on based on the Win32DLL engineering StereoDriver_AutoDesk_OpenGL of C Plus Plus as the interception code skeleton.
2. define a data structure OpenGL_Stereo in StereoDriver_AutoDesk_OpenGL, this data structure comprises following content:
1) Windows drawing context variable hDC, type HDC;
2) OpenGL rendering context variable hGLRC, type HGLRC;
3) whether the current hardware of record supports the variable IsStereoSupport of stereo display, type bool;
4) the wide high variable width of record viewport, height, type int;
5) the variable ColorBuffer of buffer memory color data, type GLbyte*;
6) the variables D epthBuffer of buffer memory depth data, type GLfloat;
7) the variable MatrixMode of the current transformation matrix pattern of record, type GLMatrixMode
8) the variable Matrix of the current perspective projection matrix of record, type GLfloat[4] [4]
9) the chained list gOpenGL_Stereos that creates an overall situation preserves the pointer of OpenGL_Stereo structure.
10) the OpenGL_Stereo pointer Act iveOpenGL_Stereo of an overall situation of establishment is initialized as NULL.
3. realize monitoring based on Detours API as minor function:
1)wglCreateContext
WglCreateContext creates the rendering context of a corresponding OpenGL according to the setting of application program.Create monitoring function My_wglCreateContext, in wglCreateContext, be achieved as follows function:
Resolve the parameter of wglCreateContext, judge whether user program uses the PFD_STEREO mark to start the binary channels solid and play up support, plays up support if user program starts solid, illustrate that then user program support solid itself plays up.
If user program is not activated solid and plays up support, show that then user program do not support solid to play up, whether the inquiry user starts that implanted is three-dimensional to be supported.
If the user selects to enable and implants is three-dimensional the support, create the OpenGL_Stereo structure, and be kept in the global listings that comprises the OpenGLStereo structured fingers, and initialization.Use wglChoosePixelFormat function and PF_STEREO mark to inquire about current video card and whether support stereo display.If support stereo display then the IsStereoSupport of OpenGLStereo is set to true, otherwise be set to false.
Use original wglCreateContext to create HGLRC, and in OpenGLStereo, write down corresponding HDC and HGLRC, the OpenGLStereo structure is joined among the gOpenGL_Stereos.
2)wglMakeCurrent
WglMakeCurrent selects one as current active in some OpenGL rendering contexts, generally begin and finish the drafting of a frame after wglMakeCurrent.Create monitoring function My_wglMakeCurrent, in My_wglMakeCurrent, be achieved as follows function: when HDC parameter and HGLRC parameter during for NULL, the OpenGL_Stereo structure of from gOpenGL_Stereos, searching corresponding hDC and hGLRC with these two parameters, and assignment is given the ActiveOpenGL_Stereo variable.If two parameters are NULL, be NULL then with the ActiveOpenGL_Stereo assignment.
Call original wglMakeCurrent.
3)glViewport
GlViewport is set to assigned address and size with the viewport of the OpenGL rendering context of current active.Create monitoring function My_glViewport, in My_glViewport, be achieved as follows function:
If ActiveOpenGL_Stere is not empty, then judge the wide height of new viewport whether with ActiveOpenGL_Stereo in width, height equates.If original ColorBuffer and DepthBuffer internal memory among the unequal release OpenGL_Stereo; Wide high color buffer area ColorBuffer and the depth buffer district DepthBuffer of creating according to viewport; Write down new width and height.
Call original glViewport.
4)glMatrixMode
GlMatrixMode is provided with the active matrix model of current active OpenGL rendering context.Create monitoring function My_glMatrixMode, in My_glMatrixMode, be achieved as follows function:
If ActiveOpenGL_Stereo is not empty, then the MatrixMode of ActiveOpenGL_Stere is set to the parameter of glMatrixMode.
Call original glMatrixMode.
5)glLoadMatrixd,glLoadMatrixf
GlLoadMatrix is provided with matrix for movable OpenGL plays up current matrix pattern up and down.Create monitoring function My_glMLoadMatrix, in My_glLoadMatrix, be achieved as follows function:
If ActiveOpenGL_Stereo is not empty, and its variable MatrixMode equals GL_PROJECTION, and the m variable that then writes down this function is in the Matrix of ActiveOpenGL_Stere.
Call original glLoadMatrix function.
6)SwapBuffers
This function outputs to the frame that OpenGL plays up on the display device from video memory.Create monitoring function My_SwapBuffers, in this function, be achieved as follows function:
If ActiveOpenGL_Stereo is not empty, call the glReadPixels function, from the color buffer district, read the ColorBuffer variable of color with GL_RGB to ActiveOpenGL_Stereo; Call the glReadPixels function with the GL_DEPTH_COMPONENT parameter, read depth value in the DepthBuffer of ActiveOpenGL_Stereo.
From the Matrix variable of ActiveOpenGL_Stereo, obtain the width width of the hither plane of perspective projection, height height, and the zNear of hither plane and far plane zFar.
According to the width ViewPortWidth and the ViewPortHeight of the viewport that writes down among the ActiveOpenGL_Stereo, create interim color buffer district, ColorBufferLeft and ColorBufferRight.
From being provided with, the user obtains viewpoint horizontal-shift D x, viewpoint vertical shift D zWith pixel-shift D PixelSet up a circulation,, take out corresponding pixel coordinate iX, the depth value among the DepthBuffer of iY and color RGB and correspondence each ColorBuffer pixel.Coordinate P in the eye coordinates system of pixel correspondence (X, Y, Z).To left eye with D x, D z, D PixelBe parameter, by generating the projection matrix and the wide height of viewport of three-dimensional rendering output, calculate the color and the depth data of the output of three-dimensional rendering key control parameter (viewpoint position, hither plane, far plane) and three-dimensional rendering, and then calculate the three-dimensional coordinate of each pixel in the visual space and corresponding color characteristics, the three-dimensional scenic data of rasterizing under the reconstruct visual space, the pixel coordinate P of calculating P correspondence LeIIItTo right eye with-D x,-D z,-D PixelBe parameter, by generating the projection matrix and the wide height of viewport of three-dimensional rendering output, calculate the color and the depth data of the output of three-dimensional rendering key control parameter (viewpoint position, hither plane, far plane) and three-dimensional rendering, and then calculate the three-dimensional coordinate of each pixel in the visual space and corresponding color characteristics, the three-dimensional scenic data of rasterizing under the reconstruct visual space, the right pixel coordinate P of calculating P correspondence RightThe color difference assignment of current pixel is given the P of ColorBufferLeft LeIIItThe P of position and ColorBufferRight RightThe position.
Whether the IsStereoSupport that judges ActiveOpenGL_Stere is true.If be true, call glDrawPixels and respectively the content among ColorBufferLef and the ColorBufferRight is copied among GL_BACK_LEFT and the GL_BACK_RIGT.Otherwise with the G among the ColorBufferRight, B passage assignment is to the G of ColorBufferLeft respective pixel, and the B passage gets on, and forms a red green solid, and the content of ColorBufferLeft is copied among the GL_BACK.
Call original SwapBuffer.
4. compiling StereoDriver_AutoDesk_OpenGL engineering generates the StereoDriver_AutoDesk_OpenGL.DLL file
5. with the withdll.Exe order line startup corresponding program of StereoDriver_AutoDesk_OpenGL.DLL file by detours SDK.

Claims (10)

1, towards the implantation type true three-dimensional stereo rendering method of AutoCAD and 3DS MAX software, it is characterized in that this method may further comprise the steps:
Data interception is monitored and played up to step (1) at the 3D API OpenGL of AutoCAD and 3DS MAX use;
Step (2) is utilized scene change matrix and projective transformation matrix reconstructing grid three-dimensional data;
Step (3) self-adaptation screen resolution and people's eye cardinal distance is set two different viewpoint positions and is generated stereogram;
Step (4) is carried out true three-dimensional observation at different stereoscopy equipment.
2, true-three-dimensional stereo rendering method according to claim 1 is characterized in that, described true-three-dimensional stereo rendering method further comprises the following steps, the following step in no particular order:
A. the function of 3-D display environment is created in monitoring, in this function, add system's detection function function of calling 3D API, obtain system's stereo display characteristic, according to corresponding stereo display characteristic, stereo display pattern in the display environment of change original start, on the hardware of supporting stereo display, open real tri-dimension and show support, on the hardware of not supporting stereo display, sign is set so that carry out red green stereo display;
B. monitoring begins the function that a frame is drawn, and the adding code obtains the viewport size when the pre-plot frame in this function, is that stereogram is created interim buffer zone according to the pixel format of playing up;
C. monitoring changes the function of current drafting matrix, in this function, add code to obtain of the change of three-dimensional applications software, by the projection type of matrix parameter identification scene rendering, when being perspective projection to current drafting matrix, write down this matrix, as the key parameter of three-dimensional scenic reconstruct;
D. monitor the function that frame buffer is outputed to display device, add code to obtain each color of pixel and depth data in the entire frame at the monitoring function, the projective transformation matrix information of obtaining based on step c, the three-dimensional coordinate of each pixel of inverse under eye coordinates system reconstructs the three-dimensional scenic based on the rasterizing of pixel; According to the stereoscopic vision model of eye, generation can be for the stereogram of stereo display.
3, true-three-dimensional stereo rendering method according to claim 1, it is characterized in that, in the described step (1) monitoring of OpenGL API with play up data interception and further comprise: utilize API interception technology, obtain the output of 3 D rendering correlation matrix and three-dimensional rendering data, extract the wide height of projection matrix, viewport of realizing the three-dimensional perspective conversion, as the key parameter of three-dimensional scenic reconstruct; Utilize the specific function of 3D API, the output of interception three-dimensional rendering is extracted color and depth data in the video card frame buffer, as the basis of three-dimensional scenic reconstruct.
4, true-three-dimensional stereo rendering method according to claim 1, it is characterized in that, also further comprise the concrete steps that realize the interception of 3D api function at it in the described step (1): inject or/and the Hook Function technology is write specific hook procedure by code, in the data load stage of three-dimensional visualization program, 3D API hook procedure is loaded in the process of three-dimensional visualization program, thus interception and monitoring 3D API Calls.
5, true-three-dimensional stereo rendering method according to claim 1, it is characterized in that, described step (2) further comprises the following steps: by generating the projection matrix and the wide height of viewport of three-dimensional rendering output, calculate the color and the depth data of the output of three-dimensional rendering key control parameter and three-dimensional rendering, and then calculate the three-dimensional coordinate of each pixel in the visual space and corresponding color characteristics, the three-dimensional scenic data of rasterizing under the reconstruct visual space.
6, true-three-dimensional stereo rendering method according to claim 1 is characterized in that, described step (2) further comprises following steps:
I. the identification of perspective projection transformation matrix: suppose that the perspective projection transformation matrix is consistent in the render process of a frame, perspective projection matrix is tackled, the eigenwert in the matrix as criterion, is judged whether the matrix of current interception is perspective projection matrix;
II. setting up viewpoint is the three dimensional space coordinate system of true origin: the perspective projection transformation matrix of intercepting and capturing with step I is a parameter, foundation is the view coordinate system of true origin with the power pin: the Z axle passes the center of hither plane, the X-axis of the Y-axis of hither plane and X-direction and this coordinate system, Y direction unanimity, hither plane are positioned on the scale of Z axle of hither plane value correspondence; The codomain of X is [width/2, width/2] on the hither plane, and the codomain of Y is [height/2, height/2]; In this coordinate system, (X, Y Z) are tried to achieve by the perspective projection matrix conversion with the coordinate figure P ' of the intersection point of hither plane (X ', Y ', Z ') arbitrary coordinate point P, and wherein Z ' is corresponding to the depth value in the frame depth buffer, X '=width/2*X/Z; Y '=height/2*Y/Z; Z '=(z-zNear)/z*zFar/ (zFar-zNear), wherein Z ' is corresponding to the value in the depth buffer;
III. the reconstruct of rasterizing three-dimensional scenic data: the width of establishing viewport is width ', highly for height ', the coordinate P of any three-dimensional rendering two field picture pixel " ' (X " ', Y " ') corresponding to the three-dimensional coordinate Pn on the hither plane (xn; yn; zn); xn=(X " '-width '/2) * width/2 wherein, yn=(Y " '-height '/2) * height/2; Value Z ' in the corresponding depth buffer, corresponding eye coordinates system is Z=Z ' * (zFar-zNear)/zFar+zNear down, the coordinate of pixel under eye coordinates system be P (X, Y, Z), X=xNear/zNear*Z wherein, Y=yNear/zNear*Z; All three-dimensional coordinates are coupled together with triangle surface, just constituted a three-dimensional surface that can carry out three-dimensional rendering.
7, true-three-dimensional stereo rendering method according to claim 1, it is characterized in that the method that generates space image in the described step (3) is: call 3D API, play up the contextual data that obtains in the described step (2), original image as left visual point image situation under, generate right visual point image; Original image as right visual point image situation under, generate left visual point image; Do not preserving under the original image situation, generating left and right sides visual point image, thereby realizing that stereogram generates.
8, true-three-dimensional stereo rendering method according to claim 1, it is characterized in that, the method that generates space image in the described step (3) is: adopt rasterizing three-dimensional scenic data, make up the mapping relations of pixel under original visual space and the target visual space, the pixel under the original visual space is converted directly under the target visual space; Original image as left visual point image situation under, generate right visual point image; Original image as right visual point image situation under, generate left visual point image; Do not preserving under the original image situation, generating left and right sides visual point image, thereby realizing that stereogram generates fast.
9, true-three-dimensional stereo rendering method according to claim 1 is characterized in that, at different demonstrations and scope, carries out stereo display and observation in the described step (4), comprising:
X. on the equipment of supporting stereo display, stereogram is outputed to two passages about video card respectively, carry out stereo display; Or
Y. on the equipment of not supporting stereo display, in stereogram, an image extracts red channel, and another image extracts green and blue channel, and the passage that extracts is merged, and forms the stereo-picture of a complementary colors, and supports mycyscope to observe; Or
Z. stereo-picture or picture are supported on the stereoscopic display device being transported to other.
10, true-three-dimensional stereo rendering method according to claim 1 is characterized in that, the 3D api function of described interception comprises:
(21) 3D API creates the function of 3-D display environment;
(22) 3D API begins the function of a frame scene rendering;
(23) 3D API changes the current function of playing up matrix;
(24) 3D API finishes the function of a frame scene rendering;
(25) 3D API will play up data and output to function on the current screen.
CN200910025518XA 2009-02-06 2009-02-06 Built-in real tri-dimension rendering process oriented to AutoCAD and 3DS MAX Expired - Fee Related CN101477701B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200910025518XA CN101477701B (en) 2009-02-06 2009-02-06 Built-in real tri-dimension rendering process oriented to AutoCAD and 3DS MAX

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200910025518XA CN101477701B (en) 2009-02-06 2009-02-06 Built-in real tri-dimension rendering process oriented to AutoCAD and 3DS MAX

Publications (2)

Publication Number Publication Date
CN101477701A true CN101477701A (en) 2009-07-08
CN101477701B CN101477701B (en) 2012-08-15

Family

ID=40838409

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200910025518XA Expired - Fee Related CN101477701B (en) 2009-02-06 2009-02-06 Built-in real tri-dimension rendering process oriented to AutoCAD and 3DS MAX

Country Status (1)

Country Link
CN (1) CN101477701B (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101916316A (en) * 2010-08-20 2010-12-15 镇江科大船苑计算机网络工程有限公司 Scutcheon scale value drawing method
CN102157014A (en) * 2011-04-13 2011-08-17 西安理工大学 Method for three-dimensional visualization of comprehensive pipeline of metro
CN102157012A (en) * 2011-03-23 2011-08-17 深圳超多维光电子有限公司 Method for three-dimensionally rendering scene, graphic image treatment device, equipment and system
CN102722376A (en) * 2012-06-25 2012-10-10 苏州科达科技有限公司 Method for secondary encoding and decoding based on video monitoring drawing and device thereof
CN102831649A (en) * 2012-09-03 2012-12-19 江苏科技大学 Layered rendering method
CN104299258A (en) * 2013-07-15 2015-01-21 超威半导体(上海)有限公司 Solid figure processing method and equipment
CN104463955A (en) * 2014-11-19 2015-03-25 长江大学 Geological model display method based on shutter type 3D technology
CN107481307A (en) * 2017-07-05 2017-12-15 国网山东省电力公司泰安供电公司 A kind of method of Fast rendering three-dimensional scenic
CN108064447A (en) * 2017-11-29 2018-05-22 深圳前海达闼云端智能科技有限公司 Method for displaying image, intelligent glasses and storage medium
CN111667906A (en) * 2020-06-15 2020-09-15 上海交通大学医学院附属仁济医院 Eyeball structure virtual teaching system and digital model establishing method thereof
CN113473226A (en) * 2021-08-09 2021-10-01 深圳软牛科技有限公司 Method and device for improving video rendering efficiency, computer equipment and storage medium

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101916316A (en) * 2010-08-20 2010-12-15 镇江科大船苑计算机网络工程有限公司 Scutcheon scale value drawing method
CN102157012A (en) * 2011-03-23 2011-08-17 深圳超多维光电子有限公司 Method for three-dimensionally rendering scene, graphic image treatment device, equipment and system
CN102157012B (en) * 2011-03-23 2012-11-28 深圳超多维光电子有限公司 Method for three-dimensionally rendering scene, graphic image treatment device, equipment and system
CN102157014A (en) * 2011-04-13 2011-08-17 西安理工大学 Method for three-dimensional visualization of comprehensive pipeline of metro
CN102157014B (en) * 2011-04-13 2013-01-16 西安理工大学 Method for three-dimensional visualization of comprehensive pipeline of metro
CN102722376B (en) * 2012-06-25 2015-04-08 苏州科达科技股份有限公司 Method for secondary encoding and decoding based on video monitoring drawing and device thereof
CN102722376A (en) * 2012-06-25 2012-10-10 苏州科达科技有限公司 Method for secondary encoding and decoding based on video monitoring drawing and device thereof
CN102831649A (en) * 2012-09-03 2012-12-19 江苏科技大学 Layered rendering method
CN104299258A (en) * 2013-07-15 2015-01-21 超威半导体(上海)有限公司 Solid figure processing method and equipment
CN104463955A (en) * 2014-11-19 2015-03-25 长江大学 Geological model display method based on shutter type 3D technology
CN107481307A (en) * 2017-07-05 2017-12-15 国网山东省电力公司泰安供电公司 A kind of method of Fast rendering three-dimensional scenic
CN108064447A (en) * 2017-11-29 2018-05-22 深圳前海达闼云端智能科技有限公司 Method for displaying image, intelligent glasses and storage medium
CN111667906A (en) * 2020-06-15 2020-09-15 上海交通大学医学院附属仁济医院 Eyeball structure virtual teaching system and digital model establishing method thereof
CN111667906B (en) * 2020-06-15 2024-02-13 上海交通大学医学院附属仁济医院 Eyeball structure virtual teaching system and digital model building method thereof
CN113473226A (en) * 2021-08-09 2021-10-01 深圳软牛科技有限公司 Method and device for improving video rendering efficiency, computer equipment and storage medium
CN113473226B (en) * 2021-08-09 2023-02-14 深圳软牛科技有限公司 Method and device for improving video rendering efficiency, computer equipment and storage medium

Also Published As

Publication number Publication date
CN101477701B (en) 2012-08-15

Similar Documents

Publication Publication Date Title
CN101477701B (en) Built-in real tri-dimension rendering process oriented to AutoCAD and 3DS MAX
CN101477700B (en) Real tri-dimension display method oriented to Google Earth and Sketch Up
CN101477702B (en) Built-in real tri-dimension driving method for computer display card
CN101635061B (en) Adaptive three-dimensional rendering method based on mechanism of human-eye stereoscopic vision
US20110273444A1 (en) System and method for displaying selected garments on a computer-simulated mannequin
CN102819855B (en) The generation method of two dimensional image and device
CN101521828B (en) Implanted type true three-dimensional rendering method oriented to ESRI three-dimensional GIS module
CN101540056B (en) Implanted true-three-dimensional stereo rendering method facing to ERDAS Virtual GIS
Gimeno et al. Multiuser augmented reality system for indoor exhibitions
CN101511034A (en) Truly three-dimensional stereo display method facing Skyline
CN101488229B (en) PCI three-dimensional analysis module oriented implantation type ture three-dimensional stereo rendering method
CN116958344A (en) Animation generation method and device for virtual image, computer equipment and storage medium
CN106204703A (en) Three-dimensional scene models rendering intent and device
RU2295772C1 (en) Method for generation of texture in real time scale and device for its realization
CN101482978B (en) ENVI/IDL oriented implantation type true three-dimensional stereo rendering method
CN108876921B (en) Three-dimensional decorating model processing method and device, computer equipment and storage medium
JP2020532022A (en) Sphere light field rendering method in all viewing angles
CN101488232B (en) Implanted true three-dimension volumetric display method oriented to C Tech software
CN101488230B (en) VirtualEarth oriented ture three-dimensional stereo display method
CN101561935B (en) GoCAD software-oriented implanted true three-dimensional display method
CN101561936B (en) GeoGlobe-oriented true three-dimensional stereoscopic display method
CN101482977B (en) Microstation oriented implantation type true three-dimensional stereo display method
CN101488231B (en) Creator software oriented implantation type true three-dimensional stereo display method
JP2023153534A (en) Image processing apparatus, image processing method, and program
CN113313796A (en) Scene generation method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20120815

Termination date: 20150206

EXPY Termination of patent right or utility model