linepick a mesh within a mesh

Blitz3D Forums/Blitz3D Programming/linepick a mesh within a mesh

cash(Posted 2006) [#1]
I have searched the forums but cannot find the answer so any help would be appreciated.

I have a single NON animated level mesh

Each item in the mesh has a name. The mesh is exported as a .b3d.

Is it possible to find the individual items and pick them?

I dont really want to have to load each item as an individual mesh.


Hujiklo(Posted 2006) [#2]
Yes - load the mesh as an animmesh and then you'll have access to all the tiny parts as children...set them to pickable using the true or false flag when you set your mesh to pickable.

Look up the enity child /parent commands for lots of juicy commands for getting access to children and their data.


cash(Posted 2006) [#3]
So its a non animated model and I load it with loadanimmesh. This loads fine.

Still cant find the child entities though.

Exported from Milkshape as b3d. The name in milkshape for the item is "chair"

So ensuring case sensitivity I use

chair1=FindChild(level1,"chair")
EntityPickMode chair1,2,True

I dont think its working.


BlitzSupport(Posted 2006) [#4]
Is the value of 'chair1' zero or non-zero after the FindChild call?


cash(Posted 2006) [#5]
I have a variable ch=0

When it is picked it should change to 1.

It doesn`t work.

Is there any easy way to check if it is found as such ?


I opened the b3d file in notepad and cannot find any reference to the names in the original Milkshape model. Is this normal ?


Hujiklo(Posted 2006) [#6]
use the 'countchildren' command and find out how many children you mesh has.
It may be that you simply have to recurse through the entire mesh hierarchy before you get to the child you want.
I ripped this from my own code (something similar is available in the code archives too) you should be able to adjust it to find your exact mesh




cash(Posted 2006) [#7]
Well the bad news is I still cant get this to work.

All I want it to "do something" to an object within my main mesh. There are no animations but it is loaded as an animmesh.

I don`t think the code can read the .b3d file objects as individual items.

I read about openng it in notepad and checking the names. The names do not appear in plain text but the textures do.

I guess unless there is a simple answer, I will need to load clear meshes individually at the correct points to interact with.

Any last possibilities. (Thanks for the help so far though).


Stevie G(Posted 2006) [#8]
Sounds to me that all your objects form a single mesh but each object has a separate surface. You can confirm this by checking the pickedsurface() results which should differ when you click on each object.

Problem here is that you won't then be able to manipulate the other objects as you would a normal entity.

I think you have to look again at how you're saving the original mesh as you should be able to do this correctly keeping the mesh heirarchy intact. What modeller are you using?

Sorry I can't be of more help.
Stevie


cash(Posted 2006) [#9]
I am using Milkshape then export to b3d.
eg A cube would be broken down into 6 "squares" and textured.
Perhaps this is where it goes wrong. The cube is infact 6 surfaces.


b32(Posted 2006) [#10]
If that is the case, you could copy each surface to a new object. I think it could be the pickmodes. Try this function maybe:
Function SetPickMode(mesh, mode)

	EntityPickMode mesh, mode
	For i = 1 To CountChildren(mesh)
		SetPickMode GetChild(mesh, i), mode
	Next
	
End Function

->SetPickMode level1, 2


cash(Posted 2006) [#11]
As a quick test I created a model which contained 4 cubes and nothing else. I left the cubes as "whole" items and did not modify them in anyway. There are not textures assines and no joints/animations.

I gave each cube a unique group name in Milkshape, cube1,cube2 etc.

Exported to b3d and loaded using loadanimmesh.

Voila, the cubes all appear in a nice grey colour.

But I still cant seem to do anything with them as "child" objects. "Error object not found".

global level1=loadanimmesh("cubes.b3d")

global c1= findchild(level1,"cube1")


Main loop

various other code

if keydown(K_a) then entityalpha c1,0
if keydown(K_s) then entityalpha c1,1

end main loop


The above code is just a sample similar to what I am trying to test with.

What annoys me is that I am working with much more complex code than this no problem, but this child stuff is really starting to bug me.

Am I right in thinking findchild does not need a recursive check ?

What is the difference between getchild and findchild in coding terms ?

Sorry if I sound crazy. I have been using Blitz3d for a few years now and am working towards a largish game. This is something that would greatly simplify the level creation / picking process.....


Matty(Posted 2006) [#12]
Milkshape does not store different objects in the same file as children when exported to b3d, as far as I remember. Only bones created in milkshape are treated as children by b3d. You may have to try another modeling tool. However - in Giles (lightmapping program) each individual object can be exported as children.