|
DeleD Community Edition Forums
|
View previous topic :: View next topic |
Author |
Message |
mappy DeleD PRO user
Joined: 18 Aug 2005 Posts: 340 Location: France
|
Posted: Sat Aug 27, 2005 5:37 pm Post subject: DeleD and Blitz Basic |
|
|
Hi,
if someone here uses DeleD and BB, maybe he could help me :
I've built a level with DeleD, then exported it with the B3D plugin.
In BB, all is fine on the screen.
The only problem I have is the following :
I can't get the x,y,z coords of individual objects (torchs) from the B3D file (using the LoadAnimMesh command). The torchs are imported objects in my DeleD map, and each is named individually in the scene tab.
It seems that my code is ok, and someone told me at the BB forums "Since it isn't, the problem is your mesh, not your code. Evidently, you've exported your objects all based around a single pivot. You're going to have to go back into your modeller and see what you can adjust to give the objects a local pivot point.".
So I'm just curious to know if someone here use BB and gets the x,y,z coords of an object correctly ?
Or maybe someone here could have a hint about that "single pivot" thing ...
We have no pivots in DeleD, have we ?
OL. |
|
Back to top |
|
|
Daaark DeleD PRO user
Joined: 01 Sep 2004 Posts: 2696 Location: Ottawa, Canada
|
Posted: Sat Aug 27, 2005 5:46 pm Post subject: |
|
|
If your level mesh contains the torches as individial objects, find the named torch objects... (write a function to find the proper objects by name) then avergage out all the x,y,z in the vertcies to find the centre midpoint, and that is your xyz of the object.
Of course, I have no clue how blitz works, and how your level is stored. |
|
Back to top |
|
|
mappy DeleD PRO user
Joined: 18 Aug 2005 Posts: 340 Location: France
|
Posted: Sat Aug 27, 2005 6:18 pm Post subject: |
|
|
Vampyre_Dark wrote: |
If your level mesh contains the torches as individial objects, find the named torch objects... (write a function to find the proper objects by name) then avergage out all the x,y,z in the vertcies to find the centre midpoint, and that is your xyz of the object.
Of course, I have no clue how blitz works, and how your level is stored. |
Hi Vampyre,
I have no problem finding my torchs with BB, and then creating individual entities for them.
The only problem is that for BB all the objects exported in the B3D file (not only the torchs) have the same x,y,z coords ... but they all appear correctly on the screen ...
And I'm not too sure how to deal with vertices in BB for now (yes I'm a beginner here too .
|
|
Back to top |
|
|
hairyprogramer DeleD PRO user
Joined: 23 May 2005 Posts: 7
|
Posted: Sun Aug 28, 2005 12:04 am Post subject: |
|
|
Just read the dmf file that deled created to find xyz for each object.The xyz your getting is for the whole mesh I think. I don't know now to read the b3d to get the xyz of object,but in deled format its real simple to read.You'll have to avergage ot the vertex like Vampryre_dark said or you can use the object inspector and enter the xyz in the user info box using the xyz in the same window.Hope this helps. |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Sun Aug 28, 2005 7:55 am Post subject: |
|
|
I think I know what you mean, let me explain:
In DeleD, all vertices are stored in so-called World Coordinates (coordinates in World Space), so if a box runs from (100, 100, 100) - ( 120, 120, 120 ) it is stored exactly as such.
Blitz however, allows the use of Object Coordinates with a world position (and orientation). So a native blitz application would probably store the cube as ( -10, -10, -10 ) to ( 10, 10, 10 ) with the world position at ( 110, 110, 110 ). However, DeleD simply saves (100, 100, 100) - ( 120, 120, 120 ) with world position at ( 0, 0, 0 ), as that is how things are stored within DeleD.
So here is your 'problem', all objects are stored with World Coordinates and have their center at ( 0, 0, 0 ). Three solutions:
1) Load objects you want to treat separately as separate DMF's, and set their world position manually from within Blitz
2) We could give the plugin an optional 'approximate object coordinates', where it would automatically save all vertices relative to the object center. As 'object center' is an implicit concept in DeleD, this would not be ideal, but it might suit your needs.
3) Eventually, DeleD is very (very) likely to move to object coordinates anyway, so things would be the same in DeleD and Blitz, and the problem would disappear. This will take a while though, as it doesn't rank too high on our priority list.
Does that make sense? If I misread your post and it is not at all what you were talking about, please ignore everything above |
|
Back to top |
|
|
Jeroen Site Admin
Joined: 07 Aug 2004 Posts: 5332 Location: The Netherlands
|
Posted: Sun Aug 28, 2005 8:02 am Post subject: Re: DeleD and Blitz Basic |
|
|
mappy wrote: |
I can't get the x,y,z coords of individual objects (torchs) from the B3D file (using the LoadAnimMesh command). It seems that my code is ok, and someone told me at the BB forums "Since it isn't, the problem is your mesh, not your code. Evidently, you've exported your objects all based around a single pivot. You're going to have to go back into your modeller and see what you can adjust to give the objects a local pivot point.".
So I'm just curious to know if someone here use BB and gets the x,y,z coords of an object correctly ?
Or maybe someone here could have a hint about that "single pivot" thing ...
We have no pivots in DeleD, have we ?
|
Getting a single pivot points or getting all individual vertices of an object are two different things. What is it you really want? As BB shows the level correctly, nothing is wrong with the vertices of your objects obviously. How to retrieve them in BB is beyond my knowledge. However, if you want to calculate a center point (which would be the basic pivot point) for your object, you will have to calculate the Axis Aligned Bounding Box (that's the thing you see in DeleD when you press F7 ) and get the center of that box by using the method Vampyre described. Just averaging out _all_ vertices of an object (so without using an AABB) won't really do in some cases (just imagine having a simple cube with on of the faces having 90000 vertices and the rest having only 4 vertices... can you see how this affects the center point if you only averaged out the vertices?). |
|
Back to top |
|
|
mappy DeleD PRO user
Joined: 18 Aug 2005 Posts: 340 Location: France
|
Posted: Sun Aug 28, 2005 1:00 pm Post subject: |
|
|
Hi all and thanks for your help.
I've done some searchs, and some tests, and I must say I'm a bit confused ...
but the good news is that I'm now able to retrieve all the surfaces/vertices of an object with their proper coordinates in BB !
Funny thing (?) my torchs in BB have each only 2 surfaces (!) and 206 vertices ... go figure.
But the vertices coords seem to be ok
So I'm going to calculate the average "out _all_ vertices" of my torchs, like Vampyre and Jeroen said. So how do I proceed ? Let's say I've a simple cube with 8 vertices :
0,0,0
0,0,10
10,0,10
10,0,0
0,-10,0
0,-10,10
10,-10,10
10,-10,0
Where is the center mid-point ?
hairyprogramer : good idea to parse the dmf file, could be helpful in the future.
Jeroen : what kind of cube could have 90000 vertices for one of its faces and only 4 for the rest ?
OL. |
|
Back to top |
|
|
Jeroen Site Admin
Joined: 07 Aug 2004 Posts: 5332 Location: The Netherlands
|
Posted: Sun Aug 28, 2005 1:07 pm Post subject: |
|
|
Just add all components of all vertices together and divide them with the number of vertices. For example:
Code: |
x = 0
y = 0
z = 0
for i = 0 to numVertices do begin
vertice = allVertices[i] // allVertices being an array containing all your vertices
x = x + vertice.x
y = y + vertice.y
z = z + vertice.z
end
x = x / numVertices
y = y / numVertices
z = z / numVertices
|
But do remember that this method won't work in all cases. Agreed, my previous example about a cube having a 9000 vertices face wasn't a good one, but I think you get my point. |
|
Back to top |
|
|
mappy DeleD PRO user
Joined: 18 Aug 2005 Posts: 340 Location: France
|
Posted: Sun Aug 28, 2005 4:04 pm Post subject: |
|
|
Thank you and yes I got your point |
|
Back to top |
|
|
Daaark DeleD PRO user
Joined: 01 Sep 2004 Posts: 2696 Location: Ottawa, Canada
|
Posted: Sun Aug 28, 2005 4:28 pm Post subject: |
|
|
Jeroen wrote: |
Code: |
x = 0
y = 0
z = 0
for i = 0 to numVertices do begin
vertice = allVertices[i] // allVertices being an array containing all your vertices
x = x + vertice.x
y = y + vertice.y
z = z + vertice.z
end
x = x / numVertices
y = y / numVertices
z = z / numVertices
|
|
I wanted to type that out in my first reply, but I couldn't remember Basic syntax. Even though, I used Basic from 1998-2000. |
|
Back to top |
|
|
Jeroen Site Admin
Joined: 07 Aug 2004 Posts: 5332 Location: The Netherlands
|
Posted: Sun Aug 28, 2005 5:57 pm Post subject: |
|
|
Vampyre_Dark wrote: |
I wanted to type that out in my first reply, but I couldn't remember Basic syntax. Even though, I used Basic from 1998-2000. |
It's not really Basic syntax but just pseudocode with some Basic and Pascal elements mixed. I use Delphi for DeleD (of course!) and Basic variants at my daily job so go figure...
Last edited by Jeroen on Tue Aug 30, 2005 11:03 am; edited 1 time in total |
|
Back to top |
|
|
inquisitor DeleD PRO user
Joined: 30 Aug 2005 Posts: 4 Location: Lyon, France
|
Posted: Tue Aug 30, 2005 11:00 am Post subject: |
|
|
hi,
i have the same probleme ( coord. retrieving ).
can you give me the portion of the code that let you to retrieve your object coord.
so,
u have another problem with b3b exporter.
if i want to add a light into a scene create & exported in B3d with DeleD in blitzbasic, the light does not appear. but if i export the same scene in .X format the light appear.
anyone have an idea ?
thanks. |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Tue Aug 30, 2005 7:27 pm Post subject: |
|
|
Yes, I think I could throw an educated guess at that
As far as I know, B3D doesn't support storage of lights, so the B3D exporter doesn't export them. If I am wrong here, please correct me and point me to a resource that describes how to store the lights within the file.
Please remember development is an ongoing process, especially where the plugins are concerned. If you find a feature missing, don't think "ah bummer there is a feature missing", request it! Without user feedback, we developers are quite lost |
|
Back to top |
|
|
mappy DeleD PRO user
Joined: 18 Aug 2005 Posts: 340 Location: France
|
Posted: Wed Aug 31, 2005 7:52 am Post subject: |
|
|
inquisitor wrote: |
hi,
i have the same probleme ( coord. retrieving ).
can you give me the portion of the code that let you to retrieve your object coord.
so,
u have another problem with b3b exporter.
if i want to add a light into a scene create & exported in B3d with DeleD in blitzbasic, the light does not appear. but if i export the same scene in .X format the light appear.
anyone have an idea ?
thanks. |
Hi, for retrieving the "center" point of an entity in BB :
For i = 1 To CountSurfaces(entity)
surf = GetSurface(entity,i)
nb_vert = CountVertices(surf)
tot_nb_vert = tot_nb_vert + nb_vert
For j = 0 To (nb_vert - 1)
x = x + VertexX(surf,j)
y = y + VertexY(surf,j)
z = z + VertexZ(surf,j)
Next
Next
--> then the coords are : x/tot_nb_vert,y/tot_nb_vert,z/tot_nb_vert
For the lights export, I don't know really, as I haven't worked with lights for now.
But I know that gile(s) exports lights with tags in the b3d file ([light] and [/light]).
Then the lights are retrieved parsing the b3d file in BB ...
So maybe you may have to look at the b3d file generated by DeleD and see if you can do the same ... I don't know
Hope this helps.
OL. |
|
Back to top |
|
|
inquisitor DeleD PRO user
Joined: 30 Aug 2005 Posts: 4 Location: Lyon, France
|
Posted: Wed Aug 31, 2005 3:53 pm Post subject: |
|
|
Thanks a lot !
For the light :
i don't talk about deled light.
I try to explain.
1. i create my 3D scene with deled ( lightmapped or not ) and export it into B3D format.
2. i load it in my Blitz sourcecode ( scene=LoadAnimMesh("scene.b3d") )
3. if i create a light into my code ( light=createlight(2) for exemple ) it doesn't affect the scene.
if i export with X format, it's work.
but X format isn't easy to handle into Blitzbasic.
thanks all again. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|