[x3d-public] PROTO Usefulness Question

Leonard Daly Leonard.Daly at realism.com
Wed Feb 24 14:40:11 PST 2016


On 2/24/2016 1:57 PM, Yves Piguet wrote:
> In the scenes I'm writing now, I find it difficult to use proto fields as parameters without scripts. So my protos often have just a script with an initialize function, without any event or route, to set some child fields with simple calculation or type adjustment. This kind of syntax would be pretty cool:

This seems to be more like a MACRO expansion (simple parameters and 
basic mathematical operations). Something like (using a pseudo-PHP syntax):


MACRO Pyramid ($height=SFFloat(2), $base=SFFloat(2)) {
     node-definition using $height and $base with +-*/() and constants
}

This would be expanded during parsing to the collection of X3D nodes 
with all operations pre-computed. It would be used something like (in 
HTML-type syntax):

<Pyramid height='4' base='1'>

I think using inputOutput (or any variant) on that is misleading because 
(as per the example above), all of the computations are carried out 
during the initial parse and expansion. Any subsequent changes to those 
values would be controlled by what the node allows.


Another way to do this for geometry creation, is a file of standard 
shapes. You would change the size of these shapes by using the scale 
field of a Transform node. This is what is done for Box, Sphere, 
Cylinder, and Cone.


Leonard Daly



>
> PROTO Pyramid [
>   inputOutput height 2
>   inputOutput base 2
> ] {
>   IndexedFaceSet {
>     coord Coordinate {
>       point [
>         (base/2) (-height/2) (-base/2),
>         (-base/2) (-height/2) (-base/2),
>         (-base/2) (-height/2) 1,
>         (base/2) (-height/2) (base/2),
>         0 (height/2) 0
>       ]
>     }
>     coordIndex [
>       0 4 3 -1
>       1 4 0 -1
>       2 4 1 -1
>       3 4 2 -1
>       0 3 2 1 -1
>     ]
>   }
> }
>
> Yves
>
> On 24 févr. 2016, at 19:02, Leonard Daly wrote:
>
>> I asked this before but I don't think I got any answers. This is a slight rephrase of the question to help make it clearer.
>>
>> I am looking for examples of PROTOs (either internal or external) that are
>> 1) non-trivial
>> 2) do not use one or more Script nodes
>>
>>
>> By (1) I mean something that does something useful that is not easy to do without using a PROTO. Something like the Universal Media PROTOs (e.g., http://www.web3d.org/x3d/content/examples/Basic/UniversalMediaMaterials/_pages/page02.html) provide a lot of convenience to the X3D developer, but each one just defines a Material node with specific characteristics.
>>
>> A PROTO that is used repeated in a scene providing a critical feature might be an example of something that meets (1).
>>
>>
>> I am asking this to determine if it is necessary or useful to have a PROTO expander (sort-of like a MACRO). The expander would not support Script nodes. If there are no examples to this question, then it indicates that PROTOs need Script node(s). Either way, this has an impact on the design of V4.
>>
>> -- 
>> Leonard Daly
>> 3D Systems & Cloud Consultant
>> X3D Co-Chair on Sabbatical
>> LA ACM SIGGRAPH Chair
>> President, Daly Realism - Creating the Future
>> _______________________________________________
>> x3d-public mailing list
>> x3d-public at web3d.org
>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>


-- 
*Leonard Daly*
3D Systems & Cloud Consultant
X3D Co-Chair on Sabbatical
LA ACM SIGGRAPH Chair
President, Daly Realism - /Creating the Future/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160224/86c030d6/attachment.html>


More information about the x3d-public mailing list