Forum: Ruby Rotate object in superengine for ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fb02e38715b4dda5236079bb8bb91e8b?d=identicon&s=25 Geasy Devon (geasy)
on 2009-04-03 17:14
Hi

I need help. I use a ruby superengine software to virtualize 3D object.
This software use a ruby scripts. In this virtualizer I need rotate
object. And aj dont know how to do it. For example i give to this page
example of moveobject and part of my definition of rotateobject. For
answers thx.

examples :

def MoveObject(object,x,y,z,speed=1)

  pdx = (object.px - x).abs;
  pdy = (object.py - y).abs;
  pdz = (object.pz - z).abs;
  if(pdx<=0.001 && pdy<=0.001 && pdz<=0.001) then return true end

  dirx = 1.0;
  diry = 1.0;
  dirz = 1.0;

  dx = x - object.px;
  dy = y - object.py;
  dz = z - object.pz;

  if(dx<0.0) then dirx = -1.0 end
  if(dy<0.0) then diry = -1.0 end
  if(dz<0.0) then dirz = -1.0 end

  deltax = speed * dirx * $FRAMETIME;
  deltay = speed * diry * $FRAMETIME;
  deltaz = speed * dirz * $FRAMETIME;

  max = dx.abs;
  if(dy.abs > max) then max = dy.abs end
  if(dz.abs > max) then max = dz.abs end

  if(max == dx.abs) then
    deltay = deltay * (dy.abs/dx.abs);
    deltaz = deltaz * (dz.abs/dx.abs);
  elsif(max == dy.abs) then
    deltax = deltax * (dx.abs/dy.abs);
    deltaz = deltaz * (dz.abs/dy.abs);
  elsif(max == dz.abs) then
    deltax = deltax * (dx.abs/dz.abs);
    deltay = deltay * (dy.abs/dz.abs);
  end

  object.px = object.px + deltax;
  object.py = object.py + deltay;
  object.pz = object.pz + deltaz;

  if(dirx<0.0) then
    if(object.px <= x) then object.px = x end
  else
    if(object.px >= x) then object.px = x end
  end

  if(diry<0.0) then
    if(object.py <= y) then object.py = y end
  else
    if(object.py >= y) then object.py = y end
  end

  if(dirz<0.0) then
    if(object.pz <= z) then object.pz = z end
  else
    if(object.pz >= z) then object.pz = z end
  end

  finished = false;
  pdx = (object.px - x).abs;
  pdy = (object.py - y).abs;
  pdz = (object.pz - z).abs;
  if(pdx<=0.001 && pdy<=0.001 && pdz<=0.001) then return true
  else return false end
end

This script is OK and its fully function

now rotate object

def RotateObject(object,dx,dy,dz,rotation_time=1,speed=1)

        dirx = 1.0;
  diry = 1.0;
  dirz = 1.0;

  if(dx<0.0) then dirx = -1.0 end
  if(dy<0.0) then diry = -1.0 end
  if(dz<0.0) then dirz = -1.0 end

  a=dx/(rotation_time);

  deltax = speed * dirx * $FRAMETIME;
  deltay = speed * diry * $FRAMETIME;
  deltaz = speed * dirz * $FRAMETIME;


  ## Rotation angle
  $angle  = $angle + ($FRAMETIME/16.0)*360.0;

  ## Are we about to change model?
  if($angle > $max_rotation) then
    $angle = 0;
    $modelID = $modelID + 1;
  end

  ## Looping
  if($modelID > 5) then
    $modelID = 0;
  end

  ## Now we set rotation to each model
  $gallon_small_finished.oz = $angle;
  end
And this script has no errors but do nothing :(
This topic is locked and can not be replied to.