Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1 | -- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved. |
2 | |
3 | MissionPhysicsObject= {}; |
4 | MissionPhysicsObject_mt = Class(MissionPhysicsObject, MountableObject); |
5 | |
6 | InitStaticObjectClass(MissionPhysicsObject, "MissionPhysicsObject", ObjectIds.OBJECT_MISSION_PHYSICS_OBJECT); |
7 | |
8 | function MissionPhysicsObject:new(isServer, isClient, customMt) |
9 | local mt = customMt; |
10 | if mt == nil then |
11 | mt = MissionPhysicsObject_mt; |
12 | end; |
13 | |
14 | local self = MountableObject:new(isServer, isClient, mt); |
15 | |
16 | self.forcedClipDistance = 80; |
17 | |
18 | return self; |
19 | end; |
20 | |
21 | function MissionPhysicsObject:delete() |
22 | if self.i3dFilename ~= nil then |
23 | Utils.releaseSharedI3DFile(self.i3dFilename, nil, true); |
24 | end |
25 | MissionPhysicsObject:superClass().delete(self); |
26 | end; |
27 | |
28 | function MissionPhysicsObject:readStream(streamId, connection) |
29 | local i3dFilename = Utils.convertFromNetworkFilename(streamReadString(streamId)); |
30 | if self.nodeId == 0 then |
31 | self:createNode(i3dFilename); |
32 | end; |
33 | MissionPhysicsObject:superClass().readStream(self, streamId, connection); |
34 | end; |
35 | |
36 | function MissionPhysicsObject:writeStream(streamId, connection) |
37 | streamWriteString(streamId, Utils.convertToNetworkFilename(self.i3dFilename)); |
38 | MissionPhysicsObject:superClass().writeStream(self, streamId, connection); |
39 | end; |
40 | |
41 | function MissionPhysicsObject:setNodeId(nodeId) |
42 | MissionPhysicsObject:superClass().setNodeId(self, nodeId); |
43 | end; |
44 | |
45 | function MissionPhysicsObject:createNode(i3dFilename) |
46 | self.i3dFilename = i3dFilename; |
47 | local rootNode = Utils.loadSharedI3DFile(i3dFilename); |
48 | |
49 | local nodeId = getChildAt(rootNode, 0); |
50 | link(getRootNode(), nodeId); |
51 | delete(rootNode); |
52 | |
53 | self:setNodeId(nodeId); |
54 | end; |
55 | |
56 | function MissionPhysicsObject:load(i3dFilename, x,y,z, rx,ry,rz) |
57 | self.i3dFilename = i3dFilename; |
58 | self:createNode(i3dFilename); |
59 | setTranslation(self.nodeId, x, y, z); |
60 | setRotation(self.nodeId, rx, ry, rz); |
61 | |
62 | return true; |
63 | end; |
64 | |
65 | function MissionPhysicsObject:loadFromMemory(nodeId, i3dFilename) |
66 | self.i3dFilename = i3dFilename; |
67 | self:setNodeId(nodeId); |
68 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de