Jump to content

ItsDangerous

Members
  • Content count

    15
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by ItsDangerous


  1. I went ahead and attempted this myself. It isn't quite right.. Lots of random glitches which causes the colors to get lost. I really don't know what I'm doing.

     

    Could anyone look at this and tell me what I'm doing wrong? It seems to work the first try but then the second time I try updating my model, all the colors disappear.

     

    Here's basically all the code I'm using. You can see how I used it in this video. I didn't mean to add an extra z_AditionalVertexStream script. Sometimes it automatically spawns in the mesh and sometimes it doesn't. 

     

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    
    
    namespace Polybrush
    {
        [ExecuteInEditMode]
    
        public class SaveLoadVertexColors : MonoBehaviour
        {
            public Mesh referenceMesh;
            public bool load;
    
            //Debug info
            public List<Vector3> verticies = new List<Vector3>();
            public List<Color> colors = new List<Color>();
            
            public bool transfer;
            private Mesh streamMesh;//The temporary mesh that we will have
            public z_AdditionalVertexStreams targetMesh;
            private Mesh newMeshToEdit;//The mesh that the modeler updated to
            
            public List<Color> colorsN = new List<Color>();
    
    
    
            void Update()
            {
    
                if (load)
                {
    
                    referenceMesh = GetComponent<z_AdditionalVertexStreams>().m_AdditionalVertexStreamMesh;
    
                    referenceMesh.GetVertices(verticies);
                    
    
                    referenceMesh.GetColors(colors);
    
    
                    //Create our own stream mesh
                    newMeshToEdit = targetMesh.gameObject.GetComponent<MeshFilter>().sharedMesh;//Gets an error if it's not shared
                    streamMesh = newMeshToEdit;
                    colorsN.Clear();
    
                    
                    load = false;
                }
    
                if (transfer)
                {
    
                    int iterate = 0;
                    foreach (Vector3 nVer in newMeshToEdit.vertices)
                    {
                        colorsN.Add(Color.white);
                        int iterate2 = 0;
                        foreach (Vector3 vert in verticies)
                        {
                            if ((vert - nVer).magnitude < 0.0001f)//Then they are the same
                            {
                                colorsN[iterate] = colors[iterate2];
                            }
                            iterate2++;
                        }
                        iterate++;
                    }
    
    
                    streamMesh.SetColors(colorsN);
    
                    targetMesh.SetAdditionalVertexStreamsMesh(streamMesh);//That should do it
    
    
                    transfer = false;
                }
            }
        }
    }

     


  2. Has anything from this topic been implemented yet? I think technically speaking, you could just iterate through all the vertices in the old model and then check for vertices in the new model that are closer than 0.01 then transfer the colors to the new one. Of course, the process might take a while to compute. So I don't know what optimizations you have built in that you can use. 64000 times 64000 is a lot of iterations.


  3. I just learned about Giles and I'm very impressed with the demos. With probuilder under the hood, I think this would be near perfect for my game. 

    I do have some requests with Probuilder and Giles.

    First, I'm not sure if this is planned, but the ability to select polygons and clone them is one of the most time saving things in my workflow in both Blender and Sketchup. No having to deal with objects; just clone some polygons and have their UV's stay the same. That would be perfect.

    Second, with the stackable modifiers I'm hearing about, it would be nice to include a weld modifier. This would make it so you could weld the vertices to any other object including other procedural meshes. I included a screenshot attempting to show the benefits of this.

    Third, I believe the less mesh colliders you have, the faster PhysX runs. So, why not make it so that multiple objects can be batched together into one mesh collider (or something along those lines)? Might be pretty useful.

    Lastly, it would be nice to be able to edit parts out of the spline. For example, in  the screenshot, those yellow arrow signs are just a repeating geometry block, but I deleted the parts out that I didn't need.

     

     

    road.png


  4. The spline has a problem when you loop it.

    It appears that you are using world up to calculate the rotation along the spline. I think instead try using world up on your first segment and then referencing the previous segment as a new up direction for all of them. Then it should flow naturally I think. If not that, there has to be a way. Blender can do it. 

    loop.png


  5. To reproduce this, here are the steps:


    1. open a new scene


    2. import the latest polybrush 0.9.10b0 using unity 5.5.0f3


    3. make a cube. scale it out and flaten to make the floor in the scene - set it to static


    4. make a regular sized cube so it is casting a shadow on the floor (choose a non zero location like 2 meters away from zero). Paint half of this cube with a transparent color and the other with a solid. Set this to static as well. Close the polybrush window.


    5. Set the sunlight to "bake". Wait for your scene to bake that shadow into the floor.


    6. Hit play. Your cube mesh will appear somewhewere else while your collider of the cube stays in place. Doesn't matter what shader. They all seem to do the same. 


     


    I am using Windows10


     


    I even redownloaded polybrush right before typing this. Same result.


     


     


    Also, here is a video: https://youtu.be/ECh7duN1u7g


     


    - Mack


    post-1469-0-33262400-1483058814_thumb.jpg


  6. So, I made a physics engine to go along side PhysX 3. The special thing about it though is it uses vertex colors that I paint from polybrush to determine properties of the individual triangles.

     

    Right now, I have two types of collisions:

     

    Speed pads - which increase speed based on brush opacity (I also have a shader that scrolls a texture to this speed - it also takes the existing color and hue shifts it to match my vertex color - oh and does a little motion blur)

     

    Launch pads - which launch my car in the air with power based on brush opacity.

     

    It uses a super efficient indexing system, but tells more information, like for example, the rotation of the texture's UV coordinates and which texture it is colliding with.

     

    It is however just code to compliment a real physics engine like PhysX as it does not do any rigidbody simulation. It just solves ray casts against triangles.

     

     

    post-1469-0-37299100-1463791868_thumb.png


  7. The problem I'm having is that whenever I update my model using sketchup (really any modeler will do the same thing) I have to delete and replace the entire model to see the actual changes. That basically clears all vertex colors which will then have to be painted again at some point.

     

    If polybrush could just detect or have a "refresh model" option, the workflow could be much better. You could program it to repaint the new updated model from the colors in the old model.

     

    In terms of a workflow for a large game level, this could make visualizing your progress more easy being that you can paint as you model things. As it is now, it only makes sense to paint the model when it's finished as it's a waste of time to paint if it's just going to be cleared with your next update anyway. 

×