Ludeon Forums

RimWorld => Mods => Help => Topic started by: BeingBen on December 31, 2014, 02:23:45 PM

Title: Improper Texture Scaling
Post by: BeingBen on December 31, 2014, 02:23:45 PM
I just started to play and mod this game yesterday. Wanted to dable in a few smaller modifications before trying anything advance. My current problem is the lack of documentation makes it hard to code. My current small_table mod is simply that just a small 1,1 table but the texture made within the (64x64) parameters is incredibly large, like a (3,3) and in the GUI it is also large like a (5,5).
Any help or even direction on where or what to read to fix the problem myself would be much appreciated.



<?xml version="1.0" encoding="utf-8"?>
<Buildings>

<ThingDef Name="BuildingBase" Abstract="True">
    <category>Building</category>
    <thingClass>Building</thingClass>
    <soundImpactDefault>BulletImpactMetal</soundImpactDefault>
    <selectable>true</selectable>
    <drawerType>MapMeshAndRealTime</drawerType>
    <terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
    <repairEffect>Repair</repairEffect>
  </ThingDef>
 
  <!-- Table Base -->
 
    <ThingDef Abstract="True" ParentName="BuildingBase" Name="TableBase">
<eType>Building_Table</eType>
<thingClass>Building</thingClass>
<altitudeLayer>Waist</altitudeLayer>
<description>People eat off tables when chairs are placed facing them.</description>
<graphicOverdraw>true</graphicOverdraw>
<passability>PassThroughOnly</passability>
<castEdgeShadows>true</castEdgeShadows>
<pathCost>60</pathCost>
<fillPercent>0.4</fillPercent>
<stuffCategories>
<li>Woody</li>
</stuffCategories>
<filthLeavings>
<SlagRubble>1</SlagRubble>
</filthLeavings>
<leaveResourcesWhenKilled>true</leaveResourcesWhenKilled>
<designationCategory>Furniture</designationCategory>
<staticSunShadowHeight>0.20</staticSunShadowHeight>
<itemSurface>true</itemSurface>
<comps>
<li>
<compClass>CompGatherSpot</compClass>
</li>
</comps>
</ThingDef>

<ThingDef ParentName="TableBase">
<defName>SmallTable</defName>
    <label>table (small)</label>
<graphicClass>Graphic_Single</graphicClass>
    <graphicPath>Things/Building/Furniture/SmallTable</graphicPath>
    <graphicOverdraw>true</graphicOverdraw>
    <statBases>
      <MaxHealth>50</MaxHealth>
      <WorkToMake>500</WorkToMake>
      <Flammability>1.0</Flammability>
      <Beauty>5</Beauty>
    </statBases>
    <size>(1,1)</size>
    <costStuffCount>7</costStuffCount>
    <rotatable>false</rotatable>
    <killedLeavings>
      <ChunkSlag>1</ChunkSlag>
    </killedLeavings>
  </ThingDef>

</Buildings>
Title: Re: Improper Texture Scaling
Post by: Shinzy on December 31, 2014, 02:48:59 PM
<graphicOverdraw>true</graphicOverdraw>

pretty sure that's the issue
turn that bit to false

as I've understood it's trying to draw the image like square wider to each direction
(or alternatively you could change the size of your canvas to 192 and leave the overdraw on)

like this
(http://i.imgur.com/qtuGwNF.png) <- this one with overdraw being false

(http://i.imgur.com/68W0Zrj.png) <- or this one with overdraw as true

the latter one can be used for if you want your image to have some fancy squiggles going over the border of the actual size of the object

like a tree stomp or something =P with the roots going really far but with the stomp being the only impassable part or something like this


..Or I could be entirely wrong, too! that's always the possibility! *Suffers from chronic uncertainty*
Title: Re: Improper Texture Scaling
Post by: BeingBen on December 31, 2014, 03:15:39 PM
Question about the image nesting. I receive an error if there isn't a file called "SmallTable.png" in my furniture folder. When i remove that image and use a folder called "SmallTable" with two files in it SmallTable_Atlas and SmallTable_MenuIcon.png it doesn't load the image. The size is still incorrect with overdraw toggled on or off. Below is an image and example.

(http://imageshack.com/a/img537/162/7v70F2.jpg)
Title: Re: Improper Texture Scaling
Post by: Shinzy on December 31, 2014, 03:40:24 PM
Oooh! only the wall textures use the "_Atlas" bit far as I've seen (or other connecting textures)
the game tries to find texture named SmallTable.png with the stuff you have in your xml file
and with the stuff in your xml file I mean this one -> <graphicClass>Graphic_Single</graphicClass>

you could change that to multi <graphicClass>Graphic_Multi</graphicClass>
and then it would seek table textures like Table_front.png, Table_side.png and Table_side.png
from the folder (but with round table that's probably not needed =P)

but if you have the overdraw false and the texture was named SmallTable.png then
I'm not sure what's wrong (things may have changed a bit since I did any furnitures myself =/ )
resizing the background is still an option if you didn't try that!
wish I could help more =P may have to wait for someone with brains to appear!
Title: Re: Improper Texture Scaling
Post by: unifex on December 31, 2014, 06:38:59 PM
I ran into some of these shennanigans (and have no understanding of Unity's rendering), I think I settled on just not supplying a menuIcon image in most cases. For everything else I stick to using 64x64 pixels to represent one square and build on that (128x128 for 4 squares etc) and things behave (with graphicOverdraw=false and Graphic_Single as the graphicClass).
Title: Re: Improper Texture Scaling
Post by: BeingBen on December 31, 2014, 11:46:00 PM
I have no idea then, That table is using a 64x64 and as you can see when I placed the table its roughly a 4x4 grid and not a 1x1 grid as intended. I'll have to read into unity or disect the code a bit better since there is truly no documentation or tutorials that work....
Title: Re: Improper Texture Scaling
Post by: mrofa on January 01, 2015, 05:35:21 AM
Becouse you didnt set "<graphicOverdraw>" to false like shinzy said
Title: Re: Improper Texture Scaling
Post by: Shinzy on January 01, 2015, 07:40:48 AM
Quote from: mrofa on January 01, 2015, 05:35:21 AM
Becouse you didnt set "<graphicOverdraw>" to false like shinzy said

but he did try it though!

..you did try it right? *glares*

;D I've had best luck with figuring out my own problems by looking at other peoples mods that add similar things
so you could have a snoop at the "More Furniture" mod or "Clutter"
More Furniture is probably better as a first step for learning, it has much less stuff in it to look at
Clutter would be the "advanced training session"

aand I don't even know what I'm saying anymore *hides*
Title: Re: Improper Texture Scaling
Post by: mrofa on January 01, 2015, 08:36:11 AM
I mean that he got graphicOverdraw in 2 places, in parent and child.
So if he did  change it to false only in parent, then the child still will use its own setting.
Title: Re: Improper Texture Scaling
Post by: Shinzy on January 01, 2015, 08:37:55 AM
Quote from: mrofa on January 01, 2015, 08:36:11 AM
I mean that he got graphicOverdraw in 2 places, in parent and child.
So if he did  change it to false only in parent, then the child still will use its own setting.

Ooh! Mrofa! you have eyes! =O I didn't even see the parent had one
Title: Re: Improper Texture Scaling
Post by: BeingBen on January 01, 2015, 12:22:25 PM
Thumbs up! Seems to have been the problem, now just need to write some scripts to allow me to place my lamps and candles on top of a table. XD
Title: Re: Improper Texture Scaling
Post by: mrofa on January 01, 2015, 12:59:17 PM
Well you got 3 ways for it
1. make a texture table with a cande,table with lamp and optionaly table with both, add a button to a table that add thous with a cost.
2. make a object of lamp and candle, then add button to a table to spawn it on table position
3.there is a attachment system in game, same like the fire that attach to stuff, since fire is attahment type, but it have no idea how it works :D
Title: Re: Improper Texture Scaling
Post by: BeingBen on January 01, 2015, 07:28:18 PM
My initial idea was to look at the raw-potato code and the production table code. Thus finding a way to allow "item" to be placed onto a table. I will let you know how that goes though.
Title: Re: Improper Texture Scaling
Post by: mrofa on January 02, 2015, 12:24:56 AM
This is actually a <AltitudeLayer> set to Item for the lamp/candle and  <itemSurface> set to true for table, thats how potato works ;p
Title: Re: Improper Texture Scaling
Post by: Rikiki on January 02, 2015, 05:28:33 AM
If you want the table and lamp to be both buildings, I think using the different altitude layer and the <IsEdifice> tag should do the trick.
=> Table at waist altitude layer, IsEdifice = True,
=> Lamp/candle at item layer, IsEdifice = False.
A little difficulty will appear when deconstructing. I suspect it will designate both the table and candle.

An other best option would be to set your table as a storage place (like the equipement rack) and only accept to store a candle/lamp item.
Then you can add grimoir, dust, skulls and all the wizardry stuffs! :D
Title: Re: Improper Texture Scaling
Post by: mrofa on January 02, 2015, 05:33:45 AM
You cant use buildings as a class for this, since 2 buildings cant be in the same square(one destroy other on spawn or error), this is why his lamps/candels need to be item class
Title: Re: Improper Texture Scaling
Post by: Rikiki on January 02, 2015, 07:34:42 AM
I did not tried it myself for now but power conduit (with the tag <isEdifice>false</isEdifice>) can be built under any other building.
So why not 2 buildings in the same square? ???
Title: Re: Improper Texture Scaling
Post by: mrofa on January 02, 2015, 08:55:29 AM
Hmm interesting didnt know that ;)