MFColor problem 
Author Message
 MFColor problem

Is it possible to send out of JavaScript an MFColor to different
IndexedFaceSets? So for example four colors are defined in a MFColor in
a script and we want to send each color to a different IndexedFaceSet.

Marnix & Marco



Tue, 12 Nov 2002 03:00:00 GMT  
 MFColor problem
have to split it and send them sepeartely, all possible from vrml
2 options, via directOutput or event driven
i presume you are trying to set the entire colour of the IndexedFaceSet by
changing its materials diffuseColor field, rather than using color{*filter*}ex
or PerFace.
1 - event driven
Shape {
    appearance Appearance {
        material DEF ifs1 Material {
            diffuseColor 0 0 0
        }
    }
    geometry DEF ifs1 IndexedFaceSet {
    }
Quote:
}

Shape {
    appearance Appearance {
        material DEF ifs2 Material {
            diffuseColor 0 0 0
        }
    }
    geometry DEF ifs2 IndexedFaceSet {
    }
Quote:
}

Shape {
    appearance Appearance {
        material DEF ifs3 Material {
            diffuseColor 0 0 0
        }
    }
    geometry DEF ifs3 IndexedFaceSet {
    }
Quote:
}

Shape {
    appearance Appearance {
        material DEF ifs4 Material {
            diffuseColor 0 0 0
        }
    }
    geometry IndexedFaceSet {
    }
Quote:
}

DEF ifsScript Script {
    field MFColor colors [1 1 1,1 0 0,0 1 0,0 0 1]    #first shape is white,
then red, green and finally blue
    eventOut SFColor c1
    eventOut SFColor c2
    eventOut SFColor c3
    eventOut SFColor c4
    url "javascript:
        function initialize(){
            c1 = MFColor[0]
            c2 = MFColor[1]
            c3 = MFColor[2]
            c4 = MFColor[3]
        }
    "
Quote:
}

ROUTE ifsScript.c1 TO ifs1.diffuseColor
ROUTE ifsScript.c2 TO ifs2.diffuseColor
ROUTE ifsScript.c3 TO ifs3.diffuseColor
ROUTE ifsScript.c4 TO ifs4.diffuseColor

if you would prefer a demo of the directOutput method, which imho is much
more fun, just email me and i'll c what i can do
hope this helps
db


Quote:
> Is it possible to send out of JavaScript an MFColor to different
> IndexedFaceSets? So for example four colors are defined in a MFColor in
> a script and we want to send each color to a different IndexedFaceSet.

> Marnix & Marco



Wed, 13 Nov 2002 03:00:00 GMT  
 MFColor problem
Thank you for your reaction, but can you also explain how it works with
directOutput, because we want to fill the colors in the color field of an
IndexedFaceSet node and not in the material node (diffuseColor). We hope you can
tell us how this works. At this moment thanks.

Our problem is that we've got a legend and when we activate one block of the
legend we want to change the color of all the shapes with the same color. We
hope anybody can tell us the principle of this.

Greetings Marnix and Marco

Quote:

> have to split it and send them sepeartely, all possible from VRML
> 2 options, via directOutput or event driven
> i presume you are trying to set the entire colour of the IndexedFaceSet by
> changing its materials diffuseColor field, rather than using color{*filter*}ex
> or PerFace.
> 1 - event driven
> Shape {
>     appearance Appearance {
>         material DEF ifs1 Material {
>             diffuseColor 0 0 0
>         }
>     }
>     geometry DEF ifs1 IndexedFaceSet {
>     }
> }
> Shape {
>     appearance Appearance {
>         material DEF ifs2 Material {
>             diffuseColor 0 0 0
>         }
>     }
>     geometry DEF ifs2 IndexedFaceSet {
>     }
> }
> Shape {
>     appearance Appearance {
>         material DEF ifs3 Material {
>             diffuseColor 0 0 0
>         }
>     }
>     geometry DEF ifs3 IndexedFaceSet {
>     }
> }
> Shape {
>     appearance Appearance {
>         material DEF ifs4 Material {
>             diffuseColor 0 0 0
>         }
>     }
>     geometry IndexedFaceSet {
>     }
> }
> DEF ifsScript Script {
>     field MFColor colors [1 1 1,1 0 0,0 1 0,0 0 1]    #first shape is white,
> then red, green and finally blue
>     eventOut SFColor c1
>     eventOut SFColor c2
>     eventOut SFColor c3
>     eventOut SFColor c4
>     url "javascript:
>         function initialize(){
>             c1 = MFColor[0]
>             c2 = MFColor[1]
>             c3 = MFColor[2]
>             c4 = MFColor[3]
>         }
>     "
> }
> ROUTE ifsScript.c1 TO ifs1.diffuseColor
> ROUTE ifsScript.c2 TO ifs2.diffuseColor
> ROUTE ifsScript.c3 TO ifs3.diffuseColor
> ROUTE ifsScript.c4 TO ifs4.diffuseColor

> if you would prefer a demo of the directOutput method, which imho is much
> more fun, just email me and i'll c what i can do
> hope this helps
> db


> > Is it possible to send out of JavaScript an MFColor to different
> > IndexedFaceSets? So for example four colors are defined in a MFColor in
> > a script and we want to send each color to a different IndexedFaceSet.

> > Marnix & Marco



Fri, 15 Nov 2002 03:00:00 GMT  
 MFColor problem
if i understand your problem this may be the sort of thig your after ?
all you really need is the COLTABLE(ie Color) and CHANGECOL(ie Script) the
rest is just selecting etc

#VRML V2.0 utf8
DEF STILL Viewpoint { jump TRUE position 0 0 50 description "still"}

DEF COLTABLE Color {color[0 0 1,0 1 0,0 1 1,1 0 0,1 0 1,1 1 0]}

Transform {children [Shape {
geometry IndexedFaceSet{
color USE COLTABLE
coord Coordinate {point [0 0 0,-1 1 0,1 1 0,1 -1 0,-1 -1 0]}
colorIndex [0,0,0,-1,1,1,1-1,2,2,2,-1,3,3,3,-1]
coordIndex [0,1,2,-1,0,2,3,-1,0,3,4,-1,0,4,1,-1]

Quote:
}}]rotation 1 0 0 3.142 translation -6 0 0}

Transform {children [Shape {
geometry IndexedFaceSet{
color USE COLTABLE
coord Coordinate {point [0 0 0,-1 1 0,1 1 0,1 -1 0,-1 -1 0]}
colorIndex [1,1,1,-1,2,2,2-1,3,3,3,-1,4,4,4,-1]
coordIndex [0,1,2,-1,0,2,3,-1,0,3,4,-1,0,4,1,-1]

Quote:
}}]rotation 1 0 0 3.142 translation 0 0 0}

Transform {children [Shape {
geometry IndexedFaceSet{
color USE COLTABLE
coord Coordinate {point [0 0 0,-1 1 0,1 1 0,1 -1 0,-1 -1 0]}
colorIndex [5,5,5,-1,2,2,2-1,4,4,4,-1,0,0,0,-1]
coordIndex [0,1,2,-1,0,2,3,-1,0,3,4,-1,0,4,1,-1]

Quote:
}}]rotation 1 0 0 3.142 translation  6 0 0}

DEF CHANGECOL Script {
field  SFNode color USE COLTABLE
field  MFColor colororig []
field  SFInt32 colorprev 0

eventIn SFInt32 highlight
directOutput TRUE

url "javascript:
function initialize()
{
 for(c = 0;c < color.color.length;c++)
 {
 colororig[c] = new
SFColor(color.color[c][0],color.color[c][1],color.color[c][2]);
 }

Quote:
}

function highlight(value)
{
 if(value < color.color.length)
 {
 color.color[colorprev] = new
SFColor(colororig[colorprev][0],colororig[colorprev][1],colororig[colorprev]
[2]);
 color.color[value] = new SFColor(1,1,1);//ie a highlight col
 colorprev = value;
 }

Quote:
}
"
}

PROTO Button[
field  SFNode script NULL
field  SFInt32 color 0
field  SFVec3f pos 0 0 0
eventIn SFBool pressed
]
{
Transform{ children [
DEF ToS TouchSensor{}
Shape {geometry Box{size 2 2 1}}]translation IS pos}

DEF Buttonscript Script{
field  SFInt32 color IS color
field  SFNode script IS script
eventIn SFBool pressed
url"javascript:
function pressed(value)
{
if(value == true)
{
script.highlight = color;

Quote:
}
}
"
}

ROUTE ToS.isActive TO Buttonscript.pressed
Quote:
}

Button{pos -6 3 0 color 0 script USE CHANGECOL}
Button{pos -3 3 0 color 1 script USE CHANGECOL}
Button{pos  3 3 0 color 2 script USE CHANGECOL}
Button{pos  6 3 0 color 3 script USE CHANGECOL}



Quote:
> Thank you for your reaction, but can you also explain how it works with
> directOutput, because we want to fill the colors in the color field of an
> IndexedFaceSet node and not in the material node (diffuseColor). We hope
you can
> tell us how this works. At this moment thanks.

> Our problem is that we've got a legend and when we activate one block of
the
> legend we want to change the color of all the shapes with the same color.
We
> hope anybody can tell us the principle of this.

> Greetings Marnix and Marco



Sat, 16 Nov 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Populating an MFColor array with smoothly transisting colors - problems

2. Problem creating MFColor eventOut in vrmlscript

3. MFColor for skysets

4. How to put MFColor into SFNode

5. MFColor Interpolator: thanks and a question

6. Problems, problems, problems

7. Eiffel Problems, Problems, Problems

8. Finn Idiom problems and Re: {rho} problem

9. Combinatorial Problem [ & a new Combinatorial Problem ]

10. Database problem/Memory problem??

11. CW 2003 - Focus problem & a select problem

12. 32bit problem - one problem solved & another found

 

 
Powered by phpBB® Forum Software