1 /**********
2 *
3 * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
4 * University of Manchester, UK. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 *
9 * . Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * . Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 *
16 * . Neither the name of the University of Manchester nor the names of its
17 * contributors may be used to endorse or promote products derived from this
18 * software without specific prior written permission.
19 *
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
33 **********
34 *
35 * Program : TINA
36 * File : $Source: /home/tina/cvs/tina-tools/tinatool/tlbase/tlbaseSter_thrd.c,v $
37 * Date : $Date: 2009/03/24 12:58:52 $
38 * Version : $Revision: 1.6 $
39 * CVS Id : $Id: tlbaseSter_thrd.c,v 1.6 2009/03/24 12:58:52 paul Exp $
40 *
41 * Author : Legacy TINA
42 *
43 * Notes :
44 *
45 *********
46 */
47
48 #include "tlbaseSter_thrd.h"
49
50 #if HAVE_CONFIG_H
51 #include <config.h>
52 #endif
53
54 #include <stdio.h>
55
56 #include <tina/sys/sysDef.h>
57 #include <tina/sys/sysPro.h>
58 #include <tina/math/mathDef.h>
59 #include <tina/math/mathPro.h>
60 #include <tina/geometry/geomGen_hull.h>
61
62 #include <tinatool/draw/drawDef.h>
63 #include <tinatool/draw/drawPro.h>
64 #include <tinatool/tlbase/tlbase_InfrDef.h>
65 #include <tinatool/tlbase/tlbase_InfrPro.h>
66
67 static Bool geom_on = true;
68 static Bool surface_on;
69 static Bool ground_on;
70
71 void threed_geom_on(Bool on)
72 {
73 geom_on = on;
74 }
75
76 void threed_surface_on(Bool on)
77 {
78 surface_on = on;
79 }
80
81 void threed_ground_on(Bool on)
82 {
83 ground_on = on;
84 }
85
86 static Vec3 centre = {Vec3_id};
87 static double radius = 1000.0;
88
89 void threed_fulldraw(Tv * tv)
90 {
91 List *geom = threed_geom_get();
92 List *surface = threed_surface_get();
93
94 tv_screen_double_buffer_start(tv->tv_screen);
95
96 if (geom_on && (geom != NULL))
97 reclist_list_draw(tv, geom, 0, geom_col_draw, NULL);
98 if (surface_on && (surface != NULL))
99 {
100 double z;
101
102 z = vec3_dot(centre, tv->ez3);
103 tv_set_zbuff(tv, z - 5 * radius, z + 5 * radius);
104
105 reclist_list_draw(tv, surface, CONE, zbuff_shade_cone, NULL);
106 }
107
108 tv_screen_double_buffer_end(tv->tv_screen);
109 }
110
111 void threed_tv_set_zbuff(Tv * tv)
112 {
113 double z;
114
115 z = vec3_dot(centre, tv->ez3);
116 tv_set_zbuff(tv, z - 5 * radius, z + 5 * radius);
117 }
118
119 static void threed_init(Tv * tv)
120 {
121 Vec3 aim = {Vec3_id};
122 Vec3 down = {Vec3_id};
123 double pscale;
124 List *geom = threed_geom_get();
125
126 (void) tv_set_zoomlevel(tv, ZOOM3);
127
128 if (geom == NULL)
129 return;
130
131 geom_hull_get(geom, ¢re, &radius);
132 pscale = 3.0;
133 aim = vec3_ez();
134 down = vec3_ey();
135 tv_camera3(tv, centre, radius, pscale, aim, down);
136 }
137
138 void threed_skeldraw(Tv * tv)
139 {
140 List *geom = threed_geom_get();
141 int old_sample = curve_draw_sample_get();
142
143 if (tv == NULL)
144 return;
145
146 tv_screen_double_buffer_start(tv->tv_screen);
147
148 curve_draw_sample_set(MAX(tv->height, tv->width) / 10);
149 if (geom_on && (geom != NULL))
150 reclist_list_draw(tv, geom, 0, geom_draw, NULL);
151 curve_draw_sample_set(old_sample);
152
153 tv_screen_double_buffer_end(tv->tv_screen);
154 }
155
156 Tv *threed_tv_make(void)
157 {
158 Tv *tv3d = NULL;
159
160 centre = vec3(0.0, 0.0, 0.0);
161
162 tv3d = tv_create("threed");
163 (void) tv_set_fulldraw(tv3d, threed_fulldraw);
164 (void) tv_set_skeldraw(tv3d, threed_skeldraw);
165 tv_set_init(tv3d, threed_init);
166 tv_init(tv3d);
167 return (tv3d);
168 }
169
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.