Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How I change the initial rotation of my ship?


wdna

Recommended Posts

I found a free model I can play with of nice quality.

I have the following situation:

 

post-9104-0-76944700-1400786858.png

 

Like you can see the models initial rotation is wrong, it should be facing the direction of brush.

This code can fix the rotation for me:

ship->SetRotation(90,90,0, true);

 

But then I have issue with ship movement:

 

if(window->KeyDown(Key::A)) {
 ship->Move(-move_speed,0,0);
}
if(window->KeyDown(Key:)) {
 ship->Move(move_speed,0,0);
}
if(window->KeyDown(Key::S)) {
 ship->Move(0,0,-move_speed);
}
if(window->KeyDown(Key::W)) {
 ship->Move(0,0,move_speed);
}

 

Movement would be in the wrong then directions. I could also adjust this but obviously it's not the right way. I am aware you can rotate it in some 3D software like blender, but I'm trying to avoid it right now.

 

and generally what would be best practice for such cases?

Link to post

You could create a pivot entity, then call Entity::SetParent() to parent the ship to the pivot, and then call your commands on the pivot. That would basically fix the model's orientation to be the way you want.

Link to post

Thanks! This worked for me!

 

ship = Model::Load("Models/Ship/dark_fighter_6.mdl");
ship->SetPosition(0,4,0);
shipPivot = Pivot::Create();
ship->SetParent(shipPivot);
ship->SetRotation(90,90,0, true);

...

if(window->KeyDown(Key::A)) {
   shipPivot->Move(-move_speed,0,0);
}

...

 

There's some pattern to handle this in more global manner?

Edited by wdna
Link to post

I think rotate and move commands in the model editor, below scale, would come in really handy.

 

Rotate would rotate the model around its origin/anchor, whether that's at the bottom of the feet or middle of the model or wherever.

Move would move the model relative to the origin/anchor.

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Facebook Twitter Youtube Github Steam
×
×
  • Create New...