Page 1 of 1

generating drawInfo

Posted: Wed Mar 21, 2007 8:54 pm
by anomaly
Is there a way to generate drawInfo? Other than by hand. I have searched the forums, not much on drawInfo.

Posted: Wed Mar 21, 2007 9:05 pm
by Spazzy McGee
DrawInfo was never documented properly, as Trepan, the developer behind it discontinued his development with the project.

Myself and others have looked into the drawinfo code, and currently we need to work out things such as the order we need to define corners for the tristrips and quadstrips. This is no mean feat.

I would suggest looking at some of Trepan's example code.

Posted: Wed Mar 21, 2007 9:30 pm
by Teppic
AFAIK Louman is the only person to make much sense of it (after Trepan of course). If you know what you want to do, you can find Trepan in the IRC channel from time to time.

Posted: Tue Mar 27, 2007 2:02 pm
by optic delusion
Here's some drawinfo I made last week. Players with oscillation overthuster may have client crash on this. I'm not sure if the normals are in the wrong order, or the corner data is bad, I'm still working on it.

Some hints...
I focused on one type of "display list" or dList, Tristrips. ( I believe dList is a better term to use than drawinfo. Drawinfo is just an arbitrary word trepan used to represent dLists in BZFlag?)

In order to make a tristrip list you first need an object that is made out of all triangles. I did this by taking an .obj format document and running it through this program. http://www.cs.sunysb.edu/~stripe/ . Then convert the v/vn/t words in the obj format to vertex/normal/texcoord. Then paste that into your bzw.
There are other ways to make triangulated objs. I would have saved myself a lot of time if I had chosen to use quads in my experiments. It looks like trifans are usually used for cones, and should be easy to do. Tristrips should be great for terrain as that's where LOD will be most useful. The fastest, and probably most future-proof way to do dLists is with indexed points. By the way, openGL and nVidia have several functions that should be great for generating tristrips and quads, in a few decades i might even be able to use them. (0__0)


There must be a group both before and after the object define.
Everything between "define" and "drawinfo" is the same as always, test the object without drawinfo before adding drawinfo.
You must define a material.
Extents and sphere are calculated automatically by bzfs, no need to have that there, at all. I guess the first time you run the complete object thru bzfs the extents and sphere should be pasted into the dList. This helps with group transforms? colDet?
You need one set of corners, for each vertex.


You can build the tristrips, quadstrips, etc by hand.
Making a tristrip... start with 0 1 2, that should display one face. then add new faces one at a time, adding one number to the strip, and testing each time. For a quad, that would be "quadstrip 0 1 2 3"
bzfs doesn't care how long the strip is or how may strips there are, This single face at least allows you to verify your bzw syntax is correct before adding to the strip.
The corners are whats beguiling me, right now. We really need to make an exporter. Also.. the code trepan added is incomplete, this isn't as useful as you might think. The true power of drawinfo is in the LOD's, and I've barely scratched the suface in making "Levels Of Detail", but I think I understand it.

### Trying to make tristrips ,
material
name po
alphathresh 0.9
#noradar
noshadow
noculling
nosorting
addtexture http://cbg.bzflag.org/images/Pants/planetmofologo.png
end

define box
group quadspo
#scale 15 15 -30
#shift 0 0 30
matref po
end
enddef


define quadspo
mesh
name cube1

vertex 25.000000 0.000000 -0.000000
vertex 0.000000 -25.000000 0.000000
vertex -25.000000 -0.000000 0.000000
vertex 0.000000 25.000000 -0.000000
vertex 0.000000 0.000000 15.000000

normal 0.867371 0.000000 0.497663
normal 0.000000 -0.867371 0.497663
normal -0.867371 0.000000 0.497663
normal -0.000000 0.867371 0.497663
normal 0.000000 0.000000 1.000000

texcoord 0.001469 0.002450 0.000000
texcoord 0.002927 0.996503 0.000000
texcoord 0.167564 0.851543 0.000000
texcoord 0.177459 0.143798 0.000000
texcoord 0.531782 0.423244 0.000000
texcoord 0.875309 0.861438 0.000000
texcoord 0.885204 0.153693 0.000000
texcoord 0.995522 0.000993 0.000000
texcoord 0.996979 0.995045 0.000000


face
vertices 0 4 1
normals 0 4 1
texcoords 2 4 5
endface
face
vertices 1 2 3 0
normals 1 2 3 0
texcoords 8 1 0 7
endface
face
vertices 1 4 2
normals 1 4 2
texcoords 5 4 6
endface
face
vertices 2 4 3
normals 2 4 3
texcoords 6 4 3
endface
face
vertices 3 4 0
normals 3 4 0
texcoords 3 4 2
endface

drawInfo
dlist
# extents -1 -1 0 1 1 1
# sphere 0 0 0.5 2.25
angvel 50
corner 0 0 0
corner 1 1 1
corner 2 2 2
corner 3 3 3
corner 4 4 4

lod # 0
lengthPerPixel 0
matref -1
dlist
tristrip 0 1 4 2 4 3 0 2 1

#tristrip 2 3 4 0 1 3 2 4
#tristrip 0 1 3 2 4 1
end # material -1
end # lod 0

end # drawInfo


end
enddef

group box
matref po
scale 10 10 10
shift 0 0 1
end


box
size 1 4 2
position 0 0 0
drivethrough
shootthrough
end
#local

One other note... he trees in louman's churchyard are made with quadstrips and trifans, louman told me trepan gave him those objects, and lou has not really worked on drawinfo much.

Posted: Thu Mar 29, 2007 2:59 pm
by anomaly
Thanks for the info Optic. This is good stuff. I am considering writing some code to generate drawInfo (dlist) for bzw meshes by reading a standard bzw mesh and converting. Maybe something that could be implented in python and added to bzwtools. I obviously need to know more about how drawInfo is implemented. I am currently studying the drawinfo code in bzflag-2.0.9. Thanks for your help.
If I come up with anything worth sharing, I will.

Don't bother

Posted: Thu Mar 29, 2007 5:13 pm
by optic delusion
If i was you, I wouldn't bother, the code trepan committed is incomplete. For instance, any client in "experimental" graphics mode that enters a drawinfo with Oscillation overthruster, crashes. Better to just wait and see what comes of crystal space, or OGRE. whichever engine the devs decide to go with, in the future.
Still.... It is a rether interesting puzzle, and was a fun little hobby for me, for a few weeks. If you really want to....


EDIT: This is bad information.
The client crash only occurs with badly made drawinfo, like the object I posted here. Correctly built drawinfo does not cause crash.