This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > July 2005 > changing a texture...





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author changing a texture...
nunomartins01

2005-07-05, 7:33 pm

Hi

I'm trying to change a object texure, but the instruction
textura.setValue(val[0][0]);
doesn't work...

MFString is an array right?

I'm printing the "val" variable (System.out.println(val[0][0]);) and it
is correct ("im.jpg")

I can't atribute this value to the MFSring "textura"...
textura.setValue(val[0][0]);


private void Clicar(java.awt.event.MouseEvent evt) {

textField1.setText("Textura Mudada");

mat = mainScene.getNamedNode("MAT");

MFString textura = (MFString) mat.getField("url");

String[][] val=new String[1][1];

val[0][0]= (String)"im.jpg";

System.out.println(val[0][0]);

textura.setValue(val[0][0]); <- ERROR

}

Tnaks for your help

Nuno

James Anderson

2005-07-06, 8:20 am

nunomartins01 wrote:

> private void Clicar(java.awt.event.MouseEvent evt) {
>
> textField1.setText("Textura Mudada");
>
> mat = mainScene.getNamedNode("MAT");
>
> MFString textura = (MFString) mat.getField("url");
>
> String[][] val=new String[1][1];
>
> val[0][0]= (String)"im.jpg";
>
> System.out.println(val[0][0]);
>
> textura.setValue(val[0][0]); <- ERROR
>
> }


Nuno,

MFString.setValue takes an argument of type String[], but your code is
giving it an argument of type String. (Since val is of type String[][],
val[0][0] is of type String.) Try this instead:

String[] val = {"im.jpg"};
textura.setValue(val);

Or neater still:

textura.setValue(new String[] {"im.jpg"});

The following should also work:

textura.set1Value(0, "im.jpg");

James
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews