Associate
- Joined
- 21 May 2003
- Posts
- 1,008
Hi there. I'm trying to make some code for shapes and colours.
so now I've got the colour purple in my materials vector. (Matte extends Material).
however, when I want to set the material of a sphere to purple (or any other colour, it won't work:
line[1] is a buffered reader input and it's coming from an outside file. with *** above code it give the error:
inconvertible types, found string, required material.
but the function set_material requres a material type.
so how do i convert the String it's read from the file to a Material type?
i know i can do Integers and Doubles but what if it's not a standard java type?
Code:
public static Vector<Material> materials = new Vector<Material>();
Matte purple = new Matte();
purple.set_cd(new RGBColour(0.5f, 0, 1));
materials.add(purple);
however, when I want to set the material of a sphere to purple (or any other colour, it won't work:
Code:
objects.get(0).set_material((Material) line[1]);
line[1] is a buffered reader input and it's coming from an outside file. with *** above code it give the error:
inconvertible types, found string, required material.
but the function set_material requres a material type.
so how do i convert the String it's read from the file to a Material type?
i know i can do Integers and Doubles but what if it's not a standard java type?