This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > March 2004 > Another question





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 Another question
Lee Garrington

2004-02-27, 2:30 pm

Hey,

Forget that last question, thats not important now. I need a way to
dynamically create VRML code from javascript.

I found the createVrmlFromString command which I thought was great but when
I tried to dynamically create some VRML using either one of my prototypes or
a url for a texture I get an error like:-

Undefined node type grass (where grass.jpg is the name of the texture)

Is there something else I should be doing to prevent this error or is VRML
just _that_ bad :)

Maybe there is another method of accomplishing my goal?

Thx.


R. Russell Kinter

2004-02-28, 12:29 am

> a url for a texture I get an error like:-
>
> Undefined node type grass (where grass.jpg is the name of the texture)
>

Sounds like a simple error in how the string is put together.
Sheer specualtion here since you haven't posted the scripts,
but the quotation marks surrounding grass.jpg maybe throwing things
off because the script thinks the first quotation mark is the end of
the string. Preface quotation marks like that with a back slash, like: \"
to differentiate them as part of the VRML not string beginnings and endings.

"Lee Garrington" <zen25492@zen.co.uk> wrote in message news:<403f8988$0$17810$fa0fcedb@lovejoy.zen.co.uk>...
> Hey,
>
> Forget that last question, thats not important now. I need a way to
> dynamically create VRML code from javascript.
>
> I found the createVrmlFromString command which I thought was great but when
> I tried to dynamically create some VRML using either one of my prototypes or
> a url for a texture I get an error like:-
>
> Undefined node type grass (where grass.jpg is the name of the texture)
>
> Is there something else I should be doing to prevent this error or is VRML
> just _that_ bad :)
>
> Maybe there is another method of accomplishing my goal?
>
> Thx.

Braden McDaniel

2004-02-28, 1:28 am

On Fri, 27 Feb 2004 18:16:40 +0000, Lee Garrington wrote:

> Hey,
>
> Forget that last question, thats not important now. I need a way to
> dynamically create VRML code from javascript.
>
> I found the createVrmlFromString command which I thought was great but when
> I tried to dynamically create some VRML using either one of my prototypes or
> a url for a texture I get an error like:-
>
> Undefined node type grass (where grass.jpg is the name of the texture)
>
> Is there something else I should be doing to prevent this error or is VRML
> just _that_ bad :)
>
> Maybe there is another method of accomplishing my goal?


You have to include the PROTO definition in the string.

--
Braden McDaniel e-mail: <braden@endoframe.com>
<http://endoframe.com> Jabber: <braden@jabber.org>

Lee Garrington

2004-02-28, 9:29 am

Hey,

Well it ran without errors after using the escape scharacter before both
quotes BUT it does not display the texture.

node = 'Transform'+
'{'+
'children'+
'['+
'Shape'+
'{'+
'geometry Box'+
'{'+
'size '+width+' 0.1 '+length+
'}'+
'appearance Appearance'+
'{'+
'texture ImageTexture'+
'{url \"grass.jpg\"}'+
'}'+
'}'+
']'+
'}';
node = Browser.createVrmlFromString(node);
maze.addChildren = node;

I assume that the escape character is altering the filename of the .jpg
therefore not loading it in. Thats just a guess though. Any ideas?

Many thanks

"R. Russell Kinter" <Pyth7@comcast.net> wrote in message
news:1a90d129.0402272004.15f80e3c@posting.google.com...
> Sounds like a simple error in how the string is put together.
> Sheer specualtion here since you haven't posted the scripts,
> but the quotation marks surrounding grass.jpg maybe throwing things
> off because the script thinks the first quotation mark is the end of
> the string. Preface quotation marks like that with a back slash, like: \"
> to differentiate them as part of the VRML not string beginnings and

endings.
>
> "Lee Garrington" <zen25492@zen.co.uk> wrote in message

news:<403f8988$0$17810$fa0fcedb@lovejoy.zen.co.uk>...[color=darkred]
when[color=darkred]
prototypes or[color=darkred]
VRML[color=darkred]


R. Russell Kinter

2004-02-28, 8:29 pm

Am surprised your browser didn't throw a fit.
Box Node does not use width or length.
Simply size, then three float numbers for x y and z dimensions
This error kept it from loading the jpg

Try this: node = 'Transform'+
'{'+
'children'+
'['+
'Shape'+
'{'+
'geometry Box'+
'{'+
'size 1 1 1 ' +
'}'+
'appearance Appearance'+
'{'+
'texture ImageTexture'+
'{url \"grass.jpg\"}'+
'}'+
'}'+
']'+
'}';
"Lee Garrington" <zen25492@zen.co.uk> wrote in message news:<40408c97$0$17848$fa0fcedb@lovejoy.zen.co.uk>...[color=darkred]
> Hey,
>
> Well it ran without errors after using the escape scharacter before both
> quotes BUT it does not display the texture.
>
> node = 'Transform'+
> '{'+
> 'children'+
> '['+
> 'Shape'+
> '{'+
> 'geometry Box'+
> '{'+
> 'size '+width+' 0.1 '+length+
> '}'+
> 'appearance Appearance'+
> '{'+
> 'texture ImageTexture'+
> '{url \"grass.jpg\"}'+
> '}'+
> '}'+
> ']'+
> '}';
> node = Browser.createVrmlFromString(node);
> maze.addChildren = node;
>
> I assume that the escape character is altering the filename of the .jpg
> therefore not loading it in. Thats just a guess though. Any ideas?
>
> Many thanks
>
> "R. Russell Kinter" <Pyth7@comcast.net> wrote in message
> news:1a90d129.0402272004.15f80e3c@posting.google.com...
> endings.
> news:<403f8988$0$17810$fa0fcedb@lovejoy.zen.co.uk>...
> when
> prototypes or
> VRML
Lee Garrington

2004-02-29, 7:28 am

Hey,

This is not the error. I tried putting in size 1 1 1 instead and it still
did not work. Width and height are 2 variables to denote the size of the
box. Is there anything else it could be?

Thx

"R. Russell Kinter" <Pyth7@comcast.net> wrote in message
news:1a90d129.0402281556.17cff82b@posting.google.com...
> Am surprised your browser didn't throw a fit.
> Box Node does not use width or length.
> Simply size, then three float numbers for x y and z dimensions
> This error kept it from loading the jpg
>
> Try this: node = 'Transform'+
> '{'+
> 'children'+
> '['+
> 'Shape'+
> '{'+
> 'geometry Box'+
> '{'+
> 'size 1 1 1 ' +
> '}'+
> 'appearance Appearance'+
> '{'+
> 'texture ImageTexture'+
> '{url \"grass.jpg\"}'+
> '}'+
> '}'+
> ']'+
> '}';
> "Lee Garrington" <zen25492@zen.co.uk> wrote in message

news:<40408c97$0$17848$fa0fcedb@lovejoy.zen.co.uk>...[color=darkred]
texture)[color=darkred]
\"[color=darkred]
but[color=darkred]
texture)[color=darkred]
is[color=darkred]


Cecile Muller

2004-02-29, 11:28 am

> Well it ran without errors after using the escape scharacter before both
> quotes BUT it does not display the texture.


Is the texture in the same folder as the vrml file ? (it should
because of the url given in the string). Also check that it has the
case case (i.e. not a ".JPG" instead of ".jpg")
Because this works fine (better call the length variable another way
btw because it's a predefined variable in Cosmo) :

--------
#VRML V2.0 utf8

DEF maze Group{}
Script{
field SFNode maze USE maze
url "java script:
function initialize(){
width = 5;
len = 0.1;
node = 'Transform'+
'{'+
'children'+
'['+
'Shape'+
'{'+
'geometry Box'+
'{'+
'size '+width+' 0.1 '+len+
'}'+
'appearance Appearance'+
'{'+
'texture ImageTexture'+
'{url \"grass.jpg\"}'+
'}'+
'}'+
']'+
'}';
node = Browser.createVrmlFromString(node);
maze.addChildren = node;

}
"
}
Viewpoint{}
----------
Lee Garrington

2004-02-29, 11:28 am

I copied that exact code and it still did not display the texture. The jpg
is in the same directory and the name is grass.jpg so there is no error
there. I am using Cortona. Maybe its a bug with that?

What do you recommend as the VRML software to use? Cosmo player?

Thx

"Cecile Muller" <spam@wildpeaks.com> wrote in message
news:aff31ac6.0402290638.145aeb27@posting.google.com...
>
> Is the texture in the same folder as the vrml file ? (it should
> because of the url given in the string). Also check that it has the
> case case (i.e. not a ".JPG" instead of ".jpg")
> Because this works fine (better call the length variable another way
> btw because it's a predefined variable in Cosmo) :
>
> --------
> #VRML V2.0 utf8
>
> DEF maze Group{}
> Script{
> field SFNode maze USE maze
> url "java script:
> function initialize(){
> width = 5;
> len = 0.1;
> node = 'Transform'+
> '{'+
> 'children'+
> '['+
> 'Shape'+
> '{'+
> 'geometry Box'+
> '{'+
> 'size '+width+' 0.1 '+len+
> '}'+
> 'appearance Appearance'+
> '{'+
> 'texture ImageTexture'+
> '{url \"grass.jpg\"}'+
> '}'+
> '}'+
> ']'+
> '}';
> node = Browser.createVrmlFromString(node);
> maze.addChildren = node;
>
> }
> "
> }
> Viewpoint{}
> ----------



Cecile Muller

2004-02-29, 4:29 pm

> I copied that exact code and it still did not display the texture. The jpg
> is in the same directory and the name is grass.jpg so there is no error
> there. I am using Cortona. Maybe its a bug with that?


Check that textures are allowed ("right click -> Preferences ->
Renderer -> Do not render texture" should be unchecked).

Also, try to view this scene:
http://help.wildpeaks.com/dynamique_box_creation.wrl
which is meant to display the texture, so if it doesn't, it's probably
coming from Corto or from that .jpg file.


> What do you recommend as the VRML software to use? Cosmo player?


No (or just for testing purposes), i'd recommend BS Contact, but
that shape should be visible in Cortona too.
Lee Garrington

2004-02-29, 6:29 pm

Hey,

Yep I could view that texture and that option is not ticked. I have
absolutely no idea why it is not working, its a joke to be honest.

It cant be the grass texture either because it works if I add the child node
not using the createVrmlFromString command. I can only speculate that the
command cannot parse statements with texture calls in......but that would be
ridiculous.

Have you ever done a program in which you have accomplished what I am trying
to do? If you have the time, can you have a go at trying to get a program
to display a texture using that command? I have tried both cortona and
cosmo player and neither worked.

Failing that, is there any other method at all I can use to do the same
thing?

Thx in advance


R. Russell Kinter

2004-03-01, 12:28 am

I tested your script with corrections and it worked fine on my
'puter and OS.
Both of which are closing in on 3 years old.
Could it be that that Billy boy Gates has been mischevious again
and one his "Service" Packs is pulling security b.s.?

"Lee Garrington" <zen25492@zen.co.uk> wrote in message news:<40425ccc$0$25003$fa0fcedb@lovejoy.zen.co.uk>...

> Hey,
>
> Yep I could view that texture and that option is not ticked. I have
> absolutely no idea why it is not working, its a joke to be honest.
>
> It cant be the grass texture either because it works if I add the child node
> not using the createVrmlFromString command. I can only speculate that the
> command cannot parse statements with texture calls in......but that would be
> ridiculous.
>
> Have you ever done a program in which you have accomplished what I am trying
> to do? If you have the time, can you have a go at trying to get a program
> to display a texture using that command? I have tried both cortona and
> cosmo player and neither worked.
>
> Failing that, is there any other method at all I can use to do the same
> thing?
>
> Thx in advance

Cecile Muller

2004-03-01, 8:29 am

> Failing that, is there any other method at all I can use to do the same
> thing?


You could try this way too:
-----
#VRML V2.0 utf8

DEF maze Group{}
Script{
field SFNode grassTexture ImageTexture{url "pai.jpg"}
field SFNode maze USE maze
url "java script:
function initialize(){
width = 2;
len = 0.1;
str = 'Transform{children Shape{geometry Box{size '+width+' 2
'+len+'} appearance Appearance{}}}';
nodes = Browser.createVrmlFromString(str);
nodes[0].children[0].appearance.texture = grassTexture;
maze.addChildren = nodes;
}
"
}
Viewpoint{}
----------

But imho you will get the same result if the first one doesn't work
either.
Sponsored Links


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