3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: Rotate selected skinmesh according to mouse  (Read 94 times)

« on: March 04, 2014, 06:58:51 AM »
hey everyone,

right my first question lol i have done a search but cant find what i need
i might be wording it wrong but here goes

What i need to do is to be able to rotate a skin mesh, now i know i can just tick the spin box but i want the player to be able to control the spin using there mouse kinda like 3d modelling programs. Also this will be used on two separate skins so i need it switchable any one any ideas i cant script yet but the basic logic i need to figure out is

detect mouse over which skin mesh
once clicked mesh frees from static position and clicked point follows mouse.
once mouse is unclicked revert to step one

obviously this is wrong as sudo logic but its the general idea

I'm not asking for anyone to do it for me just some ideas to solve the problem would be awesome

thanks

Danipren
« Reply #1 on: March 08, 2014, 07:19:00 PM »
well... you've done the first, most important part... you've thought out the logic and written it down...
so no matter what, don't worry about anyone accusing you of doing  it for you...

ok, since you've got the logic, next step is to code the logic...

1 - detect mouse over which skinmesh...  first you're gonna need a script object, a 1st person cam (no need to link it to gforce or terrain), and a few skinmeshes...

set the skinmeshes' detect mouse over properties and link the meshes to the script object...

turn off the mouse control for the cam 1st person so the mouse cursor will show... aim the cam at the meshes...

we need to see if the mouse over event is being detected for each mesh so add a value print and link it to the script...  add the following script and run...

Code: [Select]
int  target;


void Main()
int  target;


void Main()
{
   target=0;                    //  always reset the target to 0
   if(IN_3==1  )target=OBJ_0;   //  if mouse over obj_0 mesh,  it must be the target
   if(IN_47==1 )target=OBJ_44;  //  if mouse over obj_47 mesh, it must be the target
   if(IN_69==1 )target=OBJ_66;  //  if mouse over obj_66 mesh, it must be the target

   OUT_22=target;               //  send target to value print
}

this should show that the first step in your logic has been successfully implemented...



2 - once clicked mesh frees from static position and clicked point follows mouse... is the next bit of logic we'll need to code... this is gonna require a lil in depth thinking... it sounds like you want the selected target from above to follow the mouse pointer around while the button is down...  hhmmmm...

we're gonna have to implement a switch... to keep the target object identified until the mouse button is released... then we're gonna have to figure a way to have the target look at the mouse pointer as it moves, until the button is released...

first thing that comes to mind is iQuaternionLookAt()... but what to look at...

lets see what you come up with... i'll revisit this to see how far you've gotten  :)


--Mike
« Last Edit: March 08, 2014, 09:32:43 PM by Mike Hense »
« Reply #2 on: March 10, 2014, 07:17:26 PM »
Thanks mike I haven't been able to put this together yet (girlfriends taken over my netbook to do her coursework so my stuff on the backburner lol) but this is starting to sound exactly what i need.

i cant script yet but i can kinda read them so that one is perfect for me to look over so thanks again. The only part I'm getting lost on is the QuaternionLookAt(), i unfortunately have no idea what that is sorry.

One thing that might make this easier is that there will only be on skinmesh in the scene. (other meshes will be attached by bone to that mesh so they shouldn't be a problem) so maybe i wouldn't have to go as far as detecting the mouse over mesh but maybe just click to turn on and off the rotation.  sorry i know that kinda just defeats the purpose of what you said and i could be wrong but i just thought would that be less complicated or pretty much the same?
Pages: [1]