Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AbrahamR), 717 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
So simple... #245102
01/08/09 12:41
01/08/09 12:41
Joined: Feb 2008
Posts: 337
V
Vadim647 Offline OP
Senior Member
Vadim647  Offline OP
Senior Member
V

Joined: Feb 2008
Posts: 337
I was wondering around, and thought about a simple yet very usefull function:
draw_triangle(VECTOR vertex1,VECTOR vertex2,VECTOR vertex3,BMAP texture, VECTOR texturepos1, VECTOR texturepos2, VECTOR texturepos3);
It should do a very simple thing - draw a textured triangle.
Also (optional), add a function to change color tilting and alpha for that (like draw_triangle_color(VECTOR color,var alpha);
Possible usages:
* Dynamic terrain\waves\etc
* Object trails
* All variety of spells and stuff
* ... (I'm not in mood to think of other usage ways, but I'm pretty sure that this one would be a awesome addition to engine (esp. if you will update LiteC download with it smile )

Re: So simple... [Re: Vadim647] #245119
01/08/09 13:54
01/08/09 13:54
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cowabanga Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Yeah... It would be a awesome addition to engine. please JCL put this awesome function!

Re: So simple... [Re: Cowabanga] #245122
01/08/09 14:00
01/08/09 14:00
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Hmm, quads are normally needed more often than triangles, but I'll think about it.

Re: So simple... [Re: jcl] #245126
01/08/09 14:14
01/08/09 14:14
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
in that case, maybe you can add quads, too smile

Re: So simple... [Re: ello] #245291
01/09/09 08:55
01/09/09 08:55
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
And basic bodies like boxes, cyliners, cones and cubes smile

Re: So simple... [Re: FBL] #245293
01/09/09 09:01
01/09/09 09:01
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
yes! smile

i noticed in the manual that with

ent_create(NULL, nullvector, NULL);

it's possible to create dummy entities. it would be cool if some shape like BOX, CONE, CUBE,... could be specified for them.

Re: So simple... [Re: FBL] #245294
01/09/09 09:04
01/09/09 09:04
Joined: Feb 2008
Posts: 337
V
Vadim647 Offline OP
Senior Member
Vadim647  Offline OP
Senior Member
V

Joined: Feb 2008
Posts: 337
Any basic body can be drawn with some poly\triangle functions. If the feature will be added, I'll provide functions for those smile


I switched to other account since marth 2010. Guess which.
Re: So simple... [Re: Vadim647] #245300
01/09/09 10:01
01/09/09 10:01
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
I can write a draw_triangle function in DirectX, it is no so difficult, there is also an example already in the samples folder.

But the problem is Triangles can not be used for drawing bodies because they have no necessary features such as materials, normals, lighting, collision detection, clipping and so on.

Code:
#include <acknex.h>
#include <default.c>
#include <d3d9.h>

// define a 2D vertex struct
typedef struct VERTEX_FLAT { 
	float x,y,z; 
	float rhw; 
	D3DCOLOR color; 
} VERTEX_FLAT;
#define D3DFVF_FLAT (D3DFVF_XYZRHW | D3DFVF_DIFFUSE)


function main()
{ 
	vec_set(screen_color,vector(1,1,1)); // black nontransparent screen

// define and preset the triangle
   VERTEX_FLAT vf[3];
   vf[0].color = 0xFFFF0000; // the red corner
   vf[1].color = 0xFF0000FF; // the blue corner
   vf[2].color = 0xFF00FF00; // the green corner
   vf[0].rhw = vf[1].rhw = vf[2].rhw = 1.0; // no perspective
   
// define three corner vectors   
   VECTOR v[3];
   vec_set(v[0],vector(100,100,0));
   vec_set(v[1],vector(400,100,0));
   vec_set(v[2],vector(400,400,0));

// define the rotation center
	VECTOR center;
	vec_set(center,vector(250,250,0));
	
	wait(1); //wait until the D3D Device is opened after the first frame

// draw a red/blue/green rotating triangle
	var angle = 0;
	while(1) 
	{
// rotate the corner vectors
		int i;
		for (i=0; i<3; i++)
		{
			VECTOR vTemp;
			vec_diff(vTemp,v[i],center);
			vec_rotate(vTemp,vector(angle,0,0));
			vec_add(vTemp,center);
			vf[i].x = vTemp.x;
			vf[i].y = vTemp.y;
			vf[i].z = 0;
		}
		angle += 10*time_step;
		
// open the scene and get the active D3D device
	   LPDIRECT3DDEVICE9 pd3dDev = (LPDIRECT3DDEVICE9)draw_begin();
	   if (!pd3dDev) return;
	
// set some render and stage states
	   pd3dDev->SetRenderState(D3DRS_ALPHABLENDENABLE,FALSE);
	   pd3dDev->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE);
	   pd3dDev->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG2);
	
// now draw the triangle
	   pd3dDev->SetFVF(D3DFVF_FLAT);
	   pd3dDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,1,(LPVOID)vf,sizeof(VERTEX_FLAT));
	
		wait(1);
	}
}


Re: So simple... [Re: Tobias] #245306
01/09/09 10:45
01/09/09 10:45
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Quote:
But the problem is Triangles can not be used for drawing bodies because they have no necessary features such as materials, normals, lighting, collision detection, clipping and so on.
I drawed a mesh object with diffuse colors and several triangles with DX in 3d space, I suppose that's a body? Creating a box isn't really that hard.

Last edited by Joozey; 01/09/09 10:46.

Click and join the 3dgs irc community!
Room: #3dgs
Re: So simple... [Re: Joozey] #245310
01/09/09 11:16
01/09/09 11:16
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Well for 3D objects it would be cool to have them as real entities, just as proposed by ventilator.

Page 1 of 2 1 2

Moderated by  aztec, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1