Crystal Space
Welcome, Guest. Please login or register.
December 21, 2014, 10:13:06 am

Login with username, password and session length
Search:     Advanced search
9032 Posts in 2046 Topics by 9297 Members
Latest Member: Adrihjapa
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  "Low-level" Polygon-handling
« previous next »
Pages: [1] Print
Author Topic: "Low-level" Polygon-handling  (Read 4045 times)
Yoshi bla
Guest


Email
« on: April 21, 2006, 11:39:23 pm »

Specs: CS version: Most recent CVS build, cslibs r20, Windows XP, MSVC 7.1, software renderer

Hello, sorry bout not signing in (public computer, too lazy Tongue), but anyway, I have a number of questions about "low-level" polygon-handling.  By "low-level," I mean like "Vertex v1(x, y, z, RGBA(r, g, b, a)), v2(...), ...;  Polygon p(v1, v2, v3, v4); p.setPos(x, y, z);" that kind of stuff.

The reason why I want such low-level control is cuz I'm making a mostly-2d sudoku game gui for a class project.  Basically, it is 2d, but I am sticking it in 3d space, cuz I want to be able to make it have cool effects.  But due to my lack of CS knowledge, I am having trouble getting even the basics down.  I am mainly working off of Simple1, and I've been trying to implement stuff by using Simple1 code and looking through the documentation, API, forums, etc.  This is what I have so far:



This is what I have:
  • The background is a thingmesh that I made using "engine->CreateThingMesh(room, "background")".  Then, once I got the state, i used "AddQuad" (as opposed to "AddInsideBox" like in the Simple1 tutorial) to set up a single quad that the camera always faces (i.e. can't move the camera).
  • The sudoku board is also a thingmesh, that I made in the same way, and the texture was made from a loaded PNG image.  The position of the board is a little bit in front of the background quad.
  • The title text and the smiley-faces are drawn using the 2d engine, though I am considering rendering it to the sudoku board (the smiley-faces, which are where the numbers will be, obviously).

This is what I want, but can't figure out how to do despite hours of work/searching and browsing sample code and documentation:
  • I would like the sudoku board to be semi-transparent (the PNG opacity data doesn't seem to be carrying over... or maybe it's that binary alpha mode that's making it fully opaque anyway...).  I remember a long time ago, fooling around with this sort of thing in opengl, and I remember it being pretty annoying/complicated, so I don't really expect this to be easy.
  • I would like the background to be able to change in-program, i.e., replace the texture on the background thingmesh with a different image.  I've tried getting the thingfactorystate of the background mesh and doing the whole SetPolygonMaterial + SetPolygonTextureMapping but to no avail.
  • I would like to be able to fade the polygons in and out... which I suspect has to do with changing the alpha values of the polygons/vertices but I have little to no idea about how to do this.
  • I think it'd be cool to have each bakground be on the face of a cube, and the cube could spin to the right face once a background has been selected (kind of like user-switching in mac osx).  In the How to Create a ThingMesh part of the documentation, it at least implied that I do "walls_state->AddQuad(...); walls_state->SetPolygonMaterial(...); ..." etc. for each of the faces of the cube.  But every time I try to add another face to the thingfactorystate, my program crashes.  I could always make a cube mesh and texture it in blender or something and then import it into CS... but I would prefer to do it manually through code.
  • Oh yeah, and in general, I would like to know if you can make a polygon without a texture (a material, but no texture), and if so, how?  Because all the functions I've seen seem to require, in some capacity, a texture to be used as well.

I think those are the major issues at the moment.  Of course, none of this important... I could finish the gui without any of that fancy stuff, but I consider this an opportunity to learn more about CS, too, so I would like to do it.  Even if you can't help me with stuff that I WANT to do, if (while reading the descriptiong of how I implement stuff) you notice that I lack some fundamental understanding of the way CS works, then if you could set me straight, that would be awesome.

Also, if I asked really dumb questions or questions whose answers are readily available in the documentation/on the site/in the forums, then I apologize and ask you to tell me so; but I did spend hours coding/reading/researching/experimenting before resorting to asking for help, so... yeah.  Thanks for your help.

- Yoshi
Logged
yoshi
Newbie
*
Posts: 40


View Profile WWW
« Reply #1 on: May 08, 2006, 11:13:50 pm »

Ok well, we finished our Sudoku solver program today... I ended up not being able to figure out much of anything, except 2d procedural textures, and I'm not really sure if I'm doing it right.

But to anyone who's interested, you can grab a copy at http://www.people.virginia.edu/~yn5d/misc/sudokool.zip

Just unzip it, find start.bat and run that (all it does is run sudokool.exe -mode=800x600).  It's not very interesting, and it screws up somewhat often, but it gets the job done for the most part.  Just a word of caution: I don't use threading, so when you solve something, it freezes on that frame until it's done solving.  And any board with fewer than around 21 numbers takes a very very very long time to complete.

gui: Yoshi N. (me)
solver: Lucas G. (classmate)

P.S.  I had a post some time ago about the cs-python plugin that nobody responded to.  I basically just want to know if you can call python scripts from within a CS program (as opposed to a python script calling a CS program); I know this can be done with the python plugin, but no such project seems to exist in wkstypical.  So I was wondering what's going on with that.  Thanks.
Logged
Photonman
Newbie
*
Posts: 8


View Profile Email
« Reply #2 on: May 14, 2006, 08:48:23 pm »

I downloaded this zip... Why do use the very big .bmp picture (fruity.bmp)?
And how could u separate crystal .dll-s? (all .dll-s about 16 mb size)
Logged
yoshi (not logged in)
Guest


Email
« Reply #3 on: May 17, 2006, 03:51:49 am »

Quote
Why do use the very big .bmp picture (fruity.bmp)?

I used it for the background.  I guess I could have made it a jpg or PNG or something, but the computers I worked with didnt have Photoshop (only paint!) so I was too lazy to change it Tongue

Quote
how could u separate crystal .dll-s?
I'm not sure what you mean by this.  Are you asking me how I knew which DLLs to include in the folder and which I could leave out?  If so, then the answer is simply that I re-named each one (to something like "engine.dll.bak") one at time and tried running my program to see if anything screwed up.  Then, I deleted the dll if nothing screwed up.  (Note: engine.dll is necessary!)

Though if you notice, after about an hour of doing that, I got pretty tired and left a lot of unneccessary dlls in there anyway Tongue
Logged
Photonman
Newbie
*
Posts: 8


View Profile Email
« Reply #4 on: May 18, 2006, 10:21:07 pm »

Quote
how could u separate crystal .dll-s?
I'm not sure what you mean by this.  Are you asking me how I knew which DLLs to include in the folder and which I could leave out?  If so, then the answer is simply that I re-named each one (to something like "engine.dll.bak") one at time and tried running my program to see if anything screwed up.  Then, I deleted the dll if nothing screwed up.  (Note: engine.dll is necessary!)

Though if you notice, after about an hour of doing that, I got pretty tired and left a lot of unneccessary dlls in there anyway Tongue
If I renamed engine.dll, my program did not do anything of course.
Well CS got about 300 .dlls = 310 mb. Your program got 100 dlls = 16 mb. I separated dlls to my program: 77 dlls = 80 mb.
Your .dlls is very small size. For example: my explo.dll 1 mb, and your dll 86 kb etc.. What CS version do u using now?

Last question. I see your program using big size fonts. How could u make the custom fonts exactly?  CSFONT_LARGE etc. is default font, it is very small size. I try this code but it is wrong: fnt = g3d->GetDriver2D()->GetFontServer()->LoadFont("/fonts/ttf/Vera.ttf", 12");

thx
« Last Edit: May 18, 2006, 10:39:55 pm by Photonman » Logged
yoshi
Newbie
*
Posts: 40


View Profile WWW
« Reply #5 on: May 20, 2006, 05:12:38 am »

I used the bleeding-edge CVS Crystal Space from a couple months ago to make my program.  I don't think that matters though.  I suspect that my dlls are a lot smaller than yours because I built Crystal Space in release mode, instead of debug mode.  However, I am not certain if this is the case.

As for using custom fonts, you can follow the online documentation at http://crystalspace3d.org/docs/online/manual-cvs/cs_4.12.1.php and the following section http://crystalspace3d.org/docs/online/manual-cvs/cs_4.12.2.php#4.12.2

After you make a call to LoadFont(...), make sure that it was successful by checking that the "font" pointer is not NULL.  If it is, then maybe your VFS is not configured correctly.  It probably is, though, since the documentation code just assumes you're using the default VFS.cfg file in the root CS directory.  Another mistake (that seems to be common and that I made as well) is using the wrong font server.  In the section of your code where you request all those plugins, look for

CS_REQUEST_FONTSERVER

and replace it with

CS_REQUEST_PLUGIN("crystalspace.font.server.freetype2", iFontServer)

It turns out that CS_REQUEST_FONTSERVER is a #define for the non-freetype font server, which cannot load ttf files.  I hope this helps!

-yoshi
Logged
Photonman
Newbie
*
Posts: 8


View Profile Email
« Reply #6 on: May 20, 2006, 01:50:33 pm »

I used the bleeding-edge CVS Crystal Space from a couple months ago to make my program.  I don't think that matters though.  I suspect that my dlls are a lot smaller than yours because I built Crystal Space in release mode, instead of debug mode.  However, I am not certain if this is the case.

As for using custom fonts, you can follow the online documentation at http://crystalspace3d.org/docs/online/manual-cvs/cs_4.12.1.php and the following section http://crystalspace3d.org/docs/online/manual-cvs/cs_4.12.2.php#4.12.2

After you make a call to LoadFont(...), make sure that it was successful by checking that the "font" pointer is not NULL.  If it is, then maybe your VFS is not configured correctly.  It probably is, though, since the documentation code just assumes you're using the default VFS.cfg file in the root CS directory.  Another mistake (that seems to be common and that I made as well) is using the wrong font server.  In the section of your code where you request all those plugins, look for

CS_REQUEST_FONTSERVER

and replace it with

CS_REQUEST_PLUGIN("crystalspace.font.server.freetype2", iFontServer)

It turns out that CS_REQUEST_FONTSERVER is a #define for the non-freetype font server, which cannot load ttf files.  I hope this helps!

-yoshi

Thank u this instructions. Smiley
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 9.245 seconds with 16 queries.