res/main.cs edit
This commit is contained in:
parent
84ec6445e7
commit
efe969b049
8
proj1/p1/Assets/Resources.meta
Normal file
8
proj1/p1/Assets/Resources.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef40bad1d4204e841a7a589e1c79dd36
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
84
proj1/p1/Assets/Resources/GroundMat.mat
Normal file
84
proj1/p1/Assets/Resources/GroundMat.mat
Normal file
@ -0,0 +1,84 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: GroundMat
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords: _NORMALMAP
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 2800000, guid: 9511ab33cd5f6724f8c31c380a4814af, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2800000, guid: a87cbf62329d56d4681d92302095915c, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0.832
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 0.93017626, b: 0.8160377, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
m_BuildTextureStacks: []
|
8
proj1/p1/Assets/Resources/GroundMat.mat.meta
Normal file
8
proj1/p1/Assets/Resources/GroundMat.mat.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68daadd29e830ba4eb802c712e2f055f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -6,8 +6,8 @@ using System.IO;
|
||||
public class main : MonoBehaviour
|
||||
{
|
||||
//ground
|
||||
float m_groundWidth = 10.0f;
|
||||
float m_groundHeight = 10.0f;
|
||||
float m_groundWidth = 150.0f;
|
||||
float m_groundHeight = 120.0f;
|
||||
Shader m_groundShader;
|
||||
Texture m_groundTexture;
|
||||
Color m_groundColor;
|
||||
@ -15,18 +15,27 @@ public class main : MonoBehaviour
|
||||
//camera GUI
|
||||
float m_FieldOfView = 60.0f;
|
||||
float m_camPosX = 0.0f;
|
||||
float m_camPosY = 10.0f;
|
||||
float m_camPosZ = 20.0f;
|
||||
float m_camPosY = 8.0f;
|
||||
float m_camPosZ = 10.0f;
|
||||
float m_camLookAtX = 0.0f;
|
||||
float m_camLookAtY = 0.0f;
|
||||
float m_camLookAtY = -15.0f;
|
||||
float m_camLookAtZ = 0.0f;
|
||||
|
||||
Vector3 lightDir = new Vector3(10.0f, 10.0f, 10.0f);
|
||||
|
||||
//SceneVariables
|
||||
float PlantSpacing = 10.0f;
|
||||
float PlantDist = 4.0f;
|
||||
float PlantOffset = 20.0f;
|
||||
static int rowCount = 8;
|
||||
static int colCount = 10;
|
||||
|
||||
//components
|
||||
GameObject mainCamera;
|
||||
GameObject directionalLight;
|
||||
GameObject ground;
|
||||
GameObject[,] trees = new GameObject[colCount,rowCount];
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
@ -67,6 +76,7 @@ public class main : MonoBehaviour
|
||||
MeshFilter groundMeshFilter = ground.AddComponent<MeshFilter>();
|
||||
|
||||
Mesh groundMesh = new Mesh();
|
||||
//ground.transform.Translate(new Vector3(0, 0, -20));
|
||||
|
||||
//dane wierzcho<68>k<EFBFBD>w
|
||||
Vector3[] vertices = new Vector3[4]
|
||||
@ -103,13 +113,30 @@ public class main : MonoBehaviour
|
||||
groundMesh.normals = normals;
|
||||
|
||||
//dane wsp<73>rz<72>dnych tekstury dla groundMesh
|
||||
Vector2[] uv = new Vector2[4]
|
||||
//Vector2[] uv = new Vector2[4]
|
||||
//{
|
||||
// new Vector2(0, 0),
|
||||
// new Vector2(1, 0),
|
||||
// new Vector2(0, 1),
|
||||
// new Vector2(1, 1)
|
||||
//};
|
||||
|
||||
//Material mat = Resources.Load("GroundMat") as Material;
|
||||
//groundMeshRenderer.material = mat;
|
||||
|
||||
//Inna wersja współrzędnych dla tekstury(small tiles)
|
||||
Vector2[] uv = new Vector2[4];
|
||||
for (int i = 0; i < uv.Length; i++)
|
||||
{
|
||||
new Vector2(0, 0),
|
||||
new Vector2(1, 0),
|
||||
new Vector2(0, 1),
|
||||
new Vector2(1, 1)
|
||||
};
|
||||
uv[i] = new Vector2(vertices[i].x, vertices[i].z);
|
||||
}
|
||||
|
||||
Material groundMaterial = Resources.Load("GroundMat") as Material;
|
||||
groundMaterial.SetTextureScale("_MainTex", new Vector2(0.03f, 0.03f));
|
||||
groundMeshRenderer.material = groundMaterial;
|
||||
|
||||
|
||||
|
||||
|
||||
//bufor wsp<73>rz<72>dnych tekstury dla groundMesh
|
||||
groundMesh.uv = uv;
|
||||
@ -132,9 +159,26 @@ public class main : MonoBehaviour
|
||||
go.transform.rotation = Quaternion.FromToRotation(Vector3.up, normal);
|
||||
}
|
||||
|
||||
|
||||
//Create multiple tree objects based on Width/Length spacing
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < colCount; i++)
|
||||
{
|
||||
for (int j = 0; j < rowCount; j++)
|
||||
{
|
||||
trees[i, j] = GameObject.CreatePrimitive(PrimitiveType.Sphere);
|
||||
//TODO randomization
|
||||
Vector3 position = new Vector3(groundMesh.vertices[2].x - i * PlantSpacing - PlantOffset, 0, groundMesh.vertices[2].z + j * PlantDist - 50);
|
||||
|
||||
trees[i, j].transform.position = position;
|
||||
}
|
||||
}
|
||||
|
||||
//mesh dla GameObject "Ground"
|
||||
groundMeshFilter.mesh = groundMesh;
|
||||
|
||||
//GetComponent<MeshFilter>().mesh = groundMesh;
|
||||
}
|
||||
|
||||
void Update()
|
||||
@ -142,6 +186,18 @@ public class main : MonoBehaviour
|
||||
mainCamera.GetComponent<Camera>().fieldOfView = m_FieldOfView;
|
||||
mainCamera.GetComponent<Camera>().transform.position = new Vector3(m_camPosX,m_camPosY,m_camPosZ);
|
||||
mainCamera.transform.LookAt(new Vector3(m_camLookAtX, m_camLookAtY, m_camLookAtZ), new Vector3(0.0f, 1.0f, 0.0f));
|
||||
|
||||
|
||||
//Update location of objects based on Spacing and Dist variables
|
||||
for (int i = 0; i < colCount; i++)
|
||||
{
|
||||
for (int j = 0; j < rowCount; j++)
|
||||
{
|
||||
Vector3 position = new Vector3(ground.GetComponent<MeshFilter>().mesh.vertices[2].x - i * PlantSpacing - PlantOffset, 0, ground.GetComponent<MeshFilter>().mesh.vertices[2].z + j * PlantDist - 50);
|
||||
trees[i, j].transform.position = position;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
@ -156,7 +212,7 @@ public class main : MonoBehaviour
|
||||
m_camPosY = GUI.HorizontalSlider(new Rect(70, 70, 150, 20), m_camPosY, -30.0f, 30.0f);
|
||||
|
||||
GUI.Label(new Rect(10, 95, 60, 20), "camPosZ");
|
||||
m_camPosZ = GUI.HorizontalSlider(new Rect(70, 95, 150, 20), m_camPosZ, -30.0f, 30.0f);
|
||||
m_camPosZ = GUI.HorizontalSlider(new Rect(70, 95, 150, 20), m_camPosZ, -30.0f, 50.0f);
|
||||
|
||||
GUI.Label(new Rect(10, 120, 60, 20), "LookAtX");
|
||||
m_camLookAtX = GUI.HorizontalSlider(new Rect(70, 120, 150, 20), m_camLookAtX, -30.0f, 30.0f);
|
||||
@ -167,6 +223,14 @@ public class main : MonoBehaviour
|
||||
GUI.Label(new Rect(10, 170, 60, 20), "LookAtZ");
|
||||
m_camLookAtZ = GUI.HorizontalSlider(new Rect(70, 170, 150, 20), m_camLookAtZ, -30.0f, 30.0f);
|
||||
|
||||
GUI.Label(new Rect(10, 200, 60, 20), "PlantSpacing");
|
||||
PlantSpacing = GUI.HorizontalSlider(new Rect(70, 205, 150, 20), PlantSpacing, 3.0f, 15.0f);
|
||||
|
||||
GUI.Label(new Rect(10, 230, 60, 20), "PlantDist");
|
||||
PlantDist = GUI.HorizontalSlider(new Rect(70, 240, 150, 20), PlantDist, 1.0f, 20.0f);
|
||||
|
||||
GUI.Label(new Rect(10, 260, 60, 20), "PlantOffset");
|
||||
PlantOffset = GUI.HorizontalSlider(new Rect(70, 270, 150, 20), PlantOffset, 10.0f, 60.0f);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user