Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

New ships under development

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: New ships under developemnt

Post by Smivs »

Shipbuilder wrote:
I do intend changing to OpenStep but have a few ships that I have already produced using XML script which I am tweaking and I wasn't too keen on rewriting them. That said future oxp ships, (other than the ones at the start of this thread) will be based on OpenStep.
:D fair enough. converting them will be a fair bit of work I guess. I think you'll find OpenStep much easier (and quicker and half as long :) ) once you start.
Shipbuilder wrote:
One thing that I was going to do for my own purposes, in order to get my head around OpenStep, was to produce template shipdata and shipyard scripts that I would use as a starting point for future ship oxps.
Why not just use Oolite's own plists as templates? They are already in OpenStep, and there is almost certainly something similar to what you are making in the core ship set, reducing the amount of editing needed.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5526
Joined: Thu Jun 12, 2008 6:55 pm

Re: New ships under developemnt

Post by Thargoid »

Going from XML to openStep isn't as bad as you may fear, given careful and planned use of search and replace functionality in your editor of choice. That followed by a bit of a tidy-up can usually be done reasonably quickly.

Or else I think there are some programs (mainly on Mac iirc) which do it at the touch of a button. Someone on a suitable system may be able to confirm and perhaps even assist on that.
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: New ships under developemnt

Post by Capt. Murphy »

There's a python script to convert XML to openStep found [EliteWiki] here. I've used it a couple of times and it's very good.
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
Shipbuilder
---- E L I T E ----
---- E L I T E ----
Posts: 877
Joined: Thu May 10, 2012 9:41 pm
Location: Derby

Re: New ships under developemnt

Post by Shipbuilder »

Thanks Capt Murphy I'll take a look and give it a go. :)
The GalTech Industries Corporation - Building ships to populate the galaxies.

Increase the variety of ships within your Ooniverse by downloading my OXPs

Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"
User avatar
Shipbuilder
---- E L I T E ----
---- E L I T E ----
Posts: 877
Joined: Thu May 10, 2012 9:41 pm
Location: Derby

Re: New ships under developemnt

Post by Shipbuilder »

Thargoid wrote:
Scale is something of a matter of personal taste. A few of us put together an OXP of liners (unsurprisingly called Liners.oxp), which some people loved and some disliked, both due at least in part to the scale of them (some of them are huge, like my Emerald). And given the somewhat elastic nature of Oolite's rule(r) anyway (consider how many Cobbie's would actually fit in the volume of a Coriolis, compared to the stated capacities of both, and ditto for ships and cargo pods) then I'd say go with whatever looks and feels right to you.

As for bigShips - just include the role "bigTrader" (with a weighting if you wish) in the roles list, and optionally use the AI packed in the OXP. Then put in the readme that your OXP requires bigShips to be installed, and you're good to go.
Thargoid - Can I just check that I have understood what I need to do to get the Constitution Class Heavy Cruiser to use the bigShips script (I have specified 2 versions in the script - A military version and a hunter version).

I have specified the bigShip AI using the following code for both versions

Code: Select all

		<key>ai_type</key>
		<string>bigShips_route1BigTraderAI.plist</string>
I have then added a reference to the bigTrader role for the military version using the following code i.e. I assume that I need to list both military and bigTrader as the roles.

Code: Select all

		<key>roles</key>
		<string>military bigTrader</string>
		<key>scan_class</key>
		<string>CLASS_MILITARY</string>
And for the hunter version I assume that I need to list both hunter and bigTrader as the roles.

Code: Select all

		<key>roles</key>
		<string>hunter bigTrader</string>
		<key>scan_class</key>
		<string>CLASS_NEUTRAL</string>
I have attached the full code below incase you need it.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">



<dict>
	<key>constitutionclassheavycruiser-military</key>
	<dict>	
		<key>aft_eject_position</key>
		<string>0.0 0.0 -1.0</string>
		<key>ai_type</key>
		<string>bigShips_route1BigTraderAI.plist</string>
		<key>cargo_carried</key>
		<string>Computers</string>
		<key>energy_recharge_rate</key>
		<real>7.5</real>

		<key>subentities</key>
		<array>
			<string>*FLASHER* 0 -19.2 38 175 0 1 16</string>
			<string>*FLASHER* 0.25 13.5 142.5 50 0.5 1 1.0</string>
			<string>*FLASHER* 1.5 5.0 66.8 50 0 1 1.0</string>
			<string>*FLASHER* 0 5.0 66.8 50 0 1 1.0</string>
			<string>*FLASHER* -1.5 5.0 66.8 50 0 1 1.0</string>
			<string>*FLASHER* 43.7 31.7 -145.7 50 3 1 3.0</string>
			<string>*FLASHER* -43.7 31.7 -145.7 50 3 1 3.0</string>
			<string>*FLASHER* 0 5.6 90.2 50 0 1 1</string>
			<string>*FLASHER* 0.8 30.5 80.4 50 0 1 1.0</string>
			<string>*FLASHER* 0 30.5 81.6 50 0 1 1.0</string>
			<string>*FLASHER* -0.8 30.5 81.4 50 0 1 1.0</string>	
			<string>*FLASHER* 6.2 18.8 5.5 360 0 1 5.0</string>
			<string>*FLASHER* -6.2 18.8 5.5 360 0 1 5.0</string>
			<string>*FLASHER* 0.0 22.0 27.5 175 0 1 8.0</string>
			<string>*FLASHER* 0.0 32.4 77.3 50 0.5 1 3.0</string>
			<string>*FLASHER* -43.0 32.7 -28.5 175 0 1 4.5</string>
			<string>*FLASHER* 43.0 32.7 -28.5 175 0 1 4.5</string>
			<string>*FLASHER* 4.5 18.8 5.5 360 0 1 5.0</string>
			<string>*FLASHER* -4.5.0 18.8 5.5 360 0 1 5.0</string>
			<string>*FLASHER* -2.5 -3.1 30.8 30 0 1 2.0</string>
			<string>*FLASHER* 2.5 -3.1 30.8 30 0 1 2.0</string>		
		</array>

		<key>forward_weapon_type</key>
		<string>WEAPON_MILITARY_LASER</string>
		<key>rear_weapon_type</key>
		<string>WEAPON_MILITARY_LASER</string>		
		<key>has_ecm</key>
		<real>1.0</real>
		<key>has_shield_booster</key>
		<real>1.0</real>
		<key>has_fuel_injection</key>
		<real>1.0</real>
		<key>has_shield_enhancer</key>
		<real>1.0</real>		
		<key>has_energy_unit</key>
		<real>1.0</real>		
		<key>has_escape_pod</key>
		<string>6.0</string>
		<key>has_scoop</key>
		<string>1.0</string>
		<key>laser_color</key>
		<string>redColor</string>
		<key>likely_cargo</key>
		<integer>6</integer>
		<key>max_cargo</key>
		<string>50</string>
		<key>max_energy</key>
		<real>1200</real>
		<key>max_flight_pitch</key>
		<real>1.1</real>
		<key>max_flight_roll</key>
		<real>1.1</real>
		<key>max_flight_speed</key>
		<real>550</real>
		<key>max_missiles</key>
		<integer>16</integer>
		<key>missile_load_time</key>
		<integer>5</integer>
		<key>missile_launch_position</key>
		<string>0.0 -11 0</string>
		<key>missile_roles</key>
		<string>EQ_HARDENED_MISSILE</string>
		<key>missiles</key>
		<integer>16</integer>
		<key>model</key>
		<string>constitutionclassheavycruiser.dat</string>
		<key>name</key>
		<string>Constitution Class Heavy Cruiser</string>
		<key>roles</key>
		<string>military bigTrader</string>
		<key>scan_class</key>
		<string>CLASS_MILITARY</string>
		<key>thrust</key>
		<real>45</real>
		<key>scoop_position</key>
		<string>0.0 -11.0 0</string>

		<key>weapon_position_aft</key>
		<string>0.0 0 -10</string>
		<key>weapon_position_forward</key>
		<string>0.0 5 100</string>

		<key>death_actions</key>
		<array>		
		<string>commsMessage: [constitutionclassheavycruiser-plea]</string>
		<string>spawn: explosive_shrapnel 4</string>
		</array>

		<key>smooth</key>
		<true/>
</dict>

	<key>constitutionclassheavycruiser-hunter</key>
	<dict>	
		<key>aft_eject_position</key>
		<string>0.0 0.0 -1.0</string>
		<key>ai_type</key>
		<string>bigShips_route1BigTraderAI.plist</string>
		<key>cargo_carried</key>
		<string>Computers</string>
		<key>energy_recharge_rate</key>
		<real>7.0</real>

		<key>subentities</key>
		<array>
			<string>*FLASHER* 0 -19.2 38 175 0 1 16</string>
			<string>*FLASHER* 0.25 13.5 142.5 50 0.5 1 1.0</string>
			<string>*FLASHER* 1.5 5.0 66.8 50 0 1 1.0</string>
			<string>*FLASHER* 0 5.0 66.8 50 0 1 1.0</string>
			<string>*FLASHER* -1.5 5.0 66.8 50 0 1 1.0</string>
			<string>*FLASHER* 43.7 31.7 -145.7 50 3 1 3.0</string>
			<string>*FLASHER* -43.7 31.7 -145.7 50 3 1 3.0</string>
			<string>*FLASHER* 0 5.6 90.2 50 0 1 1</string>
			<string>*FLASHER* 0.8 30.5 80.4 50 0 1 1.0</string>
			<string>*FLASHER* 0 30.5 81.6 50 0 1 1.0</string>
			<string>*FLASHER* -0.8 30.5 81.4 50 0 1 1.0</string>	
			<string>*FLASHER* 6.2 18.8 5.5 360 0 1 5.0</string>
			<string>*FLASHER* -6.2 18.8 5.5 360 0 1 5.0</string>
			<string>*FLASHER* 0.0 22.0 27.5 175 0 1 8.0</string>
			<string>*FLASHER* 0.0 32.4 77.3 50 0.5 1 3.0</string>
			<string>*FLASHER* -43.0 32.7 -28.5 175 0 1 4.5</string>
			<string>*FLASHER* 43.0 32.7 -28.5 175 0 1 4.5</string>
			<string>*FLASHER* 4.5 18.8 5.5 360 0 1 5.0</string>
			<string>*FLASHER* -4.5.0 18.8 5.5 360 0 1 5.0</string>
			<string>*FLASHER* -2.5 -3.1 30.8 30 0 1 2.0</string>
			<string>*FLASHER* 2.5 -3.1 30.8 30 0 1 2.0</string>		
		</array>

		<key>forward_weapon_type</key>
		<string>WEAPON_MILITARY_LASER</string>
		<key>rear_weapon_type</key>
		<string>WEAPON_MILITARY_LASER</string>		
		<key>has_ecm</key>
		<real>1.0</real>
		<key>has_shield_booster</key>
		<real>1.0</real>
		<key>has_fuel_injection</key>
		<real>1.0</real>
		<key>has_shield_enhancer</key>
		<real>1.0</real>		
		<key>has_energy_unit</key>
		<real>1.0</real>		
		<key>has_escape_pod</key>
		<string>6.0</string>
		<key>has_scoop</key>
		<string>1.0</string>
		<key>laser_color</key>
		<string>redColor</string>
		<key>likely_cargo</key>
		<integer>6</integer>
		<key>max_cargo</key>
		<string>50</string>
		<key>max_energy</key>
		<real>1200</real>
		<key>max_flight_pitch</key>
		<real>1.1</real>
		<key>max_flight_roll</key>
		<real>1.1</real>
		<key>max_flight_speed</key>
		<real>550</real>
		<key>max_missiles</key>
		<integer>16</integer>
		<key>missile_load_time</key>
		<integer>5</integer>
		<key>missile_launch_position</key>
		<string>0.0 -11 0</string>
		<key>missile_roles</key>
		<string>EQ_HARDENED_MISSILE</string>
		<key>missiles</key>
		<integer>16</integer>
		<key>model</key>
		<string>constitutionclassheavycruiser.dat</string>
		<key>name</key>
		<string>Constitution Class Heavy Cruiser</string>
		<key>roles</key>
		<string>hunter bigTrader</string>
		<key>scan_class</key>
		<string>CLASS_NEUTRAL</string>
		<key>thrust</key>
		<real>40</real>
		<key>scoop_position</key>
		<string>0.0 -11.0 0</string>

		<key>weapon_position_aft</key>
		<string>0.0 0 -10</string>
		<key>weapon_position_forward</key>
		<string>0.0 5 100</string>

		<key>death_actions</key>
		<array>		
		<string>commsMessage: [constitutionclassheavycruiser-plea]</string>
		<string>spawn: explosive_shrapnel 4</string>
		</array>

		<key>smooth</key>
		<true/>
</dict>

</dict>
</plist
The GalTech Industries Corporation - Building ships to populate the galaxies.

Increase the variety of ships within your Ooniverse by downloading my OXPs

Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5526
Joined: Thu Jun 12, 2008 6:55 pm

Re: New ships under developemnt

Post by Thargoid »

Almost. The AI setting is correct (although I would also add the second key for auto_AI and in this case set it to "no"). That will stop the AI setting getting overridden in some cases.

For the roles, the only one you need is bigTrader. That is the specific role that the bigships populator uses for spawning. If you have the other roles, then any OXP which uses those roles will include your ships in its available pool for spawning. That may be what you want, but the problem will come if the role is used for a station launching a ship. The launch will probably fail as the ship is too large, and no launch will occur (and you'll get a log error).

The military role won't be an issue as the trunk populator doesn't use it for launching ships (but an OXP station may do so via its script or AI if coded to do so), but the hunter role could cause an aborted launch as a main station can launch role "hunter" and it may pick your ship if it has the role.

For details of how the system trunk populator works and what roles it uses, see [EliteWiki] its wiki page.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: New ships under developemnt

Post by Eric Walch »

Hunters are never launched by oolite itself. That was probably also the reason aegidian gave his original behemot ships a hunter role. :P
But, now I would stick to the bigTrader role and not add an populating script yourself. That prevents any system to get overpopulated with all those big ships.
User avatar
Shipbuilder
---- E L I T E ----
---- E L I T E ----
Posts: 877
Joined: Thu May 10, 2012 9:41 pm
Location: Derby

Re: New ships under developemnt

Post by Shipbuilder »

Thargoid and Eric - Thanks very much for getting back to me on the queries relating to the bigShips script. I think that I have correctly understood what you have advised.

What I have decided to do is specify the ship with two alternative roles.

Firstly a military role but limit this using a (0.1) weighting so that it would be possible, but rare, to see one of these ships battling Thargoids.

The second role would be the standard bigShips role.

To do this I have tweaked the following sections of the code for the military role version. i.e. I have removed the bigShipsAI and replaced it with the autoAI.

Code: Select all

		<key>auto_ai</key>
		<string>yes</string>
		<key>roles</key>
		<string>military(0.1)</string>
		<key>scan_class</key>
		<string>CLASS_MILITARY</string>
While for the standard bigShips role I have tweaked sections of the code as follows: -

Code: Select all

		<key>ai_type</key>
		<string>bigShips_route1BigTraderAI.plist</string>
		<key>auto_ai</key>
		<string>no</string>
		<key>roles</key>
		<string>bigTrader(0.5)</string>
		<key>scan_class</key>
		<string>CLASS_NEUTRAL</string>
Can I specify CLASS_MILITARY for the bigShips role or should I keep it as CLASS_NEUTRAL as per the code above ?

I have included for a rare military version which I understand will be ok as it won't attempt to launch or dock from stations and a standard version which will be introduced with reduced weighting with the bigShip script.

Hopefully, with the weightings specified above, the ships will only be occasional visitors to the Ooniverse and also won’t end up embedded in to a station ! :oops:

I would be most grateful if either of you could cast your eye over the code above and confirm or otherwise that I have correctly tweaked it.

I think the next step is to make a final decision upon a size and use the script Thargoid advised me of in the earlier thread to set the new size (Presumably I will need to re-specify things such as flasher locations in the shipdata.plist as I understand the script is used to reconfigure the .dat model file only).

If this is the case however presumably if I, for example, double the ship size then all I need to do with the x y and z co-ordinates locating the flashers is double them.

I am hoping to get this oxp issued during the course of this week.

Gents - Thanks again for the advice and use of your bigShips script
The GalTech Industries Corporation - Building ships to populate the galaxies.

Increase the variety of ships within your Ooniverse by downloading my OXPs

Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5526
Joined: Thu Jun 12, 2008 6:55 pm

Re: New ships under developemnt

Post by Thargoid »

I think you'll have to set an AI for the military ship, as auto_AI only works for the trunk populator roles if I remember correctly. It's designed to automagically give the correct AI to trunk ships which have mixed role such as traders/pirates/bounty hunters all in one ship definition. But military isn't a trunk role, it's an OXP one. You can look in autoAImap.plist in the games oolite.app/resources/config directory for details on what trunk role gets assigned which trunk AI.

For the scanclass for bigTraders, you can set what you want. All bigShips is is an OXP populator which spawns ships with role "bigTrader" in suitable systems when the player enters them.

One point about the weightings is it's a weighting within the pool of ships with that role, not an absolute weighting. For example if you have a ship with role "myRole(0.01)", if there is a script which spawns a ship with that role and your ship is the only one in the game with that role, it will be spawned regardless of the weighting (basically it's chance is 1 in 0.01/0.01, ie every time). But if you install a second ship with role "myRole(0.1)" then 1 in 11 (ie 1 in 0.01/(0.1+0.01)) will be the original ship, and 10 in 11 will be the new one.

For resizing, yes the script only resizes the model. You will have to adjust all positional items in shipdata.plist (subent positions, exhaust positions, launch positions, weapon positions, flashers etc) but the shipdata.plist co-ordinates will of course just scale by whatever factor you used in the script rescale of the model so it's not as much work as it sounds, as you rightly surmised.

Anyway good luck with it. The Enterprise model screenshot you posted was stunning.
User avatar
Shipbuilder
---- E L I T E ----
---- E L I T E ----
Posts: 877
Joined: Thu May 10, 2012 9:41 pm
Location: Derby

Re: New ships under developemnt

Post by Shipbuilder »

Thanks Thargoid.

I think for the time being then I will look to issue the oxp using the standard bigShips AI (I will probably revisit at a later date to incorporate a more complex AI script for an alternative military role once I have got to grips with scripting a little more).

Therefore my tasks for the rest of the week are to increase the model size, re-specify locations of flashers, weapon positions, launch positions etc before carrying out some last minute checks so hopefully I will be able to make an official release this week.
:D
The GalTech Industries Corporation - Building ships to populate the galaxies.

Increase the variety of ships within your Ooniverse by downloading my OXPs

Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"
User avatar
Shipbuilder
---- E L I T E ----
---- E L I T E ----
Posts: 877
Joined: Thu May 10, 2012 9:41 pm
Location: Derby

Re: New ships under developemnt

Post by Shipbuilder »

Thargoid wrote:
The texture will be fine, presuming you just rescale without modifying in detail.

Indeed there is a datscale.py script which can make a model uniformly bigger (or smaller) - you can grab it from Berlios in the same place as obj2dat and it's bretheren.

Editted to add - see here
Can anyone explain how I can use the datscale.py script to resize a 3D wings model in layman’s terms ?

I'm sure it's easy when you know how but I have been fiddling around trying to work out what to do for a while and haven't made much progress.
The GalTech Industries Corporation - Building ships to populate the galaxies.

Increase the variety of ships within your Ooniverse by downloading my OXPs

Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: New ships under developemnt

Post by Svengali »

Code: Select all

DatScale.py modelname.dat factor
e.g. DatScale.py myModel.dat 3.0

Output filename will be "myModel x 3.0.dat".
User avatar
Shipbuilder
---- E L I T E ----
---- E L I T E ----
Posts: 877
Joined: Thu May 10, 2012 9:41 pm
Location: Derby

Re: New ships under developemnt

Post by Shipbuilder »

Svengali wrote:

Code: Select all

DatScale.py modelname.dat factor
e.g. DatScale.py myModel.dat 3.0

Output filename will be "myModel x 3.0.dat".
Sorry to be pest but I'm still not sure what I need to do. :?

Do I need to copy and paste the code below in to a python file and if so where do I input the above code i.e. in my case

Code: Select all

DatScale.py constitutionclassheavycruiser.dat 1.8 
Also do I need to create a file with a copy of the current .dat file and the python script file in ?

Code: Select all

#!/usr/bin/python 

""" 
This script takes an Oolte .dat file, scales it by a specified scale factor,
and writes it out again (appending the scale factor to the name).

Only the VERTEX section is modified. The rest of the file is passed through
unchanged.
""" 

import sys, string, math, re


class DATLexer:
	""" Tokens scanner for DAT files. """
	def __init__(self, data):
		self.__data = data
		self.__end = len(data)
		self.__cursor = 0
		self.__tokenLength = 0
		self.__lineNumber = 1
		self.__lastSeparator = ""
		self.__isSeparatorChar = re.compile(r"[\ \r\n\t,]")
		self.__isLineEnd = re.compile(r"[\r\n]")
		self.__isNotLineEnd = re.compile(r"[^\r\n]")
		self.__lastIsCR = False
	
	def lineNumber(self):
		""" Returns the line number at the beginning of the current token. """
		return self.__lineNumber
	
	def currentToken(self):
		""" Returns the current token. """
		return self.__currentToken
		
	def lastSeparator(self):
		""" Returns the non-token content between the current token and the previous token. """
		return self.__lastSeparator
	
	def nextToken(self):
		""" Reads the next token. """
		self.__advance(False)
		return self.currentToken()
	
	def expectLiteral(self, literal):
		""" Reads a token and checks whether it matches the expected string. """
		return self.nextToken() == literal
	
	def readInt(self):
		""" Reads an integer. """
		self.__advance(False)
		return int(self.currentToken())
	
	def readFloat(self):
		""" Reads a floating-point number. """
		self.__advance(False)
		return float(self.currentToken())
	
	def readUntilNewLine(self):
		""" Reads until the beginning of a new line or the beginning of a comment. """
		sef.__advance(True)
		return self.currentToken()
		
	def atEnd(self):
		""" Tests whether the lexer has reached the end of its data. """
		return self.__cursor == self.__end
	
	
	def __advance(self, untilEOL):
		self.__cursor += self.__tokenLength
		assert self.__cursor < self.__end
		initialCursor = self.__cursor
		
		# Find beginning of token.
		while 1:
			self.__skipWhile(self.__isSeparatorChar)
			
			if not self.atEnd() and self.__commentAt(self.__cursor):
				self.__skipWhile(self.__isNotLineEnd)
			else:
				break
		
		self.__lastSeparator = self.__data[initialCursor:self.__cursor]
		
		# Find length of token.
		endCursor = None
		if untilEOL:
			endCursor = self.__scanTokenLength(self.__isLineEnd)
		else:
			endCursor = self.__scanTokenLength(self.__isSeparatorChar)
		
		self.__tokenLength = endCursor - self.__cursor
		self.__currentToken = self.__data[self.__cursor:endCursor]
	
	
	def __skipWhile(self, matcher):
		while 1:
			if self.__cursor == self.__end:
				return
			
			curr = self.__data[self.__cursor]
			if not matcher.match(curr):
				return
			
			if self.__isNotLineEnd.match(curr):
				self.__lastIsCR = False
			else:
				if curr != '\n' or not self.__lastIsCR:
					self.__lineNumber = self.__lineNumber + 1
				self.__lastIsCR = curr == '\r'
			
			self.__cursor = self.__cursor + 1
	
	def __scanTokenLength(self, endCriterion):
		endCursor = self.__cursor + 1
		while endCursor < self.__end and not endCriterion.match(self.__data[endCursor]) and not self.__commentAt(endCursor):
			endCursor = endCursor + 1
		return endCursor
	
	def __commentAt(self, offset):
		if self.__data[offset] == '#':
			return True
		if offset + 1 < self.__end and self.__data[offset] == '/' and self.__data[offset + 1] == '/':
			return True
		return False
	

if len(sys.argv) != 3:
	print "Expected two arguments, file name and scale factor."
	exit(1)

inputFileName = sys.argv[1]
factor = float(sys.argv[2])

outputFileName = ""
outputFileComponents = inputFileName.rsplit(".", 1)
if len(outputFileComponents) == 1 or outputFileComponents[1].lower() != "dat":
	outputFileName = inputFileName
else:
	outputFileName = outputFileComponents[0]

outputFileName += " x " + str(factor) + ".dat";

print "Scaling \"" + inputFileName + "\" by " + str(factor) + " to \"" + outputFileName + "\"..."

nVerts = 0
inputFile = open(inputFileName, "r")
fileData = inputFile.read()
lexer = DATLexer(fileData)

lexer.expectLiteral("NVERTS")
nverts = lexer.readInt()
lexer.expectLiteral("NFACES")
nfaces = lexer.readInt()
lexer.expectLiteral("VERTEX")

outputFile = open(outputFileName, "w")
outputFile.write("// " + inputFileName + " rescaled by a factor of " + str(factor) + "\n\n")
outputFile.write("NVERTS " + str(nverts) + "\nNFACES " + str(nfaces) + "\n\nVERTEX\n");


for i in range(nverts):
	x = lexer.readFloat() * factor
	y = lexer.readFloat() * factor
	z = lexer.readFloat() * factor
	
	outputFile.write('% 5f,% .5f,% .5f\n' % (x, y, z))
	#outputFile.write(str(x * factor) + ", " + str(y * factor) + ", " + str(z * factor) + "\n")


while not lexer.atEnd():
	token = lexer.nextToken();
	outputFile.write(lexer.lastSeparator())
	outputFile.write(token)
The GalTech Industries Corporation - Building ships to populate the galaxies.

Increase the variety of ships within your Ooniverse by downloading my OXPs

Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: New ships under developemnt

Post by Svengali »

Shipbuilder wrote:
Do I need to copy and paste the code below in to a python file and if so where do I input the above code i.e. in my case

Code: Select all

DatScale.py constitutionclassheavycruiser.dat 1.8 
Also do I need to create a file with a copy of the current .dat file and the python script file in ?
It works similiar to the obj2dat conversion you've already done with the Constitution after exporting from WINGS3D.

Just place the model and the downloaded DatScale.py in a folder, open a terminal, move to that folder and type in the commands.
The original .dat file doesn't get changed, so you can even work with the original, although it's always safer to use a copy .-)
Last edited by Svengali on Thu May 31, 2012 12:07 am, edited 1 time in total.
User avatar
Shipbuilder
---- E L I T E ----
---- E L I T E ----
Posts: 877
Joined: Thu May 10, 2012 9:41 pm
Location: Derby

Re: New ships under developemnt

Post by Shipbuilder »

Thanks Svengali - I'll have a look at it tomorrow evening.
The GalTech Industries Corporation - Building ships to populate the galaxies.

Increase the variety of ships within your Ooniverse by downloading my OXPs

Flying the [wiki]Serpent_Class_Cruiser[/wiki] "Thargoid's Bane"
Post Reply