diff --git a/README.md b/README.md index 475fab9..eba2d92 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ HyperCode Engine is a fork of the Psych Engine - **Buffer [Work in Progress]** Buffers temporarily store data in memory for more efficient data handling, improving overall performance. -- **3D model support [ !! Work in Progress !! | NOT WORKING, IT TOO MUCH ERROR ]** +- **3D model support** Now you can use 3D models in your mods! This feature allows for more complex and visually appealing scenes. # **Easy Modding** (with Chaos Included) @@ -61,7 +61,6 @@ Just like Psych Engine, HyperCode Engine is made for modders — with a cool API ### Haxe-Only - `NdllUtil` -- `Manager3D` --- diff --git a/setup/unix.sh b/setup/unix.sh index 6b9f884..a3878ec 100644 --- a/setup/unix.sh +++ b/setup/unix.sh @@ -15,9 +15,9 @@ haxelib set lime 8.2.2 haxelib set openfl 9.4.1 haxelib git flxanimate https://github.com/Dot-Stuff/flxanimate 768740a56b26aa0c072720e0d1236b94afe68e3e haxelib git linc_luajit https://github.com/superpowers04/linc_luajit 1906c4a96f6bb6df66562b3f24c62f4c5bba14a7 -haxelib git funkin.vis https://github.com/FunkinCrew/funkVis 22b1ce089dd924f15cdc4632397ef3504d464e90 +haxelib git funkin.vis https://github.com/FunkinCrew/funkVis haxelib git grig.audio https://gitlab.com/haxe-grig/grig.audio.git cbf91e2180fd2e374924fe74844086aab7891666 -haxelib git away3d https://github.com/CodenameCrew/away3d +haxelib git away3d https://github.com/CodenameCrew/away3d.git haxelib install tink_core haxelib install tink_await haxelib git hscript-improved https://github.com/FNF-CNE-Devs/hscript-improved.git diff --git a/setup/windows.bat b/setup/windows.bat index 84a3df4..93c33cd 100644 --- a/setup/windows.bat +++ b/setup/windows.bat @@ -17,9 +17,9 @@ haxelib set lime 8.2.2 haxelib set openfl 9.4.1 haxelib git flxanimate https://github.com/Dot-Stuff/flxanimate 768740a56b26aa0c072720e0d1236b94afe68e3e haxelib git linc_luajit https://github.com/superpowers04/linc_luajit 1906c4a96f6bb6df66562b3f24c62f4c5bba14a7 -haxelib git funkin.vis https://github.com/FunkinCrew/funkVis 22b1ce089dd924f15cdc4632397ef3504d464e90 +haxelib git funkin.vis https://github.com/FunkinCrew/funkVis haxelib git grig.audio https://gitlab.com/haxe-grig/grig.audio.git cbf91e2180fd2e374924fe74844086aab7891666 -haxelib git away3d https://github.com/CodenameCrew/away3d +haxelib git away3d https://github.com/CodenameCrew/away3d.git haxelib install tink_core haxelib install tink_await haxelib git hscript-improved https://github.com/FNF-CNE-Devs/hscript-improved.git diff --git a/source/EngineConfig.hx b/source/EngineConfig.hx index ecfd0c4..a05f9de 100644 --- a/source/EngineConfig.hx +++ b/source/EngineConfig.hx @@ -11,6 +11,7 @@ class EngineConfig { public static inline final ENGINR_NAME:String = "HyperCode"; public static inline final VERSION:String = "Indev 30042025"; + public static inline final THISTESTBUILD:BOOL = true; public static inline final ENGINE_URL:String = "https://github.com/Paopun20/FNF-HyperCode-Engine"; public static inline final GITVERSION:String = "https://raw.githubusercontent.com/Paopun20/FNF-HyperCode-Engine/main/gitVersion.txt"; diff --git a/source/Manager3D/Manager3D.hx b/source/Manager3D/Manager3D.hx deleted file mode 100644 index 40f6154..0000000 --- a/source/Manager3D/Manager3D.hx +++ /dev/null @@ -1,203 +0,0 @@ -package manager3D; - -import away3d.containers.View3D; -import flixel.FlxG; -import openfl.display.DisplayObject; -import away3d.entities.Mesh; -import away3d.events.Asset3DEvent; -import openfl.geom.Vector3D; -import openfl.display.BitmapData; -import away3d.textures.BitmapTexture; -import flx3d.Flx3DCamera; -import away3d.materials.TextureMaterial; -import manager3D.util.RaycastHelper; -import manager3D.extensions.MeshExtension; -import openfl.Assets; -import away3d.library.assets.Asset3DType; - -class Manager3D { - public static var camera:Flx3DCamera; - public static var view:View3D; - public static var loadedModels:Map = new Map(); - - /** - * Initializes the 3D camera. - * - * @param x The x-coordinate of the camera. - * @param y The y-coordinate of the camera. - * @param width The width of the camera's viewport. - * @param height The height of the camera's viewport. - */ - public static function initCamera(x:Int = 0, y:Int = 0, width:Int = 0, height:Int = 0):Void { - if (camera != null) - return; - - if (width == 0) - width = FlxG.width; - if (height == 0) - height = FlxG.height; - camera = new Flx3DCamera(x, y, width, height); - FlxG.cameras.add(camera); - view = camera.view; - } - - /** - * Loads a 3D model from the specified asset path. - * - * @param assetPath The path to the 3D model file. - * @param callback The callback function to be executed when the model is loaded. - * @param texturePath (Optional) The path to the texture file or a FlxGraphic to apply to the model. - * @param smoothTexture (Optional) Whether to use smooth texture filtering (default: true). - */ - public static function loadModel(assetPath:String, callback:Asset3DEvent->Void, ?texturePath:Dynamic, smoothTexture:Bool = true):Void { - if (loadedModels.exists(assetPath)) { - // Model already loaded, call the callback with the existing model - var event:Asset3DEvent = new Asset3DEvent(Asset3DEvent.ASSET_COMPLETE, loadedModels.get(assetPath)); - callback(event); - return; - } - - if (camera == null) { - trace("Error: 3D camera not initialized. Call Manager3D.initCamera() first."); - return; - } - - // In Manager3D.hx, inside loadModel - camera.addModel(assetPath, function(event:Asset3DEvent) { - if (event.asset != null && (event.asset.assetType == Asset3DType.MESH || event.asset.assetType == Asset3DType.CONTAINER || event.asset.assetType == Asset3DType.GEOMETRY)) { - if (cast event.asset is Mesh) { - var mesh:Mesh = cast event.asset; - loadedModels.set(assetPath, mesh); - callback(event); - } else { - trace('Error: Asset is not a Mesh: $assetPath'); - } - } - - }, texturePath, smoothTexture); - } - - /** - * Adds a loaded 3D model to the scene. - * - * @param assetPath The path to the loaded 3D model. - * @param x The x-coordinate of the model. - * @param y The y-coordinate of the model. - * @param z The z-coordinate of the model. - */ - public static function addModelToScene(assetPath:String, x:Float = 0, y:Float = 0, z:Float = 0):Void { - if (camera == null) { - trace("Error: 3D camera not initialized. Call Manager3D.initCamera() first."); - return; - } - - if (!loadedModels.exists(assetPath)) { - trace("Error: Model not loaded: $assetPath. Call Manager3D.loadModel() first."); - return; - } - - var model:Mesh = loadedModels.get(assetPath); - if (model == null) return; - model.x = x; - model.y = y; - model.z = z; - view.scene.addChild(model); - } - - /** - * Removes a model from the scene. - * @param assetPath The path to the loaded 3D model. - */ - public static function removeModelFromScene(assetPath:String):Void { - if (view == null) { - trace("Error: 3D camera not initialized. Call Manager3D.initCamera() first."); - return; - } - - if (!loadedModels.exists(assetPath)) { - trace("Error: Model not loaded: $assetPath."); - return; - } - - var model:Mesh = loadedModels.get(assetPath); - if (model == null) return; - view.scene.removeChild(cast model); - } - - /** - * Removes all models from the scene and clears the loaded models map. - */ - public static function clearScene():Void { - if (view == null) { - trace("Error: 3D camera not initialized. Call Manager3D.initCamera() first."); - return; - } - - for (model in loadedModels) { - if (view.scene.contains(model)) { - view.scene.removeChild(cast model); - } - } - loadedModels.clear(); - } - - /** - * Destroys the 3D camera and clears the scene. - */ - public static function destroy():Void { - clearScene(); - if (view != null) { - view.dispose(); - view = null; - } - loadedModels.clear(); - if (camera != null) { - FlxG.cameras.remove(camera); - camera = null; - } - } - - /** - * Helper function to apply a texture to a mesh. - * @param mesh The mesh to apply the texture to. - * @param texturePath The path to the texture. - */ - public static function applyTexture(mesh:Mesh, texturePath:String):Void { - if (texturePath != null && texturePath.length > 0) { - var texture = new BitmapTexture(Assets.getBitmapData(texturePath)); - mesh.material = new TextureMaterial(texture); - } else { - trace('Texture not found: $texturePath'); - } - } - - /** - * Move mesh in the scene by applying transformations. - * @param mesh The mesh to move. - * @param x The target X position. - * @param y The target Y position. - * @param z The target Z position. - */ - public static function moveMesh(mesh:Mesh, x:Float, y:Float, z:Float):Void { - MeshExtension.moveTo(mesh, x, y, z); - } - - /** - * Rotate mesh in the scene by applying a rotation. - * @param mesh The mesh to rotate. - * @param axis The axis of rotation ('x', 'y', 'z'). - * @param angle The angle of rotation in degrees. - */ - public static function rotateMesh(mesh:Mesh, axis:String, angle:Float):Void { - MeshExtension.rotateMesh(mesh, axis, angle); - } - - /** - * Change color of the mesh. - * @param mesh The mesh to change color. - * @param color The new color in hex format (e.g., 0xFF0000 for red). - */ - public static function changeMeshColor(mesh:Mesh, color:Int):Void { - MeshExtension.setColor(mesh, color); - } -} diff --git a/source/states/CustomStage.hx b/source/states/CustomStage.hx index 31e5874..8b3af11 100644 --- a/source/states/CustomStage.hx +++ b/source/states/CustomStage.hx @@ -159,20 +159,8 @@ class CustomStage extends MusicBeatState { tryCall(script, "onDestroy"); script.destroy(); } - hscriptArray = []; - } - - override function beatHit():Void { - super.beatHit(); - for (script in hscriptArray) { - tryCall(script, "onBeatHit"); - } - } - - override function stepHit():Void { - super.stepHit(); - for (script in hscriptArray) { - tryCall(script, "onStepHit"); - } + + while (array.length > 0) + hscriptArray.pop(); } } diff --git a/source/states/MainMenuState.hx b/source/states/MainMenuState.hx index 2a7d98d..8396d22 100644 --- a/source/states/MainMenuState.hx +++ b/source/states/MainMenuState.hx @@ -42,7 +42,6 @@ class MainMenuState extends MusicBeatState { super.create(); if (EngineConfig.IS_DEVELOPER) { - // optionShit.push('TEST'); optionShit.push('TEST2'); } @@ -98,7 +97,12 @@ class MainMenuState extends MusicBeatState rightItem.x -= rightItem.width; } - var psychVer:FlxText = new FlxText(12, FlxG.height - 44, 0, EngineConfig.ENGINR_NAME+" Engine v " + psychEngineVersion, 12); + var text:String = EngineConfig.ENGINR_NAME+" Engine v " + psychEngineVersion + if (EngineConfig.THISTESTBUILD) { + text = text + " [Early Access Edition] // This is Test Build, Please report any bugs!" + } + + var psychVer:FlxText = new FlxText(12, FlxG.height - 44, 0, text, 12); psychVer.scrollFactor.set(); psychVer.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); add(psychVer); @@ -120,10 +124,12 @@ class MainMenuState extends MusicBeatState #end #if CHECK_FOR_UPDATES - if (showOutdatedWarning && ClientPrefs.data.checkForUpdates && substates.OutdatedSubState.updateVersion != psychEngineVersion) { - persistentUpdate = false; - showOutdatedWarning = false; - openSubState(new substates.OutdatedSubState()); + if (EngineConfig.THISTESTBUILD) { + if (showOutdatedWarning && ClientPrefs.data.checkForUpdates && substates.OutdatedSubState.updateVersion != psychEngineVersion) { + persistentUpdate = false; + showOutdatedWarning = false; + openSubState(new substates.OutdatedSubState()); + } } #end @@ -325,8 +331,6 @@ class MainMenuState extends MusicBeatState PlayState.SONG.splashSkin = null; PlayState.stageUI = 'normal'; } - case 'TEST': - // MusicBeatState.switchState(new TestState()); case 'TEST2': MusicBeatState.switchCustomStage("testmenu"); case 'donate': diff --git a/source/states/TestState.hx b/source/states/TestState.hx deleted file mode 100644 index 767a8e6..0000000 --- a/source/states/TestState.hx +++ /dev/null @@ -1,35 +0,0 @@ -package states; - -import flixel.FlxG; -import flixel.FlxSprite; -import flixel.FlxState; -import flixel.util.FlxColor; -import manager3D.Manager3D; -import away3d.entities.Mesh; -import away3d.events.Asset3DEvent; -import backend.Paths; - -class TestState extends MusicBeatState { - override public function create() { - super.create(); - var text:FlxText = new FlxText(10, 10, 0, "Test State [3D TEST]", 32); - text.color = FlxColor.WHITE; - add(text); - - Manager3D.initCamera(); - Manager3D.loadModel(Paths.getSharedPath(Paths.obj("3DTEST")), onModelLoaded); - } - - function onModelLoaded(event:Asset3DEvent) { - var mesh:Mesh = cast event.asset; - Manager3D.addModelToScene(Paths.getSharedPath(Paths.obj("3DTEST")), 0, 0, 0); - Manager3D.moveMesh(mesh, 100, 0, 0); - Manager3D.rotateMesh(mesh, 'y', 45); - Manager3D.changeMeshColor(mesh, 0xFF0000); - } - - override public function update(elapsed:Float) { - super.update(elapsed); - - } -}