[MOD] Real Grass 2

A curated forum for approved mods. Users are unable to create new topics in this forum but can reply to existing topics. Please message a moderator to have your mod moved into this forum area.
User avatar
Interkarma
Posts: 3011
Joined: Sun Mar 22, 2015 1:51 am

Re: [MOD] Real Grass 2

Post by Interkarma » Sat May 05, 2018 9:01 pm

TheLacus wrote:
Sat May 05, 2018 5:19 pm
The position of a location calculated at line 1048 of StreamingWorld is not the one assigned to the transform. Not sure how location layout works, is scene position accessible somewhere? I can make the same calculations again but i think there is an easier way to get from location instance to terrain position. If not, may be useful to store it in a field?

Ps. attachments seems very unreliable after forum update, sometimes they get lost when i click preview. I'm using imgur as an alternative.
I'll take a look at exposing required position for you.

I've noticed that sometimes with attachments as well. Not sure if theme or phpbb itself at this stage.

User avatar
Interkarma
Posts: 3011
Joined: Sun Mar 22, 2015 1:51 am

Re: [MOD] Real Grass 2

Post by Interkarma » Sat May 05, 2018 10:36 pm

TheLacus wrote:
Sat May 05, 2018 5:19 pm
The position of a location calculated at line 1048 of StreamingWorld is not the one assigned to the transform. Not sure how location layout works, is scene position accessible somewhere? I can make the same calculations again but i think there is an easier way to get from location instance to terrain position. If not, may be useful to store it in a field?
Here's how the location transform is calculated currently.

Code: Select all

[1049] float height = terrainInstance.SampleHeight(pos + terrainArray[terrain].terrainObject.transform.position);
...
[1056] locationObject.transform.position = terrainArray[terrain].terrainObject.transform.position + new Vector3(0, height, 0);
The location is a separate gameobject not parented to the terrain, just the transforms are aligned so the location is in right spot. Everything in location is parented to the location parent.

What would be more useful for your mod, the location transform or the terrain transform?

User avatar
TheLacus
Posts: 607
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: [MOD] Real Grass 2

Post by TheLacus » Sun May 06, 2018 1:29 pm

Interkarma wrote:
Sat May 05, 2018 10:36 pm
TheLacus wrote:
Sat May 05, 2018 5:19 pm
The position of a location calculated at line 1048 of StreamingWorld is not the one assigned to the transform. Not sure how location layout works, is scene position accessible somewhere? I can make the same calculations again but i think there is an easier way to get from location instance to terrain position. If not, may be useful to store it in a field?
Here's how the location transform is calculated currently.

Code: Select all

[1049] float height = terrainInstance.SampleHeight(pos + terrainArray[terrain].terrainObject.transform.position);
...
[1056] locationObject.transform.position = terrainArray[terrain].terrainObject.transform.position + new Vector3(0, height, 0);
The location is a separate gameobject not parented to the terrain, just the transforms are aligned so the location is in right spot. Everything in location is parented to the location parent.

What would be more useful for your mod, the location transform or the terrain transform?
I'm interested in this position plus the y

Code: Select all

float scale = terrainInstance.terrainData.heightmapScale.x;
float xSamplePos = dfUnity.TerrainSampler.HeightmapDimension * 0.55f;
float ySamplePos = dfUnity.TerrainSampler.HeightmapDimension * 0.55f;
Vector3 pos = new Vector3(xSamplePos * scale, 0, ySamplePos * scale);
The location transform keeps only the height, x and z are set as the terrain position.

Code: Select all

locationObject.transform.position = terrainArray[terrain].terrainObject.transform.position + new Vector3(0, height, 0);
They can be calculated again with the code above, but i think it would be a convenience to store in location instance class the actual position of visible location in scene (x location, y terrain + offset, z location), which is different than location transform. Basically i need the surface actually occupied by location, not entire terrain (I'm using scaled BlockWidth and BlockHeight in location summary summed to the vector3 pos above).

Now that i read the code again, i see there is also LocationRect but in Daggerfall world units so providing access to CityNavigation.WorldToScenePosition() from UpdateLocation() may also be an alternative.
If you are interested in creating mods for Daggerfall Unity you can find the documentation here.

User avatar
King of Worms
Posts: 629
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow
Contact:

Re: [MOD] Real Grass 2

Post by King of Worms » Sun May 06, 2018 2:48 pm

Those mists are amazing, very good at the graveyards as well. With a bit of fine-tuning this will be definitely a great addition to the game. I personally love it. Plus it opens new possibilities maybe... like a dungeon mists at the floor level for example, like in the Aleid ruins from a more recent TES games... maybe underwater particles... who knows

User avatar
Interkarma
Posts: 3011
Joined: Sun Mar 22, 2015 1:51 am

Re: [MOD] Real Grass 2

Post by Interkarma » Tue May 08, 2018 12:37 am

TheLacus wrote:
Sun May 06, 2018 1:29 pm
Now that i read the code again, i see there is also LocationRect but in Daggerfall world units so providing access to CityNavigation.WorldToScenePosition() from UpdateLocation() may also be an alternative.
Using the CityNavigation component is actually quite clever, as it exposes a lot of this information in an easy to use way. I wasn't sure what you meant by providing access from UpdateLocation(). Did you mean using an event or something? Let me know and I'm happy to work in with your requirements.

In the interim, I've added a new method to StreamingWorld called GetCurrentCityNavigation() that will return CityNavigation component for town object inside player's current location tile (if any). It will return null if player not inside a location tile.

So you should be able to use:

Code: Select all

CityNavigation cityNavigation =  GameManager.Instance.StreamingWorld.GetCurrentCityNavigation();
if (cityNavigation)
{
	// Do stuff
}
With a CityNavigation reference, you can use the public method WorldToScenePosition() to calcuate any world position back to scene space relative to the actual location itself. Use refineY=true to sample the actual terrain height under that world position coord. CityNavigation also exposes a couple of useful properties such as the dimensions of the town itself. All you'd need is the town origin from world rect and a reference to CityNavigation and you should be able to compute very precisely the town area.

Keep in mind that WorldToScenePosition() is very slightly expensive (more so when using refineY=true). It's not the sort of thing you want to use every frame, but should be OK for scene setup and placement.

Let me know if anything else I can do to help. :)

User avatar
TheLacus
Posts: 607
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: [MOD] Real Grass 2

Post by TheLacus » Wed May 09, 2018 6:19 pm

Interkarma wrote:
Tue May 08, 2018 12:37 am
Using the CityNavigation component is actually quite clever, as it exposes a lot of this information in an easy to use way. I wasn't sure what you meant by providing access from UpdateLocation(). Did you mean using an event or something? Let me know and I'm happy to work in with your requirements.
Thank you Interkama. There is already an event when the location is created but is raised before CityNavigation and all other components are added. It would be helpful to have an event which passes the location gameobject after is full init. Maybe even with the allowyeld flag as an argument so expensive code from mods can also make use of it. Note that this works fine it the subscribers also invoke coroutines, otherwise we need to always do at least one yield before event is raised to allow static methods to access components after their Start() function has been called. For example CityNavigation uses Start to set location.
If you are interested in creating mods for Daggerfall Unity you can find the documentation here.

User avatar
Interkarma
Posts: 3011
Joined: Sun Mar 22, 2015 1:51 am

Re: [MOD] Real Grass 2

Post by Interkarma » Wed May 09, 2018 11:43 pm

Would raising an event at the end of UpdateLocation() with both a reference to DaggerfallLocation and state of allowYield be appropriate for you? I'm thinking of raising event around line 733 of StreamingWorld.cs.

User avatar
TheLacus
Posts: 607
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: [MOD] Real Grass 2

Post by TheLacus » Thu May 10, 2018 7:18 pm

Interkarma wrote:
Wed May 09, 2018 11:43 pm
Would raising an event at the end of UpdateLocation() with both a reference to DaggerfallLocation and state of allowYield be appropriate for you? I'm thinking of raising event around line 733 of StreamingWorld.cs.
Sure, i would pass the gameobject but it doesn't change much if you prefer location component.

What i was saying in my previous message is that, when allowyeld is false, start function on components is not called before raising the event. For example this is CityNavigation

Code: Select all

private void Start()
{
	dfLocation = GetComponent<DaggerfallLocation>();
}
Calling a method that requires location reference, without waiting for the following frame to be executed, results in noLocationError. Not a big issue, just something to be careful with :)
If you are interested in creating mods for Daggerfall Unity you can find the documentation here.

User avatar
Interkarma
Posts: 3011
Joined: Sun Mar 22, 2015 1:51 am

Re: [MOD] Real Grass 2

Post by Interkarma » Thu May 10, 2018 9:31 pm

Thanks for the information. I'll take a look at reordering some things here when I can.

User avatar
TheLacus
Posts: 607
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: [MOD] Real Grass 2

Post by TheLacus » Sun May 13, 2018 8:02 pm

Harvestable Crops v0.2 is on first page. It makes all crops harvestable, with a chance based on live luck (including effect mods). Loot is not random but i'm using existings plant ingredients, so don't expect complete realism.
Note that the original billboards are used but through asset-injection, as this allows to replace batched billboards with individual gameobjects, which i can reference and add new components individually after injection in scene. Texture-replacement should still be supported.

This mod is the first to make use of save support of which i talked with Interkarma a few posts ago. This is used to store a list of harvested crops and the time of harvest, meaning that they won't re-appear if you enter a bulding or restart the game. If you let time to pass (typically with fast travel) crops will grow and be harvestable again. You can set the number of days they are in harvested state from settings. Let me know if you find any issue or have suggestions :)
If you are interested in creating mods for Daggerfall Unity you can find the documentation here.

Post Reply