diff --git a/scripts/object/building/corellia/shuttleport_corellia.py b/scripts/object/building/corellia/shuttleport_corellia.py index ccad8904..5cdd5f87 100644 --- a/scripts/object/building/corellia/shuttleport_corellia.py +++ b/scripts/object/building/corellia/shuttleport_corellia.py @@ -1,4 +1,10 @@ import sys def setup(core, object): + + objSvc = core.objectService + objSvc.createChildObject(object, 'object/tangible/terminal/shared_terminal_travel.iff', -13, 0.6, -10, -0.707107, 0.707107) + objSvc.createChildObject(object, 'object/creature/npc/theme_park/shared_player_shuttle.iff', 0, 0.6, 0, 1, 0) + objSvc.createChildObject(object, 'object/tangible/travel/ticket_collector/shared_ticket_collector.iff', -13, 0.6, 10, -0.707107, 0.707107) + return \ No newline at end of file diff --git a/scripts/object/building/corellia/starport_corellia.py b/scripts/object/building/corellia/starport_corellia.py index e71c9121..5b881257 100644 --- a/scripts/object/building/corellia/starport_corellia.py +++ b/scripts/object/building/corellia/starport_corellia.py @@ -3,13 +3,16 @@ import sys def setup(core, object): stcSvc = core.staticService cell = object.getCellByCellNumber(4) + objSvc = core.objectService if cell: stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(11.5), float(0.6), float(51.3), float(0.195405), float(-0.980722)) stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(3.1), float(0.6), float(49), float(0), float(1)) stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-2.7), float(0.6), float(49), float(0), float(1)) stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.2), float(0.6), float(51.3), float(-0.195405), float(-0.980722)) - + + objSvc.createChildObject(object, 'object/creature/npc/theme_park/shared_player_transport.iff', 0, 0, 0, 1, 0) + objSvc.createChildObject(object, 'object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 10, 0, -10, 0.707107, 0.707107) core.mapService.addLocation(object.getPlanet(), 'Starport', object.getPosition().x, object.getPosition().z, 15, 0, 0) return \ No newline at end of file diff --git a/scripts/object/building/military/outpost_starport.py b/scripts/object/building/military/outpost_starport.py index ccad8904..b686025c 100644 --- a/scripts/object/building/military/outpost_starport.py +++ b/scripts/object/building/military/outpost_starport.py @@ -1,4 +1,16 @@ import sys def setup(core, object): + + stcSvc = core.staticService + objSvc = core.objectService + objSvc.createChildObject(object, 'object/creature/npc/theme_park/shared_player_transport.iff', 0, 7, 0, 0.707107, 0.707107) + objSvc.createChildObject(object, 'object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 1, 0, -10, 0, 1) + + cell = object.getCellByCellNumber(1) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-3.12), float(0.14659503), float(-17.57), float(0.707107), float(-0.707107)) + + return \ No newline at end of file diff --git a/scripts/object/building/naboo/shuttleport_naboo.py b/scripts/object/building/naboo/shuttleport_naboo.py index ccad8904..5cdd5f87 100644 --- a/scripts/object/building/naboo/shuttleport_naboo.py +++ b/scripts/object/building/naboo/shuttleport_naboo.py @@ -1,4 +1,10 @@ import sys def setup(core, object): + + objSvc = core.objectService + objSvc.createChildObject(object, 'object/tangible/terminal/shared_terminal_travel.iff', -13, 0.6, -10, -0.707107, 0.707107) + objSvc.createChildObject(object, 'object/creature/npc/theme_park/shared_player_shuttle.iff', 0, 0.6, 0, 1, 0) + objSvc.createChildObject(object, 'object/tangible/travel/ticket_collector/shared_ticket_collector.iff', -13, 0.6, 10, -0.707107, 0.707107) + return \ No newline at end of file diff --git a/scripts/object/building/naboo/starport_naboo.py b/scripts/object/building/naboo/starport_naboo.py index e71c9121..0060e877 100644 --- a/scripts/object/building/naboo/starport_naboo.py +++ b/scripts/object/building/naboo/starport_naboo.py @@ -3,13 +3,15 @@ import sys def setup(core, object): stcSvc = core.staticService cell = object.getCellByCellNumber(4) + objSvc = core.objectService if cell: stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(11.5), float(0.6), float(51.3), float(0.195405), float(-0.980722)) stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(3.1), float(0.6), float(49), float(0), float(1)) stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-2.7), float(0.6), float(49), float(0), float(1)) stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.2), float(0.6), float(51.3), float(-0.195405), float(-0.980722)) - + objSvc.createChildObject(object, 'object/creature/npc/theme_park/shared_player_transport.iff', 0, 0, 0, 1, 0) + objSvc.createChildObject(object, 'object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 10, 0, -10, 0.707107, 0.707107) core.mapService.addLocation(object.getPlanet(), 'Starport', object.getPosition().x, object.getPosition().z, 15, 0, 0) return \ No newline at end of file diff --git a/scripts/object/building/tatooine/shuttleport_tatooine.py b/scripts/object/building/tatooine/shuttleport_tatooine.py index c5cf71c2..55348477 100644 --- a/scripts/object/building/tatooine/shuttleport_tatooine.py +++ b/scripts/object/building/tatooine/shuttleport_tatooine.py @@ -2,6 +2,11 @@ import sys def setup(core, object): + objSvc = core.objectService + objSvc.createChildObject(object, 'object/tangible/terminal/shared_terminal_travel.iff', -13, 0.6, -10, -0.707107, 0.707107) + objSvc.createChildObject(object, 'object/creature/npc/theme_park/shared_player_shuttle.iff', 0, 0.6, 0, 1, 0) + objSvc.createChildObject(object, 'object/tangible/travel/ticket_collector/shared_ticket_collector.iff', -13, 0.6, 10, -0.707107, 0.707107) + core.mapService.addLocation(object.getPlanet(), 'Shuttleport', object.getPosition().x, object.getPosition().z, 14, 0, 0) return \ No newline at end of file diff --git a/scripts/object/building/tatooine/starport_tatooine.py b/scripts/object/building/tatooine/starport_tatooine.py index 34468ac1..0e620101 100644 --- a/scripts/object/building/tatooine/starport_tatooine.py +++ b/scripts/object/building/tatooine/starport_tatooine.py @@ -3,12 +3,14 @@ import sys def setup(core, object): stcSvc = core.staticService cell = object.getCellByCellNumber(4) - + objSvc = core.objectService if cell: stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(11.5), float(0.6), float(51.3), float(0.195405), float(-0.980722)) stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(3.1), float(0.6), float(49), float(0), float(1)) stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-2.7), float(0.6), float(49), float(0), float(1)) stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.2), float(0.6), float(51.3), float(-0.195405), float(-0.980722)) + objSvc.createChildObject(object, 'object/creature/npc/theme_park/shared_player_transport.iff', 0, 0, 0, 1, 0) + objSvc.createChildObject(object, 'object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 10, 0, -10, 0.707107, 0.707107) core.mapService.addLocation(object.getPlanet(), 'Starport', object.getPosition().x, object.getPosition().z, 15, 0, 0) return \ No newline at end of file diff --git a/scripts/object/creature/npc/theme_park/player_transport.py b/scripts/object/creature/npc/theme_park/player_transport.py index 30d15cfb..e1dd8242 100644 --- a/scripts/object/creature/npc/theme_park/player_transport.py +++ b/scripts/object/creature/npc/theme_park/player_transport.py @@ -3,7 +3,8 @@ import sys def setup(core, object): object.setPosture(0) # land = 0 : away = 2 tp = core.travelService.getNearestTravelPoint(object) - tp.setShuttle(object) - tp.setShuttleAvailable(True) - tp.setShuttleLanding(False) + if tp: + tp.setShuttle(object) + tp.setShuttleAvailable(True) + tp.setShuttleLanding(False) return \ No newline at end of file diff --git a/scripts/static_spawns/naboo.py b/scripts/static_spawns/naboo.py index ac5d19ca..86f073af 100644 --- a/scripts/static_spawns/naboo.py +++ b/scripts/static_spawns/naboo.py @@ -4,28 +4,4 @@ def addPlanetSpawns(core, planet): stcSvc = core.staticService - # Travel spawns - - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'naboo', long(0), float(-5487.8), float(-149.4), float(-12.5), float(-0.710457), float(0.703739)) # Lake Retreat - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'naboo', long(0), float(4717.7), float(4.2), float(-4650.6), float(1), float(0)) # moenia starport - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'naboo', long(0), float(4968.6), float(4.4), float(-4883.3), float(0.71), float(-0.71)) # moenia shuttleport - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'naboo', long(0), float(5301.1), float(-192), float(6671.5), float(0), float(1)) # kaadara starport - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'naboo', long(0), float(5134.3), float(-191.4), float(6617.2), float(-0.373413), float(0.927665)) # kaadara shuttleport - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'naboo', long(0), float(1347.8), float(13), float(2760.3), float(0.988256), float(0.152808)) # keren starport - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'naboo', long(0), float(1558.3), float(25.6), float(2884.8), float(1), float(0)) # keren shuttleport a - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'naboo', long(0), float(2027.7), float(19.6), float(2535.2), float(-0.710457), float(0.703739)) # keren shuttleport b - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'naboo', long(0), float(5338.6), float(327.6), float(-1567.2), float(-0.710457), float(0.703739)) # deeja peek shuttleport - - - - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(0), float(-5487), float(-149.4), float(-31.8), float(-0.710457), float(0.703739)) # Lake Retreat - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(0), float(5121.5), float(-191.4), float(6603.8), float(-0.373413), float(0.927665)) # kaadara shuttleport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(0), float(1577.6), float(25.6), float(2845.1), float(1), float(0)) # keren shuttleport a - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(0), float(2028.5), float(19.6), float(2515.6), float(-0.710457), float(0.703739)) # keren shuttleport b - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(0), float(5339.3), float(327.6), float(-1586.7), float(-0.710457), float(0.703739)) # deeja peek shuttleport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(0), float(4969.4), float(4.4), float(-4902.6), float(-0.710457), float(0.703739)) # moenia shuttleport - - - - return \ No newline at end of file diff --git a/scripts/static_spawns/rori.py b/scripts/static_spawns/rori.py index 0ebd4454..ae6e37f3 100644 --- a/scripts/static_spawns/rori.py +++ b/scripts/static_spawns/rori.py @@ -2,17 +2,7 @@ import sys def addPlanetSpawns(core, planet): - stcSvc = core.staticService - - # Travel spawns - - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'rori', long(0), float(3672.5), float(96), float(-6411.2), float(0.938551), float(0.345142)) # rebel outpost - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'rori', long(0), float(-5381.5), float(80), float(-2162.8), float(1), float(0)) # narmle starport - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'rori', long(0), float(-5257.2), float(81.3), float(-2150.3), float(-0.924076), float(0.382209)) # narmle shuttleport - - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'rori', long(0), float(-5243), float(81.3), float(-2163.5), float(-0.924076), float(0.382209)) # narmle shuttleport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'rori', long(4505530), float(-3.5), float(0.1), float(-17.5), float(-0.69182), float(0.72207)) # rebel outpost - + stcSvc = core.staticService # Restuss Spawns diff --git a/scripts/static_spawns/tatooine.py b/scripts/static_spawns/tatooine.py index a42c22ca..80b02bde 100644 --- a/scripts/static_spawns/tatooine.py +++ b/scripts/static_spawns/tatooine.py @@ -3,36 +3,7 @@ import sys def addPlanetSpawns(core, planet): stcSvc = core.staticService - - # Travel spawns - - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'tatooine', long(0), float(-1090.8), float(12.6), float(-3554.9), float(-0.67), float(0.74)) # bestine shuttleport - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'tatooine', long(0), float(-1382.15), float(12), float(-3583.25), float(1), float(-0.08)) # bestine starport - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'tatooine', long(0), float(3427.5), float(5.6), float(-4644.1), float(-0.485545), float(0.874212)) # mos eisley shuttleport - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'tatooine', long(0), float(3622), float(5), float(-4788), float(-0.276903063059), float(0.960897982121)) # mos eisley starport - - stcSvc.spawnObject('object/creature/npc/theme_park/shared_player_transport.iff', 'tatooine', long(0), float(3618), float(5), float(-4801), float(0.500574469566), float(0.865693628788)) # mos eisley starport - - - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'tatooine', long(0), float(-2886.3), float(5.6), float(1929.4), float(-0.113814), float(0.993502)) # mos espa shuttleport a - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'tatooine', long(0), float(-3116.3), float(5.6), float(2166.1), float(-0.621933), float(0.783071)) # mos espa shuttleport b - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'tatooine', long(0), float(3623.5), float(5.6), float(2178.4), float(-0.123692), float(0.992321)) # mos espa shuttleport c - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'tatooine', long(0), float(38.15), float(52.6), float(-5532.2), float(1), float(0)) # anchorhead shuttleport - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'tatooine', long(0), float(1241.95), float(7), float(3053.42), float(0.89), float(0.46)) # mos entha starport - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'tatooine', long(0), float(1386.12), float(7.6), float(3473.81), float(1), float(0)) # mos entha shuttleport a - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'tatooine', long(0), float(1721.5), float(7.6), float(3191.3), float(1), float(0)) # mos entha shuttleport b - stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'tatooine', long(0), float(-2820.5), float(5), float(2083.71), float(0), float(1)) # mos espa starport - - - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(0), float(-1091.9), float(12.6), float(-3572.7), float(-0.645025), float(0.764162)) # bestine shuttleport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(0), float(-2903.5), float(5.6), float(1924), float(-0.113814), float(0.993502)) # mos espa shuttleport a - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(0), float(-3124.4), float(5.6), float(2138.1), float(0.621933), float(0.783071)) # mos espa shuttleport b - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(0), float(-2810), float(12.6), float(2173.8), float(-0.123962), float(0.992321)) # mos espa shuttleport c - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(0), float(55.7), float(52.6), float(-5531.4), float(1), float(0)) # anchorhead shuttleport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(0), float(1403.6), float(7.6), float(3474.4), float(1), float(0)) # mos entha shuttleport a - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(0), float(1739), float(7.6), float(3192.1), float(1), float(0)) # mos entha shuttleport b - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(0), float(3418.4), float(5.6), float(-4659.3), float(-0.485545), float(0.874212)) # mos eisley shuttleport - + stcSvc.spawnObject('object/mobile/shared_lifeday_saun_dann.iff', 'tatooine', long(0), float(-5037.00), float(75), float(-6561), float(-0.75), float(0)) # Life Day stcSvc.spawnObject('object/tangible/holiday/life_day/shared_main_lifeday_tree.iff', 'tatooine', long(0), float(-5043.00), float(75), float(-6541.00), float(0.999132931232), float(-0.0416347384453)) # Lifeday Tree stcSvc.spawnObject('object/mobile/shared_lifeday_figrin_dan.iff', 'tatooine', long(0), float(-5046.00), float(75), float(-6560), float(-0.75), float(0)) # LD Figrin diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 03c0d448..f1a4ed52 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -253,14 +253,16 @@ public class NGECore { terrainService.addPlanet(10, "dathomir", "terrain/dathomir.trn", true); terrainService.addPlanet(11, "mustafar", "terrain/mustafar.trn", true); terrainService.addPlanet(12, "kashyyyk_main", "terrain/kashyyyk_main.trn", true); - terrainService.loadSnapShotObjects(); - - // Zone services that need to be loaded after the above - simulationService = new SimulationService(this); - zoneDispatch.addService(simulationService); - // Travel Points travelService.loadTravelPoints(); + simulationService = new SimulationService(this); + + terrainService.loadSnapShotObjects(); + simulationService.insertSnapShotObjects(); + + // Zone services that need to be loaded after the above + zoneDispatch.addService(simulationService); + // Static Spawns staticService.spawnStatics(); diff --git a/src/resources/common/MathUtilities.java b/src/resources/common/MathUtilities.java new file mode 100644 index 00000000..8cf73cc0 --- /dev/null +++ b/src/resources/common/MathUtilities.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.common; + +import engine.resources.scene.*; + +public class MathUtilities { + + public static Quaternion rotateQuaternion(Quaternion quaternion, float radians, Point3D axis) { + + float sin = (float) Math.sin(radians / 2); + + Quaternion rotateQ = new Quaternion((float) Math.cos(radians / 2), axis.x * sin, axis.y * sin, axis.z * sin); + + return multiplyQuaternions(rotateQ, quaternion); + + } + + public static Quaternion multiplyQuaternions(Quaternion q1, Quaternion q2) { + + return new Quaternion(q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z, + q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y, + q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z, + q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x); + + } + +} diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index b0ffc16b..443d57cb 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -103,13 +103,6 @@ public class SimulationService implements INetworkDispatch { quadTrees.put(terrainService.getPlanetList().get(i).getName(), new QuadTree(-8192, -8192, 8192, 8192)); } - List objectList = new ArrayList(core.objectService.getObjectList().values()); - for(SWGObject obj : objectList) { - if(obj.getParentId() == 0 && obj.isInSnapshot()) { - core.objectService.loadServerTemplate(obj); - add(obj, obj.getPosition().x, obj.getPosition().z); - } - } core.commandService.registerCommand("opencontainer"); core.commandService.registerCommand("transferitem"); core.commandService.registerCommand("transferitemarmor"); @@ -145,13 +138,23 @@ public class SimulationService implements INetworkDispatch { } + public void insertSnapShotObjects() { + List objectList = new ArrayList(core.objectService.getObjectList().values()); + for(SWGObject obj : objectList) { + if(obj.getParentId() == 0 && obj.isInSnapshot()) + add(obj, obj.getPosition().x, obj.getPosition().z); + } + } + public void add(SWGObject object, int x, int y) { object.setIsInQuadtree(true); + core.objectService.loadServerTemplate(object); quadTrees.get(object.getPlanet().getName()).put(x, y, object); } public boolean add(SWGObject object, float x, float y) { object.setIsInQuadtree(true); + core.objectService.loadServerTemplate(object); return quadTrees.get(object.getPlanet().getName()).put(x, y, object); } @@ -864,7 +867,7 @@ public class SimulationService implements INetworkDispatch { public float getHeightOrigin(CreatureObject creature) { - float height = (float) (creature.getHeight() - 0.3); + float height = (float) (creature.getHeight()/* - 0.3*/); if(creature.getPosture() == 2 || creature.getPosture() == 13) height = 0.3f; diff --git a/src/services/StaticService.java b/src/services/StaticService.java index 0dfd37fc..726093e7 100644 --- a/src/services/StaticService.java +++ b/src/services/StaticService.java @@ -110,6 +110,7 @@ public class StaticService implements INetworkDispatch { return object; } parent.add(object); + core.objectService.loadServerTemplate(object); } return object; diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index 75ff8708..801fec4a 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -199,7 +199,7 @@ public class ObjectService implements INetworkDispatch { object.setPlanetId(planet.getID()); - loadServerTemplate(object); + //loadServerTemplate(object); objectList.put(objectID, object); @@ -566,5 +566,37 @@ public class ObjectService implements INetworkDispatch { System.out.println("Finished loading client objects for: " + planet.getName()); } + /** + * Creates a child object and places it at a position and orientation offset from the parent object. + * @param parent The parent Object. + * @param template The template file of the child. + * @param position The position as an offset to the parent object. + * @param orientation The orientation as an offset to the parent object. + */ + public void createChildObject(SWGObject parent, String template, Point3D position, Quaternion orientation) { + + + float radians = parent.getRadians(); + Point3D parentPos = parent.getWorldPosition(); + + float x = (float) ((Math.cos(radians) * position.x) + (Math.sin(radians) * position.z)); + float y = position.y + parentPos.y; + float z = (float) ((Math.cos(radians) * position.z) - (Math.sin(radians) * position.x)); + + x += parentPos.x; + z += parentPos.z; + + position = new Point3D(x, y, z); + orientation = MathUtilities.rotateQuaternion(orientation, radians, new Point3D(0, 1, 0)); + SWGObject child = createObject(template, 0, parent.getPlanet(), position, orientation); + + core.simulationService.add(child, x, z); + + } + + public void createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw) { + createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0)); + } + }