예제 #1
0
        public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
                              OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
            : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical)
        {
            // Default linkset implementation for this prim
            LinksetType = (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation;

            Linkset = BSLinkset.Factory(PhysScene, this);

            Linkset.Refresh(this);
        }
예제 #2
0
    public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
                       OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
        : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical)
    {
        // Default linkset implementation for this prim
        LinksetType = (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation;

        Linkset = BSLinkset.Factory(PhysScene, this);

        Linkset.Refresh(this);
    }
예제 #3
0
        // Convert the existing linkset of this prim into a new type.
        public bool ConvertLinkset(BSLinkset.LinksetImplementation newType)
        {
            bool ret = false;

            if (LinksetType != newType)
            {
                DetailLog("{0},BSPrimLinkable.ConvertLinkset,oldT={1},newT={2}", LocalID, LinksetType, newType);

                // Set the implementation type first so the call to BSLinkset.Factory gets the new type.
                this.LinksetType = newType;

                BSLinkset oldLinkset = this.Linkset;
                BSLinkset newLinkset = BSLinkset.Factory(PhysScene, this);

                this.Linkset = newLinkset;

                // Pick up any physical dependencies this linkset might have in the physics engine.
                oldLinkset.RemoveDependencies(this);

                // Create a list of the children (mainly because can't interate through a list that's changing)
                List <BSPrimLinkable> children = new List <BSPrimLinkable>();
                oldLinkset.ForEachMember((child) =>
                {
                    if (!oldLinkset.IsRoot(child))
                    {
                        children.Add(child);
                    }
                    return(false); // 'false' says to continue to next member
                });

                // Remove the children from the old linkset and add to the new (will be a new instance from the factory)
                foreach (BSPrimLinkable child in children)
                {
                    oldLinkset.RemoveMeFromLinkset(child, true /*inTaintTime*/);
                }
                foreach (BSPrimLinkable child in children)
                {
                    newLinkset.AddMeToLinkset(child);
                    child.Linkset = newLinkset;
                }

                // Force the shape and linkset to get reconstructed
                newLinkset.Refresh(this);
                this.ForceBodyShapeRebuild(true /* inTaintTime */);
            }
            return(ret);
        }
예제 #4
0
        public override object Extension(string pFunct, params object[] pParams)
        {
            DetailLog("{0} BSPrimLinkable.Extension,op={1},nParam={2}", LocalID, pFunct, pParams.Length);
            object ret = null;

            switch (pFunct)
            {
            // physGetLinksetType();
            // pParams = [ BSPhysObject root, null ]
            case ExtendedPhysics.PhysFunctGetLinksetType:
            {
                ret = (object)LinksetType;
                DetailLog("{0},BSPrimLinkable.Extension.physGetLinksetType,type={1}", LocalID, ret);
                break;
            }

            // physSetLinksetType(type);
            // pParams = [ BSPhysObject root, null, integer type ]
            case ExtendedPhysics.PhysFunctSetLinksetType:
            {
                if (pParams.Length > 2)
                {
                    BSLinkset.LinksetImplementation linksetType = (BSLinkset.LinksetImplementation)pParams[2];
                    if (Linkset.IsRoot(this))
                    {
                        PhysScene.TaintedObject(LocalID, "BSPrim.PhysFunctSetLinksetType", delegate()
                            {
                                // Cause the linkset type to change
                                DetailLog("{0},BSPrimLinkable.Extension.physSetLinksetType, oldType={1},newType={2}",
                                          LocalID, Linkset.LinksetImpl, linksetType);
                                ConvertLinkset(linksetType);
                            });
                    }
                    ret = (object)(int)linksetType;
                }
                break;
            }

            // physChangeLinkType(linknum, typeCode);
            // pParams = [ BSPhysObject root, BSPhysObject child, integer linkType ]
            case ExtendedPhysics.PhysFunctChangeLinkType:
            {
                ret = Linkset.Extension(pFunct, pParams);
                break;
            }

            // physGetLinkType(linknum);
            // pParams = [ BSPhysObject root, BSPhysObject child ]
            case ExtendedPhysics.PhysFunctGetLinkType:
            {
                ret = Linkset.Extension(pFunct, pParams);
                break;
            }

            // physChangeLinkParams(linknum, [code, value, code, value, ...]);
            // pParams = [ BSPhysObject root, BSPhysObject child, object[] [ string op, object opParam, string op, object opParam, ... ] ]
            case ExtendedPhysics.PhysFunctChangeLinkParams:
            {
                ret = Linkset.Extension(pFunct, pParams);
                break;
            }

            default:
                ret = base.Extension(pFunct, pParams);
                break;
            }
            return(ret);
        }