本文整理汇总了C#中JBooth.VertexPainterPro.PaintJob类的典型用法代码示例。如果您正苦于以下问题:C# PaintJob类的具体用法?C# PaintJob怎么用?C# PaintJob使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PaintJob类属于JBooth.VertexPainterPro命名空间,在下文中一共展示了PaintJob类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LerpFunc
// this is the delegate we're going to return to apply a brush stamp. Your passed a paint job,
// which contains important cached information to make painting fast, and hold the actual stream data.
// the index is the index into the vertex array, the val is the brush data we supplied in GetBrushObject,
// and r is a 0 to 1 with how far to tween the value towards the brush (brush pressure * deltatime)
void LerpFunc(PaintJob j, int idx, ref object val, float r)
{
// retrieve our brush data and get the stream we're painting into
BrushData bd = val as BrushData;
var s = j.stream;
// use our vertex position to generate noise. We use the get position function because it will
// return a vert position from the original meshes cached verticies or modified verticies if
// we've modified them. This makes it compatible with deformations, etc.
Vector3 pos = j.GetPosition(idx);
// convert into world space
pos = j.renderer.localToWorldMatrix.MultiplyPoint(pos);
// scale by frequency
pos.x *= bd.frequency;
pos.y *= bd.frequency;
pos.z *= bd.frequency;
float noise = 0.5f * (0.5f * JBooth.VertexPainterPro.SimplexNoise.Noise.Generate(pos.x, pos.y, pos.z) + 0.5f);
noise += 0.25f * (0.5f * JBooth.VertexPainterPro.SimplexNoise.Noise.Generate(pos.y * 2.031f, pos.z * 2.031f, pos.x * 2.031f) + 0.5f);
noise += 0.25f * (0.5f * JBooth.VertexPainterPro.SimplexNoise.Noise.Generate(pos.z * 4.01f, pos.x * 4.01f, pos.y * 4.01f) + 0.5f);
noise *= bd.amplitude;
// lerp the noise in
Color c = s.colors[idx];
c.r = Mathf.Lerp(c.r, noise, r);
c.g = Mathf.Lerp(c.g, noise, r);
c.b = Mathf.Lerp(c.b, noise, r);
s.colors[idx] = c;
}
示例2: OnGUI
public void OnGUI(PaintJob[] jobs)
{
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Combine Meshes"))
{
VertexPainterUtilities.MergeMeshes(jobs);
}
if (GUILayout.Button("Combine and Save"))
{
if (jobs.Length != 0)
{
string path = EditorUtility.SaveFilePanel("Save Asset", Application.dataPath, "models", "asset");
if (!string.IsNullOrEmpty(path))
{
path = FileUtil.GetProjectRelativePath(path);
GameObject go = VertexPainterUtilities.MergeMeshes(jobs);
Mesh m = go.GetComponent<MeshFilter>().sharedMesh;
AssetDatabase.CreateAsset(m, path);
AssetDatabase.SaveAssets();
AssetDatabase.ImportAsset(path);
GameObject.DestroyImmediate(go);
}
}
}
EditorGUILayout.EndHorizontal();
}
示例3: OnGUI
public void OnGUI(PaintJob[] jobs)
{
bakingTex = EditorGUILayout.ObjectField("Texture", bakingTex, typeof(Texture2D), false) as Texture2D;
bakeSourceUV = (BakeSourceUV)EditorGUILayout.EnumPopup("Source UVs", bakeSourceUV);
bakeChannel = (BakeChannel)EditorGUILayout.EnumPopup("Bake To", bakeChannel);
if (bakeSourceUV == BakeSourceUV.WorldSpaceXY || bakeSourceUV == BakeSourceUV.WorldSpaceXZ || bakeSourceUV == BakeSourceUV.WorldSpaceYZ)
{
worldSpaceLower = EditorGUILayout.Vector2Field("Lower world position", worldSpaceLower);
worldSpaceUpper = EditorGUILayout.Vector2Field("Upper world position", worldSpaceUpper);
}
EditorGUILayout.BeginHorizontal();
EditorGUILayout.Space();
if (GUILayout.Button("Bake"))
{
if (bakingTex != null)
{
BakeFromTexture(jobs);
}
else
{
EditorUtility.DisplayDialog("Error", "Baking texture is not set", "ok");
}
}
EditorGUILayout.Space();
EditorGUILayout.EndHorizontal();
}
示例4: BakeColor
void BakeColor(PaintJob job, BakeChannel bc, Vector4 val, int i)
{
switch (bc)
{
case BakeChannel.Color:
{
job.stream.colors[i] = new Color(val.x, val.y, val.z, val.w); break;
}
case BakeChannel.UV0:
{
job.stream.uv0[i] = val;
break;
}
case BakeChannel.UV1:
{
job.stream.uv1[i] = val;
break;
}
case BakeChannel.UV2:
{
job.stream.uv2[i] = val;
break;
}
case BakeChannel.UV3:
{
job.stream.uv3[i] = val;
break;
}
}
}
示例5: MergeMeshes
public static GameObject MergeMeshes(PaintJob[] jobs)
{
if (jobs.Length == 0)
return null;
List<CombineInstance> meshes = new List<CombineInstance>();
for (int i = 0; i < jobs.Length; ++i)
{
Mesh m = BakeDownMesh(jobs[i].meshFilter.sharedMesh, jobs[i].stream);
CombineInstance ci = new CombineInstance();
ci.mesh = m;
ci.transform = jobs[i].meshFilter.transform.localToWorldMatrix;
meshes.Add(ci);
}
Mesh mesh = new Mesh();
mesh.CombineMeshes(meshes.ToArray());
GameObject go = new GameObject("Combined Mesh");
go.AddComponent<MeshRenderer>();
var mf = go.AddComponent<MeshFilter>();
mesh.Optimize();
mesh.RecalculateBounds();
mesh.UploadMeshData(false);
mf.sharedMesh = mesh;
for (int i = 0; i < meshes.Count; ++i)
{
GameObject.DestroyImmediate(meshes[i].mesh);
}
return go;
}
示例6: FlowColorRG
static void FlowColorRG(PaintJob j, int idx, ref object v, float r)
{
Vector2 vv = (Vector2)v;
var s = j.stream;
Color c = s.colors[idx];
s.colors[idx].r = Mathf.Lerp(c.r, vv.x, r);
s.colors[idx].g = Mathf.Lerp(c.g, vv.y, r);
}
示例7: FlowColorBA
static void FlowColorBA(PaintJob j, int idx, ref object v, float r)
{
Vector2 vv = (Vector2)v;
var s = j.stream;
Color c = s.colors[idx];
s.colors[idx].b = Mathf.Lerp(c.b, vv.x, r);
s.colors[idx].a = Mathf.Lerp(c.a, vv.y, r);
}
示例8: FlowUV1_XY
static void FlowUV1_XY(PaintJob j, int idx, ref object v, float r)
{
var s = j.stream;
Vector4 o = s.uv1[idx];
Vector2 t = (Vector2)v;
o.x = Mathf.Lerp(o.x, t.x, r);
o.y = Mathf.Lerp(o.y, t.y, r);
s.uv1[idx] = o;
}
示例9: FlowUV2_ZW
static void FlowUV2_ZW(PaintJob j, int idx, ref object v, float r)
{
var s = j.stream;
Vector4 o = s.uv2[idx];
Vector2 t = (Vector2)v;
o.z = Mathf.Lerp(o.z, t.x, r);
o.w = Mathf.Lerp(o.w, t.y, r);
s.uv2[idx] = o;
}
示例10: DoBakePivot
void DoBakePivot(PaintJob[] jobs)
{
switch (pivotTarget)
{
case PivotTarget.UV0:
{
InitBakeChannel(BakeChannel.UV0, jobs);
foreach (PaintJob job in jobs)
{
Vector3 lp = bakePivotUseLocal ? job.meshFilter.transform.localPosition : job.meshFilter.transform.position;
job.stream.SetUV0(new Vector4(lp.x, lp.y, lp.z, UnityEngine.Random.Range(0.0f, 1.0f)), job.verts.Length);
EditorUtility.SetDirty(job.stream);
EditorUtility.SetDirty(job.stream.gameObject);
}
break;
}
case PivotTarget.UV1:
{
InitBakeChannel(BakeChannel.UV1, jobs);
foreach (PaintJob job in jobs)
{
Vector3 lp = bakePivotUseLocal ? job.meshFilter.transform.localPosition : job.meshFilter.transform.position;
job.stream.SetUV1(new Vector4(lp.x, lp.y, lp.z, UnityEngine.Random.Range(0.0f, 1.0f)), job.verts.Length);
EditorUtility.SetDirty(job.stream);
EditorUtility.SetDirty(job.stream.gameObject);
}
break;
}
case PivotTarget.UV2:
{
InitBakeChannel(BakeChannel.UV2, jobs);
foreach (PaintJob job in jobs)
{
Vector3 lp = bakePivotUseLocal ? job.meshFilter.transform.localPosition : job.meshFilter.transform.position;
job.stream.SetUV2(new Vector4(lp.x, lp.y, lp.z, UnityEngine.Random.Range(0.0f, 1.0f)), job.verts.Length);
EditorUtility.SetDirty(job.stream);
EditorUtility.SetDirty(job.stream.gameObject);
}
break;
}
case PivotTarget.UV3:
{
InitBakeChannel(BakeChannel.UV3, jobs);
foreach (PaintJob job in jobs)
{
Vector3 lp = bakePivotUseLocal ? job.meshFilter.transform.localPosition : job.meshFilter.transform.position;
job.stream.SetUV3(new Vector4(lp.x, lp.y, lp.z, UnityEngine.Random.Range(0.0f, 1.0f)), job.verts.Length);
EditorUtility.SetDirty(job.stream);
EditorUtility.SetDirty(job.stream.gameObject);
}
break;
}
}
}
示例11: OnGUI
public void OnGUI(PaintJob[] jobs)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.Space();
if (GUILayout.Button("Save Mesh"))
{
VertexPainterUtilities.SaveMesh(jobs);
}
EditorGUILayout.Space();
EditorGUILayout.EndHorizontal();
}
示例12: OnGUI
public void OnGUI(PaintJob[] jobs)
{
EditorGUILayout.HelpBox("Multiply a channel by a value. Useful for scaling UVs, objects, etc", MessageType.Info);
bakeChannel = (BakeChannel)EditorGUILayout.EnumPopup("Channel", bakeChannel);
multValue = EditorGUILayout.FloatField("Multiply By", multValue);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.Space();
if (GUILayout.Button("Multiply It"))
{
Bake(jobs);
}
EditorGUILayout.Space();
EditorGUILayout.EndHorizontal();
}
示例13: OnGUI
public void OnGUI(PaintJob[] jobs)
{
pivotTarget = (PivotTarget)EditorGUILayout.EnumPopup("Store in", pivotTarget);
bakePivotUseLocal = EditorGUILayout.Toggle("Use Local Space", bakePivotUseLocal);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.Space();
if (GUILayout.Button("Bake Pivot"))
{
DoBakePivot(jobs);
}
if (GUILayout.Button("Bake Rotation"))
{
DoBakeRotation(jobs);
}
EditorGUILayout.Space();
EditorGUILayout.EndHorizontal();
}
示例14: SaveMesh
public static void SaveMesh(PaintJob[] jobs)
{
if (jobs.Length != 0)
{
string path = EditorUtility.SaveFilePanel("Save Asset", Application.dataPath, "models", "asset");
if (!string.IsNullOrEmpty(path))
{
path = FileUtil.GetProjectRelativePath(path);
Mesh firstMesh = BakeDownMesh(jobs[0].meshFilter.sharedMesh, jobs[0].stream);
AssetDatabase.CreateAsset(firstMesh, path);
for (int i = 1; i < jobs.Length; ++i)
{
Mesh m = BakeDownMesh(jobs[i].meshFilter.sharedMesh, jobs[i].stream);
AssetDatabase.AddObjectToAsset(m, firstMesh);
}
AssetDatabase.SaveAssets();
AssetDatabase.ImportAsset(path);
}
}
}
示例15: OnGUI
public void OnGUI(PaintJob[] jobs)
{
var window = VertexPainterWindow.GetWindow<VertexPainterWindow>();
window.brushMode = (VertexPainterWindow.BrushTarget)EditorGUILayout.EnumPopup("Target Channel", window.brushMode);
aoSamples = EditorGUILayout.IntSlider("Samples", aoSamples, 64, 1024);
EditorGUILayout.BeginHorizontal();
aoRange = EditorGUILayout.Vector2Field("Range (Min, Max)", aoRange);
aoRange.x = Mathf.Max(aoRange.x, 0.0001f);
EditorGUILayout.EndHorizontal();
aoIntensity = EditorGUILayout.Slider("Intensity", aoIntensity, 0.25f, 4.0f);
bakeLighting = EditorGUILayout.Toggle("Bake Lighting", bakeLighting);
if (bakeLighting)
{
aoLightAmbient = EditorGUILayout.ColorField("Light Ambient", aoLightAmbient);
}
aoBakeMode = (AOBakeMode)EditorGUILayout.EnumPopup("Mode", aoBakeMode);
EditorGUILayout.Space();
if (GUILayout.Button("Bake"))
{
DoBakeAO(jobs, window);
}
}