public GPUInstancingRenderer(VoxelPlayEnvironment env) { this.env = env; defaultInstancingMaterial = Resources.Load <Material> ("VoxelPlay/Materials/VP Model VertexLit"); instancedChunks = new FastIndexedList <VoxelChunk, InstancedChunk> (); batchedMeshes = new FastList <BatchedMesh> (); }
public GPUInstancingIndirectRenderer(VoxelPlayEnvironment env) { this.env = env; defaultInstancingMaterial = Resources.Load <Material> ("VoxelPlay/Materials/VP Indirect VertexLit"); if (!SystemInfo.supportsComputeShaders) { Debug.LogError("Current platform does not support compute buffers. Switch off 'Compute Buffers' option in Voxel Play Environment inspector."); } instancedChunks = new FastIndexedList <VoxelChunk, InstancedChunk> (); cells = new FastIndexedList <Vector3, BatchedCell> (); }
void Start() { woodenBlock = GetComponent <WoodenBlock>(); env = VoxelPlayEnvironment.instance; voxelLib = WoodenBlockVoxelLibrary.instance; // Create scene objects CreateColorSwatch(); CreateSlotSwatch(); CreateInputSwatch(); InitMenuButtons(); }
void Start() { env = VoxelPlayEnvironment.instance; // When Voxel Play is ready, do some stuff... env.OnInitialized += OnInitialized; // Get notified is player is damaged VoxelPlayPlayer.instance.OnPlayerGetDamage += OnPlayerGetDamage; // Get notified is player is killed VoxelPlayPlayer.instance.OnPlayerIsKilled += OnPlayerIsKilled; }
private void Start() { env = VoxelPlayEnvironment.instance; if (env != null) { if (!VoxelPlayEnvironment.supportsBrightPointLights) { DestroyImmediate(this); return; } env.OnTorchAttached += (chunk, lightSource) => rebuildBuffer = true; env.OnTorchDetached += (chunk, lightSource) => rebuildBuffer = true; env.OnChunkRender += (chunk) => rebuildBuffer = true; env.OnLightRefreshRequest += () => rebuildBuffer = true; } }
// Start is called before the first frame update void Start() { if (GameObject.FindGameObjectWithTag("NetworkManager")) { nmp = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkManager_Photon>(); } env = VoxelPlayEnvironment.instance; env.OnInitialized += OnInitialized; if (!nmp) { Debug.LogError("Network Manager Not Found"); } if (!env) { Debug.LogError("Voxel Play Environment not found"); } }
void OnEnable() { if (lights == null) { lights = new List <Light> (); } if (lightPosBuffer == null || lightPosBuffer.Length < 32) { lightPosBuffer = new Vector4[32]; } if (lightColorBuffer == null || lightColorBuffer.Length < 32) { lightColorBuffer = new Vector4[32]; } env = VoxelPlayEnvironment.instance; env.OnTorchAttached += (chunk, lightSource) => rebuildBuffer = true; env.OnTorchDetached += (chunk, lightSource) => rebuildBuffer = true; env.OnChunkChanged += (chunk) => rebuildBuffer = true; env.OnLightRefreshRequest += () => rebuildBuffer = true; }
void Start() { env = VoxelPlayEnvironment.instance; // Position player on the scene and setup orbit parameters fps = VoxelPlayFirstPersonController.instance; // Create scene objects CreateCube(); CreateLabels(); CreateColorSwatch(); // Color the voxel in black when clicked OR place a new voxel env.OnVoxelClick += (chunk, voxelIndex, buttonIndex) => { if (buttonIndex == 0) { if (!eraseMode) { // If left click, change the color of voxel to white env.VoxelSetColor(chunk, voxelIndex, currentColor); } } else { // If right click, places a new voxel on top of this in the direction of the plane Vector3 position = fps.crosshairHitInfo.voxelCenter + fps.crosshairHitInfo.normal; env.VoxelPlace(position, Color.red, true); } }; // Control erase mode env.OnVoxelDamaged += (VoxelChunk chunk, int voxelIndex, ref int damage) => { if (!eraseMode) { damage = 0; } }; }
// Start is called before the first frame update void Start() { env = VoxelPlayEnvironment.instance; }
WoodenBlockVoxelLibrary() { env = VoxelPlayEnvironment.instance; }
// Use this for initialization void Start() { env = VoxelPlayEnvironment.instance; env.OnInitialized += InitializeGame; }
void Start() { env = VoxelPlayEnvironment.instance; voxelLib = WoodenBlockVoxelLibrary.instance; // Position player on the scene and setup orbit parameters fps = VoxelPlayFirstPersonController.instance; // Create scene objects CreateCube(); //CreateInputSwatch(); // Color the voxel in black when clicked OR place a new voxel env.OnVoxelClick += (chunk, voxelIndex, buttonIndex, hitInfo) => { if (!EventSystem.current.IsPointerOverGameObject()) { if (false == voxelLib.isGridBlock(chunk, voxelIndex)) { currentChunk = chunk; currentVoxelIndex = voxelIndex; env.VoxelHighlight(hitInfo, Color.red, 30); } if (buttonIndex == 0) { switch (controlMode) { case ControlMode.BUILD: { if (voxelLib.isGridBlock(hitInfo)) { if (hitInfo.normal.y == 1) // only can make Top Direction { Vector3 position = hitInfo.voxelCenter + hitInfo.normal; //env.VoxelPlace(position, newVoxelDefine, createColor, true); VoxelChunk chunk_; int voxelIndex_; env.VoxelPlace(position, newVoxelDefine, currentColor, out chunk_, out voxelIndex_, true); currentChunk = chunk_; currentVoxelIndex = voxelIndex_; hitInfo.voxelCenter = position; hitInfo.chunk = chunk_; hitInfo.voxelIndex = voxelIndex_; env.VoxelHighlight(hitInfo, Color.red, 30); } } else { Vector3 position = hitInfo.voxelCenter + hitInfo.normal; if (false == voxelLib.isGridBlock(position)) { //env.VoxelPlace(position, newVoxelDefine, createColor, true); VoxelChunk chunk_; int voxelIndex_; env.VoxelPlace(position, newVoxelDefine, currentColor, out chunk_, out voxelIndex_, true); currentChunk = chunk_; currentVoxelIndex = voxelIndex_; hitInfo.voxelCenter = position; hitInfo.chunk = chunk_; hitInfo.voxelIndex = voxelIndex_; env.VoxelHighlight(hitInfo, Color.red, 30); } } } break; case ControlMode.COLOR: //Vector2 pos = Camera.main.WorldToScreenPoint(hitInfo.voxelCenter); //RectTransformUtility.ScreenPointToLocalPointInRectangle(uiCanvas.transform as RectTransform, pos, uiCanvas.worldCamera, out pos); //colorPanel.transform.position = uiCanvas.transform.TransformPoint(pos); //colorPanel.SetActive(true); //isPropertyVisible = true; env.VoxelSetColor(currentChunk, currentVoxelIndex, currentColor); break; case ControlMode.ERASE: break; } } } }; // Control erase mode env.OnVoxelDamaged += (VoxelChunk chunk, int voxelIndex, ref int damage) => { if (controlMode != ControlMode.ERASE) { damage = 0; } else { if (voxelLib.isGridBlock(chunk, voxelIndex)) { damage = 0; } } }; var data = PlayerPrefs.GetString("0"); if (string.IsNullOrEmpty(data)) { SaveGame("0"); } Camera[] cameras = GetComponentsInChildren <Camera>(true); for (int i = 0; i < cameras.Length; ++i) { cameras[i].gameObject.SetActive(true); } }