Thank you for your hints~~ :)

On Sat, Dec 17, 2011 at 5:50 AM, Jukka Jylänki <[email protected]> wrote:

> Two (non-Tundra-specific) hints for the code:
>
> 1. Never compare floats using the built-in equality operator. Due to how
> IEEE-754 operates, it is possible that the equality operator is never true.
> Instead, use float3::Distance(float3), or float3::DistanceSq(float3).
> 2. Instead of accumulating the coordinates per-component, you should
> vectorize your code to make it more compact (and faster as well). float3
> has a member function .Add(float3).
>
> 2011/12/17 赵柏萱 <[email protected]>
>
>> Great! I'll try this, thank you Jonne!
>>
>> On Fri, Dec 16, 2011 at 6:42 PM, Jonne Nauha <[email protected]>wrote:
>>
>>> Fun to see you are learning Tundra scripting fast. And to answer your
>>> question yes this is one way of doing movement if we are talking about pos,
>>> rot, scale. You can make it a bit cleaner by just using the transform to
>>> assing new values and assign it back to the placeable like so:
>>>
>>> function updates()
>>> {
>>>    var t = me.placeable.transform;
>>>
>>>    if (tarpos.x != t.pos.x)
>>>        t.pos.x = tarpos.x > t.pos.x ? t.pos.x + moveSpeed : t.pos.x -
>>> moveSpeed;
>>>    if (tarpos.y != t.pos.y)
>>>        t.pos.y = tarpos.y > t.pos.y ? t.pos.y + moveSpeed : t.pos.y -
>>> moveSpeed;
>>>    if (tarpos.z != t.pos.z)
>>>        t.pos.z = tarpos.z > t.pos.z ? t.pos.z + moveSpeed : t.pos.z -
>>> moveSpeed;
>>>
>>>    <same for rot, just use t.rot>
>>>
>>>    <whatever else logic you need>
>>>
>>>    // Assign back to the full trasnform attribute, no need for new
>>> Transform(..)
>>>    me.placeable.transform = t;
>>> }
>>>
>>> Other option is to use the math library lerp and slerp functions, I have
>>> made some camera transition movement animations with them. float3 and Quat
>>> for example has them http://clb.demon.fi/MathGeoLib/docs/float3_Lerp.php For
>>> the t you can use eg. QTimeLine
>>> http://doc.trolltech.com/4.7/qtimeline.html with setting duration and
>>> range from 0.0 to 1.0 and connecting to the proper signal.
>>>
>>> For animations you need to have a EC_Mesh with a .mesh ref and a
>>> .skeleton ref set. Then you need EC_AnimationController component in the
>>> same entity. This will "snoop" the available animations from the .skeleton
>>> file in the EC_Mesh and you have various playback and stop functions for
>>> the animations, eg. me.animationcontroller.EnableExclusiveAnimation("walk",
>>> true); See doxygen for 
>>> more<http://realxtend.org/doxygen/class_e_c___animation_controller.html>
>>> .
>>>
>>> Hope that helps.
>>>
>>> Best regards,
>>> Jonne Nauha
>>> Adminotech developer
>>>
>>>
>>>
>>> On Fri, Dec 16, 2011 at 11:58 PM, Zhao Boxuan <[email protected]>wrote:
>>>
>>>> Great presentation!  It's very interesting when I see some animals
>>>> walk around. It seems like blender makes the animation of animals, but
>>>> can we use javascript to generate animation in real time(just
>>>> movement)? Currently, I just connect an function using  "
>>>> frame.Updated.connect(updates);" and define the updates function like
>>>> below:
>>>>
>>>> function updates()
>>>> {
>>>>    var rot = me.placeable.transform.rot;
>>>>    var scale = me.placeable.transform.scale;
>>>>    var pos = me.placeable.transform.pos;
>>>>
>>>>    if (tarpos.x > pos.x)
>>>>        pos.x = pos.x + moveSpeed;
>>>>    else if(tarpos.x < pos.x)
>>>>        pos.x = pos.x - moveSpeed;
>>>>    if (tarpos.y > pos.y)
>>>>        pos.y = pos.y + moveSpeed;
>>>>    else if(tarpos.y < pos.y)
>>>>        pos.y = pos.y - moveSpeed;
>>>>    if (tarpos.z > pos.z)
>>>>        pos.z = pos.z + moveSpeed;
>>>>    else if(tarpos.z < pos.z)
>>>>        pos.z = pos.z - moveSpeed;
>>>>
>>>>    if (tarRot.x > rot.x)
>>>>        rot.x = rot.x + rotSpeed;
>>>>    else if(tarRot.x < rot.x)
>>>>        rot.x = rot.x - rotSpeed;
>>>>    else if (tarRot.y > rot.y)
>>>>        rot.y = rot.y + rotSpeed;
>>>>    else if(tarRot.y < rot.y)
>>>>        rot.y = rot.y - rotSpeed;
>>>>    else if (tarRot.z > rot.z)
>>>>        rot.z = rot.z + rotSpeed;
>>>>    else if(tarRot.z < rot.z)
>>>>        rot.z = rot.z - rotSpeed;
>>>>
>>>>    me.placeable.transform = new Transform(pos, rot, scale);
>>>>
>>>>    if(tarpos.Sub(pos).Length() <= 0.1 && tarRot.Sub(rot).Length() <=
>>>> 0.3)
>>>>    {
>>>>        entity.placeable.transform = new Transform(tarpos, tarRot,
>>>> scale);
>>>>    }
>>>> }
>>>>
>>>> Reset the object's transform every frame. seems not a good way to do
>>>> that. :)  So, do we have some better way to make an movement?
>>>>
>>>> Thank you!
>>>>
>>>> Zhao
>>>>
>>>> On Dec 16, 6:07 am, Toni Alatalo <[email protected]> wrote:
>>>> > is up on youtube, thanks for the bconf folks - i posted about it to
>>>> thehttp://www.realxtend.org/blog ..
>>>> http://realxtend.wordpress.com/2011/12/16/tundra-and-blender-integrat.
>>>> ..
>>>> >
>>>> > will need to install blender2ogre on more computers and configure it
>>>> fully for the nice integration to work etc., has been really nice to have
>>>> at hand -- thanks Brett for the work, and help with preparing the demo too!
>>>> >
>>>> > ~Toni
>>>>
>>>> --
>>>> http://groups.google.com/group/realxtend
>>>> http://www.realxtend.org
>>>>
>>>
>>>  --
>>> http://groups.google.com/group/realxtend
>>> http://www.realxtend.org
>>>
>>
>>  --
>> http://groups.google.com/group/realxtend
>> http://www.realxtend.org
>>
>
>  --
> http://groups.google.com/group/realxtend
> http://www.realxtend.org
>

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

Reply via email to