Finding child entities of a model created in UU3D

Blitz3D Forums/Blitz3D Beginners Area/Finding child entities of a model created in UU3D

Blitzplotter(Posted 2009) [#1]
I have been having some problems trying to identify individual faces of a model I created within UU3D, to update the sides of a cube programmitically within B3D.

I suspected that my file maybe was not being saved/exported properly from UU3D. I used the following code to analyse my .b3d file, the only child entities returned were:

ROOT_UU3D

The file in question has had individual groups assigned to each side on the model within B3D, i.e. under the Groups expander I have Box, front, back, side1, side2, top and bottom.

[LAST...EDIT] solved now.... big thankyou to Ross for his help - see post #9 scroll down a bit to see the cuboids with various (albeit unimaginative) images applied via code.



[EDIT] - resolved this......:Why can't I see these as child entities using the code below and I only see ROOT_UU3D ?


[EDIT] seem to have resolved it by saving as B3D extension with multiple textures option selected. I now am getting the child entities.

How can I apply an image to one of the child entities identified upon loading - thanks.
, trying to use the following somehow:


This may depend on your model - and how you designed each face and named them.

You can 'face=FindChild(entity,"face name")' - then texture each face.






Ross C(Posted 2009) [#2]
Hmm, your code is quite confusing to follow...

You don't need to create brushes, in order to texture these entities. Find child seperates each mesh into an individual entity, so:

Topside = findchild(main_mesh,"topside")

texture_top = loadtexture("topside.png")

Entitytexture topside,texture_top


Should do the trick...?


Blitzplotter(Posted 2009) [#3]
thanks Ross, sorry about the confusing code its kind of work in progress.....


Ross C(Posted 2009) [#4]
Did it work ?


Blitzplotter(Posted 2009) [#5]
Not so far, some reason my entity has stopped rotating also, but still move up/down & left right ?

However I did achieve my goal of producing a 3d box of my software product, so thankyou for that.

I just got a bit fixated on wanting to change the sides of a cuboid ( well its a kind of cereal box sized cube), and I think I'm close.

If you find a child of an entity is it possible to obtain the x and y sizes of the child ? Or do you just get a memory location and you have to ensure your image you are attempting to apply is exactly the same dimensions?

here is the code to date:




Ross C(Posted 2009) [#6]
I'm slightly confused here. You are loading two meshes, both the exact same. So, they surely must be overlapping. Try the below code and see what you get. You should see another cube, textured with the texture for the top side.

;--- attempt To paint different sides of a box with different images ----

;--- v4 attempt to apply images to sides of a model

;---v5

;You don't need to create brushes, in order to texture these entities. Find child seperates each mesh into an individual entity, so:
;
;Topside = findchild(main_mesh,"topside")
;
;texture_top = loadtexture("topside.png")
;
;Entitytexture topside,texture_top
;
;--- end versions

Graphics3D 640,480,0,2 
SetBuffer BackBuffer() 

camera=CreateCamera() 
PositionEntity camera,0,2,-5

filepath$=("H:\TORTOISE\top_level_tort_check_ootski\UltimateUnwrapProjects\try_b3d.b3d") 

Global mesh_with_children = LoadAnimMesh( filepath$ )


light=CreateLight() 
RotateEntity light,90,45,45


;source textures for applying to the top/side and bottom of the box
global tex_top=LoadTexture( "c:\top_box_200_x_80.png") 
global tex_side=LoadTexture("c:\side_80_x_300.png" )
global tex_bottom=LoadTexture("c:\bot_box_200_x_80.png" )
global tex_front=LoadTexture( "c:\200_by_300.png" )
 

Global top_box = FindChild(mesh_with_children,"top")
Global bottom_box = FindChild(mesh_with_children,"bottom")

Global front = FindChild(mesh_with_children,"front")


EntityTexture bottom_box,tex_top              ;not causing any compile errors but not modifying the 'top' of the box

	; test to see if texture is loading properly
		c = createcube()
		positionentity c,2,0,0
		entitytexture c,tex_top
	; end test

EntityTexture front,tex_front  


PositionEntity mesh_with_children,0,0,MeshDepth(mesh_with_children)*2 

While Not KeyDown( 1 ) 

If KeyDown( 205 )=True Then TurnEntity camera,0,-1,0 
If KeyDown( 203 )=True Then TurnEntity camera,0,1,0 
If KeyDown( 208 )=True Then MoveEntity camera,0,0,-0.05 
If KeyDown( 200 )=True Then MoveEntity camera,0,0,0.05

;move camera up and down
If KeyDown( 30 )=True Then MoveEntity camera,0,1,0  ;a
If KeyDown( 44 )=True Then MoveEntity camera,0,-1,0 ;z


If KeyDown( 49 )=True Then yaw#=yaw#-1 
If KeyDown( 50 )=True Then yaw#=yaw#+1 


RotateEntity mesh_with_children,pitch#,yaw#,roll# 


RenderWorld 

Text 0,0,"Use cursor keys to move about" 
Text 0,20,"Use a/z for camera up/down"
Text 0,40,"Use m/n for rotate the box"

Flip 

Wend 

End 



Blitzplotter(Posted 2009) [#7]
Ross, you are a star, I have moved the code you sent me forward slightly and I am very nearly there! Gotta go for a quick run before the inky blackness of night rolls in, but heres your code stepped on a little, basically I'm checking all my individually loaded textures now and applying to sides of the cuboid with some minor scaling issues. Woo Hoo!

Code:--

;--- attempt To paint different sides of a box with different images ----

;-v6.........
;v7 Ross's one with a little more....
;--- end versions

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,2,-5

filepath$=("H:\TORTOISE\top_level_tort_check_ootski\UltimateUnwrapProjects\try_b3d.b3d")

Global mesh_with_children = LoadAnimMesh( filepath$ )


light=CreateLight()
RotateEntity light,90,45,45


;source textures for applying to the top/side and bottom of the box
Global tex_top=LoadTexture( "c:\top_box_200_x_80.png")
Global tex_side=LoadTexture("c:\side_80_x_300.png" )
Global tex_bottom=LoadTexture("c:\bot_box_200_x_80.png" )
Global tex_front=LoadTexture( "c:\200_by_300.png" )


Global top_box = FindChild(mesh_with_children,"top")
Global bottom_box = FindChild(mesh_with_children,"bottom")

Global front = FindChild(mesh_with_children,"front")


EntityTexture bottom_box,tex_top ;not causing any compile errors but not modifying the 'top' of the box

; test to see if top_texture is loading properly
c = CreateCube()
PositionEntity c,2,0,0
EntityTexture c,tex_top
; end test

; test to see if bottom_texture is loading properly
d = CreateCube()
PositionEntity d,1,0,5
EntityTexture d,tex_bottom
; end test

; test to see if front_texture is loading properly
e = CreateCube()
PositionEntity e,0,0,10
EntityTexture e,tex_front
; end test


EntityTexture front,tex_front

EntityTexture top_box,tex_top


;PositionEntity mesh_with_children,0,0,MeshDepth(mesh_with_children)*2
PositionEntity mesh_with_children,0,-20,20


While Not KeyDown( 1 )

If KeyDown( 205 )=True Then TurnEntity camera,0,-1,0
If KeyDown( 203 )=True Then TurnEntity camera,0,1,0
If KeyDown( 208 )=True Then MoveEntity camera,0,0,-0.05
If KeyDown( 200 )=True Then MoveEntity camera,0,0,0.05

;move camera up and down
If KeyDown( 30 )=True Then MoveEntity camera,0,1,0 ;a
If KeyDown( 44 )=True Then MoveEntity camera,0,-1,0 ;z

If KeyDown( 24 )=True Then TurnEntity camera,0,0,-1 ;O
If KeyDown( 25 )=True Then TurnEntity camera,0,0,1 ;P


If KeyDown( 49 )=True Then yaw#=yaw#-1
If KeyDown( 50 )=True Then yaw#=yaw#+1


RotateEntity mesh_with_children,pitch#,yaw#,roll#


RenderWorld

Text 0,0,"Use cursor keys to move about"
Text 0,20,"Use a/z for camera up/down"
Text 0,40,"Use m/n for rotate the box"

Flip

Wend

End


Blitzplotter(Posted 2009) [#8]
Another Evolution, this one displays 7 cuboids - each with a different side modified. Stuck the cuboids and their child entities into an array to allow simple manipulation - contemplated a select case switch thingy but am happy with it in its current guise.


will upload media for the code if anyone wants, or might upload anyway and stick in the code archives.... ?




Ross C(Posted 2009) [#9]
Glad you got it sorted man!


Blitzplotter(Posted 2009) [#10]
Cheers Ross!


Blitzplotter(Posted 2009) [#11]
Added an image of what the code in post #8 does....