⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 typeomatic.cpp.in

📁 学习 open inventor 的例子
💻 IN
📖 第 1 页 / 共 4 页
字号:
/**************************************************************************\ * *  This file is part of a set of example programs for the Coin library. *  Copyright (C) 2000-2003 by Systems in Motion. All rights reserved. * *                   <URL:http://www.coin3d.org> * *  This sourcecode can be redistributed and/or modified under the *  terms of the GNU General Public License version 2 as published by *  the Free Software Foundation. See the file COPYING at the root *  directory of the distribution for more details. * *  As a special exception, all sourcecode of the demo examples can be *  used for any purpose for licensees of the Coin Professional *  Edition License, without the restrictions of the GNU GPL. See our *  web pages for information about how to acquire a Professional Edition *  License. * *  Systems in Motion, <URL:http://www.sim.no>, <mailto:support@sim.no> *\**************************************************************************/// Written by Lars J. Aas <larsa@sim.no>#include <Inventor/@Gui@/So@Gui@.h>#include <Inventor/@Gui@/viewers/So@Gui@ExaminerViewer.h>#include <Inventor/SoDB.h>#include <Inventor/SoInput.h>#include <Inventor/errors/SoDebugError.h>#include <Inventor/nodes/SoCallback.h>#include <Inventor/nodes/SoPerspectiveCamera.h>#include <Inventor/nodes/SoSwitch.h>#include <Inventor/actions/SoSearchAction.h>#include <Inventor/actions/SoCallbackAction.h>#include <Inventor/actions/SoHandleEventAction.h>#include <Inventor/events/SoMouseButtonEvent.h>#include <stdlib.h>#include <stdio.h>#include <assert.h>#include <strutils.h>#include <Inventor/nodes/SoGroup.h>#include <Inventor/fields/SoMFBool.h>#include <Inventor/nodes/SoSubNode.h>class Switchboard : public SoGroup {  typedef SoGroup inherited;  SO_NODE_HEADER(Switchboard);public:  static void initClass(void);  Switchboard(void);  Switchboard(int numchildren);  SoMFBool enable;  virtual void doAction(SoAction * action);  virtual void callback(SoCallbackAction * action);  virtual void GLRender(SoGLRenderAction * action);  virtual void pick(SoPickAction * action);  virtual void getBoundingBox(SoGetBoundingBoxAction * action);  virtual void handleEvent(SoHandleEventAction * action);  virtual void getMatrix(SoGetMatrixAction * action);  virtual void search(SoSearchAction * action);protected:  virtual ~Switchboard(void);};#include <Inventor/fields/SoMFEnum.h>#include <Inventor/fields/SoMFInt32.h>#include <Inventor/events/SoKeyboardEvent.h>class SwitchboardOperator : public Switchboard {  typedef Switchboard inherited;  SO_NODE_HEADER(SwitchboardOperator);public:  static void initClass(void);  SwitchboardOperator(void);  SwitchboardOperator(int numchildren);  enum Behavior {    NONE, TOGGLE, HOLD, INVERSE_HOLD, TIME_HOLD  };  enum Key {    ANY = SoKeyboardEvent::ANY,    UNDEFINED = SoKeyboardEvent::UNDEFINED,    LEFT_SHIFT = SoKeyboardEvent::LEFT_SHIFT,    RIGHT_SHIFT = SoKeyboardEvent::RIGHT_SHIFT,    LEFT_CONTROL = SoKeyboardEvent::LEFT_CONTROL,    RIGHT_CONTROL = SoKeyboardEvent::RIGHT_CONTROL,    LEFT_ALT = SoKeyboardEvent::LEFT_ALT,    RIGHT_ALT = SoKeyboardEvent::RIGHT_ALT,    CAPS_LOCK = SoKeyboardEvent::CAPS_LOCK,    A = SoKeyboardEvent::A,    B = SoKeyboardEvent::B,    C = SoKeyboardEvent::C,    D = SoKeyboardEvent::D,    E = SoKeyboardEvent::E,    F = SoKeyboardEvent::F,    G = SoKeyboardEvent::G,    H = SoKeyboardEvent::H,    I = SoKeyboardEvent::I,    J = SoKeyboardEvent::J,    K = SoKeyboardEvent::K,    L = SoKeyboardEvent::L,    M = SoKeyboardEvent::M,    N = SoKeyboardEvent::N,    O = SoKeyboardEvent::O,    P = SoKeyboardEvent::P,    Q = SoKeyboardEvent::Q,    R = SoKeyboardEvent::R,    S = SoKeyboardEvent::S,    T = SoKeyboardEvent::T,    U = SoKeyboardEvent::U,    V = SoKeyboardEvent::V,    W = SoKeyboardEvent::W,    X = SoKeyboardEvent::X,    Y = SoKeyboardEvent::Y,    Z = SoKeyboardEvent::Z,    NUMBER_0 = SoKeyboardEvent::NUMBER_0,    NUMBER_1 = SoKeyboardEvent::NUMBER_1,    NUMBER_2 = SoKeyboardEvent::NUMBER_2,    NUMBER_3 = SoKeyboardEvent::NUMBER_3,    NUMBER_4 = SoKeyboardEvent::NUMBER_4,    NUMBER_5 = SoKeyboardEvent::NUMBER_5,    NUMBER_6 = SoKeyboardEvent::NUMBER_6,    NUMBER_7 = SoKeyboardEvent::NUMBER_7,    NUMBER_8 = SoKeyboardEvent::NUMBER_8,    NUMBER_9 = SoKeyboardEvent::NUMBER_9,    MINUS = SoKeyboardEvent::MINUS,    EQUAL = SoKeyboardEvent::EQUAL,    SPACE = SoKeyboardEvent::SPACE,    BACKSPACE = SoKeyboardEvent::BACKSPACE,    TAB = SoKeyboardEvent::TAB,    RETURN = SoKeyboardEvent::RETURN,    BRACKETLEFT = SoKeyboardEvent::BRACKETLEFT,    BRACKETRIGHT = SoKeyboardEvent::BRACKETRIGHT,    SEMICOLON = SoKeyboardEvent::SEMICOLON,    APOSTROPHE = SoKeyboardEvent::APOSTROPHE,    COMMA = SoKeyboardEvent::COMMA,    PERIOD = SoKeyboardEvent::PERIOD,    SLASH = SoKeyboardEvent::SLASH,    BACKSLASH = SoKeyboardEvent::BACKSLASH,    GRAVE = SoKeyboardEvent::GRAVE  };  SoMFEnum key;  SoMFEnum behavior;  SoMFInt32 msecs;  virtual void handleEvent(SoHandleEventAction * action);protected:  virtual ~SwitchboardOperator(void);private:  void constructor(void);};// *************************************************************************static const char * keyboard_iv[] ={  "#Inventor V2.1 ascii",  "# **************************************************************************",  "# This is a basic keyboard model (ab)using the SwitchboardOperator node",  "# I've just writtenn.",  "#",  "#   Lars J",  "",  "Group {",  " Separator {",  "  DirectionalLight {",  "    direction -1 -1 0.5",  "  }",  "  DEF camera PerspectiveCamera {",  "    position 37.6813 -29.2411 26.4421",  "    orientation 0.352193 0.189524 0.126368 0.907784",  "  }",  "  DEF callback Callback {}",  "  SwitchboardOperator {",  "    enable [ FALSE ]",  "    key [ SPACE ]",  "    behavior [ HOLD ]",  "    RotationXYZ {",  "      axis X",  "      angle 0.005",  "    }",  "  }",  "  SwitchboardOperator {",  "    enable [ FALSE ]",  "    key [ RETURN ]",  "    behavior [ HOLD ]",  "    RotationXYZ {",  "      axis Y",  "      angle 0.002",  "    }",  "  }",  "  Separator {",  "    Material { diffuseColor 0.6 0.6 0.6 }",  "    Translation { translation 17.5 -5 -1 }",  "    Scale { scaleFactor 20 8 1 }",  "    Cube {}",  "  }",  "  Separator {",  "    Group {",  "      SwitchboardOperator {",  "        enable [ FALSE TRUE FALSE ]",  "        key [ GRAVE UNDEFINED GRAVE ]",  "        behavior [ HOLD NONE HOLD ]",  "        Translation { translation 0 0 -0.5 }",  "        Separator {",  "          Cube {} # GRAVE",  "          DEF NumericLabelTransform Group {",  "            Translation { translation -0.7 -0.7 1 }",  "            Scale { scaleFactor 0.1 0.1 0.1 }",  "            BaseColor { rgb 0 0 0 }",  "            PolygonOffset {",  "              factor -1",  "              on TRUE",  "            }",  "          }",  "          AsciiText { string \"`\" }",  "        }",  "        Translation { translation 0 0 0.5 }",  "      }",  "      Translation { translation 2.5 0 0 }",  "      SwitchboardOperator {",  "        enable [ FALSE TRUE FALSE ]",  "        key [ NUMBER_1 UNDEFINED NUMBER_1 ]",  "        behavior [ HOLD NONE HOLD ]",  "        Translation { translation 0 0 -0.5 }",  "        Separator {",  "          Cube {} # 1",  "          USE NumericLabelTransform",  "          AsciiText { string \"1\" }",  "        }",  "        Translation { translation 0 0 0.5 }",  "      }",  "      Translation { translation 2.5 0 0 }",  "      SwitchboardOperator {",  "        enable [ FALSE TRUE FALSE ]",  "        key [ NUMBER_2 UNDEFINED NUMBER_2 ]",  "        behavior [ HOLD NONE HOLD ]",  "        Translation { translation 0 0 -0.5 }",  "        Separator {",  "          Cube {} # 2",  "          USE NumericLabelTransform",  "          AsciiText { string \"2\" }",  "        }",  "        Translation { translation 0 0 0.5 }",  "      }",  "      Translation { translation 2.5 0 0 }",  "      SwitchboardOperator {",  "        enable [ FALSE TRUE FALSE ]",  "        key [ NUMBER_3 UNDEFINED NUMBER_3 ]",  "        behavior [ HOLD NONE HOLD ]",  "        Translation { translation 0 0 -0.5 }",  "        Separator {",  "          Cube {} # 3",  "          USE NumericLabelTransform",  "          AsciiText { string \"3\" }",  "        }",  "        Translation { translation 0 0 0.5 }",  "      }",  "      Translation { translation 2.5 0 0 }",  "      SwitchboardOperator {",  "        enable [ FALSE TRUE FALSE ]",  "        key [ NUMBER_4 UNDEFINED NUMBER_4 ]",  "        behavior [ HOLD NONE HOLD ]",  "        Translation { translation 0 0 -0.5 }",  "        Separator {",  "          Cube {} # 4",  "          USE NumericLabelTransform",  "          AsciiText { string \"4\" }",  "        }",  "        Translation { translation 0 0 0.5 }",  "      }",  "      Translation { translation 2.5 0 0 }",  "      SwitchboardOperator {",  "        enable [ FALSE TRUE FALSE ]",  "        key [ NUMBER_5 UNDEFINED NUMBER_5 ]",  "        behavior [ HOLD NONE HOLD ]",  "        Translation { translation 0 0 -0.5 }",  "        Separator {",  "          Cube {} # 5",  "          USE NumericLabelTransform",  "          AsciiText { string \"5\" }",  "        }",  "        Translation { translation 0 0 0.5 }",  "      }",  "      Translation { translation 2.5 0 0 }",  "      SwitchboardOperator {",  "        enable [ FALSE TRUE FALSE ]",  "        key [ NUMBER_6 UNDEFINED NUMBER_6 ]",  "        behavior [ HOLD NONE HOLD ]",  "        Translation { translation 0 0 -0.5 }",  "        Separator {",  "          Cube {} # 6",  "          USE NumericLabelTransform",  "          AsciiText { string \"6\" }",  "        }",  "        Translation { translation 0 0 0.5 }",  "      }",  "      Translation { translation 2.5 0 0 }",  "      SwitchboardOperator {",  "        enable [ FALSE TRUE FALSE ]",  "        key [ NUMBER_7 UNDEFINED NUMBER_7 ]",  "        behavior [ HOLD NONE HOLD ]",  "        Translation { translation 0 0 -0.5 }",  "        Separator {",  "          Cube {} # 7",  "          USE NumericLabelTransform",  "          AsciiText { string \"7\" }",  "        }",  "        Translation { translation 0 0 0.5 }",  "      }",  "      Translation { translation 2.5 0 0 }",  "      SwitchboardOperator {",  "        enable [ FALSE TRUE FALSE ]",  "        key [ NUMBER_8 UNDEFINED NUMBER_8 ]",  "        behavior [ HOLD NONE HOLD ]",  "        Translation { translation 0 0 -0.5 }",  "        Separator {",  "          Cube {} # 8",  "          USE NumericLabelTransform",  "          AsciiText { string \"8\" }",  "        }",  "        Translation { translation 0 0 0.5 }",  "      }",  "      Translation { translation 2.5 0 0 }",  "      SwitchboardOperator {",  "        enable [ FALSE TRUE FALSE ]",  "        key [ NUMBER_9 UNDEFINED NUMBER_9 ]",  "        behavior [ HOLD NONE HOLD ]",  "        Translation { translation 0 0 -0.5 }",  "        Separator {",  "          Cube {} # 9",  "          USE NumericLabelTransform",  "          AsciiText { string \"9\" }",  "        }",  "        Translation { translation 0 0 0.5 }",  "      }",  "      Translation { translation 2.5 0 0 }",  "      SwitchboardOperator {",  "        enable [ FALSE TRUE FALSE ]",  "        key [ NUMBER_0 UNDEFINED NUMBER_0 ]",

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -