Bezier surface (sceGumDrawBezier())

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Bezier surface (sceGumDrawBezier())

Post by Ghoti »

Hi folks,

I was trying to get a bezier surface rendered but I am in need of extra documentation or help.

Since I use the gum matrix function and render functions I also wanted to use the gum version of the bezier function.

here is what I have:

Code: Select all

int GraphicsObject::RenderExampleBezier() {

	sceGuDisable(GU_TEXTURE_2D);
	
	lineVertex* Bezier = (lineVertex*)sceGuGetMemory(4 * sizeof(lineVertex));

	Bezier[0].color = 0xffff6b38;
	Bezier[0].x = 0.0f;
	Bezier[0].y = 20.0f;
	Bezier[0].z = 0.0f;
	Bezier[1].color = 0xffff6b38;
	Bezier[1].x = 0.0f;
	Bezier[1].y = 0.0f;
	Bezier[1].z = 5.0f;
	Bezier[2].color = 0xffff6b38;
	Bezier[2].x = 5.0f;
	Bezier[2].y = 0.0f;
	Bezier[2].z = 5.0f;
	Bezier[3].color = 0xffff6b38;
	Bezier[3].x = 5.0f;
	Bezier[3].y = 0.0f;
	Bezier[3].z = 0.0f;


	/*for&#40;int i=0; i<3;i++&#41; &#123;
		for&#40;int j=0;j<3;j++&#41; &#123;
			Bezier&#91;i*3+j&#93;.color = 0xffff6b38;
			Bezier&#91;i*3+j&#93;.x = &#40;float&#41;i * 5.0f;
			if&#40;i!=j&#41;
				Bezier&#91;i*3+j&#93;.y = 0.0f;
			else
				Bezier&#91;i*3+j&#93;.y = 20.0f;
			Bezier&#91;i*3+j&#93;.z = &#40;float&#41;j * 5.0f;
		&#125;
	&#125;*/

	sceGumMatrixMode&#40;GU_MODEL&#41;; 
	sceGumLoadIdentity&#40;&#41;;

	//sceGuPatchDivide&#40;2,2&#41;;
	sceGuPatchPrim&#40;GU_TRIANGLE_STRIP&#41;;
	sceGumDrawBezier&#40;GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 2, 2, 0, Bezier&#41;;

	sceGuEnable&#40;GU_TEXTURE_2D&#41;;

	return 0;

&#125;
this does not work :s so I have some questions.

1.) sceGuPatchPrim has no gum variant, in this case does it work with the gum variant of the drawbezier?
2.) The vertices that have to be passed, should they be with a 4x4 bezier field only 16 points? or do I have to match the number of vertices when I should create that field using triangles or trianglestrips?
3.) In the documentation, sceGuPatchPrim only can have 3 primitives, is this correct or are the three just examples of all other primitives as in the drawarray function.

4.) Last but not least, What am i doing wrong? any ideas, suggestions ?

greets ghoti
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Re: Bezier surface (sceGumDrawBezier())

Post by Raphael »

Ghoti wrote: 1.) sceGuPatchPrim has no gum variant, in this case does it work with the gum variant of the drawbezier?
Yes. gumDraw* is the same as guDraw, just that it updates the matrices before the call.
3.) In the documentation, sceGuPatchPrim only can have 3 primitives, is this correct or are the three just examples of all other primitives as in the drawarray function.
When you think more about it, you should notice that the other primitive types don't make any sense with a bezier patch at all. Non-strip versions because you need a strip to connect the bezier points and the sprite primitive because it's a screen-aligned rect.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Post by Ghoti »

Okay so in that case it is clear that the nine point field I commented out does not work. However as far as I can tell the four pointfiel should. (or is there a minimum?)

1----2
| |
| |
0----3

This is how I create the 2x2 bezier patch, it should work as far as I know.

Do you know what I am doing wrong?

greets ghoti
Post Reply