Can't

Blitz3D Forums/Blitz3D Beginners Area/Can't

Guy Fawkes(Posted 2014) [#1]
Hi all. I have saved the "Middle Earth" terragen file as a B3D file from Krischan's BlitzTiles project. I then try to import it into my project with the EntityPickMode() set at EntityPickMode(mymesh, 2, 1), and I can't pick it at all for some reason, even though I CAN pick a giant object such as Psionic's Dwarf model (which loads huge, btw) easily & perfectly, with no problem at all.


Rob the Great(Posted 2014) [#2]
Kind of a dumb question, but are you calling UpdateWorld()? I believe that picking requires this to be called.

I just tested picking a terrain on my computer, and I ran into no problems. Here's what you need for a picking test:
Graphics3D 640,480
SetBuffer BackBuffer()

;Load the Middle Earth terrain here
terrain=LoadTerrain( "MIDDLE EARTH.bmp" )
EntityPickMode terrain,2,1

PickingEntity = CreatePivot()
MoveEntity PickingEntity 1,1,1 ;Do this to avoid potential picking bugs

;This is a large picking radius and will probably slow down
;the computer. Only use this for testing.
Picked = EntityPick(PickingEntity,1000000)

UpdateWorld

RenderWorld

If Picked
	Text 0,0,"Picked"
Else
        Text 0,0,"Not Picked."
EndIf

Flip
WaitKey()

If this program displays the text "Picked", then it's working and it's probably a program with the code's logic. If it displays "Not picked", then I'm not sure what's going on.


Guy Fawkes(Posted 2014) [#3]
Erm, @Rob, thank you, but the terrain is a B3D file :P


Imperium(Posted 2014) [#4]
Correct me if I am wrong but a MESH is not really a terrain file according to blitz3d. Terrains in blitz3d tessellate according to the parameters specified. A mesh does not tessellate but you can incorporate LOD if you want.

Terrains are made from a heightmap of black and white images. You can manually tweak the vertexes allowing for higher or lower terrain. This has helped my terrain look a lot smoother as opposed to jagged in my earlier experiments.

Rob is correct and if that code works then PICK should be working.


Rob the Great(Posted 2014) [#5]
@Guy Fawkes, Right. I see that now in your post. I saw the word "terrain" and just glanced over everything else.

In that case, switch
terrain=LoadTerrain( "MIDDLE EARTH.bmp" )
with
terrain=LoadMesh( "MIDDLE EARTH.b3d" )
and it should have the same effect.

I take it that you know how to set up picking based on your recent posts, so there's nothing else I can offer for help. I would need to know more about the code and the file itself before I would know where to begin.

EDIT: Ninja'd by NostalgicAlgorithms. Basically what he said.


Guy Fawkes(Posted 2014) [#6]
Erm, @Rob, thank you but the terrain is a B3D file :P Also, it has WAY more than 65535 triangles & for some reason it's causing a crash abnormally. I have made a zip file so you can see what I mean. NOTE: It WILL take some time to load (like 1 minute) so please be patient.

Here's the code:



http://www.mediafire.com/download/opkayrbwh0032sf/terrain.zip

Thank You all!


Imperium(Posted 2014) [#7]
I know their is a vertex limit for .3ds files as I have hit this limitation myself. Does anyone know the limit if any for B3d models? You may have to split up that Terrain mesh into two or more sections.

Consider also setting a camera and adjusting the "Camera range" for the player camera. That way your not rendering all those triangles at once. It doesn't look like a taxing amount of triangles as my own project can show well over that amount even on really dated hardware. I would try breaking up the mesh into 2 sections and see if it still crashes.


Rob the Great(Posted 2014) [#8]
I can get the program to run without splitting the model, but I can't get it to pick. I'm not sure where the problem lies, but it's spiked my curiosity, so I'm going to play around with the program and see what I can find out.

By the way, I'm very impressed with the model. Whoever designed it did a kick-a** job.


Guy Fawkes(Posted 2014) [#9]
How would I do that? Not to sound rude or anything, but that however, doesn't answer my first question.


Rob the Great(Posted 2014) [#10]
I've been doing some stress tests for a while, and on my machine, I can render a maximum of 65,536 vertices per surface. I can't seem to find a limit to the number of triangle per surface or surfaces per mesh. What's strange is that I can load the model (well beyond the vertex limit) and render it just fine. Even with a large camera range, I can still render the model. I'm not sure how Blitz handles loading large meshes like this, but it's doing something to get around this limit.

If I exceed the vertex limit through meshes created within Blitz, the program reports a MAV on RenderWorld. I cannot get it to fail with pick commands based on the limits of the vertices. So my thoughts are that the picking commands fail if the loaded model exceeds a certain vertex size. Whether or not this is the case, NostalgicAlgorithms is correct in that your first step should be to split the model into sections. This is likely to fix the problem. I don't have modelling software that can import .b3d files, so I am unable to test this myself.


Guy Fawkes(Posted 2014) [#11]
True, but I'm more worried about not being able to select the terrain... I need to be able to create some kind of thing maybe around the terrain, which allows me still to select the terrain without any cause for problems...


RemiD(Posted 2014) [#12]
I don't think updateworld is necessary for linepick.
Updateworld is necessary to update animations and to calculate collisions detection and response.

If linepick does not work on a high tris mesh, you may want to try :
http://www.blitzbasic.com/codearcs/codearcs.php?code=369
http://www.blitzbasic.com/codearcs/codearcs.php?code=793


Guy Fawkes(Posted 2014) [#13]
Thank You, but I need to be able to use CameraPick OR another way of picking 3d objects with 2D coordinates.

I basically need CameraPick() to work no matter how big an object, or what type of object it is.


Imperium(Posted 2014) [#14]
Just curious are you trying to make an RTS game?


Guy Fawkes(Posted 2014) [#15]
No, it's actually a program I'm building. Which would be done if CameraPick() were working on all objects regardless of size or shape ><


Mikorians(Posted 2014) [#16]
Try testing it with camera/mouse pick?
Then you can SEE if there's a problem.
If camera pick works, then use a fake camera (move it around, then back)
(Talking into my hat, don't know)


Guy Fawkes(Posted 2014) [#17]
I did test it with camera/mouse pick. There was still a problem :(


Mikorians(Posted 2014) [#18]
I had problems picking entities from a loadanimmesh where the child entity was not specifically chosen as a pick entity. 'Scene_Root' was a pivot, not a mesh.
Hexedit the file and make sure there are no parent pivots in the way, this will also allow you to address the SPECIFIC mesh BY NAME with x=findchild(ent,"bobmesh")


Guy Fawkes(Posted 2014) [#19]
hex edit? i follow this one rule:

K.I.S.S.

Keep it simple, stupid.

Is there a way around this terrible bug for camerapick()?


RemiD(Posted 2014) [#20]
Maybe you could convert the pixel 2d coordinate to the world 3d coordinate to have the coordinate of a PointA with something like this :
http://www.blitzbasic.com/Community/posts.php?topic=62658
or
http://www.blitzbasic.com/codearcs/codearcs.php?code=379
or
http://www.blitzbasic.com/Community/posts.php?topic=49109 #8

Then calculate the coordinate of a PointB. (with TFormPoint ?)

Then calculate the vector PointB-PointA (instead of linepick).

Then use the sswift function or the Coldet function to calculate if the linepick has hit a triangle and if yes, which triangle and at which U,V or near which vertex.


Floyd(Posted 2014) [#21]
Here's my guess. ( It is just an untested guess. )

You use polygon mode picking, so you need to pick a mesh. I had a look at your b3d file. It contains 256 meshes, totaling about 1.4 million vertices.

Using EntityPickMode on the loaded b3d probably just makes the first mesh pickable. Unless it happens to be in front of your picking entity EntityPick won't find anything.

You could try wading through the loaded b3d and making making each mesh pickable. If this works it will probably be slow.

Look on the Specs and utils page for details about the b3d file format. There is a description and some sample code. The code includes a "dump b3d" utility, which is how I found out there are 256 meshes.


Guy Fawkes(Posted 2014) [#22]
Ok, so is there a way I can put an invisible cube around it, pick the invisible cube instead, but apply the changes to the mesh itself? If so, how would I do that? Is there an example using my mesh that I can see to see if this works? Thank You all so kindly!


Mikorians(Posted 2014) [#23]
Yeah, your b3d is loaded with nodes named XnYn
But no scene_root parent node - this can cause a LOT of problems I've noted. Procedural b3d file creators don't often work very well and can be sloppy.

Try addressing them as child objects.

x=loadanimmesh("terrain.b3d")
for x=0 to nnnx
for y=0 to nnny
c=findchild(x,"X"+str(x)+"Y"+str(y))
entitypickmode c,2,1
next
next

Use the above method when checking for picks also.
You may have better luck.

Or, you COULD try to make a cube around it and make it as you suggested.
entityalpha cube,0
I belive they're still picked.
Use these on the LOADMESH function- not the loadanimmesh:
MeshWidth#(mesh),MeshHeight#(mesh), and MeshDepth#(mesh)
are functions you could use with the center being at
EntityX#(entity,true),... etc.

cube=createcube()
scaleentity cube,mw,mh,md
positionentity cube, x,y,z,true

[EDIT]
OOPS, I noticed you meant to change the terrain underneath.
You're probably going to need to alter your .b3d file to make it work.
Let me see what I can do with the thing...
[UPDATE]
That is a HUGE file, but none of the individual pieces are over 10K tris.
I would have busted it up into its individual parts, myself.
I can barely use this at all. It's over 400K tris total. My largest map
(and it's too big) is 39K.
[ANOTHER TIP]
Yeah, I'd bust that up. Each segment has over 200 textures applied to it also.
[LAST TIP]
In whatever modelling program you used to make this-
Make a parent object for THE WHOLE SCENE, and see if it works better after
you export it again.


Guy Fawkes(Posted 2014) [#24]
Well, can you show me a small example of how to bust it up and pick it as one object as opposed to picking each "piece" of the terrain? Thank You!


Mikorians(Posted 2014) [#25]
Oh. I assumed you'd modeled the file. This is a borrowed b3d, ergo, you don't have a 3d modeling application such as 3D-Studio Max 5 (what I use) to edit it with.
This is fundamental (like notepad or IE for browsing) for working with such large magnitude files.
You could try one of the free ones like Blender or something.
(I didn't care for any of them, and these programs can be pricey)
I don't have anywhere to post the pieces (can't) or I'd've done it for you.
I can see why you like the file. ;)


Mikorians(Posted 2014) [#26]
I'd be happy to help you figure out how to pick it piece by piece and traverse it, but then-
That would be like an engine... I'm still finishing mine. 30 years...
I will be happy to continue to provide moral support an tips-
Nobody really did that for me.


Guy Fawkes(Posted 2014) [#27]
@Mikorians, It would be helping me out big time to come up with a simple solution to fix this huge problem. I'll add your name to the credits if you wish.


Guy Fawkes(Posted 2014) [#28]
Light bump


Omnicode(Posted 2014) [#29]
bust it up and pick it as one object

I cant put together an example of exactly how to do it (seeing as i dont have your code nor models to partake and have a knock at it) but i can explain a method that could work with your current situation.

"Bust it up" - when you have an exceptionally large model it works better to parse through sections of it at a time rather than the bulk, as most of the model isn't even being displayed (which may interfere with picking as it clips the model) on the screen if its as vast as a terrain should be.

Breaking it up allows you to display these sections when needed.
-Method for this is running a routine that breaks it up into 'chunks' like an 16x16 area or whatever you'd like that would identify a given section. (Depends on if the terrain is even to the power of 2)

Then set that aside as a section, do this for the whole terrain storing them within an array and allowing easy access to redistribute and identify each section that is picked by cycling through that array and seeing if it matches any that are displayed atm, if true, that object is picked.

You can still assign a pickmode to them as they are a mesh/entity and in turn would still return the object being picked.


Guy Fawkes(Posted 2014) [#30]
This is a link to the model:

http://www.mediafire.com/download/opkayrbwh0032sf/terrain.zip

This is the source:



It won't load for some reason, but when it DID load, I couldn't pick it with my mouse BECAUSE it was so big.

Also, when you end, it's so big, it will crash when you exit the program.

Please help me!

Thank You!


Mikorians(Posted 2014) [#31]
Sorry for the delay. Been so busy.
Another diagnostic question (sorry they're one at a time and agonizing in delay)
I've been there too.

Which OS are you using?
I don't recall a crash when I displayed it. I could be wrong...
I was using 98 before and it was NO GOOD with large scenes.


Guy Fawkes(Posted 2014) [#32]
Windows 8 (x64)


Mikorians(Posted 2014) [#33]
Ya. Crashes. No outer scene root node...
Would you like me to process your mesh into pieces?
I'll get started and see where I can upload them.
I will examine your data and attempt to make a fix for you.
If it works, I have code that might fix the the Terragen exporter to spit out smaller parts for you, or a large file that might be more usable. (See free landscape editor post I made)
[UPDATE]
Yeah, scene root fixed crash- so nasty!
Attempting collision checks...
You'll be happy to hear the patient is doing fine... Pick mode worked for me on the giant file.

The ONLY thing wrong was the lack of a scene root container node.
You might not want this b3d file. Max exported it at 81MB with possible vertex weld issues (seams). This vs the 16 you started with. I don't know if I can use hosting for that.
The problem is the b3d exporter that was used. As usual (my experience).
Let me now examine the exporter link you had... Hm...


Mikorians(Posted 2014) [#34]
Here. Try this replacement for the now INFAMOUS (IMHO)
WriteBB3D function in the BlitzTile.bb program:

Blitztiles.bb in your package.





SO, PEOPLE: Just put a Scene_Root node around all your other nodes in the scene and - Make your troubles... GO AWAY!!!!