1 /*
2  * NodeScalarInterpolator.cpp
3  *
4  * Copyright (C) 1999 Stephen F. White
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program (see the file "COPYING" for details); if
18  * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19  * Cambridge, MA 02139, USA.
20  */
21 
22 #include <stdio.h>
23 #include "stdafx.h"
24 
25 #include "NodeScalarInterpolator.h"
26 #include "Proto.h"
27 #include "FieldValue.h"
28 #include "MFFloat.h"
29 #include "SFFloat.h"
30 
31 
ProtoScalarInterpolator(Scene * scene)32 ProtoScalarInterpolator::ProtoScalarInterpolator(Scene *scene)
33   : ProtoInterpolator(scene, "ScalarInterpolator", SFFLOAT, MFFLOAT,
34                       new MFFloat())
35 {
36 }
37 
38 Node *
create(Scene * scene)39 ProtoScalarInterpolator::create(Scene *scene)
40 {
41     return new NodeScalarInterpolator(scene, this);
42 }
43 
NodeScalarInterpolator(Scene * scene,Proto * def)44 NodeScalarInterpolator::NodeScalarInterpolator(Scene *scene, Proto *def)
45   : Interpolator(scene, def)
46 {
47 }
48 
49 FieldValue *
createKey(void * value) const50 NodeScalarInterpolator::createKey(void *value) const
51 {
52     FieldValue *r = new SFFloat(((float *)value)[0]);
53     return r;
54 }
55 
56 FieldValue *
createKeys(void * value,int numKeys) const57 NodeScalarInterpolator::createKeys(void *value, int numKeys) const
58 {
59     return new MFFloat((float *)value, numKeys);
60 }
61