Page 1 of 1

Does MeshCenter command work with 1.5.x ReferenceFrame code?

Posted: 10.01.2009, 10:55
by Chuft-Captain
I have a mesh for which I want the "origin" to be at the outer edge of the mesh (along the X-axis), so that point is treated as the center of the mesh for the purposes of orientation.

Assuming the radius of the mesh in Celestia is 0.0015, I would have thought that one of the following statements would have done the job:

Code: Select all

MeshCenter [ 0.0015 0 0 ]
or

Code: Select all

MeshCenter [ -0.0015 0 0 ]


However, this seems to have no effect.... It appears that reference and body frames are always centered on the center of the bounding box, and this cannot be changed by the MeshCenter statement.

This is how it's orientation is handled:

Code: Select all

BodyFrame {
    TwoVector {
        Center "Sol/Earth/GLOBALSTAR M002/GLOBALSTAR M002 Panel LHS"
        Primary {
            Axis "y"
            RelativePosition { Target "Sol" }
        }
        Secondary {
            Axis "-x"
            RelativeVelocity { Target "Sol/Earth" }
        }
    }
}

FixedRotation {}

The trouble is, this BodyFrame code seems to always act on the ceter of the bounding box (regardless of whether a MeshCemter statement is used or not)

Anyone have any ideas???

Thanks in advance
CC

Re: Does MeshCenter command work with 1.5.x ReferenceFrame code?

Posted: 10.01.2009, 14:24
by selden
1. modify your mesh to include invisible elements such that the center of them all is at the desired center.

2. use Celestia v1.6 and the directives NormalizeMesh and MeshScale.
See http://www.celestiaproject.net/forum/viewtopic ... 10&t=12520

Re: Does MeshCenter command work with 1.5.x ReferenceFrame code?

Posted: 10.01.2009, 14:42
by Chuft-Captain
selden wrote:1. modify your mesh to include invisible elements such that the center of them all is at the desired center.
Thanks Selden, but that's actually exactly how I currently manage it (see: http://www.youtube.com/watch?v=jeX9miuSDZc ).
I was actually looking for a more elegant method as I'm sick of all the *un-nescessary* messing around with meshes. :wink:

selden wrote:2. use Celestia v1.6 and the directives NormalizeMesh and MeshScale.
See http://www.celestiaproject.net/forum/viewtopic ... 10&t=12520
Perhaps this is the more elegant method I'm looking for. Why does it always have to be in the *next* version! :lol:

I still wonder why MeshCenter doesn't do what the documentation claims it does.
Maybe it only worked with 1.4.x, or maybe it was broken in some SVN builds. (The build I'm using for this is fairly old ( svn4382 ).

AHA! Just found this thread which does seem to confirm that there was a bug prior to svn 4383: http://forum.celestialmatters.org/viewt ... 5d8bd905c7

Damn it!!

Re: Does MeshCenter command work with 1.5.x ReferenceFrame code?

Posted: 10.01.2009, 15:03
by Chuft-Captain
Chuft-Captain wrote:
selden wrote:2. use Celestia v1.6 and the directives NormalizeMesh and MeshScale.
See http://www.celestiaproject.net/forum/viewtopic ... 10&t=12520
Hmm, I just read that thread Selden, and although these new directives would help with positioning objects relative to each other, I fail to see how they help with my issue.
What I'm talking about is having a way to offset a model mesh from it's reference point, or conversely: offset it's reference-point (ie. the origin of the bodyframe) from the centre of it's bounding sphere (if you prefer to think of it in that sense), for the purposes of orientation rather than position.

For example, in the video, those solar panels need IMO for their bodyframe to be centered at their tips (where they connect to the satellite), which will in this case be at, or very close to, the outside of the bounding box of the solar panel mesh (in the absence of invisible mesh tricks). So what I'm looking for is a directive to tell it that that is the position where the center of it's bodyframe should be, rather than the physical center of the panel, if you see what I mean.

Supposedly that's what MeshCenter is designed to do (ie. Change the "center" position of a mesh from the default location at the center of it's bounding sphere.), but perhaps I misunderstood.

Cheers
CC

Re: Does MeshCenter command work with 1.5.x ReferenceFrame code?

Posted: 10.01.2009, 15:38
by selden
When you specify NormalizeMesh false, the center of the coordinate system of the model is used as the center of Celestia's Mesh. In other words, place the solar panel off-center when you design it, with the center of rotation at the center of its coordinate system.

Re: Does MeshCenter command work with 1.5.x ReferenceFrame code?

Posted: 10.01.2009, 15:42
by Chuft-Captain
Hang on... I think I see where you're coming from with MeshScale.... let me try something....

Re: Does MeshCenter command work with 1.5.x ReferenceFrame code?

Posted: 10.01.2009, 16:17
by Chuft-Captain
selden wrote:When you specify NormalizeMesh false, the center of the coordinate system of the model is used as the center of Celestia's Mesh. In other words, place the solar panel off-center when you design it, with the center of rotation at the center of its coordinate system.
That's what I've done, but it's not working.
The panel:
panel.jpg
is still rotating around it's physical center. :?

Must be something wrong in my SSC. Just one question... if I specify NormaliseMesh false, does that mean that Celestia interprets the dimensions of the mesh "as modeled" in Animator. eg. If a mesh is modeled with a longest diagonal of 20meters in Animator, then a MeshScale of 1 and a radius of 1, will give a mesh in Celestia 20km long??? A Meshscale of 0.5 would give an object 10km long. I'm a little slow today, sorry Selden.

(btw. Using svn4585 at the moment to avoid old bugs getting in the way... and of course to allow use of MeshScale and NormalizeMesh directives :lol: ).

Re: Does MeshCenter command work with 1.5.x ReferenceFrame code?

Posted: 11.01.2009, 19:17
by selden
NormalizeMesh and MeshScale work fine for me with off-center 3DS models.

Here's what I see when using only one off-center model:
mysatellite.jpg


Here's the off-center model as shown by Anim8or:
solar_panel.png


Here's the SSC file that I used:

Code: Select all

"MySatellite" "Sol/Earth"
{ Class "spacecraft"
  Radius 10
  Color [1 1 0 ]

  EllipticalOrbit { SemiMajorAxis 10000 Period 1 }

}
"Panel_1" "Sol/Earth/MySatellite"
{ Class "component"
  NormalizeMesh false
  MeshScale 1
  Mesh "solar_panel.3ds"
  Radius 100

  OrbitFrame { BodyFixed { Center "Sol/Earth/MySatellite" }}
  FixedPosition [ 0 0 0 ]

  BodyFrame { BodyFixed { Center "Sol/Earth/MySatellite" }}
  FixedRotation { }
}

"Panel_2" "Sol/Earth/MySatellite"
{ Class "component"
  NormalizeMesh false
  MeshScale 1
  Mesh "solar_panel.3ds"
  Radius 100

  OrbitFrame { BodyFixed { Center "Sol/Earth/MySatellite" }}
  FixedPosition [ 0 0 0 ]

  BodyFrame { BodyFixed { Center "Sol/Earth/MySatellite" }}
  FixedRotation { MeridianAngle 180 }
}


I rebuilt Celestia using today's SVN code, r4593.

Re: Does MeshCenter command work with 1.5.x ReferenceFrame code?

Posted: 11.01.2009, 19:27
by Chuft-Captain
Try changing the bodyframe on your panels so that they track the Sun Selden.
I'd be interested to see where they pivot.

CC

My code:

Code: Select all

"GLOBALSTAR M002 Body" "Sol/Earth/GLOBALSTAR M002" {
 Class "spacecraft"
 Mesh "GlobalstarBody.cmod"
 NormalizeMesh false
 MeshScale 0.000035
 MeshCenter [ 0 -16 6.5 ]
 Radius 0.0013   #0.004999999888241291

FixedPosition [ 0 0 0 ]

BodyFrame {
    TwoVector {
        Center "Sol/Earth/GLOBALSTAR M002/GLOBALSTAR M002 Body"
        Primary {
            Axis "z"
            RelativePosition { Target "Sol/Earth" }
        }
        Secondary {
            Axis "x"
            RelativeVelocity { Target "Sol/Earth" }
        }
    }
}

FixedRotation {}

}


"GLOBALSTAR M002 Panel LHS" "Sol/Earth/GLOBALSTAR M002/GLOBALSTAR M002 Body" {
 Class "component"
# Clickable "false"
 Mesh "GlobalstarPanel.cmod"
 NormalizeMesh false
 MeshScale 0.00003
 MeshCenter [ 0 0 0 ]
 Radius 0.003

FixedPosition [ -0.00048 0.00009 -0.00056 ]

BodyFrame {
    TwoVector {
        Center "Sol/Earth/GLOBALSTAR M002/GLOBALSTAR M002 Body/GLOBALSTAR M002 Panel LHS"
        Primary {
            Axis "z"
            RelativePosition { Target "Sol" }
        }
        Secondary {
            Axis "x"
            RelativeVelocity { Target "Sol/Earth" }
        }
    }
}

FixedRotation {}

}


"GLOBALSTAR M002 Panel RHS" "Sol/Earth/GLOBALSTAR M002/GLOBALSTAR M002 Body" {
 Class "component"
# Clickable false
 Mesh "GlobalstarPanel.cmod"
 NormalizeMesh false
 MeshScale 0.00003
 MeshCenter [ 0 0 0 ]
 Radius 0.003

FixedPosition [ 0.00048 0.00009 -0.00056 ]

BodyFrame {
    TwoVector {
        Center "Sol/Earth/GLOBALSTAR M002/GLOBALSTAR M002 Body/GLOBALSTAR M002 Panel RHS"
        Primary {
            Axis "z"
            RelativePosition { Target "Sol" }
        }
        Secondary {
            Axis "-x"
            RelativeVelocity { Target "Sol/Earth" }
        }
    }
}

FixedRotation {}

}

Re: Does MeshCenter command work with 1.5.x ReferenceFrame code?

Posted: 14.01.2009, 15:47
by selden
Sorry about the delay in getting back to this. Here's what works for me.

Code: Select all


"MySatellite" "Sol/Earth"
{
   Class "spacecraft"
   NormalizeMesh false
   MeshScale 1
   Mesh "satellite.3ds"
   Radius 100

   EllipticalOrbit { SemiMajorAxis 10000 Period 1 Inclination 45}

    BodyFrame       { BodyFixed     { Center "Sol/Earth" } }
    FixedRotation   { }

}

# Orient satellite so it always points toward the Earth
# with fixed orientation relative to orbit

Modify "MySatellite" "Sol/Earth"
{
    BodyFrame
    {
        TwoVector
        {
            Center "Sol/Earth/MySatellite"
            Primary   
            {
                Axis "-y"
      RelativePosition {Target "Sol/Earth"}
            }
            Secondary   
            {
                Axis "x"
      RelativeVelocity {Target "Sol/Earth"}
            }
        }
    }
}

# specify location of 1st solar panel relative to satellite body

"panel_1" "Sol/Earth/MySatellite"
{
   Class "component"
   NormalizeMesh false
   MeshScale 1
   Mesh "solar_panel_left.3ds"
   Radius 100


    OrbitFrame       { BodyFixed { Center "Sol/Earth/MySatellite" }}
    FixedPosition [ 0 10 -5 ]

    BodyFrame       { BodyFixed  { Center "Sol/Earth/MySatellite" }}
    FixedRotation   { MeridianAngle -90 }
}

# Orient panel relative to satellite
# and orient front of panel toward sun

Modify "panel_1" "Sol/Earth/MySatellite"
{
    BodyFrame
    {
        TwoVector
        {
            Center "Sol/Earth/MySatellite/panel_1"
            Primary   
            {
                Axis "y"
      ConstantVector {
          Vector [ 0 0 1]
          Frame { BodyFixed { Center "Sol/Earth/MySatellite" }}
          }
            }
            Secondary   
            {
                Axis "-z"
      RelativePosition {Target "Sol"}
            }
        }
    }

}


# specify location of 2nd solar panel relative to satellite body

"panel_2" "Sol/Earth/MySatellite"
{
   Class "component"
   NormalizeMesh false
   MeshScale 1
   Mesh "solar_panel_left.3ds"
   Radius 100


    OrbitFrame       { BodyFixed { Center "Sol/Earth/MySatellite" }}
    FixedPosition [ 0 -10 5 ]

    BodyFrame       { BodyFixed  { Center "Sol/Earth/MySatellite" }}
    FixedRotation   { MeridianAngle 90 }
}

# Orient panel relative to satellite
# and orient front of panel toward sun

Modify "panel_2" "Sol/Earth/MySatellite"
{
    BodyFrame
    {
        TwoVector
        {
            Center "Sol/Earth/MySatellite/panel_2"
            Primary   
            {
                Axis "y"
      ConstantVector {
          Vector [ 0 0 1]
          Frame { BodyFixed { Center "Sol/Earth/MySatellite" }}
          }
            }
            Secondary   
            {
                Axis "-z"
      RelativePosition {Target "Sol"}
            }
        }
    }

}


A picture of the results:
solar_panels.jpg


The entire addon, including an8 and html to goto this viewpoint:
solar_panels.zip