예제 #1
0
파일: scene.gt.go 프로젝트: go3d/go-ngine
func (me *Scene) AddNewChildNode(parentNodeID, meshID int) (childNodeID int) {
	childNodeID = -1
	if me.allNodes.IsOk(parentNodeID) {
		me.nodeCount++
		childNodeID = me.allNodes.AddNew()
		me.allNodes[childNodeID].parentID, me.allNodes[childNodeID].Render.meshID = parentNodeID, meshID

		if len(me.allNodes[parentNodeID].childNodeIDs) == cap(me.allNodes[parentNodeID].childNodeIDs) {
			if len(me.allNodes[parentNodeID].childNodeIDs) > 0 {
				uslice.IntSetCap(&me.allNodes[parentNodeID].childNodeIDs, 2*len(me.allNodes[parentNodeID].childNodeIDs))
			} else {
				uslice.IntSetCap(&me.allNodes[parentNodeID].childNodeIDs, sceneNodeChildCap)
			}
		}
		uslice.IntAppendUnique(&me.allNodes[parentNodeID].childNodeIDs, childNodeID)
		me.ApplyNodeTransforms(childNodeID)

		var view int
		var rts *RenderTechniqueScene
		for canv := 0; canv < len(Core.Render.Canvases); canv++ {
			for view = 0; view < len(Core.Render.Canvases[canv].Views); view++ {
				if rts = Core.Render.Canvases[canv].Views[view].Technique_Scene(); rts != nil && rts.Camera.sceneID == me.ID {
					rts.Camera.initNodeCamData(me.allNodes, childNodeID)
				}
			}
		}
	}
	return
}
예제 #2
0
func (me *MeshBuffer) Add(meshID int) (err error) {
	if mesh := Core.Libs.Meshes.get(meshID); mesh != nil && mesh.meshBuffer != me {
		if mesh.meshBuffer != nil {
			err = errf("Cannot add mesh '%v' to mesh buffer '%v': already belongs to mesh buffer '%v'.", mesh.Name, me.Name, mesh.meshBuffer.Name)
		} else {
			uslice.IntAppendUnique(&me.meshIDs, meshID)
			mesh.gpuSynced, mesh.meshBuffer = false, me
		}
	}
	return
}