Jump to content

unirule

  • entries
    21
  • comments
    39
  • views
    18702

Orientation Vector

Sign in to follow this  
Awoken

1399 views

The past couple weeks I've been working on a custom class which I call an Ovector, or Orientation Vector. It's builds off of the THREE.js Vector3() class.

With the Ovector Class I can identify any three dimensional position in the scene, and then orientate it by giving it a direction to face, and an up axis so it orientates itself accordingly. The beauty of this class is that it has an internal InheritFrom function that acts a lot like lego blocks. Each new Ovector builds off of a previous Ovector.

The inheritFrom function asks for the following:[code=js:1]inheritFrom( x , distance , rotation , F1 , F2 , plane )// x: is the direction GP vector for the next position// F1: is the origin GP vector for the next pointAt vector// F2: is the direction GP vecotr for the next pointAt vector// this.position and x draw a line, so do F1 and F2.
In the following pictures each Ovector is displayed with Arrows, Blue for Up, Red for Front, White for Right.

Screenshot from 2016-12-31 09-57-48.png
The picture above was generated by the code below.[code=js:1]var vv = new Ovector( $m.rO( $m.v( $m.rN() , $m.rN() , $m.rN() ).normalize().multiplyScalar(11) , $m.v() , 0 , 10 , TGglobalMesh , 0 ).point.clone() , editorParameters.unitScale /*, undefined , zz */ );var ww = vv.inheritFrom( vv.up , 50 , 0 , vv.front , vv.topFront , vv.normal );var yy = []; yy[0] = ww.inheritFrom( ww.front , 100 , 0 , ww.position , ww.front );for( var i=1; i<55; i++){ yy = yy[i-1].inheritFrom( yy[i-1].front , 100 , (i*i /100)+1 , yy[i-1].position , yy[i-1].front );}
The newly created Ovectors do not inherit an orientation Plane to align themselves to, so they align to the surface to of the sphere instead.


Screenshot from 2016-12-31 09-56-39.png
In the picture above the same Ovectors are given a plane which to fix themselves to.
All that is added to the code is the following:[code=js:8] yy = yy[i-1].inheritFrom( yy[i-1].front , 100 , (i*i /100)+1 , yy[i-1].position , yy[i-1].front , vv.plane );
This custom class will greatly speed up my dynamic Asset creating component and will also make it easy to construct stuff.

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!