trouble drawing simple 3D tris

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

trouble drawing simple 3D tris

Post by keless »

I'm trying to use m_driver->draw3dTriangle(), but I get a crash when I do.

I can draw2dRectangle(), but I am trying to use this instead now.

I'm using OGL to render, becasue I dont have DX8 (and software is supposed to be buggy).

my code is simple (between start and end function calls):

Code: Select all

    irr::core::vector3df tl, tr, bl;
    tl.set(-10.0f, 10.0f, 0.0f);    
    tr.set(10.0f, 10.0f, 0.0f);
    bl.set(-10.0f, -10.0f, 0.0f);
    irr::core::triangle3df up, rht;
    up.set(  bl, tl, tr ); //tr, tl, bl );
    m_driver->draw3DTriangle(up, color); 
I dont set up any environment variables, or textures/lighting/anything.
This is inside of a static singleton function.
It is NOT inside of a ISceneNode derived class.

Are those things required? What am I wrongly assuming?

Your help == appreciated!
FleshCrawler
Posts: 108
Joined: Fri Aug 22, 2003 1:04 pm
Location: Kerkrade, Netherlands
Contact:

Post by FleshCrawler »

well, you have to create a cameraNode if you havent done that.
I've been absent for really long, but i'm ready to reign my terror on you once again, mwuahahahahaha
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

okay, I have stuffed my tetris blob drawing code into an ISceneNode class called PileBlobScene.

It is currently drawing the tiles in my PileBlob (I am making tetris, and this is the datastruct that keeps track of the pile of tiles).

Now I need to translate the scene. Currently, its bottom left corner is at (0,0,0), but I want to offset the whole Scene by (-80,-80,0).

I have tried:
AbsoluteTransformation.setTranslation(irr::core::vector3df(-40, -40, -40));
in the Scene's constructor, and I use:
p_driver->setTransform(irr::video::TS_WORLD, AbsoluteTransformation);
in my render() function.

I also tried setting the 'position' vector when creating my scene node.. and it still doesnt change its position any.

The first frame seems to put it in the right place, but then it quickly reverts to (0,0,0). And putting this into my Render() function doesnt seem to do anything at all.
Homer
Posts: 58
Joined: Tue Nov 18, 2003 7:11 pm
Location: Germany

Post by Homer »

Weird, I'm using ISceneNode->setPosition(core::vector3df) and this works for me. Maybe you have a problem with your camera?
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

yeah, i even tried that, and it didnt work.


right now, as a hack, I have set up my camera at (80,80,-400) looking at (80, 80, 0)
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

Does the position matter? Because if you leave the camera where it is, everything should work, right?
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

No. None of it is working. I've tried 4-5 different methods for setting the position of my scene and none of them have worked for me.

Setting the camera's position is the only thing that has worked so far.

I'm working on a Win98/500mhz using OGL/SOFTWARE devices, and at home on a Win2k/400Mhz using OGL/SOFTWARE.

Code link:
http://www.skyesurfer.net/keless/download/tetris.zip

If anyone decides to look at the code, they should follow this path:

main.cpp
tetris_game.cpp ::init()
gs_main.cpp ::constructor
tetris_pileblobscene.cpp ::constructor and render()
(or pileblobrenderer.cpp, forgot if I renamed it yet in that version)
a screen cap is worth 0x100000 DWORDS
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

Another question before I look at the source: Would it be easier to create ISceneNodes for each of the tetris pieces, and place them in the correct locations in the scene, rather than trying to create a custom renderer for the whole thing?
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

well, I am creating a seperate scene for two different groups of objects:

PileBlob and FallingBlob.

the PileBlob is the large clump of blocks that have landed at the bottom. It worries about checking for collisions from oncomming falling blobs, and removing completed lines.

the FallingBlob is one of the familiar tetris pieces, falling from the top, and rotating/shifting, eventually to collide with the Pile and add its tiles to that of the pile.

I've only got a Scene for the Pile right now (wanted to get this first) but Falling blobs will have their own scene node class afterwards (there will only be one instance of PileBlobScene per player, and 2 instances of FallingBlobScene-- curr piece and next piece).

By keeping the scene info seperate from the data, I can interchange different scene types-- so I can have a blurry, glowy, or a shakey scene for special 'power ups' or whatever.

But first I have to position the darn things.

I am keeping a difference between 'tile-size coords' and 'global coords' with a 'tile-size' variable; such that a tile's rect in global coords is:
rect( TSIZE*x, TSIZE*y, TSIZE+TSIZE*x, TSIZE+TSIZE*y)

Both PileBlob and FallingBlob keep their tile data in tile-size coords, so they can interchange their data without worrying about how they are represented on screen.

EDIT: I'm not sure if that answered your question correctly--
firstly, I certainly dont want to create a SceneNode for each tile. This seems like it would have way too much overhead, make it harder to stylize groupings of tiles, and just be overkill. That leads me to believe I should do it for groups (Pile and Falling).
a screen cap is worth 0x100000 DWORDS
Post Reply