b3d Pipeline and Helpers

Blitz3D Forums/Blitz3D Programming/b3d Pipeline and Helpers

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

LoadAnimMesh loads a mesh hierarchically - when you load a mesh this way and try to apply collision, you need to apply the collsion type to each child in the model / scene.

To do this, load the map with loadanimmesh, then parse all the child objects, like this:

map = LoadAnimMesh("map.b3d")

ent = citymap
While ent
    EntityType(ent, COLL_TYPE_MAP)
    ent = NextChild(ent)
Wend

You need this function from the code archives too - credit to Beaker.
Function NextChild(ent)
	If CountChildren(ent)>0
		Return GetChild(ent,1)
	EndIf

	Local foundunused=False
	Local foundent = 0, parent,sibling
	While foundunused=False And ent<>0
		parent = GetParent(ent)
		If parent<>0
			If CountChildren(parent)>1
				If GetChild(parent,CountChildren(parent))<>ent
					For siblingcnt = 1 To CountChildren(parent)
						sibling = GetChild(parent,siblingcnt)
						If sibling=ent
							foundunused = True
							foundent = GetChild(parent,siblingcnt+1)
						EndIf
					Next
				EndIf
			EndIf
		EndIf
		ent = parent
	Wend
	Return foundent
End Function


If you have placed the 'helpers' (waypoints?) in the map, you could use a naming convention like "waypoint_1", and then in the While loop above, use EntityName$(ent) to determine if the object is a placeholder (in which case you can hide it / not apply collisions to it).