loading meshes

Blitz3D Forums/Blitz3D Beginners Area/loading meshes

olo(Posted 2008) [#1]
hi all, i have made some models in blitz3d and would like to incorporate them to a game i am working on.

The question is...do i have to copy and paste all the code where all the other stuff is or can i simply save the model i made(.bb) and then load it into the game using
model=LoadMesh("model.bb")


please tell me if i can do this, i have tried but the model didnt show. Does anyone know what i am doing wrong?

thanks


Xak(Posted 2008) [#2]
I do not believe that it is possible to load a .BB file using the LoadMesh() command. You may want to try using the Include command, instead.

For example:
Include "model.bb" 



puki(Posted 2008) [#3]
Models often do not show in Blitz3D. Quite often it is due to scaling - ie the model is too big or too small and it needs to be scaled, which Blitz3D can do.

When loading a model into B3D, it's always handy to use PointEntity camera,entity - at least then you have an idea of where your model is. Try moving the camera on the Z plane - PositionEntity camera blah, blah, Z - to move the camera in and out of the scene - if the model is too big, you need to move the camera out of the scene.

If this doesn't work then you will need to mess around with ScaleEntity.


olo(Posted 2008) [#4]
this is what i have:
Graphics3D 1280,800
SetBuffer BackBuffer()

light=CreateLight()

cam=CreateCamera()


model=LoadMesh("model.bb")
PositionEntity model, 0,0,6
ScaleEntity model, 0.3,0.3,0.3


While Not KeyDown(1)

RenderWorld

Flip

Wend

End


When i try this, an error pops up saying 'Entity does not exist'.

Oh and, i am not familiar with the 'Include' command. Can someone please tell me what i put after i wrote
Include "model.bb"
as i dont know.

thanks anyway


Naughty Alien(Posted 2008) [#5]
your command for loading model should be
MODEL=LoadMesh("Model.b3d")
or
MODEL=LoadMesh("Model.3ds")
or
MODEL=LoadMesh("Model.x")


Ross C(Posted 2008) [#6]
If you are creating a blitz model, inside blitz, you only need to include the .bb file that creates.


i have made some models in blitz3d



How have you made models in blitz3d? Out of primatives shapes? By manually coding vertex positions and creating triangle? Or, do you mean you have made a model FOR blitz in a modelling package?

If you could answer that, we can help you better.


olo(Posted 2008) [#7]
i have made models using spheres and cubes. Then just positioned them to make a model


Cp(Posted 2008) [#8]
put the code for making a model in a function, then include the .bb file.
Use the function for the model in the new program, then it will work.
example:
include "model.bb"
DrawModel() ;user made function to draw the model from the include
waitkey()

and this is kind of what model.bb should look like
Function DrawModel() ; you have to put the code in a function to use it
sphere = createsphere()
posionentity sphere 0,0,0
End Function



olo(Posted 2008) [#9]
i dont know why, but it still doesnt work :(
i did what you said, Cp, but when i try to run the program, it says 'unable to open include file'

does anyone know why this is not working?


Ross C(Posted 2008) [#10]
Step by step:

1. Write code for positioning/creating your model.
2. Save it as model.bb. Make sure it's saving in the same folder as the code that is including it.
3. Include the file into your main code.

OR

1. Write code for positioning/creating your model.
2. Put this code in a function.
3. Simply copy the function to your main code.
4. call the function to create your model.

Both steps will work fine.


olo(Posted 2008) [#11]
Yess, it works now, thanks so much Ross!


Ross C(Posted 2008) [#12]
Good stuff!