unit – How can I check if the eulerAngles transformation is at 0,0,0,?

private void Update()
    {
        if(toRotate == true)
        {
            transform.Rotate(0,0,100);
        }
        else
        {
            transform.eulerAngles = new Vector3(0, 0, 0);
        }
    }

I want that if the transformation does not turn, then face forward.
So I used:

transform.eulerAngles = new Vector3(0, 0, 0);

But I want to do it once. Do not always change the eulerAngles to 0,0,0 but only once when the transformation does not rotate.

The problem is that from the line:

transform.eulerAngles = new Vector3(0, 0, 0);

Is in the update, he will try to change it to 0,0,0 all the time in the game and I want him to do it every time only when stopped.

How to correctly build a unit mesh from data extracted from 3dsmax Triobj

I am trying to make an importer for my mesh file exported from 3ds max sdk using triobj
I have already changed the YZ vectors and extracted the data as an obj file.

In the unit, I don't know how to build it, it goes wrong:
unit result

Here is my code, I have included mesh data:
The

using UnityEngine;

public class autodesk_3dsmax_mesh_import : MonoBehaviour
{
    public Material DefaultMaterial;
    private float scalefactor = 10.0f;

    class MeshFace
    {
        public int _vid { get; set; }
        public int _uid { get; set; }
        public int _nid { get; set; }

        public MeshFace(int vid,int uid,int nid) {
            _vid = vid; _uid = uid; _nid = nid;
        }
    }

    //// Exported data from 3DsMax using Trimesh API (YZ flip is applied)
    //// It's in *.obj data-type format
    private Vector3() _3dsmax_vertexdata = {
      new Vector3(-5.000000f,-5.000000f,5.000000f),
      new Vector3(5.000000f,-5.000000f,5.000000f),
      new Vector3(-5.000000f,-5.000000f,-5.000000f),
      new Vector3(5.000000f,-5.000000f,-5.000000f),
      new Vector3(-5.000000f,5.000000f,5.000000f),
      new Vector3(5.000000f,5.000000f,5.000000f),
      new Vector3(-5.000000f,5.000000f,-5.000000f),
      new Vector3(5.000000f,5.000000f,-5.000000f)
    };
    private Vector3() _3dsmax_normaldata = {
      new Vector3(0.000000f,-1.000000f,0.000000f),
      new Vector3(0.000000f,-1.000000f,0.000000f),
      new Vector3(0.000000f,-1.000000f,0.000000f),
      new Vector3(0.000000f,-1.000000f,0.000000f),
      new Vector3(0.000000f,1.000000f,0.000000f),
      new Vector3(0.000000f,1.000000f,0.000000f),
      new Vector3(0.000000f,1.000000f,0.000000f),
      new Vector3(0.000000f,1.000000f,0.000000f),
      new Vector3(0.000000f,0.000000f,1.000000f),
      new Vector3(0.000000f,0.000000f,1.000000f),
      new Vector3(0.000000f,0.000000f,1.000000f),
      new Vector3(0.000000f,0.000000f,1.000000f),
      new Vector3(1.000000f,0.000000f,0.000000f),
      new Vector3(1.000000f,0.000000f,0.000000f),
      new Vector3(1.000000f,0.000000f,0.000000f),
      new Vector3(1.000000f,0.000000f,0.000000f),
      new Vector3(0.000000f,0.000000f,-1.000000f),
      new Vector3(0.000000f,0.000000f,-1.000000f),
      new Vector3(0.000000f,0.000000f,-1.000000f),
      new Vector3(0.000000f,0.000000f,-1.000000f),
      new Vector3(-1.000000f,0.000000f,0.000000f),
      new Vector3(-1.000000f,0.000000f,0.000000f),
      new Vector3(-1.000000f,0.000000f,0.000000f),
      new Vector3(-1.000000f,0.000000f,0.000000f)
    };
    private Vector2() _3dsmax_uvdata = {
      new Vector2(0.000000f,0.000000f),
      new Vector2(1.000000f,0.000000f),
      new Vector2(0.000000f,1.000000f),
      new Vector2(1.000000f,1.000000f),
      new Vector2(0.000000f,0.000000f),
      new Vector2(1.000000f,0.000000f),
      new Vector2(0.000000f,1.000000f),
      new Vector2(1.000000f,1.000000f),
      new Vector2(0.000000f,0.000000f),
      new Vector2(1.000000f,0.000000f),
      new Vector2(0.000000f,1.000000f),
      new Vector2(1.000000f,1.000000f)
        };
    private MeshFace() _3dsmax_facedata = {
      new MeshFace(4,11,1),
      new MeshFace(2,9,2),
      new MeshFace(1,10,3),
      new MeshFace(1,10,3),
      new MeshFace(3,12,4),
      new MeshFace(4,11,1),
      new MeshFace(8,12,5),
      new MeshFace(7,11,6),
      new MeshFace(5,9,7),
      new MeshFace(5,9,7),
      new MeshFace(6,10,8),
      new MeshFace(8,12,5),
      new MeshFace(6,8,9),
      new MeshFace(5,7,10),
      new MeshFace(1,5,11),
      new MeshFace(1,5,11),
      new MeshFace(2,6,12),
      new MeshFace(6,8,9),
      new MeshFace(8,4,13),
      new MeshFace(6,3,14),
      new MeshFace(2,1,15),
      new MeshFace(2,1,15),
      new MeshFace(4,2,16),
      new MeshFace(8,4,13),
      new MeshFace(7,8,17),
      new MeshFace(8,7,18),
      new MeshFace(4,5,19),
      new MeshFace(4,5,19),
      new MeshFace(3,6,20),
      new MeshFace(7,8,17),
      new MeshFace(5,4,21),
      new MeshFace(7,3,22),
      new MeshFace(3,1,23),
      new MeshFace(3,1,23),
      new MeshFace(1,2,24),
      new MeshFace(5,4,21),
    };


    void Start()
    {
        uint v_count = 8; uint n_count = 24;
        uint t_count = 12; uint f_count = 36;

        //// Extracted From 3DsMax
        string obj_name = "Box_001";
        Vector3 object_pos = new Vector3(0, 0.5f, 0);
        Quaternion object_rot = new Quaternion(0,0,0,0);
        Vector3 object_scale = new Vector3(1f,1f,1f);

        GameObject simple_mesh = new GameObject(obj_name);
        simple_mesh.transform.position = object_pos;
        simple_mesh.transform.rotation = object_rot;

        simple_mesh.AddComponent();
        simple_mesh.AddComponent();

        Mesh mesh = simple_mesh.GetComponent().mesh;
        mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;

        Vector3() vertex_data   =   new Vector3(f_count);
        Vector3() normal_data   =   new Vector3(f_count);
        Vector2() texcoord_data =   new Vector2(f_count);
        int() triangles         =   new int(f_count);

        for (int i = 0; i < f_count; i++)
        {
            int vertex_id = _3dsmax_facedata(i)._vid - 1;
            int texcoord_id = _3dsmax_facedata(i)._uid - 1;
            int normal_id = _3dsmax_facedata(i)._nid - 1;

            float vtx_x = _3dsmax_vertexdata(vertex_id).x;
            float vtx_y = _3dsmax_vertexdata(vertex_id).y;
            float vtx_z = _3dsmax_vertexdata(vertex_id).z;

            vertex_data(i) = new Vector3(vtx_x / scalefactor, vtx_y / scalefactor, vtx_z / scalefactor);

            float nrm_x = _3dsmax_normaldata(normal_id).x;
            float nrm_y = _3dsmax_normaldata(normal_id).y;
            float nrm_z = _3dsmax_normaldata(normal_id).z;

            normal_data(i) = new Vector3(nrm_x , nrm_y , nrm_z );

            float uv_x = _3dsmax_uvdata(texcoord_id).x;
            float uv_y = _3dsmax_uvdata(texcoord_id).y;

            texcoord_data(i) = new Vector2(uv_x, uv_y);

            triangles(i) = vertex_id;
        }

        mesh.Clear();
        mesh.vertices =vertex_data;
        mesh.normals = normal_data;
        mesh.uv = texcoord_data;
        mesh.triangles = triangles;
        mesh.RecalculateNormals();
        simple_mesh.GetComponent().material = DefaultMaterial;

    }
}

The data is a simple 3ds max box.

What am i doing wrong?
How can I make it work?

unit – isometric occlusion slaughter

I am creating a 3D isometric game in Unity using a standard 3D environment with a fixed camera 35 degrees from the horizontal. While the player is outside the buildings, the entire building is visible (which is a fully 3D building model) and when the player enters the building, everything above the ground on which the player is currently will not be visible, the walls closest to the camera will also not be visible. In addition, when the player is outside the building, the inside of the buildings must be obscured.

I have spent the last two days reading about the removal of the frustrum and the bite removal, but there is really not a lot of information about it. subject beyond the basics of shooting things behind the camera. information or tutorials about slaughter areas and slaughter gates seem even more scarce.

Anyone have any tips or advice on how I can get there please.

Here is a photo that I found on the Internet and which shows an example of what I am trying to achieve.
enter description of image here

unit – Animation settings (to be used later as a prefab anywhere in the canvas)

I am using Unity3D 2019 and I am creating a 2D workflow system, so I have found that the solution to creating an animation of pipeline liquid is the use of two Image Objects first used as a mask for the second used to simulate fuel or air or liquid, but once i saved it as prefab or duplicate, the animation didn’t not work properly, because the animation will use the same value parameters as those used for the first object.
Can you suggest a new or simple method for this, or can I configure an animation to work as it was saved for any state / position / rotation (as a starting point and an end point but global).
Thank you.

unit – How to force pixel rendering on Android?

My scene on Android Build looks much darker. Based on my research on the subject and the texture of light on the spheres, I guess it's because light uses by summit rendering mode on Andriod.

I'm trying to force per pixel to render on Android, here are the things I tried:

  • put it on Rendering at Important of Light on the stage (there is only one directional)
  • check my values RenderPipeline (the one provided with the LWRP model project), the Main light East By pixel, Additional light (which doesn't seem to matter) is also By pixel
  • put it on Rendering of Preset Light type at Important in the Preset manager

I will have infinite levels, the map changes dynamically, so Baking the light is not an option.

Can I do it one way or the other? Or at least force my editor to use per pixel so that I can illuminate my scene more intuitively.

enter description of image here

If you are using Spring dependency injection, does the unit test require Spring items?

I fully understand, I think, how injecting a dependency of a class makes it possible to mock this dependence and to test the class with the simulated version.

What I'm not sure about is that if you use @autowired to do this DI and write a junit test, will the new class be acceptable? In other words, will the annotation simply be ignored and can the constructor be used normally?

If yes, is there a case where you want to use Spring in the unit test to inject the model? It seems to me that if you are writing a unit test, you want it to be as simple as possible and therefore avoid involving Spring if you could.

java – Unit test of the ModelAndView controller with Mockito and Spring

I need to configure the unit test for the controller below (just for example):

import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController(value = "/test")
public class TestController {

    @GetMapping(value = "/list")
    public ModelAndView list(ModelAndView model, HttpServletRequest request) {
        model.addObject("returnedAttribute", request.getSession().getAttribute("test"));
        return model;
    }
}

I received the suggestion below from colleague @nullptr in another topic:

@Test
public void testIniciaTela() {

    ModelAndView modelAndView = new ModelAndView();
    ModelAndView modelResultado = controller.iniciaTela(modelAndView, getMockServletRequest());
    assertEquals(
        "1234", 
        modelResultado.getModelMap().get(AbstractConstantes.PERFIL_USUARIO_LOGADO)
    );

}

private HttpServletRequest getMockServletRequest() {
    MockHttpServletRequest mockRequest = new MockHttpServletRequest(); //aqui está dando erro...
    mockRequest.setSession(getMockSession());
    return mockRequest;
}

private HttpSession getMockSession() {

    PerfilUsuarioLogadoVO perfilUsuarioLogado = new PerfilUsuarioLogadoVO();
    perfilUsuarioLogado.setNuUnidade("1234");

    MockHttpSession mockSession = new MockHttpSession();
    mockSession.setAttribute(AbstractConstantes.PERFIL_USUARIO_LOGADO, perfilUsuarioLogado);

    return mockSession;

}

But I get this error:

java.lang.NoSuchMethodError: org.springframework.util.StreamUtils.emptyInput()Ljava/io/InputStream;
at org.springframework.mock.web.MockHttpServletRequest.(MockHttpServletRequest.java:102)
at xxx.controller.ManterEnvioManualControllerTest.getMockServletRequest(ManterEnvioManualControllerTest.java:110)

when you try to run the line below:

MockHttpServletRequest mockRequest = new MockHttpServletRequest();

My file pom.xml looks like this:


4.0.0

    br.xxx.sigms
    sigms
    4.0.0-SNAPSHOT

sigms-web
war


    UTF-8


SIGMS - WEB

    
        br.xxx.sigms
        sigms-common
        provided
    

    
        br.xxx.sigms
        sigms-dao
        ejb
        provided
    

    
        br.xxx.sigms
        sigms-ws
        provided
    
    
    
        junit
        junit
        test
    
    

    
        org.jboss.logmanager
        log4j-jboss-logmanager
        provided
    
    
        commons-lang
        commons-lang
        provided
    
    
        commons-beanutils
        commons-beanutils
        provided
    
    
        org.codehaus.groovy
        groovy-all
        ${version.groovy.all}
    
    
        org.jboss.spec.javax.ejb
        jboss-ejb-api_3.2_spec
        provided
    
    
        org.springframework
        spring-context
    
    
        org.springframework
        spring-aop
        ${version.spring.aop}
    
    
        org.springframework
        spring-web
        ${version.spring.web}
    
    
        org.springframework
        spring-webmvc
        ${version.spring.webmvc}
    
    
        org.codehaus.jackson
        jackson-mapper-asl
        ${version.jackson.mapper.asl}
        provided
    

    
        com.fasterxml.jackson.core
        jackson-core
        ${version.jackson.core}
        provided
    
    
        com.fasterxml.jackson.core
        jackson-databind
        ${version.jackson.databind}
        provided
    

    
        org.springframework.ldap
        spring-ldap-core
        ${version.spring.ldap.core}
    

    
        org.sitemesh
        sitemesh
        ${version.sitmesh}
    
    
        commons-pool
        commons-pool
        ${version.commons.pool}
    
    
        org.jboss.spec.javax.servlet
        jboss-servlet-api_3.1_spec
    
    
        javax.servlet
        jstl
        ${version.jstl}
    
    
        javax.validation
        validation-api
        ${version.javax.validation.api}
        provided
    
    
        org.hibernate
        hibernate-validator
        provided
    
    
        br.xxx.sigms
        sigms-core
        ${project.version}
        provided
    
    
    
        org.springframework.security
        spring-security-web
        ${version.org.spring.framework.sucurity}
    
    
        org.springframework.security
        spring-security-config
        ${version.org.spring.framework.config}
    
    
        org.springframework.security
        spring-security-taglibs
        ${version.org.spring.framework.sucurity}
    

    
        org.springframework.security
        spring-security-ldap
        ${version.org.spring.framework.ldap}
    

    
        net.sf.jasperreports
        jasperreports
        ${version.jasperreports}
        provided
    

    
        com.thoughtworks.xstream
        xstream
        1.4.8
        provided
    

    
        org.springframework.boot
        spring-boot-starter-test
        ${version.org.spring.framework.boot}
        test
    

    
        com.h2database
        h2
        test
    




    ${project.artifactId}
    
        
            maven-war-plugin
            ${version.war.plugin}
            
                src/main/webapp
                
                false
            
        
    

The properties of pom.xml of the parent project (where dependency versions are defined) looks like this:

    
    UTF-8
    1.7
    
    1.7
    1.7

    
    4.0.0-SNAPSHOT
    3.1
    1.6
    3.2.3.RELEASE
    3.2.3.RELEASE
    3.2.3.RELEASE
    3.2.8.RELEASE
    2.2.2.RELEASE
    1.1.0.Final-redhat-1
    1.2
    2.3
    1.0.0.Final-redhat-1
    3.0.0
    2.0.4.RELEASE
    1.2.1
    2.8.9.redhat-1
    2.8.9.redhat-1
    1.9.13.redhat-4
    4.1.4.RELEASE
    4.1.4.RELEASE
    4.1.4.RELEASE
    4.1.4.RELEASE
    1.7.5
    1.1.5.Final
    1.7.7
    1.1.23.Final-redhat-1
    1.1.2.Final
    7.1.1.Final
    3.0.2.Final-redhat-4
    1.1.5.Final
    1.1.7.Final
    2.12
    2.3.2
    4.2.14.SP1-redhat-1
    3.1.2.RELEASE
    2.6.10
    6.4.0
    2.8
    2.3
    2.10
    2.1.1
    4.11
    1.1.4.Final-redhat-1
    1.9.2.redhat-1
    2.6.0.redhat-6
    1.0.0.Final-redhat-1
    1.0.0.Final-redhat-2
    5.1.10.Final-redhat-1
    5.1.10.Final-redhat-1
    5.1.10.Final-redhat-1
    2.1.28.Final-redhat-1
    1.0.0.Final-redhat-1
    1.0.1.Final-redhat-1
    5.0
    2.1
    1.2.0.redhat-2
    1.0.0.redhat-6
    5.3.5.Final-redhat-2
    2.2.0.Final-redhat-1
    5.2.11.Final-redhat-2
    
    12.2.0.1
    1.4.192

unit – The update of the property of the object at startup is visible for one second when the game loads

I have a world selection scene in which I have GameObjects representing worlds. the GameObjects have default properties when the scene is loaded. For example: the text of the world name is red and each world has a "locked" status. This initial state can be seen in the following screenshot:

enter description of image here

On the Start() method, I dynamically update the properties on each GameObject depending on the values ​​that I read in a backup file. If a world is unlocked, the name text is set to white. If a world is currently selected, the name text turns green. Here's what it looks like at runtime:

enter description of image here

The problem is that when the scene is loaded from another scene (for example by clicking on a navigation button), the initial state of the GameObjectThe s can be seen for a second, then they take the appropriate values ​​as dictated by the backup file. How can I prevent this from happening? I felt like everything that is going on in the Start() the method takes place before GameObjecthave surrendered.

Here is a light code of what my code looks like:

    var worldIcons = FindObjectsOfType().OrderBy(x => x.WorldNumber).ToList();
    var saveFile = GameSaveManager.GetSaveFile();

    if (saveFile == null)
    {
        Debug.LogError("Could not find save file while loading worlds");
        return;
    }

    foreach (var worldIcon in worldIcons)
    {
        var savedWorld = saveFile.Worlds.SingleOrDefault(x => x.Number == worldIcon.WorldNumber);

        if (savedWorld == null)
        {
            //add world to save file
            GameSaveManager.CreateWorld(worldIcon.Controller);

            //unlock first world by default
            if (saveFile.Worlds.Count == 0 && worldIcon.WorldNumber == 1)
                worldIcon.Unlocked = LevelMapController.LockedStatus.Unlocked.ToString();
        }
        else
        {
            worldIcon.DisplayName = savedWorld.Name;
            worldIcon.WorldNumber = savedWorld.Number;

            var button = worldIcon.GetComponent

unit – ClientWebSocket not respecting proxy settings in options

I am trying to define a proxy for a ClientWebSocket in Unity.
Everything works fine without a proxy, but the problem is that it also works when I set an invalid proxy and I can't see the traffic.

I tried to use Charles Proxy and also a fiddler to watch the traffic.
They don't show anything when I activate the proxy and start the player. But the connections in the game all work correctly without error.

I have tried to test local proxies with a browser manually configured to use them, and they show traffic when I browse https://websocket.org/echo.html

I have also tried using http://127.0.0.1:8888 and the socks: //127.0.0.1: 8889 (with the socks enabled in Charles) without success.

I assume ClientWebSocket simply ignores the proxy.

    clientWebSocket = new ClientWebSocket();
    clientWebSocket.Options.AddSubProtocol("Tls");
    clientWebSocket.Options.Proxy = new WebProxy("https://127.0.0.1:8888");        

unit – Rotate the object always at the same speed on the screen, regardless of the distance from the camera?

I spin a globe like the hologlobe of XCOM,

enter description of image here

I rotate it using Quaternion.RotateTowards (Quaternion from, Quaternion to, float maxDegreesDelta).

I found good value for money for maxDegreesDelta, in my case it is 5.0f.

There is a limit on the distance or the distance at which the camera can be, suppose that closed is 1.0f and it is far 2.0f.

I want to be able to zoom in on the globe, but obviously when I do, it turns a little too fast.

When zoomed out, the rotation speed is satisfactory:

enter description of image here

When zoomed in, rotation is too fast, making manipulation more difficult:

enter description of image here

And the problem becomes even more evident as the size of the game view increases, that is, in full screen.

Using Mathf.Lerp and Mathf.InverseLerp, I tried to do maxDegreesDelta and the mouse delta proportional to the distance from the camera, but that is hardly convincing.

Note: I rotate the globe, not the camera.

Question:

How can I make sure that the object rotates at the same speed on the screen, regardless of the distance or the distance from the camera?