1 /*! ========================================================================
4 ** $Id: insideout.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $
6 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
8 ** This software and associated documentation
9 ** are CONFIDENTIAL and PROPRIETARY property of
10 ** the above-mentioned copyright holder.
12 ** You may not copy, print, publish, or in any
13 ** other way distribute this software without
14 ** a prior written agreement with
15 ** the copyright holder.
17 ** === N O T E S ===========================================================
19 ** ========================================================================= */
21 /* === H E A D E R S ======================================================= */
30 #include "insideout.h"
32 #include <sinfg/string.h>
33 #include <sinfg/time.h>
34 #include <sinfg/context.h>
35 #include <sinfg/paramdesc.h>
36 #include <sinfg/renddesc.h>
37 #include <sinfg/surface.h>
38 #include <sinfg/value.h>
39 #include <sinfg/valuenode.h>
40 #include <sinfg/transform.h>
44 /* === M A C R O S ========================================================= */
46 /* === G L O B A L S ======================================================= */
48 SINFG_LAYER_INIT(InsideOut);
49 SINFG_LAYER_SET_NAME(InsideOut,"inside_out");
50 SINFG_LAYER_SET_LOCAL_NAME(InsideOut,_("InsideOut"));
51 SINFG_LAYER_SET_CATEGORY(InsideOut,_("Distortions"));
52 SINFG_LAYER_SET_VERSION(InsideOut,"0.1");
53 SINFG_LAYER_SET_CVS_ID(InsideOut,"$Id: insideout.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $");
55 /* === P R O C E D U R E S ================================================= */
57 /* === M E T H O D S ======================================================= */
59 InsideOut::InsideOut():
65 InsideOut::set_param(const String & param, const ValueBase &value)
72 InsideOut::get_param(const String & param)const
83 InsideOut::hit_check(sinfg::Context context, const sinfg::Point &p)const
86 Real inv_mag=pos.inv_mag();
87 Point invpos(pos*inv_mag*inv_mag);
88 return context.hit_check(invpos+origin);
92 InsideOut::get_color(Context context, const Point &p)const
95 Real inv_mag=pos.inv_mag();
96 Point invpos(pos*inv_mag*inv_mag);
97 return context.get_color(invpos+origin);
100 class InsideOut_Trans : public Transform
102 etl::handle<const InsideOut> layer;
104 InsideOut_Trans(const InsideOut* x):layer(x) { }
106 sinfg::Vector perform(const sinfg::Vector& x)const
108 Point pos(x-layer->origin);
109 Real inv_mag=pos.inv_mag();
111 return (pos*(inv_mag*inv_mag)+layer->origin);
115 sinfg::Vector unperform(const sinfg::Vector& x)const
117 Point pos(x-layer->origin);
118 Real inv_mag=pos.inv_mag();
120 return (pos*(inv_mag*inv_mag)+layer->origin);
124 etl::handle<Transform>
125 InsideOut::get_transform()const
127 return new InsideOut_Trans(this);
131 InsideOut::get_param_vocab()const
135 ret.push_back(ParamDesc("origin")
136 .set_local_name(_("Origin"))
137 .set_description(_("Defines the where the center will be"))