Announcement

Collapse
No announcement yet.

WorldSpawn official WIP thread

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • I think I have gotten rid of all the fluff at this point. Now I need to mess with fonts. I am a hair confused about fonts but, I wont be for long.

    straight out of gfx.wad 0x40 type



    if you wanted to see where I'm at....edit:my tabbing looks like it's all over the place but, it isn't in my editor.
    Code:
    public class WAD
    {
    	private static const MAX_PALETTE_COLORS:int = 256;
    	private static const MAX_NAME_LENGTH:int	= 16;
    	private static const QCHAR_WIDTH:int		= 16;
    	private static const QNUM_GLYPHS:int		= 256;
    	
    	public static function parse(data:ByteArray):Vector.<Object>
    	{
    		data.endian		= Endian.LITTLE_ENDIAN;
    		data.position	= 0;
    		
    		//check magic
    		if (data.readMultiByte(4, "iso-8859-1") != "WAD3") 
    			throw new Error("Invalid or unsupported WAD file");
    			
    		var cnt:int = data.readInt(); 
    		var ofs:int = data.readInt(); 
    		
    		//prime vectors
    		var directories:Vector.<Object> = new Vector.<Object>(cnt);
    		var images:Vector.<Object>		= new Vector.<Object>(cnt);
    		
    		//set pointer
    		data.position = ofs;
    		
    		//get all directories
    		directories.forEach( function(val:Object, n:int, self:Vector.<Object>):void 
    		{	self[n] = {
    				offset:		data.readInt(),
    				csize:		data.readInt(),
    				dsize:		data.readInt(),
    				type:		data.readByte(),
    				comp:		data.readBoolean(),
    				dummy:		data.readShort(),
    				name:		data.readMultiByte(MAX_NAME_LENGTH, "iso-8859-1")
    			}
    		});
    		
    		//reusable vars
    		var width:int, height:int, x:int, y:int;
    		var pixels:ByteArray 		= new ByteArray();
    		var indexes:ByteArray		= new ByteArray();
    		var palette:Vector.<uint>	= new Vector.<uint>(MAX_PALETTE_COLORS);
    		
    		//parse all images
    		directories.forEach( function(val:Object, n:int, self:Vector.<Object>):void 
    		{
    			data.position = self[n].offset;				//set pointer
    			
    			if(self[n].type == 0x40 || self[n].type == 0x43)
    					data.position += MAX_NAME_LENGTH;	//skip name
    			
    			//store dimaensions
    			width	= data.readInt();
    			height	= data.readInt();
    			
    			//FIXME: fill out this conditional - QFont
    			if (self[n].type == 0x46)
    			{ 	width = 256;
    			}
    			
    			if (self[n].type == 0x40 || self[n].type == 0x43)
    				data.position += 16;						//skip this nonsense - completely useless
    			
    			//segregate palette indexes for this image 
    			if (indexes.length > 0) indexes.clear();		//reset
    			data.readBytes(indexes, 0, width * height);
    			indexes.position = 0;							//prime pointer
    			
    			//skip mips for now
    			if (self[n].type == 0x40 || self[n].type == 0x43)
    			{	for (var s:int = 1; s < 4; ++s)
    					data.position += ((width >> s) * (height >> s));
    			}
    			
    			data.position += 2; 							//pad
    			
    			//get appropriate palette - FIXME: transparency
    			palette.forEach(function(val:uint, i:int, pal:Vector.<uint>):void {
    				if (self[n].type == 0x40)
    					pal[i] = (0xFF << 24 | i << 16 | i << 8 | i);
    				else
    					pal[i] = (0xFF << 24 | data.readUnsignedByte() << 16 | data.readUnsignedByte() << 8 | data.readUnsignedByte());;
    			});
    			
    			if (pixels.length > 0) pixels.clear();			//reset
    			
    			for (y = 0; y < height; ++y)					//pixels columns
    				for (x = 0; x < width; ++x)					//pixels rows
    					pixels.writeUnsignedInt( palette[ indexes.readUnsignedByte() ] );
    			
    			pixels.position = 0;							//set pointer at beginning
    			
    			images[n] = new Object();
    			images[n].name	= self[n].name;
    			images[n].mip	= new BitmapData(width, height, true);
    			images[n].mip.setPixels(images[n].mip.rect, pixels);
    			
    		});
    		
    		return images;
    	}
    }
    Last edited by MadGypsy; 06-03-2017, 09:46 PM.
    http://www.nextgenquake.com

    Comment


    • Everything has been parsed...all types. I will have a completed package for you tomorrow. I have to go to sleep so I'm not a grouchy dickface at work tomorrow.

      PS> my parser is super fast. please feel free to show it to the know-nothings that told you flash is too slow.

      0x46 - gfx.wad



      and 0x42 - cached.wad
      Last edited by MadGypsy; 06-03-2017, 10:14 PM.
      http://www.nextgenquake.com

      Comment


      • Oh yeah....transparency is done as well.


        also, pressing go on a stopwatch at the exact same time I hit build and pressing pause on the stopwatch as fast as I can react to the parse finishing I get 15.33 seconds for 3116 images (halflife.wad). The time is actually less. For one, the second I hit build is not the exact second that the player starts and for 2 I obviously have some extra decimal of time to react to it completing. It's probably more like 12 or 13 seconds. Maybe even a little less. I'd be real interested in the benchmark for another language like c+. I'm pretty damn confident that the difference would be negligible. Keep in mind, I am not just parsing data into "structs" I am turning all 3116 entries into finalized images. And that, my friend, is why we use vectors and draw bitmaps by dumping bytes into setPixels().
        Last edited by MadGypsy; 06-03-2017, 11:00 PM.
        http://www.nextgenquake.com

        Comment


        • Wow you're fast. I am bad snail. wooops. Becuase I tried to fix. Great job Thanks for explanation.

          // EDIT:
          I am surprised because your head is faster than my head. It is okay. We improve together until collision. I know you or other members said collision for AS3 is very hard.

          Your halflife loads AS3 wow. Great work!
          Do you like Quake and Half-Life are together into own engine? It looks like Xash3D ( Xash XT ).

          1. If we prepare parse for BSP

          2. Parse whole wad, spr, tga for skypbox of Half-Life like cl_skyname

          3. models mdl3, mdl1 ( Half-Life model )

          4. Parse entitys like func_door, func_break or etc...

          5. Write whole function or implements like own engine works 100 %

          6 Test game engine

          7 Prepare custom map editor like Trendroom, Radiant or JackHammer, Valve Hammer Editor. I think we use Feathers Components for AS3.
          If we use Haxe than HaxeUI.

          Iam not lazy - I am just preparing and I want buy Steam Greenlight - If we are finish with air captive or haxe project. Or not yet?

          Thanks!
          Last edited by SourceSkyBoxer; 06-04-2017, 05:46 AM.

          Comment


          • Slow down there, brother. As I said in an earlier post I'm not looking for a partner in my engine. My engine is not a quake engine and it's definitely not going to be a half life one. My engine is a tech thief with a major twist. Also, I see that you have some skills and with some more experience you will be a very good programmer but, you still have much to learn. I am going to help you learn but, you are going to build your engine. I'm not going to let you hit a wall and never overcome it but, you need to struggle and fight a bit to get really good.

            My steps tonight after work will be to round all this off so you have a stripped down version of my content manager to add to so you have a solid base to work from and the wad3 parser will act as an example of how to use the content manager. This will be a really good head start for you.

            Once you have that core I would suggest learning how to parse a bsp and injecting the parser into the content manager. It is hard to parse a bsp your first time and it will be a good exercise for you. I know you can do it. I would highly suggest that you find a bsp parser script for half life maps and port it. It will probably be in some language you don't know and that's perfect. Do not bother to learn that language. Instead, use your programming knowledge to simply understand it. Use common sense and observation to understand it. You shouldn't need to look at any docs for that language because arrays are arrays, functions are functions etc.. and the only thing that is ever different is syntax. Syntax should never be a hurdle.

            As3 (and like 5000 other languages)
            for(i = 0; i < something; ++i)

            HaXe
            for(i in 0...something)

            learn to immediately recognize that stuff like this is the exact same thing.

            @my head faster than yours

            I have been eat,shit,sleep,breathe&shaving code for longer than you have been alive. I say this because your dad told you to turn off your computer and my programming knowledge is almost old enough to drink alcohol. If you want to know where it all began... I copied my first program out of a magazine on basically the first home computer ever invented roughly 36 years ago, but I cannot say I have been programming that long. There was a sizable gap in there where I didn't program at all. However, I have been programming in flash scripts (AS1,2&3) since it was invented and flash was released so close to quake release they are practically twins.
            Last edited by MadGypsy; 06-04-2017, 07:37 AM.
            http://www.nextgenquake.com

            Comment


            • Thanks for explanation. I understand now. like you said
              Thanks for example bytearray -> bitmapdata -> bitmap.
              Code:
              package;
              
              import openfl.display.*;
              import openfl.utils.*;
              import openfl.Lib;
              
              /**
               * ...
               * @author Jens Eckervogt
               */
              class Main extends Sprite
              {
              	static function main():Void {
              		Lib.current.stage.color = 0xFFFF8800;
              		
                      var byte:ByteArray = new ByteArray();
              		byte.endian = Endian.LITTLE_ENDIAN;
              		byte.writeUnsignedInt(0xFF000000);
              		byte.writeUnsignedInt(0xFFFFFFFF);
              		
              		var bmd:BitmapData = new BitmapData(2, 1, true);
              		byte.position = 0;
              		bmd.setPixels(bmd.rect, byte);
              		
              		var bm:Bitmap = new Bitmap(bmd);
              		bm.x = bm.y = 10;
              		bm.scaleX = bm.scaleY = 100;
              		Lib.current.addChild(bm);
                  }
              	
              	public function new()
              	{
              		super();
              	}
              }
              For Haxe and
              Code:
              package
              {
              	import flash.display.Bitmap;
              	import flash.display.BitmapData;
              	import flash.display.Sprite;
              	import flash.utils.ByteArray;
              	import flash.utils.Endian;
              	
              	public class WadView extends Sprite
              	{		
              		public function WadView()
              		{
              			stage.color = 0xFFFF8800;
              			
              			var someBa:ByteArray = new ByteArray();
              			someBa.endian = Endian.LITTLE_ENDIAN;
              			someBa.writeUnsignedInt(0xff000000);
              			someBa.writeUnsignedInt(0xffffffff);
              			
              			var bmd:BitmapData = new BitmapData(2, 1, true);
              			someBa.position = 0;
              			bmd.setPixels(bmd.rect, someBa);
              			
              			var bm:Bitmap = new Bitmap();
              			bm.bitmapData = bmd;
              			bm.x = bm.y = 10;
              			bm.scaleX = bm.scaleY = 100;
              			addChild(bm);
              		}
              	}
              }
              For AS3
              That is easy to show how does it work? I think getBitmapData(byName):BitmnapData without Loader.
              But it looks shit because Haxe doesn't output because black Color is like mask-colour.

              Top is Haxe and Bottom is Flash Player 25

              Wow it looks easy. I understand now.

              // I am sorry I supervisor about AMF or just boxed Object like obj(byName)., Thanks
              Thanks I will continue now. Thanks for help.. I will test my work. Don't worry me!
              Last edited by SourceSkyBoxer; 06-04-2017, 09:35 AM.

              Comment


              • You know I want get - like your code shows only 2 Colors black and white
                Now I want load picture into ByteArray like your ContenTManager

                IMG is Vector.<ByteArray> and img is Object.
                I try without external class just I check simple like Main.as

                But it doesn't show loaded image. How do you get string in object than in bytearray?

                Code:
                package
                {
                	import flash.display.Bitmap;
                	import flash.display.BitmapData;
                	import flash.display.Sprite;
                	import flash.display.StageAlign;
                	import flash.display.StageScaleMode;
                	import flash.utils.ByteArray;
                	import flash.utils.Endian;
                	
                	public class Main extends Sprite
                	{		
                		public function Main()
                		{
                			stage.color = 0xFFFF8800;
                			stage.align = StageAlign.TOP_LEFT;
                			stage.scaleMode = StageScaleMode.NO_SCALE;
                			
                			var someBa:ByteArray = new ByteArray();
                			someBa.endian = Endian.LITTLE_ENDIAN;
                			
                			var img:Object = {};
                			var IMGB:Vector.<ByteArray> = new Vector.<ByteArray>();
                			var imageName:String = "quad256.jpg";
                			
                			if(img[imageName] != undefined)
                			{
                				someBa = IMGB[img[imageName]];
                				someBa.position = 0;
                			}
                			
                			//someBa.writeUnsignedInt(0xff000000);
                			//someBa.writeUnsignedInt(0xffffffff);
                			var bmd:BitmapData = new BitmapData(256, 256, false);
                			bmd.setPixels(bmd.rect, someBa);
                			
                			var bm:Bitmap = new Bitmap();
                			bm.bitmapData = bmd;
                			bm.x = bm.y = 10;
                			bm.scaleX = bm.scaleY = 100;
                			addChild(bm);
                		}
                	}
                }
                And I open Flash Player and it doesn't show image.
                How do I get loaded images like textures... It is hard to understand for me. Sorry

                Comment


                • I'm at work and have limited seconds to respond so, this answer might not be much help.

                  For flash use {Bitmap(ev.target.content).bitmapData}
                  For HaXe either do the same thing but use {(cast (ev.target.content, Bitmap)).bitmapData} or parse images to 32bit color values and dump them in setPixels().

                  It seems like you are trying to do 2 different ways at once. Pick one. Obviously casting the loader content is easiest because you don't have to write a custom parser but, you will be limited to jpg, png & gif(first frame). However, you could just use the .bitmapData way for those types and only write parser for stuff like .tga. I believe format has a .tga parser but you would obviously be stuck with HaXe if you used it. Maybe you should put down the code and write out on paper what your goals are. Then simply go down the list and knock them out. This will give you time to consider what is truly important and that info will probably help you determine what language you want to use.

                  For me, the goal was always to parse everything so, it didn't matter what language I used because I could always port it to whatever language I want. I do not recommend this approach. There is no real point in it unless you just want to waste a bunch of time. Parsing is my thing. I am very good at it (given the proper specs). I have a passion for it and I consider every parser time we'll spent. This however is a terrible way to go if your goal is to build something that just needs parsed results and a parser already exists.

                  @img is Object and IMG is Vector

                  I cheat.

                  img = {
                  somename:0
                  }

                  IMG[0] = somenameBitmapData

                  var bmd:BitmapData = IMG[img.somename];

                  Faster than a Dictionary.

                  Why you may ask? Simple. Consider

                  for(name in img)

                  If that was a dictionary you would be lugging through God only knows how many BitmapDatas. My way you are flying through indexes but you get the bonus of the most important thing....the name.
                  Last edited by MadGypsy; 06-04-2017, 01:54 PM.
                  http://www.nextgenquake.com

                  Comment


                  • Hello I am devastated.

                    I don't understand how do you get success with stupid Content.as? I am very far and cannot get like you are happy and me is really unhappy. Because I cannot get success like you have written many static methods and variables?

                    Are you sure if you have to write UrlStream and Zip, ZipFile and ZipLibrary because I have painful headache if I try and try try try ... I am always unsuccessful. please tell me easy!
                    I already tried get bitmapdata static method it was from ZipFile.getBitmapData () but it cannot load - but loader need add to stage how do you get without loader?
                    Loaderinfo or UrlStream?

                    Stop to take advantage since 2 days I can not get Content.as

                    You mean I need to write like your work.
                    AFile.as and EventManager.as?

                    Thanks my god because I have headache because I write and try and got problem with non-loading. I feel very devastated. I am sorry for fighting....

                    Comment


                    • Let's handle one thing at a time.

                      First off I did everything I said I was going to do in my other post regarding setting you up with a stripped down content manager and my completed wad3 parser. You can download the entire project here. The zip parser was stripped out of that package but, using my other code you can add it back in easy enough. I made some other modifications to the content manager which are very subtle but remove dependencies on other scripts that the version you have possesses.

                      @Content.as

                      I told you from the beginning to use my code. You keep attempting to basically port my code to the very language it was written in with some delusion that you are going to write ?better code than me?. How is that working out for you? Those classes in the file directory define every possibility of the URLLoader and Loader. It is so complete that it even includes URLLoaderDataFormat.VARIABLES and you will more than likely never use that in your entire life for anything. AFile is the meat and potatoes of file format decisions where all the other files in that folder extend AFile, set the format in the constructor and define individual get methods that return the data as the respective proper type. So, in short, yes you have to do it like I did it which is exactly why I did it that way. My method brushes all the headaches away because you don't have to know or care about anything. You call Importer and it makes all the decisions for you...it is never wrong...never. The entire point is to separate you from having to worry about all the what, when, where and whys of loading files and simply dump in a path. Why are you trying to rewrite this? Why are you wasting time managing events and trying to figure everything out when my script already does all of that. I know this may be a big surprise or something but, my content manager....manages content. I know I'm being edgy but, I'm trying to smack you around a bit and get you to use your head and stop wasting time. I've ported your entire wad parser from a language I don't even know and you can't even get a zip file to work out of already completely functional code, written in a language that it seems like you have some grasp of. That ain't pro, brother.

                      @I'm very happy

                      Of course. I focused on one goal and I used my head to accomplish it. I first tried specs but, they were either incomplete or incorrect and that method failed. I spent zero time toiling over what wasn't working. I switched to a new method and found an already working script. It wasn't in AS3 so I ported it line for line. I tested it and it worked. I then went back and stripped the script of all the chicken scratch and commented the shit out of it. None of my time was spent focused on things that are unnecessary and in that I accomplished all of my goals.

                      @Are you sure if you have to write UrlStream and Zip

                      I am sure of everything in my code cause, as you already know, all of it works. You stripped that code from a working app remember?
                      Last edited by MadGypsy; 06-05-2017, 01:43 AM.
                      http://www.nextgenquake.com

                      Comment


                      • Oh my god, your source looks like rocking Magic without UrlStream and loader. I am shy because your EventManager sucks. But I don't know method of you. I knew already easy like with UrlStream, urlloader or netconect now your hard method of implementing.

                        Thank for explanation and I am shy because I don't know other method of objects and vectors via advanced event manager. Yeah I am working since AS1 to 2 with easy method implementation like example
                        Class need define variables than class has to implement methods. Of course for me is not advanced version.

                        Now my head is calmed down. I will take rest today because it is whit-monday.
                        Enjoy your whit holiday!

                        Comment


                        • So let me get this straight...my Event manager sucks because you don't understand it? ...And you want to use NetConnect and URLStream to load a local binary file?

                          Well the latter is definitely possible but, that's sort of like using an elephant gun to kill a roach. I think I'm starting to understand why you can't get any of your ideas to work. You're a copy/paste programmer with no real foundation. I'm not shy. You said it all in your post, you have an easy method but, you don't seem to understand what your easy method is intended for. Next thing you'll be telling me you need to open a Socket to load a file sitting in the same folder as the .swf. You amaze me. You go from seeming green to blowing me away to being completely oblivious. It's all rounding off to form a picture of someone that's all over the place. Study.

                          The fact that you do not understand that the EventsManager simply adds and removes events is super discouraging to me. Especially since the methods are even named addListeners and dropListeners. The second argument is named events and is of type Array(Vector..practically same shit). the guts are a loop on that array. If the events Array is null it uses the events array that is defined at the top of the class. This is like first grade stuff, bro. The events Array at the top of the class contains COMPLETE, PROGRESS and IOERROR otherwise known as the 3 most obvious events for loading any file. My class doesn't suck. It is so universal that it could be reused for anything you could ever do that requires adding an event OF ANY KIND. You could even reuse it for custom events and targets of ANY type. So, I write a class that removes all the cumbersome and verbose bullshit of applying any events to any target, label everything exactly what it is...ie this may be the most obvious class I have ever written...and you are completely lost in space over it. I would be shy to admit that.

                          For the record...I'm not mad at you at all. I'm discouraged as hell though. If I'm being a jerk, it's because I actually believe in you and these issues seem like complete nonsense to me, beneath you. I would bet that anyone that has ever followed me, programmer or not, could decipher this,

                          Code:
                          	public class EventManager extends EventDispatcher
                          	{
                          		private var _events:Vector.<String>;
                          		
                          		public function EventManager():void {	
                          			super();
                          			
                          			//default: events you would expect when using an URLLoader (load external files)
                          			_events = new <String>[Event.COMPLETE, ProgressEvent.PROGRESS, IOErrorEvent.IO_ERROR];
                          		}
                          		
                          		/** ADD_LISTENERS
                          		* 		add all events to an object with a loop
                          		* @param	target: the object in which to add the listeners to
                          		*/
                          		protected function addListeners(target:*, evts:Vector.<String> = null):void
                          		{	_events = (evts == null)? _events : evts;
                          			_events.forEach(function(value:String, n:int, self:Vector.<String>):void {
                          				if(! target.hasEventListener(value) )
                          					target.addEventListener(value, event_handler);
                          			});
                          		}
                          		
                          		/** DROP_LISTENERS
                          		* 		remove all events from an object with a loop
                          		* @param	target: the object in which to remove the listeners from
                          		*/
                          		protected function dropListeners(target:*, evts:Vector.<String> = null):void
                          		{	_events = (evts == null)? _events : evts;
                          			_events.forEach(function(value:String, n:int, self:Vector.<String>):void {
                          				if( target.hasEventListener(value) )
                          					target.removeEventListener(value, event_handler);
                          			});
                          		}
                          		
                          		/** EVENT_HANDLER
                          		* 		Handle drop listeners for any event which is not a PROGRESS event. Dispatch any event.
                          		* @param	event: the current event being processed
                          		*/
                          		protected function event_handler(generic_event:Event):void
                          		{
                          			if (generic_event.type != ProgressEvent.PROGRESS)
                          				dropListeners(generic_event.target);
                          				
                          			dispatchEvent(generic_event.clone());
                          		}
                          		
                          		/** SET_EVENTS
                          		* 
                          		* @param	evts	- the events to assign during the add/removeListeners processes
                          		*/
                          		protected function set events(evts:Vector.<String>):void
                          		{	_events = evts;
                          		}
                          		
                          		/** GET_EVENTS
                          		* 
                          		* @return	current _events array
                          		*/
                          		protected function get events():Vector.<String>
                          		{	return _events;
                          		}
                          	}
                          }
                          Are you confused about the dispatchEvent line? This class is extended by the Importer. The importer overrides this function makes a bunch of decisions and then calls super version to do the generic proper thing. Your main script that calls the Importer has to listen to the completion of the Importer so the dispatcher simply bubbles the event back to the main so it can make decisions based on the completion of the Importer. We do it this way so EventManager can stay neutral about how to process the event and do only it's one job of making sure that listeners are attached and removed from the target. In other words, EventsManager is like a slave. It keeps moving big blocks from the quarry but it has no clue what you are building. The reason why all listeners except the Progress event are removed is pretty obvious. If it's a progress event it isn't finished. We need to monitor more progress and removing that listener (and consequentially all other listeners) would crash the operation. generic_event is of type Event because ALL events extend Event (ProgressEvent, IOErrorEvent, and any other event built into flash). So, (ex) ProgressEvent is of type Event at it's core. It's a way to handle multiple event types while maintaining strict typing.
                          Last edited by MadGypsy; 06-05-2017, 11:43 AM.
                          http://www.nextgenquake.com

                          Comment


                          • Hello I have found downloaded zip with io/events/EventManager.as
                            I didn't say copy past just I check how does it work?
                            For FlashDevelop has no problem with successful compile. I have bought Half-life under Steam I have copied wad to your downloaded zip and I try you project and I have seen. I have fixed switch case statement into if statement because EventManager loads with frozen bytearray faster. At my computer is 4,5 seconds.

                            You know PaperQuake2 is very faster because it hasn't stage3D since I tried to load with Half-life and my very old computer was happened since it got voice like fireworks and I cannot get my hard disk since November 2010 or 2011. I don't remember and I lost my ideas. I am sad because I try my idea back but my head was empty like I forget. That is why I am very sorry for that. I will write idea my project and I am very busy from 2010 to December 2016 from my education, my work for disabled people than I work at company. Now I have not work. Now I want write AS3 as Half-life with Away3d 4.1.6 and I supervisor and try and fix. Since I forget to say about easy method like many separated AS3 files and it is slows and I read good performance from Adobe Help. I know like var float:Vector <int>;
                            Etc...

                            I swear that. I am slowly writer oooppss. I can not write faster if I supervisor than I write slow and check. That is why it is my reason.

                            Thanks for understanding

                            // Yeah I am near to write bsp30 I saw example from bsp29 and bsp, Bsp file
                            But I saw bsp29 header2lumps (data:ByteArray) and I write just headerLumps (lumpBa:ByteArray) and I saw why do you write double temp = null; please check your project WorldspwanBSP?

                            If you write double variables just I write own variable. But Half-life and Quake are very close same. But getTexture (byName):ByteArray is not for Half-life just I write other method if I am finish to write than I will show you.

                            So far I know collision just "CLIP" texture is like "plane collision". For Quake has same clip texture like Half-life.
                            Last edited by SourceSkyBoxer; 06-05-2017, 04:52 PM.

                            Comment


                            • Javascript implementation of halflife collision detection

                              @switch slower than if

                              Well, I would have said you were wrong considering jump tables but, I just researched it and you are correct. It's because AS3 switches allow non-integer types. Looks like I have a bunch of code to fix.

                              @double temp = null

                              I can't find that anywhere in my script. What class...what line? Chances are it was just a typo that doesn't exist in my code cause the version of code you have is sloppy and old. As a matter of fact, the BSP parser you are reading is probably junk. You got that version from my "real flash quake" thread. I wouldn't use anything in that version. Almost all of that code is a slop of trying to figure it all out and it wouldn't surprise me if there was lots of stuff wrong with it. Almost ALL of that code was written with the aim to just get it to work. I didn't bother writing clean code. The next version addressed a lot of the slop.

                              Actually, you got me playing with AS3 again and I have spent a lot of today reformatting the entire engine to more closely match the Haxe version. I'll probably build them in tandem from this point. I love Haxe but AS3 is like an old girlfriend. There really isn't any reason why I can't do both. Anything I write in Haxe can be ported to flash with practically no effort.
                              Last edited by MadGypsy; 06-05-2017, 07:57 PM.
                              http://www.nextgenquake.com

                              Comment


                              • switch replacement slim version - I really hate long if chains. I hate super long arguments even more. There is no way in hell I was about to
                                if(_extension == "png" || _extension == "jpeg" || _extension == "jpg" || _extension == "gif") ...
                                else if (_extension == "txt" || _extension == "json" || _extension == "xml") ...

                                Code:
                                removed due to the next paragraph
                                woops forgot to replace the event handler switch. Actually you don't need a switch there in the first place. The second 2 cases were included just in case I decided to make some decisions there later...it's later and I never used it. Since the event manager switch doesn't need the second 2 cases, importing ProgressEvent and IOErrorEvent is unnecessary as well.

                                With a bullshit stopwatch benchmark done the same way as my last I shaved 3 seconds off of the parse. That's fucking substantial. Good job on the if vs switch info.

                                after everything I just said here is the actual slim version
                                Code:
                                package 
                                {
                                	/**
                                	* Importer
                                	* @version	x.1
                                	* @author	OneMadGypsy
                                	* 
                                	* Redistribution and use in source and binary forms, with or without
                                	* modification, are permitted provided that the following conditions are met:
                                	*
                                	*   - Redistributions of source code must retain this list of conditions 
                                	* 	   and the following disclaimer.
                                	* 
                                	* THIS SOFTWARE IS PROVIDED BY ONEMADGYPSY "AS IS" AND ANY
                                	* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                                	* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
                                	* DISCLAIMED. IN NO EVENT SHALL THE ONEMADGYPSY BE LIABLE FOR
                                	* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                                	* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                                	* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
                                	* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                                	* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                                	* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
                                	* DAMAGE.
                                	*/
                                	
                                	import file.*;
                                	
                                	import flash.utils.ByteArray;
                                	import flash.events.Event;
                                	
                                	public class Importer extends Lib
                                	{	
                                		protected static var _file:AFile;
                                		protected static var _fullpath:String;
                                		protected static var _filename:String;
                                		protected static var _extension:String;
                                		protected static var _callback:Function;
                                		
                                		protected static var img_re:RegExp = new RegExp("png|jpg|gif|jpeg", "i");
                                		protected static var txt_re:RegExp = new RegExp("txt|json|xml", "i");
                                		protected static var bin_re:RegExp = new RegExp("wad|bsp", "i");
                                		
                                		/**	CLASS_CONSTRUCTOR
                                		 * 		simple pass-along arguments to trigger load from instantiation
                                		 * @param	path	path to the file
                                		 * @param	cb		callback function
                                		 */
                                		public function Importer(path:String = null, cb:Function = null):void
                                		{	super();
                                			if ((path != null) && (cb != null)) load(path, cb);
                                		}
                                		
                                		/** TRIGGER_FILE_LOAD
                                		 * @param	path	path to the file
                                		 * @param	cb		callback function
                                		 */
                                		public function load(path:String, cb:Function):void
                                		{	_fullpath	= path;
                                			_callback	= cb;
                                			
                                			var fname:Array = ( path.split("/").pop() ).split(".");
                                			
                                			_extension		= ( fname.pop() ).toLowerCase();	
                                			_filename		= ( fname.pop() ).toLowerCase();
                                			
                                			if (_extension.match(img_re))
                                				_file = new ImageFile();
                                			else if (_extension.match(txt_re))
                                				_file = new TextFile();
                                			else if (_extension.match(bin_re))
                                				_file = new BinaryFile();
                                			else 
                                				throw new Error("Unrecognized file type " + _extension);
                                				
                                			addListeners(_file);
                                			_file.load(_fullpath, _extension);
                                		}
                                		
                                		/**	HANDLE_LOAD_EVENTS
                                		 * @param	event	current load event
                                		 */
                                		protected override function event_handler(event:Event):void
                                		{	
                                			if(event.type == Event.COMPLETE)
                                			{	file_handler(_filename, _extension, event.target);
                                				_callback.call(this, event);
                                			}
                                			
                                			super.event_handler(event);
                                		}
                                		
                                		/** MANAGE_FILE_BY_EXTENSION
                                		 * @param	fname	filename
                                		 * @param	ext		extension
                                		 * @param	target	load target
                                		 */
                                		private function file_handler(fname:String, ext:String, target:*):void
                                		{	
                                			
                                			if (_extension.match(img_re))
                                			{	img[fname] = IMG.length;
                                				IMG.push(target.data);
                                			} else if (_extension == "txt") {
                                				txt[fname] = TXT.length;
                                				TXT.push(target.data);
                                			} else if (_extension == "json") {
                                				jso[fname] = JSO.length;
                                				JSO.push(JSON.parse(target.data));
                                			} else if (_extension == "xml") {
                                				mku[fname] = MKU.length;
                                				MKU.push(new XML(target.data));
                                			} else if (_extension == "wad") {
                                				wad3[fname] = WAD3.length;
                                				WAD3.push(target.data);
                                			}
                                		}
                                	}
                                }
                                Last edited by MadGypsy; 06-05-2017, 08:40 PM.
                                http://www.nextgenquake.com

                                Comment

                                Working...
                                X