Closed tpaviot closed 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.
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".
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.
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?
I think the latter would be better, i.e. replace parameters with paramValueMap.
I justed pushed the changes, do you think they are acceptable like that?
Yes it's ok.
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
That sounds really great, can't wait to see the results!
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.