Page 4 of 4 FirstFirst 1234
Results 61 to 67 of 67

Thread: Naval models editing

  1. #61

    Default Re: Naval models editing

    I added the Ramming ability to many of the Sengoku Jidai ships, to add another layer to naval combat, and mainly as a quick way for larger ships to deal with those pesky kobayas.

    However, I ran into an annoying issue.

    Due to the way the Battle AI is designed, ranged focused ships turn away from you once you close in. I keep ramming into the stern or prow panels of the enemy ship (especially enemy kobayas). It's almost impossible to ram them on their sides.
    Turns out, reducing the stern or prow panels hitpoints to zero (at least by ramming) has NO effect on the ship's condition. I make extra sure by setting the stern/prow hitpoints to 0 in the db. All that does is it makes the front/back of the ship look destroyed at the beginning of the battle. The ship is still 100% floating.

    When I do manage to ram the kobayas on their side panels (it only happens when they're stuck), they pretty much go down in one hit.

    So, my question is, is there a way to trick/force the game to recognize the prow/stern panels as side panels through editing naval models?

  2. #62
    Artifex
    Patrician

    Join Date
    Oct 2008
    Location
    London, UK
    Posts
    1,332

    Default Re: Naval models editing

    I for sure don't know the answer, I only make the conversion tools.

  3. #63

    Default Re: Naval models editing

    Quote Originally Posted by taw View Post
    I for sure don't know the answer, I only make the conversion tools.
    I think I have an idea. Looking at the logic.xml file for the Bow Kobaya, I can move all the panels from the prow/stern sections into the side sections. Say, prow panels go to starboard, stern panels go to port.
    Last edited by seamus2008; December 11, 2015 at 10:42 AM.

  4. #64

    Default Re: Naval models editing

    I'm planning on implementing my own naval model. I will probably write an ASE (3ds max ascii format) to XML converter to do so. Is anyone still interested in this?

    The 'something' line for each piece definition, in the unpacked files from taw's converter, looks like the face normal in the format (nx,nz,ny,|n|). I don't know why the length of the normal would differ from 1 though.

  5. #65

    Default Re: Naval models editing

    Quote Originally Posted by mauiaw View Post
    I'm planning on implementing my own naval model. I will probably write an ASE (3ds max ascii format) to XML converter to do so. Is anyone still interested in this?

    The 'something' line for each piece definition, in the unpacked files from taw's converter, looks like the face normal in the format (nx,nz,ny,|n|). I don't know why the length of the normal would differ from 1 though.
    I am interested, as that I want to implement new models in to the mod that I am building.

  6. #66
    Primergy's Avatar Protector of the Union
    Join Date
    Mar 2009
    Location
    Augsburg
    Posts
    2,491

    Default Re: Naval models editing

    In general i would be interested too.

    I tried to write a xml exporter for ship models in maxscript once, but my miserable maxscript skills found their master in some bugs i couldn't fix.

    Maybe it helps as an starting point, but most likely not^^

    Spoiler Alert, click show to read: 
    Code:
    -- S2 Ship Export Tools
    -- Primergy 2016
    --To Do: Add some security things. like warning sign if system units don't fit
    
    
    --Initialing DotNet
    
    dotNet.loadAssembly "system.xml"
    xmlDoc=dotNetObject "system.xml.xmlDocument"
    
    --Format properties and methods to the listener.
    clearListener()
    format "Properties\n"
    showProperties xmlDoc
    format "\nMethods\n"
    showMethods xmlDoc
    
    --Create a root element for the xml doc and add it to the xmlDocument
    
    root=xmlDoc.createElement "ship_logic"
    xmlDoc.appendChild root
    
    --show the properties for the new element.
    showMethods root
    
    
    --add all needed elements 
    
    buoyancy_Element=xmlDoc.createElement "buoyancy"    
    root.appendchild buoyancy_element
    
    decks_Element=xmlDoc.createElement "decks"    
    root.appendchild decks_element
    
    pipes_Element=xmlDoc.createElement "pipes"    
    root.appendchild pipes_element
        
    cannons_Element=xmlDoc.createElement "cannons"    
    root.appendchild cannons_element
        
    damage_model_Element=xmlDoc.createElement "damage_model"    
    root.appendchild    damage_model_element
    
    collision_Element=xmlDoc.createElement "collision"    
    root.appendchild collision_element
    
    ef_lines_Element=xmlDoc.createElement "ef_lines"    
    root.appendchild ef_lines_element
    
    ef_artillery_info_Element=xmlDoc.createElement "ef_artillery_info"    
    root.appendchild ef_artillery_info_element
    
    custom_positions_Element=xmlDoc.createElement "custom_positions"    
    root.appendchild custom_positions_element
    
    
    --add data to decks_element
    --BUG: Add funtion to check if all faces are non-quads, if not give warning message
    ( --select nodes in layer Decks
        fn selectNodesInLayer layer_name =
            (
                local nodes
                (LayerManager.getLayerFromName layer_name).nodes &nodes
                    select nodes
            )        
        selectNodesInLayer "DECKS"
            
        for s in selection do
        (
        -- add deck_element to "decks"
            deck_element=xmlDoc.createElement "deck"
                deck_element.setAttribute "id" (s.name as string)
            decks_element.appendchild deck_element
            
        --count faces of the deck_object and loop through it
        deckfaces = getnumfaces s    
        -- hard_vert_array stores all vertex which are "hard" ones
        hard_vert_array =#()    
        -- adds all open edges to an array and writes the vertex of those edges to another array 
        openedge = polyop.getOpenEdges s as array 
            
        --add the vertex of the open edges to the vert_array
        for t =1 to openedge.count do
            (    -- get the verts of the open edges
                hard_verts = polyop.getEdgeVerts s openedge[t]
                appendifunique hard_vert_array hard_verts[1]
                appendifunique hard_vert_array hard_verts[2]
            )
            
        for d = 1 to deckfaces do
        (-- add piece element
            piece_element=xmlDoc.createElement "piece" 
                piece_element.setAttribute "id" (d as string)    
            
            -- get Vertices of faces as array
                num_verts = polyop.getFaceVerts s d            
                
                --loop through num_verts array and get vertices coordinates
                for t = 1 to num_verts.count do
                (
                    a = num_verts[t]        
                    
                    vertex= (polyop.getvert s a)/39.37                
                    
    -- Debugging. Currenty the first elements get all the "hard" vertexes but in the originial file each face only has one "hard" vertex! Any ideas to fix this?
                    
                    -- add corner_element which stores the x,y,z, information of the vertices    
                    corner_element=xmlDoc.createElement "corner"
                        corner_element.setAttribute "x" (vertex.x as string)
                        corner_element.setAttribute "y" (vertex.y as string)
                        corner_element.setAttribute "z" (vertex.z as string)
                        --needs adaption to clear OR hard
                    
                    -- get Vert ID int the num_verts array to see if it's in the "open edge vertex array"                    
                    vert_ID = num_verts[t]
    
                    vert_pos = finditem hard_vert_array vert_ID
                    -- if 0 write 'clear' if not write "hard" and delete the vert from the array, so it' won't be used again)
                    if vert_pos == 0 then
                        (corner_element.setAttribute "type" ("clear" as string)) else 
                
                    (
                        corner_element.setAttribute "type" ("hard" as string)                    
                        --deleteitem hard_vert_array vert_pos                    
                    )                
                    
                    --corner_element.setAttribute "type" ("clear" as string)
                    piece_element.appendChild corner_element    
                )            
                
            deck_element.appendChild piece_element    
        )
        )
    )
    
    --add data to pipes_element
    (
        fn selectNodesInLayer layer_name =
            (
                local nodes
                (LayerManager.getLayerFromName layer_name).nodes &nodes
                    select nodes
            )        
        selectNodesInLayer "PIPES"
        
        for s in selection do
        (
            pipe_Element=xmlDoc.createElement "pipe"
                if classof $ == line do
                (
                    knot1 = (getknotpoint s 1 1)/39.37
                    knot2 = (getknotpoint s 1 2)/39.37
                    
                    segment1_element=xmlDoc.createElement "segment"
                        segment1_element.setAttribute "deck_piece" ("test" as string)
                        segment1_element.setAttribute "x" (knot1.x as string)
                        segment1_element.setAttribute "y" (knot1.y as string)
                        segment1_element.setAttribute "z" (knot1.z as string)                
                    pipe_element.appendchild segment1_element
                    
                    segment2_element=xmlDoc.createElement "segment"
                        segment2_element.setAttribute "deck_piece" ("test" as string)
                        segment2_element.setAttribute "x" (knot2.x as string)
                        segment2_element.setAttribute "y" (knot2.y as string)
                        segment2_element.setAttribute "z" (knot2.z as string)                
                    pipe_element.appendchild segment2_element
                )
                
            pipes_element.appendchild pipe_element
        )
    )
    
    --add data to damage_model_element
    (--select objects from the damage model layer
        fn selectNodesInLayer layer_name =
            (
                local nodes
                (LayerManager.getLayerFromName layer_name).nodes &nodes
                    select nodes
            )        
        selectNodesInLayer "LOGIC_DAMAGEMODEL"
        
        For s in selection do
        (
            part_element=xmlDoc.createElement "part"
                part_element.setAttribute "name" (s.name as string) -- BUG. It takes the whole name with damagemodel_starb_xyz but the damagemodel should get deleted!)
            -- get number of faces = panels
                panel_num = getnumfaces s
            -- loop through panels, create new panel element with vertex coordinates
            for i =1 to panel_num do
            (    
                panel_element=xmlDoc.createElement "panel"
                local vert_num = polyop.getFaceVerts s i            
                
                -- add elements for each vertex of obj
                    for j =1 to vert_num.count do
                        (
                            vertex_element=xmlDoc.createElement "vertex"
                            
                            vert_pos= (polyop.getvert s vert_num[j])/39.37 -- coordinates do not fit in the xml compared to the original. Maybe wrong divide value?
                            
                                vertex_element.SetAttribute "x" (vert_pos.x as string)
                                vertex_element.SetAttribute "y" (vert_pos.y as string)
                                vertex_element.SetAttribute "z" (vert_pos.z as string)
                        
                            panel_element.appendChild vertex_element
                        )
                part_element.appendChild panel_element
            )
            damage_model_element.appendChild part_element
        )
    )
    
    --add data to collision model
    (
        --select object in the collision layer
        fn selectNodesInLayer layer_name =
            (
                local nodes
                (LayerManager.getLayerFromName layer_name).nodes &nodes
                    select nodes
            )        
        selectNodesInLayer "3D_COLLISION"
        --Add warning sign, if more then one object is selected
        
        --convert selection to trimesh to get the proper count of faces
        MakeMesh = snapshotasmesh $
        
        NumFaces = getnumFaces MakeMesh
        
        for i=1 to NumFaces do
        (
            --add face element
            face_Element=xmlDoc.createElement "face"
                face_element.setAttribute "name" ($.name as string)
                face_element.setAttribute "index" (i as string)        
            collision_element.appendchild face_element
            
            --get number of vertex
            local VertArray = getFace MakeMesh i
            -- loop through the 3 verts
            for v=1 to 3 do
            (
                VertPos = (meshop.getvert MakeMesh VertArray[v])/39.37
                
                vertex_Element=xmlDoc.createElement "vertex"
                    vertex_element.setAttribute "x" (VertPos.x as string)
                    vertex_element.setAttribute "y" (VertPos.y as string)
                    vertex_element.setAttribute "z" (VertPos.z as string)
                face_element.appendChild vertex_element
            )
            
            --add vertex elements
        )
    )
    
    --add data to EFLInes
    (
        fn selectNodesInLayer layer_name =
            (
                local nodes
                (LayerManager.getLayerFromName layer_name).nodes &nodes
                    select nodes
            )        
        selectNodesInLayer "EF_LINES"
            
        for x in selection do
        (
        -- get Action Typea    
        actiontype =  getUserProp x "Actiontype" 
        
        --get knot coordinates of splines
        knot1 = (getknotpoint x 1 1)/39.37 -- dividing to convert system values to game (metric) values
        knot2= (getknotpoint x 1 3)/39.37
        
        -- get direction of spline    
        P3= getknotpoint x 1 2 
        P4= getknotpoint x 2 2
        
        -- calculate Vektor P3P4 (direction)
        Pdirect= (P4-P3)
        -- normalize direction vector
        Direction = normalize Pdirect
        
        --Create a ef_line_element for the object.
            (        
            ef_line_Element=xmlDoc.createElement "ef_line"
            --Set attributes on the new elements for the name of the object and the class of it.
                ef_line_Element.setAttribute "name" (x.name as string)
                ef_line_Element.setAttribute "action" (actiontype as string)
            
            --add coordinates element 
                (
                    end1_element=xmlDoc.createElement "end"
            
                        end1_element.setAttribute "x" (knot1.x as string)
                        end1_element.setAttribute "y" (knot1.y as string)
                        end1_element.setAttribute "z" (knot1.z as string)
            
                    ef_line_element.appendChild end1_element    
                )
                
                (
                    end2_element=xmlDoc.createElement "end"
            
                        end2_element.setAttribute "x" (knot2.x as string)
                        end2_element.setAttribute "y" (knot2.y as string)
                        end2_element.setAttribute "z" (knot2.z as string)
            
                    ef_line_element.appendChild end2_element    
                )
                
                --element for the direction
                (
                    direction_element=xmlDoc.createElement "direction"
                        direction_element.setAttribute "x" (direction.x as string)
                        direction_element.setAttribute "y" (direction.y as string)
                        direction_element.setAttribute "z" (direction.z as string)
                    ef_line_element.appendChild direction_element    
                )
            
            --add ef_line_element to ef_lines
            ef_lines_element.appendChild ef_line_Element
        --Append the new element to the root element.     
            )
        )
    )
    
    --add data for custom_positions
    (
        fn selectNodesInLayer layer_name =
            (
                local nodes
                (LayerManager.getLayerFromName layer_name).nodes &nodes
                    select nodes
            )        
        selectNodesInLayer "CUSTOM_POSITIONS"
        
        for s in selection do
        (    
            --add element
            custom_position_element=xmlDoc.CreateElement "custom_position"
                custom_position_element.setAttribute "name" (s.name as string)        
            custom_positions_element.appendChild custom_position_element
            
            --add position element (pivot point)
            position_element=xmlDoc.CreateElement "position"
                position_element.SetAttribute "x" ((s.pos.x/39.37) as string)
                position_element.SetAttribute "y" ((s.pos.y/39.37) as string)
                position_element.SetAttribute "z" ((s.pos.z/39.37) as string)
            custom_position_element.appendChild position_element
        )
    )
    
    --Save the xmlDoc object to a file
    xmlDoc.save ((getDir #scripts)+"\\test.xml")
    --Open the file in Max to see the result. 
    edit ((getDir #scripts)+"\\test.xml")

  7. #67

    Default Re: Naval models editing

    Do you have any idea what file code it needs to add guns on forts like is it"<cannons></cannons>" or "<ef_artillery_info></ef_artillery_info>? I have no idea what code it is using in the tech.XML file because CA didn't provide any example.
    EDIT: I resolved it. Now just looking how the units actually use the guns (animation on the walls).
    Last edited by izzi; June 25, 2022 at 09:54 AM.

Page 4 of 4 FirstFirst 1234

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •