Math3D.Vector3 & OgreVector3


28-04-2006 00:29:05

Greetings .

While adding LensFlare via billboarding to my app, I noticed something that I wanted to mention here.

BillBoardSet.GetBillboard(uint idx).Position
expects an OgreVector3. I've gotten quite used to Math3D.Vector3 and noticed that there is no explicit cast from Math3D.Vector3 to OgreVector3

everything seems to work if you set the x,y,z elements individually

mBillboardSet.GetBillboard(0).Position.x = LFvect.x ;
mBillboardSet.GetBillboard(0).Position.y = LFvect.y ;
mBillboardSet.GetBillboard(0).Position.z = LFvect.z ;

but if you try to cast a Math3D.Vector3 to OgreVector3 explicitly:

mBillboardSet.GetBillboard(0).Position = (OgreVector3) LFvect;

you'll get an error of the form

Error 1 Cannot convert type 'Math3D.Vector3' to 'OgreDotNet.OgreVector3'

I guess what I'm wondering is whether the Billboard class needs updated to use Math3D.Vector3 or whether we should add an explict cast for
Math3D.Vector3 to OgreVector3

what do you think Rastaman?



28-04-2006 00:47:36

not sure how you add explicit cast, what do you mean.

OgreVector3 has this static function:
public static OgreDotNet.OgreVector3 FromVector3( Math3D.Vector3 v )


29-04-2006 03:36:45

How about this, make new properties from SWIG. I removed the renames for properties that we convert to other things (Position, Direction, Colour) leaving them like mPosition... and added new properties with the prefered classes.

Here is the changed OgreBillboard.i. Paste this code in there and rebuild OgreBindings, and OgreDotNet (rebuild should run swig again).

#include "OgreBillboard.h"

%rename Ogre::Billboard::mParentSet ParentSet;
%rename Ogre::Billboard::mRotation Rotation;
%rename Ogre::Billboard::getRotation GetRotation;
%rename Ogre::Billboard::setRotation SetRotation;
%rename Ogre::Billboard::setPosition SetPosition;
%rename Ogre::Billboard::setPosition GetPosition;
%rename Ogre::Billboard::setDimensions SetDimensions;
%rename Ogre::Billboard::resetDimensions ResetDimensions;
%rename Ogre::Billboard::setColour SetColour;
%rename Ogre::Billboard::getColour GetColour;
%rename Ogre::Billboard::hasOwnDimensions HasOwnDimensions;
%rename Ogre::Billboard::getOwnWidth GetOwnWidth;
%rename Ogre::Billboard::getOwnHeight GetOwnHeight;

%rename Ogre::Billboard::_notifyOwner m_NotifyOwner;

%typemap(cscode) Ogre::Billboard
public Math3D.Vector3 Position {
get {
return new Math3D.Vector3(mPosition.x, mPosition.y, mPosition.z);
set {
mPosition.x = value.x;
mPosition.y = value.x;
mPosition.z = value.x;
public Math3D.Vector3 Direction {
get {
return new Math3D.Vector3(mDirection.x, mDirection.y, mDirection.z);
set {
mDirection.x = value.x;
mDirection.y = value.x;
mDirection.z = value.x;
public System.Drawing.Color Colour {
get {
return System.Drawing.Color.FromArgb((int)(mColour.GetA()*255.0f),
set {
mColour.SetR( (float)value.R/255.0f);
mColour.SetG( (float)value.G/255.0f);
mColour.SetB( (float)value.B/255.0f);
mColour.SetA( (float)value.A/255.0f);
public float OwnWidth {
get {
return GetOwnWidth();
public float OwnHeight {
get {
return GetOwnHeight();

%include OgreBillboard.h