http://developer.hoops3d.com
  HOOPS/Stream Toolkit
  Sectioned Cutting Planes

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   Sectioned Cutting Planes
Anatoly
Junior Member
posted February 06, 2006 01:07 PM     Click Here to See the Profile for Anatoly   Click Here to Email Anatoly     Edit/Delete Message   Reply w/Quote
Can somebody tell me how to use the new sectioned cutting planes feature in the stream toolkit?

Thanks in advance...

[This message has been edited by Anatoly (edited February 06, 2006).]

IP: Logged

Reuben
Junior Member
posted February 06, 2006 01:17 PM     Click Here to See the Profile for Reuben   Click Here to Email Reuben     Edit/Delete Message   Reply w/Quote
The method you’re interested in is TK_Cutting_Plane::SetPlanes(count, planes). I’m working on a sample program that shows how to use this…

IP: Logged

Reuben
Junior Member
posted February 06, 2006 01:19 PM     Click Here to See the Profile for Reuben   Click Here to Email Reuben     Edit/Delete Message   Reply w/Quote
/*
* This demo shows sectioned cutting planes using
* the base stream toolkit.
*/


#include < BStream.h>
#include < stdio.h>

#define countof(array) sizeof(array)/sizeof(array[0])

static void WriteObject(BBaseOpcodeHandler*, BStreamFileToolkit*, FILE*, char*r, int);
static char mybuffer[4096];

static float pc_pts[][3] = { {-1,0,0}, {1,0,0},};
static float pc_rdi[] = {0.75f, 0.75f};

static float cutting_planes[][4] = {
{1,0,0,0},
{0,1,0,0},
{0,0,1,0},
};

int main(){
FILE *flptr = fopen( "temp.hsf", "wb");

BStreamFileToolkit mytoolkit;
mytoolkit.PrepareBuffer(mybuffer, sizeof(mybuffer));

TK_Header header;
WriteObject(&header, &mytoolkit, flptr, mybuffer, sizeof(mybuffer));

/* Set Visibility for faces on. */
TK_Visibility vis;
vis.SetGeometry(TKO_Geo_Face);
vis.SetValue(TKO_Geo_Face);
WriteObject(&vis, &mytoolkit, flptr, mybuffer, sizeof(mybuffer));

/* Create some geometry to section. */
TK_PolyCylinder pc;
pc.SetPoints(countof(pc_pts), (float*)pc_pts);
pc.SetRadii(countof(pc_rdi), pc_rdi);
pc.SetCaps(3);
WriteObject(&pc, &mytoolkit, flptr, mybuffer, sizeof(mybuffer));

/* Insert a few cutting planes to take out a section of the object. */
TK_Cutting_Plane cp;
cp.SetPlanes(countof(cutting_planes), (float*)cutting_planes);
WriteObject(&cp, &mytoolkit, flptr, mybuffer, sizeof(mybuffer));

/* TK_Terminator indicates the end of the HSF file. */
TK_Terminator term( TKE_Termination );
WriteObject(&term, &mytoolkit, flptr, mybuffer, sizeof(mybuffer));

fwrite(mybuffer, sizeof(char), mytoolkit.CurrentBufferLength(), flptr);

fclose(flptr);
return 0;
}


static
void WriteObject(BBaseOpcodeHandler * handler,
BStreamFileToolkit * tk,
FILE * fp,
char * buffer,
int size)
{

TK_Status status;
status = handler->Write(*tk);
while (status == TK_Pending){
while (status == TK_Pending){
int count = tk->CurrentBufferLength();
fwrite(buffer, sizeof (char), count, fp);
status = tk->PrepareBuffer(buffer, size);
}
status = handler->Write(*tk);
}
}

[This message has been edited by Reuben (edited February 06, 2006).]

[This message has been edited by Reuben (edited February 06, 2006).]

IP: Logged

All times are PT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | http://developer.hoops3d.com

Copyright©2004 Tech Soft America. All Rights Reserved.


Ultimate Bulletin Board 5.46