Hello
I am student of BSCS 4th Semester.
we studied basics of java in OOP subject
i want to make a 3D Paint in java simple free hand diagrams
by using sphere..
drawing on different coordinates..
/**
*
* @author MuDi
*/
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import java.util.Scanner;
import javax.media.j3d.*;
import javax.vecmath.*;
public class Position {
boolean flag=true;
public Position() {
boolean ch = true;
while(ch)
{
SimpleUniverse universe = new SimpleUniverse();
BranchGroup group = new BranchGroup();
// X axis made of spheres
//for (float x = -1.0f; x <= 1.0f; x = x + 0.0005f)
Color3f light1Color = new Color3f(.1f, 1.4f, .1f); // green light
BoundingSphere bounds =
new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
DirectionalLight light1
= new DirectionalLight(light1Color, light1Direction);
light1.setInfluencingBounds(bounds);
universe.getViewingPlatform().setNominalViewingTransform();
group.addChild(light1);
Sphere sphere = new Sphere(0.05f);
TransformGroup tg = new TransformGroup();
Scanner sc = new Scanner(System.in);
float a = sc.nextFloat();
float b = sc.nextFloat();
float c = sc.nextFloat();
int ac = sc.nextInt();
if(ac==0)
{
ch=false;
}
Transform3D transform = new Transform3D();
Vector3f vector = new Vector3f( a, b, c);
transform.setTranslation(vector);
tg.setTransform(transform);
tg.addChild(sphere);
group.removeAllChildren();
group.addChild(tg);
// add the group of objects to the Universe
universe.addBranchGraph(group);
//universe.getCanvas().invalidate();
//universe.getCanvas().validate();
}
}
public static void main(String[] args) {
new Position();
}
}
I tried this
by reading values of coordinates..
it draw one sphere but when i enter 2nd.. it gives me error
please help me this
it will be usefull for me in some 3d project in future..
and if there is some other method of 3d drawing (free hand) which draw points on each coordinate given.. please let me know i want to learn this..
Thanks alot