Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 30th, 2012, 08:55 PM
howardcartter howardcartter is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 1 howardcartter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 6 sec
Reputation Power: 0
Help in icosahedron file please help very urgent

can someone help me get this obj file working
This is the code called "Phong.java" that I am trying to run with the icosahedron object file.
I needed to use Phong.java and the teapot input to create a icosahedron
im unable to attach the object file here can someone provide me alternative to send the obj file
its very urgent
please please please



here is the code, need help in fixing it
#isocahedron

v .29045075 0.25 0.0
v -.29045075 0.25 0.0
v .29045075f -0.25 0.0
v -.29045075 -0.25 0.0
v 0.25 0.0 .29045075
v 0.25 0.0 -.29045075
v -0.25 0.0 .29045075
v -0.25 0.0 -.29045075
v 0.0 .29045075 0.25
v 0.0 -.29045075 0.25
v 0.0 .29045075 -0.25
v 0.0 -.29045075 -0.25

f 0 8 4
f 0 5 10
f 2 4 9
f 2 11 5
f 1 6 8
f 1 10 7
f 3 9 6
f 3 7 11
f 0 10 8
f 1 8 10
f 2 9 11
f 3 11 9
f 4 2 0
f 5 0 2
f 6 1 3
f 7 3 1
f 8 6 4
f 9 4 6
f 10 5 7
f 11 7 5



import javax.vecmath.*;

import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;

import com.sun.j3d.utils.behaviors.vp.*;
import javax.swing.JFrame;
import com.sun.j3d.loaders.*;
import com.sun.j3d.loaders.objectfile.*;




/**
* An example for constructing an object (tetrahedron) with triangles
* where normal vectors are interpolated.
*
* @author Frank Klawonn
* Last change 05.07.2005
* @see GeomArrayExample
*/
public class Isocahedran extends JFrame
{

//The canvas to be drawn upon.
public Canvas3D myCanvas3D;


public Isocahedran()
{
//Mechanism for closing the window and ending the program.
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


//Default settings for the viewer parameters.
myCanvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());


//Construct the SimpleUniverse:
//First generate it using the Canvas.
SimpleUniverse simpUniv = new SimpleUniverse(myCanvas3D);


//Default position of the viewer.
simpUniv.getViewingPlatform().setNominalViewingTransform();


//The scene is generated in this method.
createSceneGraph(simpUniv);


//Add some light to the scene.
addLight(simpUniv);


//The following three lines enable navigation through the scene using the mouse.
OrbitBehavior ob = new OrbitBehavior(myCanvas3D);
ob.setSchedulingBounds(new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE));
simpUniv.getViewingPlatform().setViewPlatformBehavior(ob);


//Show the canvas/window.
setTitle("An object loaded from a file");
setSize(700,700);
getContentPane().add("Center", myCanvas3D);
setVisible(true);

}




public static void main(String[] args)
{
Isocahedran nfga = new Isocahedran();
}





//In this method, the objects for the scene are generated and added to
//the SimpleUniverse.
public void createSceneGraph(SimpleUniverse su)
{



//Load an obj-file.
ObjectFile f = new ObjectFile(ObjectFile.RESIZE);
Scene s = null;

try
{
s = f.load("isocahedron.obj");
}
catch (Exception e)
{
System.out.println("File loading failed:" + e);
}


//Generate a transformation group for the loaded object.
Transform3D tfObject = new Transform3D();
tfObject.rotZ(0.4*Math.PI);
Transform3D xRotation = new Transform3D();
xRotation.rotY(0.4*Math.PI);
tfObject.mul(xRotation);
TransformGroup tgObject = new TransformGroup(tfObject);
tgObject.addChild(s.getSceneGroup());


Appearance yellowApp = new Appearance();
setToMyDefaultAppearance(yellowApp,new Color3f(0.5f,0.5f,0.0f));

BranchGroup theScene = new BranchGroup();

//Add the tetrahedron to the scene.
Background bg = new Background(new Color3f(1.0f,1.0f,1.0f));
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE);
bg.setApplicationBounds(bounds);
theScene.addChild(bg);

theScene.compile();

//Add everything to the universe.
su.addBranchGraph(theScene);

}



/**
* Generates a default surface (Appearance) in a specified colour.
*
* @param app The Appearance for the surface.
* @param col The colour.
*/
public static void setToMyDefaultAppearance(Appearance app, Color3f col)
{
app.setMaterial(new Material(col,col,col,col,150.0f));
}



//Some light is added to the scene here.
public void addLight(SimpleUniverse su)
{

BranchGroup bgLight = new BranchGroup();

BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
Color3f lightColour1 = new Color3f(1.0f,1.0f,1.0f);
Vector3f lightDir1 = new Vector3f(-1.0f,0.0f,-0.5f);
DirectionalLight light1 = new DirectionalLight(lightColour1, lightDir1);
light1.setInfluencingBounds(bounds);


Vector3f lightDir2 = new Vector3f(1.0f,0.0f,0.5f);
DirectionalLight light2 = new DirectionalLight(lightColour1, lightDir2);
light2.setInfluencingBounds(bounds);


bgLight.addChild(light1);
bgLight.addChild(light2);

su.addBranchGraph(bgLight);
}



}

Last edited by howardcartter : November 30th, 2012 at 09:08 PM. Reason: code missing

Reply With Quote
  #2  
Old December 1st, 2012, 08:16 AM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,956 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 56 m 11 sec
Reputation Power: 345
Please edit your post and wrap the code in code tags.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Help in icosahedron file please help very urgent

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap