actually add im3d example

This commit is contained in:
aap 2021-03-10 09:40:33 +01:00
parent b7b7334dbb
commit 5b4f91b161
9 changed files with 1322 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

138
tools/im3d/im3d.cpp Normal file
View File

@ -0,0 +1,138 @@
#include <rw.h>
#include <skeleton.h>
#include "im3d.h"
bool Im3DColored = true;
bool Im3DTextured;
rw::int32 Im3DPrimType;
rw::RGBA SolidWhite = {255, 255, 255, 255};
rw::RGBA SolidBlack = {0, 0, 0, 255};
rw::RGBA SolidRed = {200, 64, 64, 255};
rw::RGBA SolidGreen = {64, 200, 64, 255};
rw::RGBA SolidBlue = {64, 64, 200, 255};
rw::RGBA SolidYellow = {200, 200, 64, 255};
rw::RGBA SolidPurple = {200, 64, 200, 255};
rw::RGBA SolidCyan = {64, 200, 200, 255};
rw::Matrix *Im3DMatrix;
rw::Texture *Im3DTexture;
void
Im3DInitialize(void)
{
Im3DMatrix = rw::Matrix::create();
assert(Im3DMatrix);
rw::Matrix *cameraMatrix = &Camera->getFrame()->matrix;
rw::V3d pos = rw::scale(cameraMatrix->at, 6.0f);
Im3DMatrix->rotate(&cameraMatrix->up, 30.0f);
Im3DMatrix->translate(&pos);
rw::Image::setSearchPath("files/");
Im3DTexture = rw::Texture::read("whiteash", nil);
LineListCreate();
LineListSetColor(!Im3DColored);
IndexedLineListCreate();
IndexedLineListSetColor(!Im3DColored);
PolyLineCreate();
PolyLineSetColor(!Im3DColored);
IndexedPolyLineCreate();
IndexedPolyLineSetColor(!Im3DColored);
TriListCreate();
TriListSetColor(!Im3DColored);
IndexedTriListCreate();
IndexedTriListSetColor(!Im3DColored);
TriStripCreate();
TriStripSetColor(!Im3DColored);
IndexedTriStripCreate();
IndexedTriStripSetColor(!Im3DColored);
TriFanCreate();
TriFanSetColor(!Im3DColored);
IndexedTriFanCreate();
IndexedTriFanSetColor(!Im3DColored);
}
void
Im3DTerminate(void)
{
if(Im3DMatrix){
Im3DMatrix->destroy();
Im3DMatrix = nil;
}
if(Im3DTexture){
Im3DTexture->destroy();
Im3DTexture = nil;
}
}
void
Im3DRender(void)
{
rw::SetRenderState(rw::ZTESTENABLE, 1);
rw::SetRenderState(rw::ZWRITEENABLE, 1);
rw::SetRenderState(rw::SRCBLEND, rw::BLENDONE);
rw::SetRenderState(rw::DESTBLEND, rw::BLENDZERO);
rw::SetRenderState(rw::TEXTUREFILTER, rw::Texture::FilterMode::LINEAR);
rw::SetRenderState(rw::CULLMODE, rw::CULLBACK);
rw::uint32 flags;
if(Im3DTextured){
rw::SetRenderStatePtr(rw::TEXTURERASTER, Im3DTexture->raster);
flags = rw::im3d::VERTEXUV | rw::im3d::ALLOPAQUE;
}else{
rw::SetRenderStatePtr(rw::TEXTURERASTER, nil);
flags = rw::im3d::ALLOPAQUE;
}
switch(Im3DPrimType){
case 0: LineListRender(Im3DMatrix, flags); break;
case 1: IndexedLineListRender(Im3DMatrix, flags); break;
case 2: PolyLineRender(Im3DMatrix, flags); break;
case 3: IndexedPolyLineRender(Im3DMatrix, flags); break;
case 4: TriListRender(Im3DMatrix, flags); break;
case 5: IndexedTriListRender(Im3DMatrix, flags); break;
case 6: TriStripRender(Im3DMatrix, flags); break;
case 7: IndexedTriStripRender(Im3DMatrix, flags); break;
case 8: TriFanRender(Im3DMatrix, flags); break;
case 9: IndexedTriFanRender(Im3DMatrix, flags); break;
}
}
void
Im3DRotate(float xAngle, float yAngle)
{
rw::Matrix *cameraMatrix = &Camera->getFrame()->matrix;
rw::V3d pos = Im3DMatrix->pos;
pos = rw::scale(pos, -1.0f);
Im3DMatrix->translate(&pos);
Im3DMatrix->rotate(&cameraMatrix->up, xAngle);
Im3DMatrix->rotate(&cameraMatrix->right, yAngle);
pos = rw::scale(pos, -1.0f);
Im3DMatrix->translate(&pos);
}
void
Im3DTranslateZ(float zDelta)
{
rw::Matrix *cameraMatrix = &Camera->getFrame()->matrix;
rw::V3d delta = rw::scale(cameraMatrix->at, zDelta);
Im3DMatrix->translate(&delta);
}

62
tools/im3d/im3d.h Normal file
View File

@ -0,0 +1,62 @@
extern rw::Camera *Camera;
extern bool Im3DColored;
extern bool Im3DTextured;
extern rw::int32 Im3DPrimType;
extern rw::RGBA SolidWhite;
extern rw::RGBA SolidBlack;
extern rw::RGBA SolidRed;
extern rw::RGBA SolidGreen;
extern rw::RGBA SolidBlue;
extern rw::RGBA SolidYellow;
extern rw::RGBA SolidPurple;
extern rw::RGBA SolidCyan;
void Im3DInitialize(void);
void Im3DTerminate(void);
void Im3DRender(void);
void Im3DRotate(float xAngle, float yAngle);
void Im3DTranslateZ(float zDelta);
void LineListCreate(void);
void LineListSetColor(bool white);
void LineListRender(rw::Matrix *transform, rw::uint32 transformFlags);
void IndexedLineListCreate(void);
void IndexedLineListSetColor(bool white);
void IndexedLineListRender(rw::Matrix *transform, rw::uint32 transformFlags);
void PolyLineCreate(void);
void PolyLineSetColor(bool white);
void PolyLineRender(rw::Matrix *transform, rw::uint32 transformFlags);
void IndexedPolyLineCreate(void);
void IndexedPolyLineSetColor(bool white);
void IndexedPolyLineRender(rw::Matrix *transform, rw::uint32 transformFlags);
void TriListCreate(void);
void TriListSetColor(bool white);
void TriListRender(rw::Matrix *transform, rw::uint32 transformFlags);
void IndexedTriListCreate(void);
void IndexedTriListSetColor(bool white);
void IndexedTriListRender(rw::Matrix *transform, rw::uint32 transformFlags);
void TriStripCreate(void);
void TriStripSetColor(bool white);
void TriStripRender(rw::Matrix *transform, rw::uint32 transformFlags);
void IndexedTriStripCreate(void);
void IndexedTriStripSetColor(bool white);
void IndexedTriStripRender(rw::Matrix *transform, rw::uint32 transformFlags);
void TriFanCreate(void);
void TriFanSetColor(bool white);
void TriFanRender(rw::Matrix *transform, rw::uint32 transformFlags);
void IndexedTriFanCreate(void);
void IndexedTriFanSetColor(bool white);
void IndexedTriFanRender(rw::Matrix *transform, rw::uint32 transformFlags);

176
tools/im3d/linelist.cpp Normal file
View File

@ -0,0 +1,176 @@
#include <rw.h>
#include <skeleton.h>
#include "im3d.h"
float LineListData[28][5] = {
{ 0.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{ 0.000f, 1.000f, 0.000f, 1.000f, 1.000f},
{ 0.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{ 0.000f, -1.000f, 0.000f, 1.000f, 1.000f},
{ 0.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{ 0.000f, 0.000f, 1.000f, 1.000f, 1.000f},
{ 0.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{ 0.000f, 0.000f, -1.000f, 1.000f, 1.000f},
{ 0.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{ 1.000f, 0.000f, 0.000f, 1.000f, 1.000f},
{ 0.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{-1.000f, 0.000f, 0.000f, 1.000f, 1.000f},
{ 0.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{ 0.577f, 0.577f, 0.577f, 1.000f, 1.000f},
{ 0.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{ 0.577f, -0.577f, 0.577f, 1.000f, 1.000f},
{ 0.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{-0.577f, 0.577f, -0.577f, 1.000f, 1.000f},
{ 0.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{-0.577f, -0.577f, -0.577f, 1.000f, 1.000f},
{ 0.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{ 0.577f, -0.577f, -0.577f, 1.000f, 1.000f},
{ 0.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{ 0.577f, 0.577f, -0.577f, 1.000f, 1.000f},
{ 0.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{-0.577f, -0.577f, 0.577f, 1.000f, 1.000f},
{ 0.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{-0.577f, 0.577f, 0.577f, 1.000f, 1.000f}
};
float IndexedLineListData[18][5] = {
{ 0.000f, 1.000f, 0.000f, 0.000f, 0.000f},
{ 0.577f, 0.577f, 0.577f, 0.000f, 0.000f},
{ 0.577f, 0.577f, -0.577f, 0.000f, 0.000f},
{-0.577f, 0.577f, -0.577f, 0.000f, 0.000f},
{-0.577f, 0.577f, 0.577f, 0.000f, 0.000f},
{ 0.000f, 0.000f, 1.000f, 0.000f, 0.000f},
{ 0.707f, 0.000f, 0.707f, 0.000f, 0.000f},
{ 1.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{ 0.707f, 0.000f, -0.707f, 0.000f, 0.000f},
{ 0.000f, 0.000f, -1.000f, 0.000f, 0.000f},
{-0.707f, 0.000f, -0.707f, 0.000f, 0.000f},
{-1.000f, 0.000f, 0.000f, 0.000f, 0.000f},
{-0.707f, 0.000f, 0.707f, 0.000f, 0.000f},
{ 0.577f, -0.577f, 0.577f, 0.000f, 0.000f},
{ 0.577f, -0.577f, -0.577f, 0.000f, 0.000f},
{-0.577f, -0.577f, -0.577f, 0.000f, 0.000f},
{-0.577f, -0.577f, 0.577f, 0.000f, 0.000f},
{ 0.000f, -1.000f, 0.000f, 0.000f, 0.000f}
};
rw::uint16 IndexedLineListIndices[96] = {
0,1, 0,2, 0,3, 0,4, 1,2, 2,3, 3,4, 4,1,
1,5, 1,6, 1,7, 2,7, 2,8, 2,9, 3,9, 3,10, 3,11, 4,11, 4,12, 4,5,
5,6, 6,7, 7,8, 8,9, 9,10, 10,11, 11,12, 12,5,
13,5, 13,6, 13,7, 14,7, 14,8, 14,9, 15,9, 15,10, 15,11, 16,11, 16,12, 16,5,
17,13, 17,14, 17,15, 17,16, 13,14, 14,15, 15,16, 16,13
};
rw::RWDEVICE::Im3DVertex LineList[28];
rw::RWDEVICE::Im3DVertex IndexedLineList[18];
void
LineListCreate(void)
{
for(int i = 0; i < 28; i++){
LineList[i].setX(LineListData[i][0]);
LineList[i].setY(LineListData[i][1]);
LineList[i].setZ(LineListData[i][2]);
LineList[i].setU(LineListData[i][3]);
LineList[i].setV(LineListData[i][4]);
}
}
void
LineListSetColor(bool white)
{
rw::RGBA SolidColor1 = SolidRed;
rw::RGBA SolidColor2 = SolidWhite;
if(white){
SolidColor1 = SolidWhite;
SolidColor2 = SolidWhite;
}
for(int i = 0; i < 28; i += 2){
LineList[i].setColor(SolidColor1.red, SolidColor1.green,
SolidColor1.blue, SolidColor1.alpha);
LineList[i+1].setColor(SolidColor2.red, SolidColor2.green,
SolidColor2.blue, SolidColor2.alpha);
}
}
void
LineListRender(rw::Matrix *transform, rw::uint32 transformFlags)
{
rw::im3d::Transform(LineList, 28, transform, transformFlags);
rw::im3d::RenderPrimitive(rw::PRIMTYPELINELIST);
rw::im3d::End();
}
void
IndexedLineListCreate(void)
{
for(int i = 0; i < 18; i++){
IndexedLineList[i].setX(IndexedLineListData[i][0]);
IndexedLineList[i].setY(IndexedLineListData[i][1]);
IndexedLineList[i].setZ(IndexedLineListData[i][2]);
IndexedLineList[i].setU(IndexedLineListData[i][3]);
IndexedLineList[i].setV(IndexedLineListData[i][4]);
}
}
void
IndexedLineListSetColor(bool white)
{
int i;
rw::RGBA SolidColor1 = SolidRed;
rw::RGBA SolidColor2 = SolidGreen;
rw::RGBA SolidColor3 = SolidBlue;
if(white){
SolidColor1 = SolidWhite;
SolidColor2 = SolidWhite;
SolidColor3 = SolidWhite;
}
IndexedLineList[0].setColor(SolidColor1.red, SolidColor1.green,
SolidColor1.blue, SolidColor1.alpha);
for(i = 1; i < 5; i++)
IndexedLineList[i].setColor(SolidColor2.red, SolidColor2.green,
SolidColor2.blue, SolidColor2.alpha);
for(; i < 13; i++)
IndexedLineList[i].setColor(SolidColor3.red, SolidColor3.green,
SolidColor3.blue, SolidColor3.alpha);
for(; i < 17; i++)
IndexedLineList[i].setColor(SolidColor2.red, SolidColor2.green,
SolidColor2.blue, SolidColor2.alpha);
IndexedLineList[i].setColor(SolidColor1.red, SolidColor1.green,
SolidColor1.blue, SolidColor1.alpha);
}
void
IndexedLineListRender(rw::Matrix *transform, rw::uint32 transformFlags)
{
rw::im3d::Transform(IndexedLineList, 18, transform, transformFlags);
rw::im3d::RenderIndexedPrimitive(rw::PRIMTYPELINELIST, IndexedLineListIndices, 96);
rw::im3d::End();
}

266
tools/im3d/main.cpp Normal file
View File

@ -0,0 +1,266 @@
#include <rw.h>
#include <skeleton.h>
#include <assert.h>
#include "im3d.h"
rw::EngineOpenParams engineOpenParams;
rw::RGBA ForegroundColor = { 200, 200, 200, 255 };
rw::RGBA BackgroundColor = { 64, 64, 64, 0 };
rw::Camera *Camera;
rw::Charset *Charset;
float TimeDelta;
rw::Camera*
CreateCamera(void)
{
Camera = sk::CameraCreate(sk::globals.width, sk::globals.height, 1);
assert(Camera);
Camera->setNearPlane(0.1f);
Camera->setFarPlane(50.0f);
return Camera;
}
void
Initialize(void)
{
sk::globals.windowtitle = "Im3D example";
sk::globals.width = 1280;
sk::globals.height = 800;
sk::globals.quit = 0;
}
bool
Initialize3D(void)
{
if(!sk::InitRW())
return false;
Charset = rw::Charset::create(&ForegroundColor, &BackgroundColor);
Camera = CreateCamera();
Im3DInitialize();
ImGui_ImplRW_Init();
ImGui::StyleColorsClassic();
rw::Rect r;
r.x = 0;
r.y = 0;
r.w = sk::globals.width;
r.h = sk::globals.height;
sk::CameraSize(::Camera, &r, 0.5f, 4.0f/3.0f);
return true;
}
void
Terminate3D(void)
{
Im3DTerminate();
if(Camera){
Camera->destroy();
Camera = nil;
}
if(Charset){
Charset->destroy();
Charset = nil;
}
sk::TerminateRW();
}
bool
attachPlugins(void)
{
rw::ps2::registerPDSPlugin(40);
rw::ps2::registerPluginPDSPipes();
rw::registerMeshPlugin();
rw::registerNativeDataPlugin();
rw::registerAtomicRightsPlugin();
rw::registerMaterialRightsPlugin();
rw::xbox::registerVertexFormatPlugin();
rw::registerSkinPlugin();
rw::registerUserDataPlugin();
rw::registerHAnimPlugin();
rw::registerMatFXPlugin();
rw::registerUVAnimPlugin();
rw::ps2::registerADCPlugin();
return true;
}
void
DisplayOnScreenInfo(void)
{
}
void
Gui(void)
{
static bool showWindow = true;
ImGui::Begin("Im2D", &showWindow);
ImGui::RadioButton("Line-list", &Im3DPrimType, 0);
ImGui::RadioButton("Line-list indexed", &Im3DPrimType, 1);
ImGui::RadioButton("Poly-line", &Im3DPrimType, 2);
ImGui::RadioButton("Poly-line indexed", &Im3DPrimType, 3);
ImGui::RadioButton("Tri-list", &Im3DPrimType, 4);
ImGui::RadioButton("Tri-list indexed", &Im3DPrimType, 5);
ImGui::RadioButton("Tri-strip", &Im3DPrimType, 6);
ImGui::RadioButton("Tri-strip indexed", &Im3DPrimType, 7);
ImGui::RadioButton("Tri-fan", &Im3DPrimType, 8);
ImGui::RadioButton("Tri-fan indexed", &Im3DPrimType, 9);
ImGui::NewLine();
ImGui::Checkbox("Textured", &Im3DTextured);
if(ImGui::Checkbox("Colored", &Im3DColored)){
LineListSetColor(!Im3DColored);
IndexedLineListSetColor(!Im3DColored);
PolyLineSetColor(!Im3DColored);
IndexedPolyLineSetColor(!Im3DColored);
TriListSetColor(!Im3DColored);
IndexedTriListSetColor(!Im3DColored);
TriStripSetColor(!Im3DColored);
IndexedTriStripSetColor(!Im3DColored);
TriFanSetColor(!Im3DColored);
IndexedTriFanSetColor(!Im3DColored);
}
ImGui::End();
}
void
Render(void)
{
Camera->clear(&BackgroundColor, rw::Camera::CLEARIMAGE|rw::Camera::CLEARZ);
Camera->beginUpdate();
ImGui_ImplRW_NewFrame(TimeDelta);
Im3DRender();
DisplayOnScreenInfo();
Gui();
ImGui::EndFrame();
ImGui::Render();
Camera->endUpdate();
Camera->showRaster(0);
}
void
Idle(float timeDelta)
{
TimeDelta = timeDelta;
Render();
}
int MouseX, MouseY;
int MouseDeltaX, MouseDeltaY;
int MouseButtons;
bool Rotate, Translate;
void
KeyUp(int key)
{
}
void
KeyDown(int key)
{
switch(key){
case sk::KEY_ESC:
sk::globals.quit = 1;
break;
}
}
void
MouseBtn(sk::MouseState *mouse)
{
MouseButtons = mouse->buttons;
Rotate = !!(MouseButtons&1);
Translate = !!(MouseButtons&4);
}
void
MouseMove(sk::MouseState *mouse)
{
MouseDeltaX = mouse->posx - MouseX;
MouseDeltaY = mouse->posy - MouseY;
MouseX = mouse->posx;
MouseY = mouse->posy;
if(Rotate)
Im3DRotate(MouseDeltaX, -MouseDeltaY);
if(Translate)
Im3DTranslateZ(-MouseDeltaY*0.1f);
}
sk::EventStatus
AppEventHandler(sk::Event e, void *param)
{
using namespace sk;
Rect *r;
MouseState *ms;
ImGuiEventHandler(e, param);
ImGuiIO &io = ImGui::GetIO();
switch(e){
case INITIALIZE:
Initialize();
return EVENTPROCESSED;
case RWINITIALIZE:
return Initialize3D() ? EVENTPROCESSED : EVENTERROR;
case RWTERMINATE:
Terminate3D();
return EVENTPROCESSED;
case PLUGINATTACH:
return attachPlugins() ? EVENTPROCESSED : EVENTERROR;
case KEYDOWN:
KeyDown(*(int*)param);
return EVENTPROCESSED;
case KEYUP:
KeyUp(*(int*)param);
return EVENTPROCESSED;
case MOUSEBTN:
if(!io.WantCaptureMouse){
ms = (MouseState*)param;
MouseBtn(ms);
}else
MouseButtons = 0;
return EVENTPROCESSED;
case MOUSEMOVE:
MouseMove((MouseState*)param);
return EVENTPROCESSED;
case RESIZE:
r = (Rect*)param;
// TODO: register when we're minimized
if(r->w == 0) r->w = 1;
if(r->h == 0) r->h = 1;
sk::globals.width = r->w;
sk::globals.height = r->h;
if(::Camera){
sk::CameraSize(::Camera, r, 0.5f, 4.0f/3.0f);
}
break;
case IDLE:
Idle(*(float*)param);
return EVENTPROCESSED;
}
return sk::EVENTNOTPROCESSED;
}

157
tools/im3d/polyline.cpp Normal file
View File

@ -0,0 +1,157 @@
#include <rw.h>
#include <skeleton.h>
#include "im3d.h"
float PolyLineData[21][5] = {
{ 0.000f, 1.000f, 1.000f, 0.500f, 1.000f},
{ 0.707f, 0.707f, 0.900f, 0.854f, 0.854f},
{ 1.000f, 0.000f, 0.800f, 1.000f, 0.500f},
{ 0.707f, -0.707f, 0.700f, 0.854f, 0.146f},
{ 0.000f, -1.000f, 0.600f, 0.500f, 0.000f},
{-0.707f, -0.707f, 0.500f, 0.146f, 0.146f},
{-1.000f, -0.000f, 0.400f, 0.000f, 0.500f},
{-0.707f, 0.707f, 0.300f, 0.146f, 0.854f},
{ 0.000f, 1.000f, 0.200f, 0.500f, 1.000f},
{ 0.707f, 0.707f, 0.100f, 0.854f, 0.854f},
{ 1.000f, 0.000f, 0.000f, 1.000f, 0.500f},
{ 0.707f, -0.707f, -0.100f, 0.854f, 0.146f},
{ 0.000f, -1.000f, -0.200f, 0.500f, 0.000f},
{-0.707f, -0.707f, -0.300f, 0.146f, 0.146f},
{-1.000f, -0.000f, -0.400f, 0.000f, 0.500f},
{-0.707f, 0.707f, -0.500f, 0.146f, 0.854f},
{ 0.000f, 1.000f, -0.600f, 0.500f, 1.000f},
{ 0.707f, 0.707f, -0.700f, 0.854f, 0.854f},
{ 1.000f, 0.000f, -0.800f, 1.000f, 0.500f},
{ 0.707f, -0.707f, -0.900f, 0.854f, 0.146f},
{ 0.000f, -1.000f, -1.000f, 0.500f, 0.000f}
};
float IndexedPolyLineData[8][5] = {
{ 1.000f, 1.000f, 1.000f, 1.000f, 0.000f},
{-1.000f, 1.000f, 1.000f, 1.000f, 1.000f},
{-1.000f, -1.000f, 1.000f, 0.500f, 1.000f},
{ 1.000f, -1.000f, 1.000f, 0.500f, 0.000f},
{ 1.000f, 1.000f, -1.000f, 0.500f, 0.000f},
{-1.000f, 1.000f, -1.000f, 0.500f, 1.000f},
{-1.000f, -1.000f, -1.000f, 0.000f, 1.000f},
{ 1.000f, -1.000f, -1.000f, 0.000f, 0.000f}
};
rw::uint16 IndexedPolyLineIndices[25] = {
0, 1, 2, 3, 0, 2, 6, 5, 1, 3, 7, 4, 0, 5, 4, 6, 1, 4, 3, 6, 7, 5, 2, 7, 0
};
rw::RWDEVICE::Im3DVertex PolyLine[21];
rw::RWDEVICE::Im3DVertex IndexedPolyLine[8];
void
PolyLineCreate(void)
{
for(int i = 0; i < 21; i++){
PolyLine[i].setX(PolyLineData[i][0]);
PolyLine[i].setY(PolyLineData[i][1]);
PolyLine[i].setZ(PolyLineData[i][2]);
PolyLine[i].setU(PolyLineData[i][3]);
PolyLine[i].setV(PolyLineData[i][4]);
}
}
void
PolyLineSetColor(bool white)
{
int i;
rw::RGBA SolidColor1 = SolidRed;
rw::RGBA SolidColor2 = SolidGreen;
rw::RGBA SolidColor3 = SolidBlue;
if(white){
SolidColor1 = SolidWhite;
SolidColor2 = SolidWhite;
SolidColor3 = SolidWhite;
}
for(i = 0; i < 7; i++)
PolyLine[i].setColor(SolidColor1.red, SolidColor1.green,
SolidColor1.blue, SolidColor1.alpha);
for(; i < 14; i++)
PolyLine[i].setColor(SolidColor2.red, SolidColor2.green,
SolidColor2.blue, SolidColor2.alpha);
for(; i < 21; i++)
PolyLine[i].setColor(SolidColor3.red, SolidColor3.green,
SolidColor3.blue, SolidColor3.alpha);
}
void
PolyLineRender(rw::Matrix *transform, rw::uint32 transformFlags)
{
rw::im3d::Transform(PolyLine, 21, transform, transformFlags);
rw::im3d::RenderPrimitive(rw::PRIMTYPEPOLYLINE);
rw::im3d::End();
}
void
IndexedPolyLineCreate(void)
{
for(int i = 0; i < 8; i++){
IndexedPolyLine[i].setX(IndexedPolyLineData[i][0]);
IndexedPolyLine[i].setY(IndexedPolyLineData[i][1]);
IndexedPolyLine[i].setZ(IndexedPolyLineData[i][2]);
IndexedPolyLine[i].setU(IndexedPolyLineData[i][3]);
IndexedPolyLine[i].setV(IndexedPolyLineData[i][4]);
}
}
void
IndexedPolyLineSetColor(bool white)
{
rw::RGBA SolidColor1 = SolidRed;
rw::RGBA SolidColor2 = SolidYellow;
rw::RGBA SolidColor3 = SolidBlack;
rw::RGBA SolidColor4 = SolidPurple;
rw::RGBA SolidColor5 = SolidGreen;
rw::RGBA SolidColor6 = SolidCyan;
rw::RGBA SolidColor7 = SolidBlue;
rw::RGBA SolidColor8 = SolidWhite;
if(white){
SolidColor1 = SolidWhite;
SolidColor2 = SolidWhite;
SolidColor3 = SolidWhite;
SolidColor4 = SolidWhite;
SolidColor5 = SolidWhite;
SolidColor6 = SolidWhite;
SolidColor7 = SolidWhite;
SolidColor8 = SolidWhite;
}
IndexedPolyLine[0].setColor(SolidColor1.red, SolidColor1.green,
SolidColor1.blue, SolidColor1.alpha);
IndexedPolyLine[1].setColor(SolidColor2.red, SolidColor2.green,
SolidColor2.blue, SolidColor2.alpha);
IndexedPolyLine[2].setColor(SolidColor3.red, SolidColor3.green,
SolidColor3.blue, SolidColor3.alpha);
IndexedPolyLine[3].setColor(SolidColor4.red, SolidColor4.green,
SolidColor4.blue, SolidColor4.alpha);
IndexedPolyLine[4].setColor(SolidColor5.red, SolidColor5.green,
SolidColor5.blue, SolidColor5.alpha);
IndexedPolyLine[5].setColor(SolidColor6.red, SolidColor6.green,
SolidColor6.blue, SolidColor6.alpha);
IndexedPolyLine[6].setColor(SolidColor7.red, SolidColor7.green,
SolidColor7.blue, SolidColor7.alpha);
IndexedPolyLine[7].setColor(SolidColor8.red, SolidColor8.green,
SolidColor8.blue, SolidColor8.alpha);
}
void
IndexedPolyLineRender(rw::Matrix *transform, rw::uint32 transformFlags)
{
rw::im3d::Transform(IndexedPolyLine, 8, transform, transformFlags);
rw::im3d::RenderIndexedPrimitive(rw::PRIMTYPEPOLYLINE, IndexedPolyLineIndices, 25);
rw::im3d::End();
}

152
tools/im3d/trifan.cpp Normal file
View File

@ -0,0 +1,152 @@
#include <rw.h>
#include <skeleton.h>
#include "im3d.h"
float TriFanData[34][5] = {
{ 0.000f, 0.000f, -1.000f, 0.500f, 0.500f},
{ 0.000f, 1.000f, 0.000f, 0.500f, 1.000f},
{ 0.383f, 0.924f, 0.000f, 0.691f, 0.962f},
{ 0.707f, 0.707f, 0.000f, 0.854f, 0.854f},
{ 0.924f, 0.383f, 0.000f, 0.962f, 0.691f},
{ 1.000f, 0.000f, 0.000f, 1.000f, 0.500f},
{ 0.924f, -0.383f, 0.000f, 0.962f, 0.309f},
{ 0.707f, -0.707f, 0.000f, 0.854f, 0.146f},
{ 0.383f, -0.924f, 0.000f, 0.691f, 0.038f},
{ 0.000f, -1.000f, 0.000f, 0.500f, 0.000f},
{-0.383f, -0.924f, 0.000f, 0.309f, 0.038f},
{-0.707f, -0.707f, 0.000f, 0.146f, 0.146f},
{-0.924f, -0.383f, 0.000f, 0.038f, 0.309f},
{-1.000f, -0.000f, 0.000f, 0.000f, 0.500f},
{-0.924f, 0.383f, 0.000f, 0.038f, 0.691f},
{-0.707f, 0.707f, 0.000f, 0.146f, 0.854f},
{-0.383f, 0.924f, 0.000f, 0.309f, 0.962f},
{ 0.000f, 1.000f, 0.000f, 0.500f, 1.000f},
{-0.383f, 0.924f, 0.000f, 0.309f, 0.962f},
{-0.707f, 0.707f, 0.000f, 0.146f, 0.854f},
{-0.924f, 0.383f, 0.000f, 0.038f, 0.691f},
{-1.000f, -0.000f, 0.000f, 0.000f, 0.500f},
{-0.924f, -0.383f, 0.000f, 0.038f, 0.309f},
{-0.707f, -0.707f, 0.000f, 0.146f, 0.146f},
{-0.383f, -0.924f, 0.000f, 0.309f, 0.038f},
{ 0.000f, -1.000f, 0.000f, 0.500f, 0.000f},
{ 0.383f, -0.924f, 0.000f, 0.691f, 0.038f},
{ 0.707f, -0.707f, 0.000f, 0.854f, 0.146f},
{ 0.924f, -0.383f, 0.000f, 0.962f, 0.309f},
{ 1.000f, 0.000f, 0.000f, 1.000f, 0.500f},
{ 0.924f, 0.383f, 0.000f, 0.962f, 0.691f},
{ 0.707f, 0.707f, 0.000f, 0.854f, 0.854f},
{ 0.383f, 0.924f, 0.000f, 0.691f, 0.962f},
{ 0.000f, 1.000f, 0.000f, 0.500f, 1.000f}
};
float IndexedTriFanData[17][5] = {
/* top */
{ 0.000f, 0.000f, -1.000f, 0.500f, 0.500f},
/* circle */
{ 0.000f, 1.000f, 0.000f, 0.500f, 1.000f},
{ 0.383f, 0.924f, 0.000f, 0.691f, 0.962f},
{ 0.707f, 0.707f, 0.000f, 0.854f, 0.854f},
{ 0.924f, 0.383f, 0.000f, 0.962f, 0.691f},
{ 1.000f, 0.000f, 0.000f, 1.000f, 0.500f},
{ 0.924f, -0.383f, 0.000f, 0.962f, 0.309f},
{ 0.707f, -0.707f, 0.000f, 0.854f, 0.146f},
{ 0.383f, -0.924f, 0.000f, 0.691f, 0.038f},
{ 0.000f, -1.000f, 0.000f, 0.500f, 0.000f},
{-0.383f, -0.924f, 0.000f, 0.309f, 0.038f},
{-0.707f, -0.707f, 0.000f, 0.146f, 0.146f},
{-0.924f, -0.383f, 0.000f, 0.038f, 0.309f},
{-1.000f, -0.000f, 0.000f, 0.000f, 0.500f},
{-0.924f, 0.383f, 0.000f, 0.038f, 0.691f},
{-0.707f, 0.707f, 0.000f, 0.146f, 0.854f},
{-0.383f, 0.924f, 0.000f, 0.309f, 0.962f}
};
rw::uint16 IndexedTriFanIndices[34] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1,
16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
};
rw::RWDEVICE::Im3DVertex TriFan[34];
rw::RWDEVICE::Im3DVertex IndexedTriFan[17];
void
TriFanCreate(void)
{
for(int i = 0; i < 34; i++){
TriFan[i].setX(TriFanData[i][0]);
TriFan[i].setY(TriFanData[i][1]);
TriFan[i].setZ(TriFanData[i][2]);
TriFan[i].setU(TriFanData[i][3]);
TriFan[i].setV(TriFanData[i][4]);
}
}
void
TriFanSetColor(bool white)
{
rw::RGBA SolidColor1 = SolidYellow;
rw::RGBA SolidColor2 = SolidBlue;
if(white){
SolidColor1 = SolidWhite;
SolidColor2 = SolidWhite;
}
TriFan[0].setColor(SolidColor1.red, SolidColor1.green,
SolidColor1.blue, SolidColor1.alpha);
for(int i = 1; i < 34; i++)
TriFan[i].setColor(SolidColor2.red, SolidColor2.green,
SolidColor2.blue, SolidColor2.alpha);
}
void
TriFanRender(rw::Matrix *transform, rw::uint32 transformFlags)
{
rw::im3d::Transform(TriFan, 34, transform, transformFlags);
rw::im3d::RenderPrimitive(rw::PRIMTYPETRIFAN);
rw::im3d::End();
}
void
IndexedTriFanCreate(void)
{
for(int i = 0; i < 17; i++){
IndexedTriFan[i].setX(IndexedTriFanData[i][0]);
IndexedTriFan[i].setY(IndexedTriFanData[i][1]);
IndexedTriFan[i].setZ(IndexedTriFanData[i][2]);
IndexedTriFan[i].setU(IndexedTriFanData[i][3]);
IndexedTriFan[i].setV(IndexedTriFanData[i][4]);
}
}
void
IndexedTriFanSetColor(bool white)
{
rw::RGBA SolidColor1 = SolidGreen;
rw::RGBA SolidColor2 = SolidBlack;
if(white){
SolidColor1 = SolidWhite;
SolidColor2 = SolidWhite;
}
IndexedTriFan[0].setColor(SolidColor1.red, SolidColor1.green,
SolidColor1.blue, SolidColor1.alpha);
for(int i = 1; i < 17; i++)
IndexedTriFan[i].setColor(SolidColor2.red, SolidColor2.green,
SolidColor2.blue, SolidColor2.alpha);
}
void
IndexedTriFanRender(rw::Matrix *transform, rw::uint32 transformFlags)
{
rw::im3d::Transform(IndexedTriFan, 17, transform, transformFlags);
rw::im3d::RenderIndexedPrimitive(rw::PRIMTYPETRIFAN, IndexedTriFanIndices, 34);
rw::im3d::End();
}

202
tools/im3d/trilist.cpp Normal file
View File

@ -0,0 +1,202 @@
#include <rw.h>
#include <skeleton.h>
#include "im3d.h"
float TriListData[36][5] = {
/* front */
{ 1.000f, 1.000f, 1.000f, 1.000f, 1.000f},
{-1.000f, -1.000f, 1.000f, 0.000f, 0.000f},
{ 1.000f, -1.000f, 1.000f, 1.000f, 0.000f},
{ 1.000f, 1.000f, 1.000f, 1.000f, 1.000f},
{-1.000f, 1.000f, 1.000f, 0.000f, 1.000f},
{-1.000f, -1.000f, 1.000f, 0.000f, 0.000f},
/* back */
{-1.000f, -1.000f, -1.000f, 1.000f, 1.000f},
{-1.000f, 1.000f, -1.000f, 1.000f, 0.000f},
{ 1.000f, 1.000f, -1.000f, 0.000f, 0.000f},
{-1.000f, -1.000f, -1.000f, 1.000f, 1.000f},
{ 1.000f, 1.000f, -1.000f, 0.000f, 0.000f},
{ 1.000f, -1.000f, -1.000f, 0.000f, 1.000f},
/* top */
{ 1.000f, 1.000f, 1.000f, 1.000f, 1.000f},
{ 1.000f, 1.000f, -1.000f, 1.000f, 0.000f},
{-1.000f, 1.000f, -1.000f, 0.000f, 0.000f},
{ 1.000f, 1.000f, 1.000f, 1.000f, 1.000f},
{-1.000f, 1.000f, -1.000f, 0.000f, 0.000f},
{-1.000f, 1.000f, 1.000f, 0.000f, 1.000f},
/* bottom */
{-1.000f, -1.000f, -1.000f, 1.000f, 1.000f},
{ 1.000f, -1.000f, 1.000f, 0.000f, 0.000f},
{-1.000f, -1.000f, 1.000f, 1.000f, 0.000f},
{-1.000f, -1.000f, -1.000f, 1.000f, 1.000f},
{ 1.000f, -1.000f, -1.000f, 0.000f, 1.000f},
{ 1.000f, -1.000f, 1.000f, 0.000f, 0.000f},
/* left */
{-1.000f, -1.000f, -1.000f, 1.000f, 1.000f},
{-1.000f, 1.000f, 1.000f, 0.000f, 0.000f},
{-1.000f, 1.000f, -1.000f, 1.000f, 0.000f},
{-1.000f, -1.000f, -1.000f, 1.000f, 1.000f},
{-1.000f, -1.000f, 1.000f, 0.000f, 1.000f},
{-1.000f, 1.000f, 1.000f, 0.000f, 0.000f},
/* right */
{ 1.000f, 1.000f, 1.000f, 1.000f, 1.000f},
{ 1.000f, -1.000f, 1.000f, 1.000f, 0.000f},
{ 1.000f, -1.000f, -1.000f, 0.000f, 0.000f},
{ 1.000f, 1.000f, 1.000f, 1.000f, 1.000f},
{ 1.000f, -1.000f, -1.000f, 0.000f, 0.000f},
{ 1.000f, 1.000f, -1.000f, 0.000f, 1.000f}
};
float IndexedTriListData[8][5] = {
{ 1.000f, 1.000f, 1.000f, 1.000f, 0.000f},
{-1.000f, 1.000f, 1.000f, 1.000f, 1.000f},
{-1.000f, -1.000f, 1.000f, 0.500f, 1.000f},
{ 1.000f, -1.000f, 1.000f, 0.500f, 0.000f},
{ 1.000f, 1.000f, -1.000f, 0.500f, 0.000f},
{-1.000f, 1.000f, -1.000f, 0.500f, 1.000f},
{-1.000f, -1.000f, -1.000f, 0.000f, 1.000f},
{ 1.000f, -1.000f, -1.000f, 0.000f, 0.000f}
};
rw::uint16 IndexedTriListIndices[36] = {
/* front */
0, 1, 3, 1, 2, 3,
/* back */
7, 5, 4, 5, 7, 6,
/* left */
6, 2, 1, 1, 5, 6,
/* right */
0, 3, 4, 4, 3, 7,
/* top */
1, 0, 4, 1, 4, 5,
/* bottom */
2, 6, 3, 6, 7, 3
};
rw::RWDEVICE::Im3DVertex TriList[36];
rw::RWDEVICE::Im3DVertex IndexedTriList[8];
void
TriListCreate(void)
{
for(int i = 0; i < 36; i++){
TriList[i].setX(TriListData[i][0]);
TriList[i].setY(TriListData[i][1]);
TriList[i].setZ(TriListData[i][2]);
TriList[i].setU(TriListData[i][3]);
TriList[i].setV(TriListData[i][4]);
}
}
void
TriListSetColor(bool white)
{
int i;
rw::RGBA SolidColor1 = SolidRed;
rw::RGBA SolidColor2 = SolidBlue;
rw::RGBA SolidColor3 = SolidGreen;
rw::RGBA SolidColor4 = SolidYellow;
rw::RGBA SolidColor5 = SolidCyan;
rw::RGBA SolidColor6 = SolidPurple;
if(white){
SolidColor1 = SolidWhite;
SolidColor2 = SolidWhite;
SolidColor3 = SolidWhite;
SolidColor4 = SolidWhite;
SolidColor5 = SolidWhite;
SolidColor6 = SolidWhite;
}
for(i = 0; i < 6; i++)
TriList[i].setColor(SolidColor1.red, SolidColor1.green,
SolidColor1.blue, SolidColor1.alpha);
for(; i < 12; i++)
TriList[i].setColor(SolidColor2.red, SolidColor2.green,
SolidColor2.blue, SolidColor2.alpha);
for(; i < 18; i++)
TriList[i].setColor(SolidColor3.red, SolidColor3.green,
SolidColor3.blue, SolidColor3.alpha);
for(; i < 24; i++)
TriList[i].setColor(SolidColor4.red, SolidColor4.green,
SolidColor4.blue, SolidColor4.alpha);
for(; i < 30; i++)
TriList[i].setColor(SolidColor5.red, SolidColor5.green,
SolidColor5.blue, SolidColor5.alpha);
for(; i < 36; i++)
TriList[i].setColor(SolidColor6.red, SolidColor6.green,
SolidColor6.blue, SolidColor6.alpha);
}
void
TriListRender(rw::Matrix *transform, rw::uint32 transformFlags)
{
rw::im3d::Transform(TriList, 36, transform, transformFlags);
rw::im3d::RenderPrimitive(rw::PRIMTYPETRILIST);
rw::im3d::End();
}
void
IndexedTriListCreate(void)
{
for(int i = 0; i < 8; i++){
IndexedTriList[i].setX(IndexedTriListData[i][0]);
IndexedTriList[i].setY(IndexedTriListData[i][1]);
IndexedTriList[i].setZ(IndexedTriListData[i][2]);
IndexedTriList[i].setU(IndexedTriListData[i][3]);
IndexedTriList[i].setV(IndexedTriListData[i][4]);
}
}
void
IndexedTriListSetColor(bool white)
{
rw::RGBA SolidColor1 = SolidRed;
rw::RGBA SolidColor2 = SolidYellow;
rw::RGBA SolidColor3 = SolidBlack;
rw::RGBA SolidColor4 = SolidPurple;
rw::RGBA SolidColor5 = SolidGreen;
rw::RGBA SolidColor6 = SolidCyan;
rw::RGBA SolidColor7 = SolidBlue;
rw::RGBA SolidColor8 = SolidWhite;
if(white){
SolidColor1 = SolidWhite;
SolidColor2 = SolidWhite;
SolidColor3 = SolidWhite;
SolidColor4 = SolidWhite;
SolidColor5 = SolidWhite;
SolidColor6 = SolidWhite;
SolidColor7 = SolidWhite;
SolidColor8 = SolidWhite;
}
IndexedTriList[0].setColor(SolidColor1.red, SolidColor1.green,
SolidColor1.blue, SolidColor1.alpha);
IndexedTriList[1].setColor(SolidColor2.red, SolidColor2.green,
SolidColor2.blue, SolidColor2.alpha);
IndexedTriList[2].setColor(SolidColor3.red, SolidColor3.green,
SolidColor3.blue, SolidColor3.alpha);
IndexedTriList[3].setColor(SolidColor4.red, SolidColor4.green,
SolidColor4.blue, SolidColor4.alpha);
IndexedTriList[4].setColor(SolidColor5.red, SolidColor5.green,
SolidColor5.blue, SolidColor5.alpha);
IndexedTriList[5].setColor(SolidColor6.red, SolidColor6.green,
SolidColor6.blue, SolidColor6.alpha);
IndexedTriList[6].setColor(SolidColor7.red, SolidColor7.green,
SolidColor7.blue, SolidColor7.alpha);
IndexedTriList[7].setColor(SolidColor8.red, SolidColor8.green,
SolidColor8.blue, SolidColor8.alpha);
}
void
IndexedTriListRender(rw::Matrix *transform, rw::uint32 transformFlags)
{
rw::im3d::Transform(IndexedTriList, 8, transform, transformFlags);
rw::im3d::RenderIndexedPrimitive(rw::PRIMTYPETRILIST, IndexedTriListIndices, 36);
rw::im3d::End();
}

169
tools/im3d/tristrip.cpp Normal file
View File

@ -0,0 +1,169 @@
#include <rw.h>
#include <skeleton.h>
#include "im3d.h"
float TriStripData[36][5] = {
{ 0.000f, 1.000f, -1.000f, 0.000f, 0.000f},
{ 0.000f, 1.000f, 1.000f, 0.000f, 1.000f},
{ 0.707f, 0.707f, -1.000f, 0.125f, 0.000f},
{ 0.707f, 0.707f, 1.000f, 0.125f, 1.000f},
{ 1.000f, 0.000f, -1.000f, 0.250f, 0.000f},
{ 1.000f, 0.000f, 1.000f, 0.250f, 1.000f},
{ 0.707f, -0.707f, -1.000f, 0.375f, 0.000f},
{ 0.707f, -0.707f, 1.000f, 0.375f, 1.000f},
{ 0.000f, -1.000f, -1.000f, 0.500f, 0.000f},
{ 0.000f, -1.000f, 1.000f, 0.500f, 1.000f},
{-0.707f, -0.707f, -1.000f, 0.625f, 0.000f},
{-0.707f, -0.707f, 1.000f, 0.625f, 1.000f},
{-1.000f, -0.000f, -1.000f, 0.750f, 0.000f},
{-1.000f, -0.000f, 1.000f, 0.750f, 1.000f},
{-0.707f, 0.707f, -1.000f, 0.875f, 0.000f},
{-0.707f, 0.707f, 1.000f, 0.875f, 1.000f},
{ 0.000f, 1.000f, -1.000f, 1.000f, 0.000f},
{ 0.000f, 1.000f, 1.000f, 1.000f, 1.000f},
{ 0.000f, 1.000f, 1.000f, 0.000f, 0.000f},
{ 0.000f, 1.000f, -1.000f, 0.000f, 1.000f},
{ 0.707f, 0.707f, 1.000f, 0.125f, 0.000f},
{ 0.707f, 0.707f, -1.000f, 0.125f, 1.000f},
{ 1.000f, 0.000f, 1.000f, 0.250f, 0.000f},
{ 1.000f, 0.000f, -1.000f, 0.250f, 1.000f},
{ 0.707f, -0.707f, 1.000f, 0.375f, 0.000f},
{ 0.707f, -0.707f, -1.000f, 0.375f, 1.000f},
{ 0.000f, -1.000f, 1.000f, 0.500f, 0.000f},
{ 0.000f, -1.000f, -1.000f, 0.500f, 1.000f},
{-0.707f, -0.707f, 1.000f, 0.625f, 0.000f},
{-0.707f, -0.707f, -1.000f, 0.625f, 1.000f},
{-1.000f, -0.000f, 1.000f, 0.750f, 0.000f},
{-1.000f, -0.000f, -1.000f, 0.750f, 1.000f},
{-0.707f, 0.707f, 1.000f, 0.875f, 0.000f},
{-0.707f, 0.707f, -1.000f, 0.875f, 1.000f},
{ 0.000f, 1.000f, 1.000f, 1.000f, 0.000f},
{ 0.000f, 1.000f, -1.000f, 1.000f, 1.000f}
};
float IndexedTriStripData[16][5] = {
{ 0.000f, 1.000f, 1.000f, 0.000f, 0.000f},
{ 0.707f, 0.707f, 1.000f, 0.250f, 0.000f},
{ 1.000f, 0.000f, 1.000f, 0.500f, 0.000f},
{ 0.707f, -0.707f, 1.000f, 0.750f, 0.000f},
{ 0.000f, -1.000f, 1.000f, 1.000f, 0.000f},
{-0.707f, -0.707f, 1.000f, 0.750f, 0.000f},
{-1.000f, -0.000f, 1.000f, 0.500f, 0.000f},
{-0.707f, 0.707f, 1.000f, 0.250f, 0.000f},
{ 0.000f, 1.000f, -1.000f, 0.000f, 1.000f},
{ 0.707f, 0.707f, -1.000f, 0.250f, 1.000f},
{ 1.000f, 0.000f, -1.000f, 0.500f, 1.000f},
{ 0.707f, -0.707f, -1.000f, 0.750f, 1.000f},
{ 0.000f, -1.000f, -1.000f, 1.000f, 1.000f},
{-0.707f, -0.707f, -1.000f, 0.750f, 1.000f},
{-1.000f, -0.000f, -1.000f, 0.500f, 1.000f},
{-0.707f, 0.707f, -1.000f, 0.250f, 1.000f},
};
rw::uint16 IndexedTriStripIndices[36] = {
0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15, 0, 8,
8, 0, 9, 1, 10, 2, 11, 3, 12, 4, 13, 5, 14, 6, 15, 7, 8, 0
};
rw::RWDEVICE::Im3DVertex TriStrip[36];
rw::RWDEVICE::Im3DVertex IndexedTriStrip[16];
void
TriStripCreate(void)
{
for(int i = 0; i < 36; i++){
TriStrip[i].setX(TriStripData[i][0]);
TriStrip[i].setY(TriStripData[i][1]);
TriStrip[i].setZ(TriStripData[i][2]);
TriStrip[i].setU(TriStripData[i][3]);
TriStrip[i].setV(TriStripData[i][4]);
}
}
void
TriStripSetColor(bool white)
{
rw::RGBA SolidColor1 = SolidRed;
rw::RGBA SolidColor2 = SolidYellow;
if(white){
SolidColor1 = SolidWhite;
SolidColor2 = SolidWhite;
}
for(int i = 0; i < 36; i += 2){
TriStrip[i].setColor(SolidColor1.red, SolidColor1.green,
SolidColor1.blue, SolidColor1.alpha);
TriStrip[i+1].setColor(SolidColor2.red, SolidColor2.green,
SolidColor2.blue, SolidColor2.alpha);
}
}
void
TriStripRender(rw::Matrix *transform, rw::uint32 transformFlags)
{
rw::im3d::Transform(TriStrip, 36, transform, transformFlags);
rw::im3d::RenderPrimitive(rw::PRIMTYPETRISTRIP);
rw::im3d::End();
}
void
IndexedTriStripCreate(void)
{
for(int i = 0; i < 16; i++){
IndexedTriStrip[i].setX(IndexedTriStripData[i][0]);
IndexedTriStrip[i].setY(IndexedTriStripData[i][1]);
IndexedTriStrip[i].setZ(IndexedTriStripData[i][2]);
IndexedTriStrip[i].setU(IndexedTriStripData[i][3]);
IndexedTriStrip[i].setV(IndexedTriStripData[i][4]);
}
}
void
IndexedTriStripSetColor(bool white)
{
int i;
rw::RGBA SolidColor1 = SolidBlue;
rw::RGBA SolidColor2 = SolidGreen;
if(white){
SolidColor1 = SolidWhite;
SolidColor2 = SolidWhite;
}
for(i = 0; i < 8; i++)
IndexedTriStrip[i].setColor(SolidColor1.red, SolidColor1.green,
SolidColor1.blue, SolidColor1.alpha);
for(; i < 16; i++)
IndexedTriStrip[i].setColor(SolidColor2.red, SolidColor2.green,
SolidColor2.blue, SolidColor2.alpha);
}
void
IndexedTriStripRender(rw::Matrix *transform, rw::uint32 transformFlags)
{
rw::im3d::Transform(IndexedTriStrip, 16, transform, transformFlags);
rw::im3d::RenderIndexedPrimitive(rw::PRIMTYPETRISTRIP, IndexedTriStripIndices, 36);
rw::im3d::End();
}