Jump to content

Editor saves incorrect pathes for brush textures after editing faces


Dreikblack
 Share

Go to solution Solved by Josh,

Recommended Posts

1. Apply texture to brush

2, Select faces of brush and do auto UV with enabled Unity faces

3. In .ultra file path looks like "texture0": "./Test Project/gfx/all.wad/crate0_top" and after restarting editor (and game) can't load this texture

If i fix it manually to "/gfx/all.wad/crate0_top" textures loads correctly

I'm using own extension to apply textures from all.wad from rerelase pak0. Textures names "city4_2", "crate0_top". Same happens with usual applied textures from default folders.

Extension code:

local extension = {}
extension.textureField = nil
extension.setTextureButton = nil
extension.fixModelButton = nil
extension.fixYField = nil
extension.modelScale = 4.68042326

function extension.hook(event, extension)

    if event.id == EVENT_WIDGETACTION then
        if event.source == extension.setTextureButton then
            if (extension.textureField.text == "") then return end
            local texture = LoadTexture("/gfx/all.wad/" .. extension.textureField.text)
            --local texture = LoadTexture("/Materials/Developer/trigger.dds")
            local material = CreateMaterial()
            material:SetTexture(texture)
            local selected = program:GetSelection()
            for n = 1, #selected do
                local currentBrush = Brush(selected[n].entity)
                if currentBrush ~= nil then
		            currentBrush:SetMaterial(material)
                    currentBrush:Build()
                    Print("Seted texture to selected brush "..extension.textureField.text)
                end           
            end
        elseif event.source == extension.fixModelButton then
            local selected = program:GetSelection()
            for n = 1, #selected do
                local currentModel = Model(selected[n].entity)
                if currentModel ~= nil then
                    local entityName = currentModel.name
                    Print("Fixed Quake model: " ..entityName)
                    local fixY = extension.fixYField.text
                    if fixY == "" then fixY = 0.02 end
                    if (entityName == "Marine" or entityName == "Grunt") then fixY = 0.02
                    elseif (entityName == "Rottweiler") then fixY = 0.1 end
		            currentModel = fixQuakeModelCenter(currentModel, fixY)
                end           
            end
        end
    end
end

--------------------------------------------------------------------
-- Add extension tab
--------------------------------------------------------------------

local sidePanel = program.sidepanel
if sidePanel ~= nil then
    sidePanel:AddItem("QtExt")
    local sz = program.sidepanel:ClientSize()
    local panel = CreatePanel(0, 0, sz.x, sz.y, program.sidepanel)
    local uiY = 20;
    local label1 = CreateLabel("Wad texture name", 32, uiY, 120, 30, panel)
    uiY = uiY + 32;
    extension.textureField = CreateTextField(20, uiY, sz.x - 40, 32, panel)
    uiY = uiY + 20 + 32;
    extension.setTextureButton = CreateButton("Set a wad texture to selected brush", 20, uiY, sz.x - 40, 32, panel)
    uiY = uiY + 20 + 32;
    local label2 = CreateLabel("Height offset", 32, uiY, 120, 30, panel)
    uiY = uiY + 32;
    extension.fixYField = CreateTextField(20, uiY, sz.x - 40, 32, panel)
    uiY = uiY + 20 + 32;
    extension.fixModelButton = CreateButton("Fix selected Quake models", 20, uiY, sz.x - 40, 32, panel)
end

ListenEvent(EVENT_WIDGETACTION, extension.setTextureButton, extension.hook, extension)
ListenEvent(EVENT_WIDGETACTION, extension.fixModelButton, extension.hook, extension)


function fixQuakeModelCenter(model, fixY)
    for i = 1, #model.lods do
        local lod = model.lods[i]
        for j = 1, #lod.meshes do
            local currentMesh = lod.meshes[j]
            currentMesh:Translate(-1 * currentMesh.bounds.center.x, -1 * currentMesh.bounds.center.y - fixY, -1 * currentMesh.bounds.center.z)
        end
    end
    model:UpdateBounds();
    model:SetScale(extension.modelScale);
    return model;
end

 

Link to comment
Share on other sites

Can this be produced without using an extension, through the regular editor interface?

If not, is there a small piece of text I can copy into the console to make the error occur when the map is saved?

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

For console

 

local texture = LoadTexture("/Materials/Developer/trigger.dds")
            local material = CreateMaterial()
            material:SetTexture(texture)
            local selected = program:GetSelection()
            for n = 1, #selected do
                local currentBrush = Brush(selected[n].entity)
                if currentBrush ~= nil then
		            currentBrush:SetMaterial(material)
                    currentBrush:Build()
                end           
            end

 

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Dreikblack said:

For console

I love Ultra. :)

Okay, here is the embedded material stored in the map file:

		"materials": [
			{
				"displacement": [
					0.05000000074505806,
					-0.02500000037252903
				],
				"metallic": 0.0,
				"pickmode": true,
				"roughness": 1.0,
				"shadow": true,
				"texture0": "./New Project 5/Materials/Developer/trigger.dds"
			}
		],

And we can see that you are correct, so let's see why this is happening...

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • Solution

Here it is with a small fix. I will have an update out soon for you:

		"materials": [
			{
				"displacement": [
					0.05000000074505806,
					-0.02500000037252903
				],
				"metallic": 0.0,
				"pickmode": true,
				"roughness": 1.0,
				"shadow": true,
				"texture0": "Materials/Developer/trigger.dds"
			}
		],

 

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...