x3dom / apps-modeling

Publicly Available Applications
Other
3 stars 3 forks source link

[ComponentEditor] Export primitive type (positive or negative) to JSON #98

Closed tpaviot closed 10 years ago

tpaviot commented 10 years ago

In the file Primitive.js, the Primitive.prototype.toJSON function exports the set of primitives to JSON so that they can be process by the StorageManager. A flag 'positive' should be added, false if negative, true if the primitive is positive.

It's not necessary to create two different lists (PositivePrimitives and NegativePrimitive). A PrimitiveList is enough, with all positive and negative primitives.

For our demo, here is what I suggest : all negative primitives will be fused together, and removed from a positive shape resulting from the fusion of all primitives. So we'll have: final_shape = (pos_prim_0 + pos_prim_1 +...) - (neg_prim_0 + neg_prim_1 + etc.)

It's a big simplification of the current workflow, but it will be enough for the demo.

mlimper commented 10 years ago

Okay, I'll adapt the toJSON function so that it just fills one list and uses a boolean attribute for positive / negative.

mlimper commented 10 years ago

I just saw that this information is already exported - it is part of the "paramValueMap", there is a boolean parameter(in string representation) called "Positive Element".

tpaviot commented 10 years ago

The problem is that paramValueMap is restricted to the scope of the primitiveInDSL method. I'd rather have access to this information from the saveScene method, and being able to include statements like 'if prim.positive' directly from the saveScene method.

mlimper commented 10 years ago

The information is also already there, it is included in the "parameters" object from which the "paramValueMap" is built. It's like this: The "parameters" object is simply the object which is used by the editor and the UI. To facilitate the handling of this object, I decided to temporarily create the "paramValueMap" when exporting the primitive.

To use the "paramValueMap" in "saveScene", one could simply decide to create it already there, and to pass just a reference to that map to the "primitiveInDSL" function. If you agree, I could also directly create the "paramValueMap" in the "Primitive.prototype.toJSON" function, and pass it as part of the jsonObject, instead of the "parameters" member?

tpaviot commented 10 years ago

I think the latter would be better, i.e. replace parameters with paramValueMap.

mlimper commented 10 years ago

I justed pushed the changes, do you think they are acceptable like that?

tpaviot commented 10 years ago

Yes it's ok.

tpaviot commented 10 years ago

Ok, thanks to this change, I was able to make the Storage manager export positive and negative primitives in a way they can be processed by the DSL interpreter see commit 8856b624061c0c787bfb6e177965fc7e7bd28568

mlimper commented 10 years ago

That sounds really great, can't wait to see the results!