Author Topic: Script that controls ship culling? (Cannot see large ships at high distances)  (Read 1217 times)

Titanicus

  • Sentient
  • **
  • Posts: 61
  • Karma: +3/-0
    • View Profile
Normally for small ships, the default camera stops rendering them after the icon has taken over. However, for larger ships this is not the case, and the ships suddenly "disappearing" or stopping to be rendered happens. The larger the ship, the more this is the case.

I haven't seen a way to change this behavior in the scripts/shaders.. am I just not seeing it or is it not there? I simply would like to have ships render out a bit further. :)

Thy Reaper

  • BMS Lead Developer
  • BMS Administrator
  • Hopeless
  • *
  • Posts: 3237
  • Karma: +397/-8
    • View Profile
    • Blind Mind Studios
To override this behavior, you would need to bind a custom node to the object rather than use the default mesh/icon node that the engine provides. You can see how this sort of thing is done with planets (see PlanetNodeScript and everywhere that creates a PlanetNode).

Titanicus

  • Sentient
  • **
  • Posts: 61
  • Karma: +3/-0
    • View Profile
Is GFX_DISTANCE_MOD not supposed to touch ship GFX?

*Edit: About creating a new node... you mean I can somehow add a graphics node into the Ship.as object that overrides the default ship GFX? Something similar to planetNode where it ... overwrites??.. the preRender and render steps?

I suppose adding in functions to handle the preRender and render overwrites the defaults?

*To further clarify... set up a shipNode that is then added to the ship object and called during the tick method?
« Last Edit: March 13, 2015, 07:42:42 PM by Titanicus »

Titanicus

  • Sentient
  • **
  • Posts: 61
  • Karma: +3/-0
    • View Profile
Ok, just want to make sure i'm understanding this right...

You define a node in the nodes.txt file. Then you create the node's script file (planetNode.as for example). Finally, you bind the node upon creation of xxx object via something like the
 PlanetNode@ plNode = cast<PlanetNode>(bindNode(planet, "PlanetNode"));
part in map_effects.as . After that, render/prerender are automatically called per tick when the engine wants to draw the object?

If this is all correct, then it seems that an object without a node will not be drawn/rendered at all? Unless there is some sort of hidden node for ships that is not in the scripts yet?

GGLucas

  • Dr. Evil
  • BMS Staff
  • Delusional
  • *
  • Posts: 1877
  • Karma: +300/-6
    • View Profile
The node for ships is a standard MeshNode, created through:

server/objects/Ship.as:

Code: [Select]
getDesignMesh(ship.blueprint.design, shipMesh);
bindMesh(ship, shipMesh);

server/object_creation.as:

Code: [Select]
MeshDesc shipMesh;
getDesignMesh(design, shipMesh);
shipMesh.memorable = memorable;

Object@ obj = makeObject(shipDesc);
bindMesh(obj, shipMesh);


scripts/shared/designs.as:

Code: [Select]
void getDesignMesh(const Design& design, MeshDesc& mesh) {
if(design.hasTag(ST_Gate) && design.hasTag(ST_Station)) {
@mesh.model = model::Warpgate;
@mesh.material = material::VolkurGenericPBR;
}
else {
@mesh.model = design.hull.model;
@mesh.material = design.hull.material;
}
@mesh.iconSheet = design.distantIcon.sheet;
mesh.iconIndex = design.distantIcon.index;
}

MeshNodes are not in scripts, but are engine entities for performance reasons. Other than that they're not meaningfully different from what a scripted node like the planet's would do.

Titanicus

  • Sentient
  • **
  • Posts: 61
  • Karma: +3/-0
    • View Profile
So if I made a separate node to show the ship's mesh at long distance I would just be showing something over top of what is already in?

Alternatively, if I could just modify the collision sphere size then I could modify the basic model size and do it that way.

Any way to just change the size of the col. sphere per xxx size? Right now to fix this culling problem I could just reduce the size of the model in max when exporting - then the actual model would be *much* smaller when the engine stopped rendering it and it wouldn't be noticeable. However, this then causes the problem of the collision sphere still being huge. It is very immersion breaking and strange to see my ship throwing everything around all over the place, causing jittering and very VERY strange movement.

I would rather take a little bit of ship-ship clipping from the reduced size collision sphere if it meant being able to get rid of this ultra-massive magic forcefield.
« Last Edit: March 13, 2015, 10:57:43 PM by Titanicus »

Titanicus

  • Sentient
  • **
  • Posts: 61
  • Karma: +3/-0
    • View Profile
Not sure why I didn't see this but in object-creation there is a radius scale factor that bumps down the radius of ships by, by default, an exponent of 2.5. Anyways, I added a simple /6 to drop all ship radius' across the board and it seems to be working well. Actually, it seems to be affecting the collision box of the ship more then the visual component of it?

In any case, creating a separate node and all the extra wasted processing doesn't seem to be necessary. By directly tweaking the radius, I can make a size 1 ship start out as small as I want it and then set up my scaling from there.

Really strange that I didn't see this before.

dalolorn

  • Sentient
  • **
  • Posts: 199
  • Karma: +7/-0
  • ABEM Developer
    • View Profile
Eh, not only may that cause trouble with other shipsets, but it'll also make your mod incompatible with anything modifying that script.