Пример #1
0
            public Node( Scene _Owner, FBX.Scene.Nodes.Node _Node )
            {
                m_Owner = _Owner;
                m_Owner.m_Nodes.Add( this );

                if ( _Node is FBX.Scene.Nodes.Mesh )
                    m_Type = TYPE.MESH;
                else if ( _Node is FBX.Scene.Nodes.Camera )
                    m_Type = TYPE.CAMERA;
                else if ( _Node is FBX.Scene.Nodes.Light )
                    m_Type = TYPE.LIGHT;
                else
                {
                    // Isolate locators as probes
                    if ( _Node.Name.ToLower().IndexOf( "locator" ) != -1 )
                        m_Type = TYPE.PROBE;
                }

                m_Local2Parent.FromMatrix4( _Node.Local2Parent );

                // Build children
                FBX.Scene.Nodes.Node[]	Children = _Node.Children;
                m_Children = new Node[Children.Length];
                for ( int ChildIndex=0; ChildIndex < Children.Length; ChildIndex++ )
                {
                    FBX.Scene.Nodes.Node	SourceChild = Children[ChildIndex];
                    Node	Child = null;
                    switch ( SourceChild.NodeType )
                    {
                        case FBX.Scene.Nodes.Node.NODE_TYPE.NODE:	Child = new Node( _Owner, SourceChild ); break;
                        case FBX.Scene.Nodes.Node.NODE_TYPE.LIGHT:	Child = new Light( _Owner, SourceChild ); break;
                        case FBX.Scene.Nodes.Node.NODE_TYPE.CAMERA:	Child = new Camera( _Owner, SourceChild ); break;
                        case FBX.Scene.Nodes.Node.NODE_TYPE.MESH:	Child = new Mesh( _Owner, SourceChild ); break;
                    }
                    m_Children[ChildIndex] = Child;
                }
            }
Пример #2
0
            //
            public Node( Scene _Owner, idTech5Map.Map _Map )
            {
                m_Owner = _Owner;
                m_Owner.m_Nodes.Add( this );

                List< Node >	Children = new List< Node >();
                foreach ( idTech5Map.Map.Entity E in _Map.m_Entities ) {
                    switch ( E.m_Type ) {
                        case idTech5Map.Map.Entity.TYPE.MODEL: {
                            Node	Child = new Mesh( _Owner, E );
                                    Child.m_Type = TYPE.MESH;
                            Children.Add( Child );
                            break;
                        }
                        case idTech5Map.Map.Entity.TYPE.LIGHT: {
                            Node	Child = new Light( _Owner, E );
                                    Child.m_Type = TYPE.LIGHT;
                            Children.Add( Child );
                            break;
                        }
                        case idTech5Map.Map.Entity.TYPE.PLAYER_START: {
                            Node	Child = new Camera( _Owner, E );
                                    Child.m_Type = TYPE.CAMERA;
                            Children.Add( Child );
                            break;
                        }
                        case idTech5Map.Map.Entity.TYPE.PROBE: {
                            Node	Child = new Node( _Owner, E );
                                    Child.m_Type = TYPE.PROBE;
                            Children.Add( Child );
                            break;
                        }

                        case idTech5Map.Map.Entity.TYPE.UNKNOWN:
                        case idTech5Map.Map.Entity.TYPE.REF_MAP:
                            // Don't care...
                            break;
                        }
                }
                m_Children = Children.ToArray();
            }
Пример #3
0
            public Mesh( Scene _Owner, idTech5Map.Map.Entity _Entity )
                : base(_Owner, _Entity)
            {
                // BUild primitives and local space BBox
                m_Primitives = new Primitive[_Entity.m_Model.m_Surfaces.Length];
                m_BBoxMin_Local = float.MaxValue * float3.One;
                m_BBoxMax_Local = -float.MaxValue * float3.One;

                int	PrimitiveIndex = 0;
                foreach ( idTech5Map.Model.Surface S in _Entity.m_Model.m_Surfaces ) {
                    m_Primitives[PrimitiveIndex] = new Primitive( this, S );
                    m_BBoxMin_Local.Min( m_Primitives[PrimitiveIndex].m_BBoxMin );
                    m_BBoxMax_Local.Max( m_Primitives[PrimitiveIndex].m_BBoxMax );
                    PrimitiveIndex++;
                }

                // Convert BBox to world space
                m_BBoxMin_World = float.MaxValue * float3.One;
                m_BBoxMax_World = -float.MaxValue * float3.One;
                for ( int CornerIndex=0; CornerIndex < 8; CornerIndex++ ) {
                    float	X = (CornerIndex >> 0) & 1;
                    float	Y = (CornerIndex >> 0) & 1;
                    float	Z = (CornerIndex >> 0) & 1;
                    float3	D = m_BBoxMax_Local - m_BBoxMin_Local;

                    float3	lsCorner = m_BBoxMin_Local + new float3( X * D.x, Y * D.y, Z * D.z );
                    float3	wsCorner = (float3) (new float4( lsCorner, 1.0f ) * m_Local2Parent);

                    m_BBoxMin_World.Min( wsCorner );
                    m_BBoxMax_World.Max( wsCorner );
                }
            }
Пример #4
0
            public Node( Scene _Owner, Node _Parent, BinaryReader _R )
            {
                m_Owner = _Owner;
                m_Owner.m_Nodes.Add( this );

                m_Parent = _Parent;

                // =============================
                // Load standard infos
                //				m_Type = (TYPE) _R.ReadByte();	// Already consumed by the guy who called this constructor!

                // Load Local2Parent matrix
                m_Local2Parent.r0.x = _R.ReadSingle();	m_Local2Parent.r0.y = _R.ReadSingle();	m_Local2Parent.r0.z = _R.ReadSingle();	m_Local2Parent.r0.w = _R.ReadSingle();
                m_Local2Parent.r1.x = _R.ReadSingle();	m_Local2Parent.r1.y = _R.ReadSingle();	m_Local2Parent.r1.z = _R.ReadSingle();	m_Local2Parent.r1.w = _R.ReadSingle();
                m_Local2Parent.r2.x = _R.ReadSingle();	m_Local2Parent.r2.y = _R.ReadSingle();	m_Local2Parent.r2.z = _R.ReadSingle();	m_Local2Parent.r2.w = _R.ReadSingle();
                m_Local2Parent.r3.x = _R.ReadSingle();	m_Local2Parent.r3.y = _R.ReadSingle();	m_Local2Parent.r3.z = _R.ReadSingle();	m_Local2Parent.r3.w = _R.ReadSingle();

                // =============================
                // Write specialized infos
                LoadSpecialized( _R );

                // =============================
                // Write end marker
                if ( _R.ReadUInt16() != 0xABCD )
                    throw new Exception( "Failed to reach end node marker!" );

                // =============================
                // Recurse through children
                m_Children = new Node[_R.ReadUInt16()];
                for ( int ChildIndex=0; ChildIndex < m_Children.Length; ChildIndex++ )
                {
                    TYPE	ChildType = (TYPE) _R.ReadByte();
                    Node	Child = null;
                    switch ( ChildType )
                    {
                        case TYPE.GENERIC:
                        case TYPE.PROBE:
                            Child = new Node( _Owner, this, _R );
                            break;

                        case TYPE.LIGHT:	Child = new Light( _Owner, this, _R ); break;
                        case TYPE.CAMERA:	Child = new Camera( _Owner, this, _R ); break;
                        case TYPE.MESH:		Child = new Mesh( _Owner, this, _R ); break;
                        default: throw new Exception( "Unsupported node type!" );
                    }
                    m_Children[ChildIndex] = Child;
                }
            }
Пример #5
0
 public Mesh( Scene _Owner, Node _Parent, BinaryReader _R )
     : base(_Owner, _Parent, _R)
 {
 }
Пример #6
0
 public Mesh( Scene _Owner, FBX.Scene.Nodes.Node _Node )
     : base(_Owner, _Node)
 {
     FBX.Scene.Nodes.Mesh _Mesh = _Node as FBX.Scene.Nodes.Mesh;
     m_Primitives = new Primitive[_Mesh.PrimitivesCount];
     int	PrimitiveIndex = 0;
     foreach ( FBX.Scene.Nodes.Mesh.Primitive SourcePrimitive in _Mesh.Primitives )
         m_Primitives[PrimitiveIndex++] = new Primitive( this, SourcePrimitive );
 }
Пример #7
0
 public Light( Scene _Owner, idTech5Map.Map.Entity _Entity )
     : base(_Owner, _Entity)
 {
     m_LightType = LIGHT_TYPE.POINT;
     // TODO
     // 				m_LightType = (LIGHT_TYPE) _Light.Type;
     // 				m_Color.FromVector3( _Light.Color );
     // 				m_Intensity = _Light.Intensity;
     // 				m_HotSpot = _Light.HotSpot;
     // 				m_ConeAngle = _Light.ConeAngle;
 }
Пример #8
0
            public Light( Scene _Owner, FBX.Scene.Nodes.Node _Node )
                : base(_Owner, _Node)
            {
                FBX.Scene.Nodes.Light _Light = _Node as FBX.Scene.Nodes.Light;

                m_LightType = (LIGHT_TYPE) _Light.Type;
                m_Color.FromVector3( _Light.Color );
                m_Intensity = _Light.Intensity;
                m_HotSpot = _Light.HotSpot;
                m_ConeAngle = _Light.ConeAngle;
            }
Пример #9
0
 public Camera( Scene _Owner, idTech5Map.Map.Entity _Entity )
     : base(_Owner, _Entity)
 {
     m_FOV = (float) (60.0 * Math.PI / 180.0);
 }
Пример #10
0
 public Camera( Scene _Owner, FBX.Scene.Nodes.Node _Node )
     : base(_Owner, _Node)
 {
     FBX.Scene.Nodes.Camera _Camera = _Node as FBX.Scene.Nodes.Camera;
     m_FOV = _Camera.FOV;
 }
Пример #11
0
            public Node( Scene _Owner, idTech5Map.Map.Entity _Entity )
            {
                m_Owner = _Owner;
                m_Owner.m_Nodes.Add( this );

                float3	X = new float3( _Entity.m_Local2World.r0.x, _Entity.m_Local2World.r1.x, _Entity.m_Local2World.r2.x );
                float3	Y = new float3( _Entity.m_Local2World.r0.y, _Entity.m_Local2World.r1.y, _Entity.m_Local2World.r2.y );
                float3	Z = new float3( _Entity.m_Local2World.r0.z, _Entity.m_Local2World.r1.z, _Entity.m_Local2World.r2.z );
                float3	P = new float3( _Entity.m_Local2World.r0.w, _Entity.m_Local2World.r1.w, _Entity.m_Local2World.r2.w );

                X = ConvTech5( X );
                Y = ConvTech5( Y );
                Z = ConvTech5( Z );
                P = ConvTech5( P );

                m_Local2Parent.r0.Set( X, 0 );
                m_Local2Parent.r1.Set( Y, 0 );
                m_Local2Parent.r2.Set( Z, 0 );
                m_Local2Parent.r3.Set( P, 1 );
            }