Behavior 応援する  BasicCode
include Java
include_class 'java.applet.Applet'
include_class 'javax.swing.JApplet'
include_class 'com.sun.j3d.utils.applet.MainFrame'
class Java3d_uni_behavior
include_package 'java.awt'
include_package 'javax.media.j3d'
include_package 'javax.vecmath'
include_package 'com.sun.j3d.utils.universe'
include_package 'com.sun.j3d.utils.geometry'
include_package 'com.sun.j3d.utils.behaviors.vp'
def initialize
@applet = Applet.new
init
end
def init
@applet.setLayout(BorderLayout.new)
@canvas = Canvas3D.new(SimpleUniverse.getPreferredConfiguration)
#@applet.add('Center',@canvas)
@applet.add(@canvas, BorderLayout::CENTER)
#SimpleUniverseの作成
@universe = SimpleUniverse.new(@canvas)
@universe.getViewingPlatform.setNominalViewingTransform
#マウスで動す処理
setOrbitBehavior
@universe.addBranchGraph(createObjects)
end
def createObjects
root = BranchGroup.new
root.addChild(ColorCube.new(0.4))
root.compile
return root
end
def setOrbitBehavior
orbit = OrbitBehavior.new(@canvas,OrbitBehavior::REVERSE_ALL)
orbit.setSchedulingBounds(BoundingSphere.new(Point3d.new(0,0,0), 100.0))
@universe.getViewingPlatform().setViewPlatformBehavior(orbit)
end
def main
MainFrame.new(@applet,200,200)
end
end
Java3d_uni_behavior.new.mains
| |
|