当前位置: 首页>>代码示例>>Java>>正文


Java ObjectFile.setFlags方法代码示例

本文整理汇总了Java中com.sun.j3d.loaders.objectfile.ObjectFile.setFlags方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectFile.setFlags方法的具体用法?Java ObjectFile.setFlags怎么用?Java ObjectFile.setFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.j3d.loaders.objectfile.ObjectFile的用法示例。


在下文中一共展示了ObjectFile.setFlags方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SparkySpacecraftMat

import com.sun.j3d.loaders.objectfile.ObjectFile; //导入方法依赖的package包/类
/**
 * Initialize with input scale factor.
 * 
 * @param    scale    Scale factor for the model.  A scale of
 *                    1.0 means the distance from the model origin, to the
 *                    furthest point on the model, will be one unit long.
 */
public SparkySpacecraftMat(double scale) {
    // allow the state of the model to be changed after compilation
  setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
  setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    // add the visual representation to the TransformGroup
  try {
      // first try the sparkymatmesh.obj model
    Scene modelScene = null;
    ObjectFile of = new ObjectFile();
    of.setFlags(ObjectFile.RESIZE     |
               ObjectFile.TRIANGULATE |
               ObjectFile.STRIPIFY);   
      // load the mesh defined below
    URL sparkyURL = SparkySpacecraftMat.class.getResource("sparkymatmesh.obj");
    if (sparkyURL == null) {
      throw new java.io.FileNotFoundException("Can't find sparkymesh.obj" +
                                                                       this);
    }
    modelScene = of.load(sparkyURL);
      // rotate model axis to align with simulation axis.  Also, offset
      // it along the x-axis so the cg and origin coincide.
    Vector3d trans = new Vector3d();  // offset along x-axis
    trans.x = XOFF*scale;
    Matrix3d m1 = new Matrix3d();
    m1.rotX(Math.PI/2.0);          // nose down into plane
    Matrix3d m2 = new Matrix3d();
    m2.rotZ(Math.PI/2.0);          // nose yaw into X
    m2.mul(m1);                    // combine
    Transform3D t3d = new Transform3D(m2, trans, scale);
    TransformGroup tg = new TransformGroup(t3d);
    BranchGroup modelBG = modelScene.getSceneGroup();
      //
    tg.addChild(modelBG);
    addChild(tg);
  } catch(java.io.FileNotFoundException ex) {
      // if the above didn't work, load a sphere
    addChild(new Sphere(1.0f));
  }
}
 
开发者ID:motoq,项目名称:vse,代码行数:47,代码来源:SparkySpacecraftMat.java

示例2: TestSpacecraft

import com.sun.j3d.loaders.objectfile.ObjectFile; //导入方法依赖的package包/类
/**
 * Initialize with input scale factor.  The model BranchGroup is retained
 * allowing for the getMassDyadic function to retrieve vertex info.
 * 
 * @param    scale    Scale factor for the model.  A scale of
 */
public TestSpacecraft(double scale) {
  sf = (float) scale;
    // allow the state of the model to be changed after compilation
  setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
  setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    // add the visual representation to the TransformGroup
  try {
      // first try the sparkymatmesh.obj model
    Scene modelScene = null;
    ObjectFile of = new ObjectFile();
    of.setFlags(ObjectFile.RESIZE     |
               ObjectFile.TRIANGULATE |
               ObjectFile.STRIPIFY);   
      // load the mesh defined below
    URL sparkyURL = TestSpacecraft.class.getResource("sparkymatmesh.obj");
    if (sparkyURL == null) {
      System.out.println("Can't find sphere.obj");
      throw new java.io.FileNotFoundException("Can't find sparkymesh.obj" +
                                                                       this);
    }
    
    modelScene = of.load(sparkyURL);
    
      // rotate model axis to align with simulation axis.  Also, offset
      // it along the x-axis so the cg and origin coincide.
    Vector3d trans = new Vector3d();  // offset along x-axis
    trans.x = XOFF*scale;
    Matrix3d m1 = new Matrix3d();
    m1.rotX(Math.PI/2.0);          // nose down into plane
    Matrix3d m2 = new Matrix3d();
    m2.rotZ(Math.PI/2.0);          // nose yaw into X
    m2.mul(m1);                    // combine
    Transform3D t3d = new Transform3D(m2, trans, scale);
    TransformGroup tg = new TransformGroup(t3d);
    modelBG = modelScene.getSceneGroup();
    
    tg.addChild(modelBG);
    addChild(tg);
  } catch(java.io.FileNotFoundException ex) {
      // if the above didn't work, load a sphere
    addChild(new Sphere(1.0f));
  }
}
 
开发者ID:motoq,项目名称:vse,代码行数:50,代码来源:TestSpacecraft.java

示例3: SparkySpacecraft

import com.sun.j3d.loaders.objectfile.ObjectFile; //导入方法依赖的package包/类
public SparkySpacecraft(double scale) {
    // zero emissive (doesn't glow) - use black
  Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
    // ambient and diffuse blue (normal object)
  Color3f blue = new Color3f(0.3f, 0.3f, 0.8f);
    // specular near white (normal object)
  Color3f specular = new Color3f(0.9f, 0.9f, 0.9f);

    // Material(ambient, emissive, diffuse, specular, shininess)
  Material blueMat= new Material(blue, black, blue, specular, 25.0f);
  blueMat.setLightingEnable(true);

  Appearance blueApp = new Appearance();
  blueApp.setMaterial(blueMat);

    // allow the state of the model to be changed after compilation
  setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
  setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    // add the visual representation to the TransformGroup
  try {
      // first try the sparkymesh.obj model
    Scene modelScene = null;
    ObjectFile of = new ObjectFile();
    of.setFlags(ObjectFile.RESIZE     |
               ObjectFile.TRIANGULATE |
               ObjectFile.STRIPIFY);   
      // load the mesh defined below
    URL sparkyURL = SparkySpacecraft.class.getResource("sparkymesh.obj");
    if (sparkyURL == null) {
      throw new java.io.FileNotFoundException("Can't find sparkymesh.obj" +
                                                                       this);
    }
    modelScene = of.load(sparkyURL);
      // rotate model axis to align with simulation axis.  Also, offset
      // it along the x-axis so the cg and origin coincide.
    Vector3d trans = new Vector3d();  // offset along x-axis
    trans.x = XOFF*scale;
    Matrix3d m1 = new Matrix3d();
    m1.rotX(Math.PI/2.0);          // nose down into plane
    Matrix3d m2 = new Matrix3d();
    m2.rotZ(Math.PI/2.0);          // nose yaw into X
    m2.mul(m1);                    // combine
    Transform3D t3d = new Transform3D(m2, trans, scale);
    TransformGroup tg = new TransformGroup(t3d);
    BranchGroup modelBG = modelScene.getSceneGroup();
      // modify appearance here
    Enumeration modelE = modelBG.getAllChildren();
    while(modelE.hasMoreElements()) {
      Object modelO = modelE.nextElement();
      if (modelO instanceof Shape3D) {
       Shape3D modelS3D = (Shape3D) modelO;
       modelS3D.setAppearance(blueApp);
      }
    }
    tg.addChild(modelBG);
    addChild(tg);
  } catch(java.io.FileNotFoundException ex) {
      // if the above didn't work, load a sphere
    addChild(new Sphere(1.0f, blueApp));
  }
}
 
开发者ID:motoq,项目名称:vse,代码行数:62,代码来源:SparkySpacecraft.java

示例4: SparkySpacecraftJ3DMat

import com.sun.j3d.loaders.objectfile.ObjectFile; //导入方法依赖的package包/类
public SparkySpacecraftJ3DMat(double scale) {
    // zero emissive (doesn't glow) - use black
  Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
    // ambient and diffuse blue (normal object)
  Color3f blue = new Color3f(0.3f, 0.3f, 0.8f);
  Color3f red  = new Color3f(0.8f, 0.3f, 0.3f);
    // specular near white (normal object)
  Color3f specular = new Color3f(0.9f, 0.9f, 0.9f);

    // Material(ambient, emissive, diffuse, specular, shininess)
  Material blueMat= new Material(blue, black, blue, specular, 25.0f);
  blueMat.setLightingEnable(true);
  Material redMat= new Material(red, black, red, specular, 25.0f);
  redMat.setLightingEnable(true);

  Appearance blueApp = new Appearance();
  blueApp.setMaterial(blueMat);
  Appearance redApp = new Appearance();
  redApp.setMaterial(redMat);

    // allow the state of the model to be changed after compilation
  setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
  setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    // add the visual representation to the TransformGroup
  try {
      // first try the sparkymesh.obj model
    Scene modelScene = null;
    ObjectFile of = new ObjectFile();
    of.setFlags(ObjectFile.RESIZE     |
               ObjectFile.TRIANGULATE |
               ObjectFile.STRIPIFY);   
      // load the mesh defined below
    URL sparkyURL =
        SparkySpacecraftJ3DMat.class.getResource("sparkymesh_noball.obj");
    if (sparkyURL == null) {
      throw new java.io.FileNotFoundException("Can't find sparkymesh.obj" +
                                                                       this);
    }
    modelScene = of.load(sparkyURL);
      // rotate model axis to align with simulation axis.  Also, offset
      // it along the x-axis so the cg and origin coincide.
    Vector3d trans = new Vector3d();  // offset along x-axis
    trans.x = XOFF*scale;
    Matrix3d m1 = new Matrix3d();
    m1.rotX(Math.PI/2.0);          // nose down into plane
    Matrix3d m2 = new Matrix3d();
    m2.rotZ(Math.PI/2.0);          // nose yaw into X
    m2.mul(m1);                    // combine
    Transform3D t3d = new Transform3D(m2, trans, scale);
    TransformGroup tg = new TransformGroup(t3d);
    BranchGroup modelBG = modelScene.getSceneGroup();
      // modify appearance here
    Enumeration modelE = modelBG.getAllChildren();
    while(modelE.hasMoreElements()) {
      Object modelO = modelE.nextElement();
      if (modelO instanceof Shape3D) {
       Shape3D modelS3D = (Shape3D) modelO;
       modelS3D.setAppearance(blueApp);
      }
    }
    tg.addChild(modelBG);
    addChild(tg);
    addChild(new Sphere(0.25f*((float) scale), redApp));
  } catch(java.io.FileNotFoundException ex) {
      // if the above didn't work, load a sphere
    addChild(new Sphere(1.0f, blueApp));
  }
}
 
开发者ID:motoq,项目名称:vse,代码行数:69,代码来源:SparkySpacecraftJ3DMat.java

示例5: ObjectLoader

import com.sun.j3d.loaders.objectfile.ObjectFile; //导入方法依赖的package包/类
public ObjectLoader() {

		setLayout(new BorderLayout());
		GraphicsConfiguration graphicsConfig = SimpleUniverse
				.getPreferredConfiguration();

		Canvas3D canvas3D = new Canvas3D(graphicsConfig);
		add(canvas3D);
		canvas3D.setSize(1200, 800);
		canvas3D.setVisible(true);

		BranchGroup scene = new BranchGroup();

		ObjectFile loader = new ObjectFile(ObjectFile.LOAD_ALL);
		loader.setFlags(ObjectFile.RESIZE);

		Color3f light1Color = new Color3f(1.8f, 0.1f, 0.1f);

		BoundingSphere bounds =

		new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

		Vector3f light1Direction = new Vector3f(2.0f, 12.0f, -12.0f);

		DirectionalLight light1

		= new DirectionalLight(light1Color, light1Direction);

		light1.setInfluencingBounds(bounds);

		scene.addChild(light1);

		Scene modelScene = null;

		try {
			modelScene = loader.load("Images/gargoyle.obj");

		} catch (Exception e) {

		}

		scene.addChild(modelScene.getSceneGroup());

		SimpleUniverse universe = new SimpleUniverse(canvas3D);
		universe.getViewingPlatform().setNominalViewingTransform();

		universe.addBranchGraph(scene);
		
		ViewingPlatform viewPlatform = universe.getViewingPlatform();
	    TransformGroup viewTransform = viewPlatform.getViewPlatformTransform();
	    Transform3D t3d = new Transform3D();
	    viewTransform.getTransform(t3d);
	    t3d.lookAt(new Point3d(0, 0, 4), new Point3d(0, 0, 0), new Vector3d(0, 1, 0));
	    t3d.invert();
	    viewTransform.setTransform(t3d);

	}
 
开发者ID:GettingNifty,项目名称:Heavy-Evil,代码行数:58,代码来源:ObjectLoader.java


注:本文中的com.sun.j3d.loaders.objectfile.ObjectFile.setFlags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。