Jump to content

[SOLVED] Run different world / cross section


photo

Recommended Posts

Another trivial question. Want to test the cross section sample, this is currently associated to an inactive SDK.

Didn't want to download again 3.2GB of data needing just this sample, so just copied the cross_section directory in another project.

I'm not able to see the cross section effect in the editor, I suppose is working only at runtime (correct?).

I'm not able to run the project using the cross_section.world and not the standard project world.

Edited by davide445
Link to comment

Maybe that's the reason why didn't work for me, working only with Engineering and Sim license? 

The Samples project is currently associated with an inactive Engineering license, currently using an Entertainment, so I just copied the cross_section dir in another Entertainment project. 

Edited by davide445
Link to comment

No, cross section sample has no such limitations.

By inappropriate versions I meant different SDK versions, not editions (we call Entertainment, Sim, etc "editions"). If you copied sample from 2.8 to 2.9 (or vice versa) it wouldn't work. Or will malfunction in some way.

Thanks.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Ok was on 2.7.2, so now downloaded and copied for 2.8 as my active SDK. Allowing to do this separated for every specific demo will be nice.

I'm trying to replicate the effect on a test project, but having set up all the same logic found in the sample didn't work right now

- Two-sided, Emission, Cross Section, Procedural Effects, SSBevel (the last two not sure have something to do, but since are in the sample) in the object material

- decal_sample_mask_0, decal_sample_mask_1 as Material Mask both in object and plane material

The demo state Cross section is determined by an Oblique Frustum near clipping plane, but I didn't find any settings related to this topic, need I to care about?

Also state position and rotation of the plane is controlled by the cross_section.cpp script (that I didn't find anywhere), I suppose is not necessary if I didn't want to make it interactive, but just fix a cross section plane at the beginning?

image.png.a672a47079783804e7c2b24664222c32.png

Edited by davide445
Link to comment

Tried to port some essential code to mine test

 

#include <core/unigine.h>
#include <core/scripts/samples.h>
#include <core/scripts/euler.h>

Node oblique_dummy;

int init() {
		
	Player camera = node_cast(engine.editor.getNodeByName("camera"));
	engine.game.setPlayer(camera);

	oblique_dummy = engine.editor.getNodeByName("ObliqueDummy");
	
	return 1;
}

int update() {

	Vec4 plane = Vec4(0.0f, 0.0f, 0.4f, 0.0f) * inverse(oblique_dummy.getWorldTransform());
	
	Player player = engine.game.getPlayer();
	if(player != NULL) {
		player.setObliqueFrustum(1);
		player.setObliqueFrustumPlane(plane);
	}
	
	return 1;
}

int shutdown() {
	
	Player player = engine.game.getPlayer();
	if(player != NULL) player.setObliqueFrustum(0);
	
	return 1;
}

Resulting this

image.png.bc077aafedde79b11915e81dc92f190e.png

I didn't need UI but want

- the plane it's in the position defined in the editor and not hardcoded in the script

- having positioned the plane in the code the same as in the editor (just copied the coordinates in the Vec 4 plane), still I didn't find matching in term of final result, you see where was the plane in the editor and where is the cut in the engine

Any hint is always useful, thanks

 

Edited by davide445
Link to comment

Hi Davide,

I've tried to reproduce your situation and all seems to work:
image.png

Does ObliqueDummy and your plane is the one object? I think you have 2 objects: ObliqueDummy and ObjectMeshDynamic Plane as a child. And Plane has a local offset that should be reset.

About Vec4(0.0f, 0.0f, 0.4f, 0.0f):

Vec4 plane = Vec4(0.0f, 0.0f, 0.4f, 0.0f) * inverse(oblique_dummy.getWorldTransform());

The first 3 components are the direction of the plane. It should be normalized (for example: (0, 0, 1), but not (0,0,0.25)).
The last one is the distance from the center of the world. If we use transform of the another object, no need to change this value.

Best regards,
Alexander

  • Like 1
Link to comment

Hi Alexander

did you just copied my posted script or changed something?

This is my World, trying to replicate exactly what's inside the sample

image.png.31568deb1d98032c738be95d683d6277.png

How do you link the position of the plane in the editor with the position of the cross section plane in the engine?

Edited by davide445
Link to comment

This is my World, trying to replicate exactly what's inside the sample
Just try to click these buttons to reset position of the Plane:
image.png

How do you link the position of the plane in the editor with the position of the cross section plane in the engine?
In my case ObliqueDummy is a ObjectMeshStatic (Plane).

  • Like 1
Link to comment

Thanks that made the trick in avoiding the offset, didn't undersood at the beginning the ObliqueDummy it's the master for shifting the plane postion.

Now trying to apply to a more complex object so to be able to cut only some parts, I find impossible to disable the cross section effect only for some components, since even disabling the single element material Cross section, Emissive and Two-sided states the part is cutted anyway.

As example this component with cross_section_1 material with "right" settings

image.thumb.png.c38a509092d3a934b10f6ec3a1743f6d.png

This other one with material cross_section_2 with disabled the needed states and the Material Mask

image.thumb.png.370d34575a4ea5f8b01cc0114a121b24.png

I want to be able to control the sectioning of every individual component of the object.

Edited by davide445
Link to comment

Reading better about how this effect it's achieved I understood it's probably a dead end using cross sections to jus hide one object.

Since the near clipping plane is aligned with the plane, everything in the world before this is not rendered, and giving a single camera there is no way to selectively apply this to single objects.

I can say the cross section topic is solved, just need another solution for the original problem of hiding part of a single object among many.

Link to comment
×
×
  • Create New...