Delgine 3D Tools & Content DeleD Community Edition
Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DeleD and Blitz Basic
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Community Edition
View previous topic :: View next topic  
Author Message
mappy
DeleD PRO user


Joined: 18 Aug 2005
Posts: 340
Location: France

PostPosted: Sat Aug 27, 2005 5:37 pm    Post subject: DeleD and Blitz Basic Reply with quote

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
View user's profile Send private message
Daaark
DeleD PRO user


Joined: 01 Sep 2004
Posts: 2696
Location: Ottawa, Canada

PostPosted: Sat Aug 27, 2005 5:46 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
mappy
DeleD PRO user


Joined: 18 Aug 2005
Posts: 340
Location: France

PostPosted: Sat Aug 27, 2005 6:18 pm    Post subject: Reply with quote

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 ... Wink
And I'm not too sure how to deal with vertices in BB for now (yes I'm a beginner here too Cool.
Rolling Eyes
Back to top
View user's profile Send private message
hairyprogramer
DeleD PRO user


Joined: 23 May 2005
Posts: 7

PostPosted: Sun Aug 28, 2005 12:04 am    Post subject: Reply with quote

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
View user's profile Send private message
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Sun Aug 28, 2005 7:55 am    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message Visit poster's website
Jeroen
Site Admin


Joined: 07 Aug 2004
Posts: 5332
Location: The Netherlands

PostPosted: Sun Aug 28, 2005 8:02 am    Post subject: Re: DeleD and Blitz Basic Reply with quote

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? Smile 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 Wink) 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
View user's profile Send private message Send e-mail Visit poster's website
mappy
DeleD PRO user


Joined: 18 Aug 2005
Posts: 340
Location: France

PostPosted: Sun Aug 28, 2005 1:00 pm    Post subject: Reply with quote

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 ! Smile
Funny thing (?) my torchs in BB have each only 2 surfaces (!) and 206 vertices ... go figure.
But the vertices coords seem to be ok Smile

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 Shocked ? Laughing

OL.
Back to top
View user's profile Send private message
Jeroen
Site Admin


Joined: 07 Aug 2004
Posts: 5332
Location: The Netherlands

PostPosted: Sun Aug 28, 2005 1:07 pm    Post subject: Reply with quote

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. Wink
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mappy
DeleD PRO user


Joined: 18 Aug 2005
Posts: 340
Location: France

PostPosted: Sun Aug 28, 2005 4:04 pm    Post subject: Reply with quote

Thank you and yes I got your point Smile
Back to top
View user's profile Send private message
Daaark
DeleD PRO user


Joined: 01 Sep 2004
Posts: 2696
Location: Ottawa, Canada

PostPosted: Sun Aug 28, 2005 4:28 pm    Post subject: Reply with quote

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. Embarassed Even though, I used Basic from 1998-2000.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Jeroen
Site Admin


Joined: 07 Aug 2004
Posts: 5332
Location: The Netherlands

PostPosted: Sun Aug 28, 2005 5:57 pm    Post subject: Reply with quote

Vampyre_Dark wrote:
I wanted to type that out in my first reply, but I couldn't remember Basic syntax. Embarassed 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... Wink


Last edited by Jeroen on Tue Aug 30, 2005 11:03 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
inquisitor
DeleD PRO user


Joined: 30 Aug 2005
Posts: 4
Location: Lyon, France

PostPosted: Tue Aug 30, 2005 11:00 am    Post subject: Reply with quote

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
View user's profile Send private message
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Tue Aug 30, 2005 7:27 pm    Post subject: Reply with quote

Yes, I think I could throw an educated guess at that Smile

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 Wink
Back to top
View user's profile Send private message Visit poster's website
mappy
DeleD PRO user


Joined: 18 Aug 2005
Posts: 340
Location: France

PostPosted: Wed Aug 31, 2005 7:52 am    Post subject: Reply with quote

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 Smile

Hope this helps.
OL.
Back to top
View user's profile Send private message
inquisitor
DeleD PRO user


Joined: 30 Aug 2005
Posts: 4
Location: Lyon, France

PostPosted: Wed Aug 31, 2005 3:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Community Edition All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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