PROBLEM NUMBER 1:
In the game, everything except the player either slowly sinks through the floor, or moves very strangely. In the level editor, everything is fine, and they both use the same code to load and position the objects!
dim objects$(50,1): dim weight(50): objnum=1
selobj = 1: obj=1000
open to read 1,"dataobjectsindex.txt"
do
read string 1,t$
if t$ = "-END-" then exit
objects$(objnum,1)=t$
if t$ <> "TREE MESH" then read string 1,t$: weight(objnum)=val(t$)
read string 1,t$
objects$(objnum,0)=t$
load object objects$(objnum,0)+".dbo", objnum+800
position object objnum+800,0,-1000,0
objnum=objnum+1
loop
close file 1
open to read 1, "datamapsm1_data.lvl"
do
read string 1,t$
if t$ = "END DOORS" then exit
loop
Default = NDB_NewtonMaterialGetDefaultGroupID(): ObjectID = NDB_NewtonMaterialCreateGroupID()
NDB_NewtonMaterialSetDefaultFriction Default, ObjectID, 0.5, 0.5: NDB_NewtonMaterialSetDefaultElasticity Default, ObjectID, 0.1
do
read string 1,t$
if t$="END" then exit
read string 1,t$
for i = 1 to 50
if objects$(i,0) = t$ then selobj=i
next i
name$ = t$
read string 1,t$: x# = val(t$)
read string 1,t$: y# = val(t$)
read string 1,t$: z# = val(t$)
read string 1,t$: rx# = val(t$)
read string 1,t$: ry# = val(t$)
read string 1,t$: rz# = val(t$)
read string 1,t$: sx# = val(t$)
read string 1,t$: sy# = val(t$)
read string 1,t$: sz# = val(t$)
print x#: print y#: print z#: print rx#: print ry#: print rz#: print sx#: print sy#: print sz#
clone object obj, selobj+800: show object obj
position object obj,0,0,0
yrotate object obj,0
if objects$(selobj,1)="TREE MESH"
offset limb obj,0,x#,y#,z#
rotate limb obj,0,rx#,ry#,rz#
endif
if objects$(selobj,1)="TREE MESH"
Col = NDB_NewtonCreateTreeCollision( obj )
Room = NDB_NewtonCreateBody( Col )
NDB_BodySetDBProData Room, obj
NDB_NewtonBodySetDestructorCallback Room
NDB_NewtonReleaseCollision Col
else
if objects$(selobj,1)="BOX" then Col = NDB_NewtonCreateBox( sx#, sy#, sz# )
if objects$(selobj,1)="CONVEX HULL" then Col = NDB_NewtonCreateConvexHull( obj )
Body = NDB_NewtonCreateBody(Col)
NDB_NewtonBodySetMassMatrix Body, weight(selobj)
NDB_NewtonReleaseCollision Col
NDB_BuildMatrix rx#,ry#,rz#,x#,y#,z#
NDB_NewtonBodySetMatrix Body
NDB_NewtonBodySetDestructorCallback Body
NDB_BodySetDBProData Body, obj
NDB_BodySetGravity Body, 1
NDB_NewtonBodySetMaterialGroupID Body, ObjectID
endif
obj=obj+1
loop
close file 1
PROBLEM NUMBER 2:
The game crashes whenever I try to use a shader on each of these objects. I tried making a second object that wasn't controlled by Newton, positioning it in the same spot as the Newton object and using a shader on it, but that didn't work. The shader worked when no objects were controlled by Newton, however. (I've attached a picture showing the error.)
EDIT:
I fixed Problem 2

. I loaded fewer objects and it worked fine. I'll load as many as I can and then load the rest part way through the level. Newton and the shaders (pixel lighting shader) probably conflict somehow with that many being used (About 390 - 400 objects all with shaders and physics). But I haven't figured out Problem 1 yet.