NavMesh Zone3 green lines problem & obj outlines

04/14/2013 16:35 mss29#1
# 2
i loaded sector
entries,
hightmap,
texturemap,
zone1,
zone2,
zone3

and

tile2d.ifo,
object.ifo


How can I put ObjectOutLines on the map. i cant found
04/14/2013 21:42 DaxterSoul#2
ObjectOutLines, ObjectInLines, ObjectGround are in the *.bms files
04/15/2013 17:27 mss29#3
i converted bms file to obj and looked into only v,vt,vn,f this is 3d model?? but how to calculating objectGround,lines for bitmap file. did not see anything like that in ?.. I am very bad at a lot of 3d modeling.

How do I calculate the objectground into bms ?
04/17/2013 15:47 DaxterSoul#4
You don't need to convert it into obj, you can load all needed information out of it.

illstar posted this 3 years ago on a different forum. If you would put some afford into it you would've found this already. There are many hints in all those silkroad collision / navmesh threads here as well.

Code:
Imports System.IO

Public Class cBmsLoader

    Public Structure sPoint
        Public x As Single
        Public y As Single
        Public z As Single
        Dim flag As Byte
    End Structure

    Public Structure sLine
        Public PointA As UInt16
        Public PointB As UInt16
        Public NeighbourA As UInt16
        Public NeighbourB As UInt16
        Dim flag As Byte
    End Structure

    Public Structure sTriangle
        Public PointA As UInt16
        Public PointB As UInt16
        Public PointC As UInt16
        Dim unk As UInt16
    End Structure


    Dim vertex As Int32
    Dim bone As Int32
    Dim triangle As Int32
    Dim unk1 As Int32
    Dim unk2 As Int32
    Dim stat As Int32
    Dim unk3 As Int32
    Dim HitBox As Int32


    Public Points As New Collections.Generic.List(Of sPoint)
    Public ObjectGround As New Collections.Generic.List(Of sTriangle)
    Public Inlines As New Collections.Generic.List(Of sLine)
    Public Outlines As New Collections.Generic.List(Of sLine)


    Sub New(ByVal path As String) 'load the bms 

        path = "\" & path
        Console.WriteLine(path)
        Dim b() As Byte = PK2_Data.Get_file(path)
        If b Is Nothing Then Exit Sub
        Dim Reader As New BinaryReader(New IO.MemoryStream(b))


        '### loding bms header ####
        Reader.ReadChars(12) 'Header --> "JMXVRES 109 "
        vertex = Reader.ReadInt32()
        bone = Reader.ReadInt32()
        triangle = Reader.ReadInt32()
        unk1 = Reader.ReadInt32()
        unk2 = Reader.ReadInt32()
        stat = Reader.ReadInt32()
        unk3 = Reader.ReadInt32()
        HitBox = Reader.ReadInt32()



        '#### Loading Points ####
        Reader.BaseStream.Position = HitBox
        Dim pCounter As Int32 = Reader.ReadInt32

        For i As Int32 = 1 To pCounter
            Dim point As New sPoint

            point.x = Reader.ReadSingle 'point X position
            point.z = Reader.ReadSingle 'point Z position
            point.y = Reader.ReadSingle 'point Y position
            Reader.ReadBytes(1) 'unk

            Points.Add(point)
        Next

        '### Loading ObjectGround ###
        pCounter = Reader.ReadInt32

        For i As Int32 = 1 To pCounter
            Dim Triangle As New sTriangle
            Triangle.PointA = Reader.ReadUInt16 'point A index --> Points
            Triangle.PointB = Reader.ReadUInt16 'point B index --> Points
            Triangle.PointC = Reader.ReadUInt16 'point C index --> Points
            Triangle.unk = Reader.ReadUInt16()
            ObjectGround.Add(Triangle)
        Next


        '### Loading Outlines ###
        pCounter = Reader.ReadInt32

        For i As Int32 = 1 To pCounter
            Dim Line As New sLine
            Line.PointA = Reader.ReadUInt16 'point A index --> Points
            Line.PointB = Reader.ReadUInt16 'point B index --> Points
            Line.NeighbourA = Reader.ReadUInt16 'index of neighbour triangle A --> ObjectGround
            Line.NeighbourB = Reader.ReadUInt16 'index of neighbour triangle B --> ObjectGround --> FFFF --> no Neighbour triangle
            Line.flag = Reader.ReadByte 'seems to intcate if passable (3=not passable 0=passable else=unk)
            Outlines.Add(Line)
        Next


        '### Loading Inlines ###
        pCounter = Reader.ReadInt32

        For i As Int32 = 1 To pCounter 'object inlines
            Dim Line As New sLine
            Line.PointA = Reader.ReadUInt16 'point A index --> Points
            Line.PointB = Reader.ReadUInt16 'point B index --> Points
            Line.NeighbourA = Reader.ReadUInt16 'index of neighbour triangle A --> objectground
            Line.NeighbourB = Reader.ReadUInt16 'index of neighbour triangle B --> objectground
            Line.flag = Reader.ReadByte 'seems to intcate if passable  (7=not passable 3=passable else=unk)
            Inlines.Add(Line)
        Next

        '... unk bytes .... 
        Reader.Close()
    End Sub
End Class
How to draw it:
Code:
//Draw it line by line ... something like that: 
foreach(Bms.sLine L in bms.Outlines) { 
            Pointf pA = new Pointf(bms.points(l.PointA).X,
					bms.points(l.PointA).Y)
            Pointf pB = new Pointf(bms.points(l.PointB).X,
					bms.points(l.PointB).Y)

            fx.DrawLine(new Pen(new SolidBrush(Color.Silver)),pA,pB)
}
Rotation Fix:
Code:
'You have to rotate before add the offset from the nvm 
            For Each Point As cBmsLoader.cPoint In Bms.Points
                'aObject.Rotation --> rotation from the nvm
                Dim newX As Single = Point.X * Math.Cos(-aObject.Rotation) - -Point.Y * Math.Sin(-aObject.Rotation)
                Dim newY As Single = Point.X * Math.Sin(-aObject.Rotation) + -Point.Y * Math.Cos(-aObject.Rotation)

                'aObject.Position.X/Y --> offset from the nvm
                Point.X = newX + aObject.Position.X
                Point.Y = newY + aObject.Position.Y
            Next
You're still far ways from loading all bms files because there are some bugs in the code.
04/18/2013 18:42 mss29#5
wow
Thank you it was a very nice resource
04/20/2013 21:53 mss29#6
omg little problem i cant find problem ? :S
[Only registered and activated users can see links. Click Here To Register...]

this is my rotation and drawlines function :/
Code:
               //'You have to rotate before add the offset from the nvm 
                    float rotation = float.Parse(textBox2.Text);
                    for (int i = 0; i < bmfile.Points.Count; i++)
                    {
                        BmsLoader.BmsLoader.sPoint spoint = bmfile.Points[i];
                        // 'aObject.Rotation --> rotation from the nvm
                        float newX = ((spoint.x) * (float)Math.Cos(rotation)) - ((spoint.y) * (float)Math.Sin(rotation));
                        float newY = ((spoint.x) * (float)Math.Sin(rotation)) + ((spoint.y) * (float)Math.Cos(rotation));

                        //'aObject.Position.X/Y --> offset from the nvm
                        spoint.x = (newX + entrie.x) ;
                        spoint.y = (newY + entrie.y);
                        bmfile.Points[i] = spoint;
                    }

                    //Draw it line by line ... something like that: 
                    foreach (BmsLoader.BmsLoader.sLine item in bmfile.Outlines)
                    {
                        try
                        {
                            PointF pA = new PointF(bmfile.Points[item.PointA].x / float.Parse(textBox3.Text), bmfile.Points[item.PointA].y / float.Parse(textBox3.Text));
                            PointF pB = new PointF(bmfile.Points[item.PointB].x / float.Parse(textBox3.Text), bmfile.Points[item.PointB].y / float.Parse(textBox3.Text));
                            //grT.DrawPolygon(new Pen(Color.Blue), new PointF[] { pA, pB });
                            grT.DrawLine(new Pen(new SolidBrush(Color.Blue)), pA, pB);
                        }
                        catch (Exception)
                        {

                        }
                    }