java scene_Java Scene類代碼示例

本文整理匯總了Java中com.sun.j3d.loaders.Scene類的典型用法代碼示例。如果您正苦於以下問題:Java Scene類的具體用法?Java Scene怎麽用?Java Scene使用的例子?那麽恭喜您, 這裏精選的類代碼示例或許可以為您提供幫助。

Scene類屬於com.sun.j3d.loaders包,在下文中一共展示了Scene類的18個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: load

​點讚 3

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

/**

* Returns the scene described in the given 3DS file.

*/

public Scene load(String file) throws FileNotFoundException, IncorrectFormatException, ParsingErrorException

{

URL baseUrl;

try

{

if (this.basePath != null)

{

baseUrl = new File(this.basePath).toURI().toURL();

}

else

{

baseUrl = new File(file).toURI().toURL();

}

}

catch (MalformedURLException ex)

{

throw new FileNotFoundException(file);

}

return load(new FileInputStream(file), baseUrl);

}

開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:24,

示例2: load

​點讚 3

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

/**

* Returns the scene described in the given DAE file.

*/

public Scene load(String file) throws FileNotFoundException, IncorrectFormatException, ParsingErrorException

{

URL baseUrl;

try

{

if (this.basePath != null)

{

baseUrl = new File(this.basePath).toURI().toURL();

}

else

{

baseUrl = new File(file).toURI().toURL();

}

}

catch (MalformedURLException ex)

{

throw new FileNotFoundException(file);

}

return load(new BufferedInputStream(new FileInputStream(file)), baseUrl);

}

開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:24,

示例3: setupLighting

​點讚 3

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

/**

* Setup the worlds lighting. If none is provided in the VRML file then

* we create a simple headlight

*

* @param scene The scene to source the lights from

*/

private void setupLighting(Scene scene) {

Light lights[] = scene.getLightNodes();

if (lights == null) {

BranchGroup lightBG = new BranchGroup();

BoundingSphere lightBounds =

new BoundingSphere(new Point3d(), Double.MAX_VALUE);

DirectionalLight headLight =

new DirectionalLight(new Color3f(1.0f,1.0f,1.0f),

new Vector3f(0,0,-1));

headLight.setCapability(Light.ALLOW_STATE_WRITE);

headLight.setInfluencingBounds(lightBounds);

lightBG.addChild(headLight);

sceneRoot.addChild(lightBG);

}

}

開發者ID:Norkart,項目名稱:NK-VirtualGlobe,代碼行數:24,

示例4: load

​點讚 3

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

/**

* Load a scene from the given filename. The scene instance returned by

* this builder will not have had any external references resolved.

* Externprotos, scripts, Inlines and all other nodes that reference part

* of their data as a URL will need to be loaded separately.

*

* @param filename The name of the file to load

* @return A description of the scene

* @throws FileNotFoundException The reader can't find the file

* @throws IncorrectFormatException The file is not one our loader

* understands (VRML 1.0 or X3D content)

* @throws ParsingErrorException An error parsing the file

*/

public Scene load(String filename)

throws FileNotFoundException,

IncorrectFormatException,

ParsingErrorException {

File file = new File(filename);

if(!file.exists())

throw new FileNotFoundException("File does not exist");

if(file.isDirectory())

throw new FileNotFoundException("File is a directory");

InputSource is = new InputSource(file);

return load(is);

}

開發者ID:Norkart,項目名稱:NK-VirtualGlobe,代碼行數:31,

示例5: succeeded

​點讚 2

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

@Override

protected void succeeded(Scene result) {

NeuGenView ngView = NeuGenView.getInstance();

ngView.setScene(s);

ngView.enableButtons();

System.gc();

ngView.outPrintln(Utils.getMemoryStatus());

if (ngView.visualizeData() == null) {

logger.info("is null!");

}

ngView.visualizeData().run();

}

開發者ID:NeuroBox3D,項目名稱:NeuGen,代碼行數:13,

示例6: loadScene

​點讚 2

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

private Scene loadScene() throws FileNotFoundException {

IfcScene result;

try {

result = new IfcScene();

SceneManager sceneManager = mapper.map(configuration);

mapper = null; // release resources

result.setSceneGroup(sceneManager.getScene());

sceneManager.animate();

} catch (TargetCreationException e) {

throw new ParsingErrorException(e.getMessage());

}

return result;

}

開發者ID:hlg,項目名稱:billie,代碼行數:14,

示例7: loadWavefrontObject

​點讚 2

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

/**

* Chargement de l'objet Wavefront (masque.obj) ainsi que les materiaux qui

* lui sont associes

*

* @param filename nom du fichier de l'objet a charger

* @return BranchGroup branch group contenant l'objet Wavefront

*/

private static BranchGroup loadWavefrontObject(String filename) {

ObjectFile waveFrontObject = new ObjectFile();

Scene scene = null;

try {

scene = waveFrontObject.load(filename);

BranchGroup bg = scene.getSceneGroup();

return bg;

} catch (Exception e) {

e.printStackTrace();

}

return null;

}

開發者ID:IGNF,項目名稱:geoxygene,代碼行數:29,

示例8: parseStream

​點讚 2

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

/**

* Returns the scene with data read from the given 3DS stream.

*/

private Scene parseStream(ChunksInputStream in) throws IOException

{

this.masterScale = 1;

this.meshes = new ArrayList();

this.materials = new LinkedHashMap();

this.meshesGroups = new HashMap>();

boolean magicNumberRead = false;

switch (in.readChunkHeader().getID())

{

case M3DMAGIC:

case MLIBMAGIC:

case CMAGIC:

magicNumberRead = true;

while (!in.isChunckEndReached())

{

switch (in.readChunkHeader().getID())

{

case M3D_VERSION:

in.readLittleEndianUnsignedInt();

break;

case EDITOR_DATA:

parseEditorData(in);

break;

case KEY_FRAMER_DATA:

parseKeyFramerData(in);

break;

default:

in.readUntilChunkEnd();

break;

}

in.releaseChunk();

}

break;

case EDITOR_DATA:

parseEditorData(in);

break;

default:

if (magicNumberRead)

{

in.readUntilChunkEnd();

}

else

{

throw new IncorrectFormatException("Bad magic number");

}

}

in.releaseChunk();

try

{

return createScene();

}

finally

{

this.meshes = null;

this.materials = null;

this.meshesGroups = null;

this.root = null;

}

}

開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:65,

示例9: load

​點讚 2

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

/**

* Returns the scene described in the given OBJ file stream.

*/

public Scene load(Reader reader) throws FileNotFoundException, IncorrectFormatException, ParsingErrorException

{

return load(reader, null);

}

開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:8,

示例10: parseObjectStream

​點讚 2

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

/**

* Returns the scene parsed from a stream.

*/

private Scene parseObjectStream(Reader reader, URL baseUrl) throws IOException

{

this.vertices = new ArrayList();

this.textureCoordinates = new ArrayList();

this.normals = new ArrayList();

this.groups = new LinkedHashMap();

this.currentGroup = new Group("default");

this.groups.put("default", this.currentGroup);

this.currentMaterial = "default";

this.appearances = new HashMap(DEFAULT_APPEARANCES);

StreamTokenizer tokenizer = createTokenizer(reader);

while (tokenizer.nextToken() != StreamTokenizer.TT_EOF)

{

switch (tokenizer.ttype)

{

case StreamTokenizer.TT_WORD:

parseObjectLine(tokenizer, baseUrl);

break;

case StreamTokenizer.TT_EOL:

break;

default:

throw new IncorrectFormatException(

"Unexpected token " + tokenizer.sval + " at row " + tokenizer.lineno());

}

}

try

{

return createScene();

}

finally

{

this.vertices = null;

this.textureCoordinates = null;

this.normals = null;

this.groups = null;

this.appearances = null;

}

}

開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:44,

示例11: getScene

​點讚 2

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

public Scene getScene() {

return s;

}

開發者ID:NeuroBox3D,項目名稱:NeuGen,代碼行數:4,

示例12: setScene

​點讚 2

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

public void setScene(Scene scene) {

this.scene = scene;

}

開發者ID:NeuroBox3D,項目名稱:NeuGen,代碼行數:4,

示例13: VisualizationTask

​點讚 2

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

public VisualizationTask(Application application, Visualization vis, Scene s) {

super(application);

this.vis = vis;

this.s = s;

}

開發者ID:NeuroBox3D,項目名稱:NeuGen,代碼行數:6,

示例14: load

​點讚 2

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

public Scene load(Reader reader) throws FileNotFoundException, IncorrectFormatException, ParsingErrorException {

throw new UnsupportedOperationException();

}

開發者ID:hlg,項目名稱:billie,代碼行數:4,

示例15: loadFile

​點讚 2

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

/**

* Load the given file into the scene.

*

* @param filename The name of the file or the URL to load

*/

private void loadFile(String file) {

int flag = VRML97Loader.LOAD_ALL;

if(staticLoad)

flag &= ~VRML97Loader.LOAD_BEHAVIOR_NODES;

VRML97Loader loader = new VRML97Loader(flag);

// if the file is a directory, ignore it

File f = new File(file);

if(f.exists() && !f.isFile()) {

System.out.println("Can't load directories specified");

System.exit(1);

}

URL url = null;

Scene scene = null;

try {

url = new URL(file);

} catch (MalformedURLException badUrl) {

// if the location is not a URL, this is what you get

}

try {

if(url != null)

scene = loader.load(url);

else

scene = loader.load(file);

} catch(Exception e) {

System.out.println("Exception loading URL:" + e);

e.printStackTrace();

System.exit(0);

}

urlLabel.setText("File " + file);

if (scene != null) {

// get the scene group

sceneGroup = scene.getSceneGroup();

sceneGroup.setCapability(BranchGroup.ALLOW_DETACH);

sceneGroup.setCapability(BranchGroup.ALLOW_BOUNDS_READ);

sceneGroup.compile();

// add the scene group to the scene

examineGroup.addChild(sceneGroup);

// now that the scene group is "live" we can inquire the bounds

setViewpoint();

setupLighting(scene);

}

}

開發者ID:Norkart,項目名稱:NK-VirtualGlobe,代碼行數:59,

示例16: Loader3D

​點讚 1

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

/**

* Chargement de l'objet Wavefront (masque.obj) ainsi que les materiaux qui

* lui sont associes

*

* @param filename nom du fichier de l'objet a charger

* @return BranchGroup branch group contenant l'objet Wavefront

*/

private static BranchGroup Loader3D(String filename) {

Loader3DS d = new Loader3DS();

if (!Manager3DS.TEXTURED) {

d.noTextures();

}

Scene scene = null;

try {

String path = filename;

scene = d.load(path);

BranchGroup bg = scene.getSceneGroup();

return bg;

} catch (Exception e) {

System.out.println(filename);

e.printStackTrace();

}

return null;

}

開發者ID:IGNF,項目名稱:geoxygene,代碼行數:35,

示例17: ObjectLoader

​點讚 1

import com.sun.j3d.loaders.Scene; //導入依賴的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,

示例18: modelFromFile

​點讚 1

import com.sun.j3d.loaders.Scene; //導入依賴的package包/類

/**

* Helper method to create model from .obj file.

*

* @param modelFile file name

* @throws java.io.FileNotFoundException

*/

protected void modelFromFile(String modelFile) throws FileNotFoundException {

ObjectFile objectFile = new ObjectFile();

Scene scene = objectFile.load(modelFile);

transformGroup.addChild(scene.getSceneGroup());

}

開發者ID:DrTon,項目名稱:jMAVSim,代碼行數:12,

注:本文中的com.sun.j3d.loaders.Scene類示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值