That makes things easier. You don't have the same number of vertices in each model, and my above method assumes it did. Wasn't a total waste of time though becuase I can use it for my stuff.
The old ghost method works with a trick though. Don't know why, but objects exported from CShop don't need the trick. Here's the code.
Rem Project: cshop multitexturing
Rem Created: 29/09/2010 17:23:27
Rem ***** Main Source File *****
`Spacekey cycles blend modes. mode 4 should emulate old method
`Controlkey rotates models
`cartography shop outputs 2 models
`"standard" way to use these in DBP is to have 2 models, making the lightmap model dark ghosted.
`Am combining models and using blendmapping, although a shader could be used for more flexibility.
`Will work if mesh data is the same apart from UVs
`have left in some stuff that is not required - like 1st index (0/1) in vertcount.
`this is because may be useful if testing this code with models from other lightmappers.
set display mode desktop width(),desktop height(),32,1
sync on
sync rate 0
autocam off
#constant world_object 1
#constant lightmap_object 2
#constant lm_image 4
REMSTART
load object "test2.x", world_object
load object "test2_lm.x", lightmap_object
load image "test2_1.bmp",lm_image
REMEND
load object "castle_of_chaos/CastleOfChaos.x", world_object
load object "castle_of_chaos/CastleOfChaos_lm.x", lightmap_object
load image "castle_of_chaos/lol.Xlm1.BMP",lm_image
`load object "multi texture test 2/test.x", world_object
`load object "multi texture test 2/test_lm.x", lightmap_object
`load image "multi texture test 2/test_1.bmp",lm_image
position camera 0,20,-50
point camera 0,0,0
set object light world_object,0
set object light lightmap_object,0
`just count limbs and vertices
dim vertcount(1,1000)
limb=0
total_vcount=0
total_icount=0
while limb exist(world_object,limb)
lock vertexdata for limb world_object,limb,0 `last flag?
vertcount(0,limb)=get vertexdata vertex count()
inc total_vcount,vertcount(0,limb)
inc total_icount,get vertexdata index count()
unlock vertexdata
inc limb
endwhile
worldobj_limbs=limb `not limb-1 because limb 0 is a limb
limb=0
total_vcount_lm=0
total_icount_lm=0
while limb exist(lightmap_object,limb)
lock vertexdata for limb lightmap_object,limb,0 `last flag?
vertcount(1,limb)=get vertexdata vertex count() `ONLY USED TO DISPLAY TO SCREEN
inc total_vcount_lm,vertcount(1,limb)
inc total_icount_lm,get vertexdata index count()
unlock vertexdata
inc limb
endwhile
lmobj_limbs=limb `not limb-1 because limb 0 is a limb
`simple solution.
ghost object on lightmap_object,1
ghostscalefactor#=0.995 `play with this. too close to 1 and will get zfighting.
`too far away and other objects on the castle may pass though shadow object.
cx#=camera position x()
cy#=camera position y()
cz#=camera position z()
ox#=object position x(world_object)
oy#=object position y(world_object)
oz#=object position z(world_object)
position object lightmap_object,cx#+(ox#-cx#)*ghostscalefactor#,cy#+(oy#-cy#)*ghostscalefactor#,cz#+(oz#-cz#)*ghostscalefactor#
scale object lightmap_object, 100.0*ghostscalefactor#,100.0*ghostscalefactor#,100.0*ghostscalefactor#
do
for limb=0 to worldobj_limbs-1
text 0,20+10*limb,"WRLDOBJ LIMB "+str$(limb)+" HAS "+str$(vertcount(0,limb))+" VERTS"
`text 0,200+10*limb,"WORLDOBJ "+str$(limb)+":"+limb texture name(world_object,limb)+":"+limb texture name(world_object,limb,1)+":"+limb texture name(world_object,limb,2)+":"+limb texture name(world_object,limb,3)+":"+limb texture name(world_object,limb,4)+":"+limb texture name(world_object,limb,5)+":"+limb texture name(world_object,limb,6)
next limb
for limb=0 to lmobj_limbs-1
text 400,20+10*limb,"LMAPOBJ LIMB "+str$(limb)+" HAS "+str$(vertcount(1,limb))+" VERTS"
`text 0,200+10*limb,"WORLDOBJ "+str$(limb)+":"+limb texture name(world_object,limb)+":"+limb texture name(world_object,limb,1)+":"+limb texture name(world_object,limb,2)+":"+limb texture name(world_object,limb,3)+":"+limb texture name(world_object,limb,4)+":"+limb texture name(world_object,limb,5)+":"+limb texture name(world_object,limb,6)
next limb
text 0,0,"base model has "+str$(worldobj_limbs)+" LIMBS AND "+str$(total_vcount)+" vertices"
text 400,0,"lightmap model has "+str$(lmobj_limbs)+" LIMBS AND "+str$(total_vcount_lm)+" vertices"
text 0,10,str$(total_icount)+" indices"
text 400,10,str$(total_icount_lm)+" indices"
t=leftkey()-rightkey()
turn object left world_object,t
turn object left lightmap_object,t
sync
loop
Your models do have the same number of indices though. Think this means they have the same poly count. Counterintuitively the lightmap model has more verts. Maybe you could get a blendmap working by matching up the vert positions, or the polys. Big job though. Perhaps by welding stuff in a modelling program you could get stuff to match.
I imagine you just want this working though. When I read "fused together" in your first post I went off on one.