Check
https://github.com/realXtend/naali/blob/tundra2/src/Core/Scene/EC_DynamicComponent.h


Our example avatar app also has good example how to use it
https://github.com/realXtend/naali/blob/tundra2/bin/scenes/Avatar/simpleavatar.js#L110

Best regards,
Jonne Nauha
Adminotech developer


On Thu, Sep 27, 2012 at 3:53 PM, Jonne Nauha <[email protected]> wrote:

> I would actually use EC_DynamicComponent. With this you can create a
> component, define it all kinds of attributes on the fly and set their
> values. Its kind of a neat "I'll just put my data hear" component, it will
> save to txml so the data is persistent.
>
> You can add/edit/remove the attributes from the entity editor by right
> clicking the component or from javascript code:
>
> var dataComp = someEntity.GetOrCreateComponent("EC_DynamicComponent",
> "MyData");
>
> if (!dataComp.HasAttribute("materialList"))
>     dataComp.CreateAttribute("qvariantlist", "materialList");
> if (!dataComp.HasAttribute("materialList"))
>     dataComp.CreateAttribute("real", "targetDistance");
> if (!dataComp.HasAttribute("logicEnabled"))
>     dataComp.CreateAttribute("bool", "logicEnabled");
> if (!dataComp.HasAttribute("targetOffset"))
>     dataComp.CreateAttribute("float3", "targetOffset");
>
> var targetDist = 12 * x / 2;
>
> dataComp.SetAttribute("materialList", [ "my.material", "whee  whoo", "
> http://assets.com/second.material";]);
> dataComp.SetAttribute("materialList", targetDist);
> dataComp.SetAttribute("logicEnabled", (targetDist > 1 ? true : false));
> dataComp.SetAttribute("targetOffset", new float3(10, 5, -1.33));
>
> // Later in the code using it
>
> var dataComp = someEntity.GetOrCreateComponent("EC_DynamicComponent",
> "MyData");
> if (dataComp.GetAttribute("logicEnabled"))
> {
>     targetEnt.placeable.WorldPosition().Add(dataComp.GetAttribute("
> targetOffset"));
>     // etc...
> }
>
> Best regards,
> Jonne Nauha
> Adminotech developer
>
>
>
> On Wed, Sep 26, 2012 at 10:03 PM, Toni Alatalo <[email protected]> wrote:
>
>> On Sep 26, 2012, at 9:08 PM, Peter C. wrote:
>>
>> I was wondering if anyone had any knowledge of how to implement a entity
>> component with an array of groups of properties. I'm trying to implement an
>> ogre terrain entity component, however in order to properly implement it, I
>> need to implement an array that can be expanded as needed of groups of
>> textures/materials. I was wondering if A. this functionality was possible
>> in RealXtend,
>>
>>
>> EC_Mesh has an array of materials in the attributes,
>> in
>> https://github.com/realXtend/naali/blob/tundra2/src/Core/OgreRenderingModule/EC_Mesh.h#L161
>>
>>
>>     /// Mesh material asset reference list, material requests are handled 
>> automatically.
>>
>>     Q_PROPERTY(AssetReferenceList meshMaterial READ getmeshMaterial WRITE 
>> setmeshMaterial);
>>
>>     DEFINE_QPROPERTY_ATTRIBUTE(AssetReferenceList, meshMaterial);
>>
>>
>> Peter
>>
>>
>> ~Toni
>>
>>  --
>> http://groups.google.com/group/realxtend
>> http://www.realxtend.org
>>
>
>

-- 
http://groups.google.com/group/realxtend
http://www.realxtend.org

Reply via email to