1 
2 /*
3 A* -------------------------------------------------------------------
4 B* This file contains source code for the PyMOL computer program
5 C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
6 D* -------------------------------------------------------------------
7 E* It is unlawful to modify or remove this copyright notice.
8 F* -------------------------------------------------------------------
9 G* Please see the accompanying LICENSE file for further information.
10 H* -------------------------------------------------------------------
11 I* Additional authors of this source file include:
12 -*
13 -*
14 -*
15 Z* -------------------------------------------------------------------
16 */
17 #ifndef _H_Ray
18 #define _H_Ray
19 
20 #include <memory>
21 #include <vector>
22 
23 #include"Base.h"
24 #include"Basis.h"
25 #include"PyMOLGlobals.h"
26 #include"Image.h"
27 
28 #define cRayMaxBasis 10
29 
30 typedef struct _CRayAntiThreadInfo CRayAntiThreadInfo;
31 typedef struct _CRayHashThreadInfo CRayHashThreadInfo;
32 typedef struct _CRayThreadInfo CRayThreadInfo;
33 
34 CRay *RayNew(PyMOLGlobals * G, int antialias);
35 void RayFree(CRay * I);
36 void RayPrepare(CRay * I, float v0, float v1, float v2,
37                 float v3, float v4, float v5,
38                 float fov, float *pos,
39                 float *mat, float *rotMat,
40                 float aspRat, int width, int height,
41                 float pixel_scale, int ortho, float pixel_ratio,
42                 float back_ratio, float magnified);
43 void RayRender(CRay * I, unsigned int *image,
44                double timing, float angle, int antialias, unsigned int *return_bg);
45 void RayRenderPOV(CRay * I, int width, int height, char **headerVLA,
46                   char **charVLA, float front, float back, float fov, float angle,
47                   int antialias);
48 
49 void RayRenderIDTF(CRay * I, char **node_vla, char **rsrc_vla);
50 
51 void RayRenderVRML1(CRay * I, int width, int height,
52                     char **vla_ptr, float front, float back,
53                     float fov, float angle, float z_corr);
54 void RayRenderVRML2(CRay * I, int width, int height,
55                     char **vla_ptr, float front, float back,
56                     float fov, float angle, float z_corr);
57 void RayRenderCOLLADA(CRay * I, int width, int height,
58                     char **vla_ptr, float front, float back, float fov);
59 void RayRenderObjMtl(CRay * I, int width, int height, char **objVLA_ptr,
60                      char **mtlVLA_ptr, float front, float back, float fov,
61                      float angle, float z_corr);
62 void RayRenderTest(CRay * I, int width, int height, float front, float back, float fov);
63 void RaySetTTT(CRay * I, int flag, float *ttt);
64 void RayGetTTT(CRay * I, float *ttt);
65 void RayPushTTT(CRay * I);
66 void RayPopTTT(CRay * I);
67 void RaySetContext(CRay * I, int context);
68 void RayRenderColorTable(CRay * I, int width, int height, int *image);
69 int RayTraceThread(CRayThreadInfo * T);
70 int RayGetNPrimitives(CRay * I);
71 void RayGetScaledAxes(CRay * I, float *xn, float *yn);
72 
73 int RayHashThread(CRayHashThreadInfo * T);
74 int RayAntiThread(CRayAntiThreadInfo * T);
75 
76 // JMS: added so they can be used in COLLADA.c
77 int RayExpandPrimitives(CRay * I);
78 int RayTransformFirst(CRay * I, int perspective, int identity);
79 void RayComputeBox(CRay * I);
80 int TriangleReverse(CPrimitive * p);
81 
82 
83 typedef struct {
84   int op;
85   int x1, y1, z1;
86   int x2, y2, z2;
87   int x3, y3, z3;
88   int c;
89   int r;
90 } G3dPrimitive;
91 
92 G3dPrimitive *RayRenderG3d(CRay * I, int width, int height, float front,
93                            float back, float fov, int quiet);
94 
95 namespace cgo{
96 namespace draw{
97   struct cylinder;
98   struct custom_cylinder;
99   struct custom_cylinder_alpha;
100 }
101 };
102 
103 struct _CRay {
104 
105   // methods
106   int sphere3fv(const float *v, float r);
107   int cylinder3fv(const cgo::draw::cylinder &cyl);
108   int cylinder3fv(const cgo::draw::cylinder &cyl, const float alpha1, const float alpha2);
109   int customCylinder3fv(const cgo::draw::custom_cylinder &cyl, const float alpha1, const float alpha2);
110   int customCylinder3fv(const cgo::draw::custom_cylinder &cyl);
111   int customCylinder3fv(const float *v1, const float *v2, float r, const float *c1,
112                         const float *c2, const int cap1, const int cap2,
113                         const float alpha1, const float alpha2);
114   int customCylinder3fv(const float *v1, const float *v2, float r, const float *c1,
115                         const float *c2, const int cap1, const int cap2);
116   int customCylinderAlpha3fv(const cgo::draw::custom_cylinder_alpha &cyl);
117   int cone3fv(const float *v1, const float *v2, float r1, float r2, const float *c1,
118 		   const float *c2, int cap1, int cap2);
119   int sausage3fv(const float *v1, const float *v2, float r, const float *c1, const float *c2);
120   void color3fv(const float *c);
121   int triangle3fv(
122 		       const float *v1, const float *v2, const float *v3,
123 		       const float *n1, const float *n2, const float *n3, const float *c1, const float *c2, const float *c3);
124   int triangleTrans3fv(
125 			    const float *v1, const float *v2, const float *v3,
126 			    const float *n1, const float *n2, const float *n3,
127 			    const float *c1, const float *c2, const float *c3,
128 			    float t1, float t2, float t3);
129   void wobble(int mode, const float *par);
130   void transparentf(float t);
131   int character(int char_id);
132   void interiorColor3fv(const float *v, int passive);
133   int ellipsoid3fv(const float *v, float r, const float *n1, const float *n2, const float *n3);
134   int setLastToNoLighting(char no_lighting);
135 
136   /* everything below should be private */
137   PyMOLGlobals *G;
138   CPrimitive *Primitive;
139   int NPrimitive;
140   CBasis *Basis;
141   int NBasis;
142   int *Vert2Prim;
143   float CurColor[3], IntColor[3];
144   float ModelView[16];
145   float ProMatrix[16];
146   float Rotation[16];
147   float Volume[6];
148   float Range[3];
149   int BigEndian;
150   int Wobble;
151   float WobbleParam[3];
152   float Trans;
153   float Random[256];
154   int TTTFlag;
155   float TTT[16];
156   float *TTTStackVLA;
157   int TTTStackDepth;
158   int Context;
159   int CheckInterior;
160   float AspRatio;
161   int Width, Height;
162   float PixelRadius;
163   int Ortho;
164   float min_box[3];
165   float max_box[3];
166   int Sampling;
167   float PixelRatio;
168   float Magnified;              /* ray pixels to screen pixels */
169   float FrontBackRatio;
170   double PrimSize;
171   int PrimSizeCnt;
172   float Fov, Pos[3];
173   std::shared_ptr<pymol::Image> bkgrd_data;
174 
175 private:
176   int cylinder3fv(const float *v1, const float *v2, float r, const float *c1, const float *c2,
177                   const float alpha1, const float alpha2);
178 };
179 
180 void RayGetScreenVertex(CRay * I, float *v, float *dest);
181 float RayGetScreenVertexScale(CRay * I, float *v1);
182 void RayAdjustZtoScreenZ(CRay * ray, float *pos, float z);
183 void RayAdjustZtoScreenZofPoint(CRay * ray, float *pos, float *zpoint);
184 void RaySetPointToWorldScreenRelative(CRay * ray, float *pos, float *screenPt);
185 float RayGetScaledAllAxesAtPoint(CRay * I, float *pt, float *xn, float *yn, float *zn);
186 float* RayGetProMatrix(CRay * I);
187 
188 #endif
189