RotateTo or LookAt: the right way?

Software: Away3D 4.x

GameDesigner, Jr. Member
Posted: 17 June 2013 07:59 AM   Total Posts: 33

Hi friends!

I’m trying to make the cone (and other meshes) rotate and behave like the line segment (along the normals) (please see attachment)

I’m trying with

testMesh.rotateTo(normal.clone().xnormal.clone().ynormal.clone().z); 

or

testMesh.lookAt(normal.clone()); 

but I guess that I’m doing something wrong.

.........
private function  
onMeshMouseMove(event:MouseEvent3D):void
  {
   
// Update normal tracer.
   
var normal:Vector3D event.sceneNormal.clone();
   
normal.scaleBy(100);
   
   
pickingNormalTracer.position event.scenePosition;
   var 
lineSegment:LineSegment pickingNormalTracer.getSegment) as LineSegment;
   
lineSegment.end normal.clone();
   
lineSegment.startColor 0xff0000;
   
lineSegment.endColor 0x00ff00;
   
   
testMesh.position event.scenePosition;
  
// THE SMAR POINT xD

testMesh.rotateTo(normal.clone().x,normal.clone().y,normal.clone().z);
  
}
...... 

 

File Attachments
Test.swf  (File Size: 744KB - Downloads: 315)
   

John Brookes, Moderator
Posted: 17 June 2013 09:01 AM   Total Posts: 732   [ # 1 ]

Cone geometry has a boolean upAxis parameter.
Toggle that to true/false.

   

GameDesigner, Jr. Member
Posted: 17 June 2013 12:26 PM   Total Posts: 33   [ # 2 ]

Hi John,
Thanks for your reply. Maybe you mean the yUp parameter of the Cone Geometry, but that doesn’t works.

Is there any other way to make the meshes behave like the segment of the example?

I’ve tried almost everything without success :/

JohnBrookes - 17 June 2013 09:01 AM

Cone geometry has a boolean upAxis parameter.
Toggle that to true/false.

   

John Brookes, Moderator
Posted: 17 June 2013 01:16 PM   Total Posts: 732   [ # 3 ]

Yeah sorry meant yUp

In your mouseMove function.

testMesh.position = event.scenePosition;

testMesh.lookAt(event.scenePosition.clone().add(event.sceneNormal.clone()));

//you can then move it futher in/out by doing something like.
testMesh.moveForward(50);

   

GameDesigner, Jr. Member
Posted: 17 June 2013 04:17 PM   Total Posts: 33   [ # 4 ]

A—W—E—S—O—M—E !!!!

Thank you so much!

JohnBrookes - 17 June 2013 01:16 PM

Yeah sorry meant yUp

In your mouseMove function.

testMesh.position = event.scenePosition;

testMesh.lookAt(event.scenePosition.clone().add(event.sceneNormal.clone()));

//you can then move it futher in/out by doing something like.
testMesh.moveForward(50);

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X