≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
how to trigger a custom animators event
Posted by:
(you are not logged in)
Enter the missing letter in: "Internatio?al"
(you are not logged in)
Text:
[quote][b]simon_marklar[/b] wrote: Hi, First off thanks for copperlicht. i've used irrlicht before and love the way it works. but i have a question :) i've made a custom animation node whos purpose is to get keyboard input and then rotate the node depending on the keypress. I know there is a rotator animator already but the animateNode behavior is not what I want ( or at least i think its not.. might experiment with it ). I know that the animateNode function is being called, but the event is not ( i dont see my console log messages ). Do i need to register the animator? here's my code for the custom animator: [code] var Rotator = function( engine ) { this.DesiredRot = new CL3D.Vect3d(); this.Animate = false; //this.init(); } Rotator.prototype = new CL3D.Animator(); Rotator.prototype. = function(e) { console.log("in rotator input"); this.DesiredRot.X = 0; this.DesiredRot.Y = 0; var key = String.fromCharCode(e.keyCode); if ( key == 'D') { this.DesiredRot.X += 90; } if ( key == 'S') { this.DesiredRot.Y += 180; } if ( key == 'A') { this.DesiredRot.X += 270; } this.Animate = true; engine.handleKeyDown(e); } Rotator.prototype.animateNode = function( n, timeMs ) { if ( !this.Animate ) return; //console.log( "animating rotator"); var currentRot = new CL3D.Quaternion( 0, 0, 0, 1 ); currentRot.setFromEuler( n.Rot.X, n.Rot.Y, n.Rot.Z ); var desiredRotQ = new CL3D.Quaternion( 0, 0, 0, 1 ); desiredRotQ.setFromEuler( this.DesiredRot.X, this.DesiredRot.Y, this.DesiredRot.Z ); var slerp = new CL3D.Quaternion(); slerp.slerp( currentRot, desiredRotQ, 0.1 ); slerp.toEuler( n.Rot ); this.Animate = false; } [/code] im not sure the function will work the way i want, but thats besides the point. I should be seeing console.log messages on a key press, but im not. thanks![/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact