Loading and display of basic 3DS models.
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define MAGICNUMBER 0xB3D0
#define CHUNKMAIN 0x4D4D
#define CHUNKMAINVERSION 0x0002
#define CHUNK3D 0x3D3D
#define CHUNK3DVERSION 0x3D3E
#define CHUNK3DOBJECT 0x4000
#define CHUNK3DOBJECTMESH 0x4100
#define CHUNK3DOBJECTMESHVERTICES 0x4110
#define CHUNK3DOBJECTMESHFACES 0x4120
#define CHUNK3DOBJECTMESHMATGROUP 0x4130
#define CHUNK3DOBJECTMESHMAPPING 0x4140
#define CHUNK3DMATERIAL 0xAFFF
#define MATNAME 0xA000
#define MATDIFFUSE 0xA020
#define MATSPECULAR 0xA030
#define MATTRANSPARENCY 0xA050
#define COLOR_F 0x0010
#define COLOR_24 0x0011
#define LIN_COLOR_24 0x0012
#define LIN_COLOR_F 0x0013
#define INT_PERCENTAGE 0x0030
#define FLOAT_PERCENTAGE 0x0031
class Material {
public:
Material()
{
color[0] = color[1] = color[2] = 0;
}
};
} Chunk;
public:
{
}
{
}
};
Material *material[1024];
{
printf(
"Error : Input File Could Not Be Opened!\n");
return -1;
}
printf(
"Error : Input File Could Not Be Read!\n");
}
return 0;
}
{
return (-1);
c->endoffset =
c->offset +
c->len;
return (0);
}
{
return (-1);
} else {
}
}
return 0;
}
{
} else {
} else {
break;
}
}
}
return 0;
}
{
} else {
} else {
break;
}
}
}
return 0;
}
{
} else {
} else {
break;
}
}
}
return 0;
}
{
} else {
} else {
break;
}
}
}
return 0;
}
{
return 0;
}
{
} else {
} else {
break;
}
}
}
return 0;
}
{
model.vlist = 0;
model.flist = 0;
model.numverts = model.numfaces = 0;
} else {
} else {
break;
}
}
}
if (model.vlist != 0)
delete[] model.vlist;
if (model.flist != 0)
delete[] model.flist;
model.vlist = 0;
model.flist = 0;
model.numverts = model.numfaces = 0;
return 0;
}
{
if (model.vlist == 0) {
for (i = 0; i <
numv; i++) {
}
printf(
"\nWarning : Insufficient Memory to Load Vertices!\n");
return -1;
}
for (i = 0; i <
numv; i++) {
}
return 0;
}
{
if (model.flist == 0) {
for (i = 0; i <
numf; i++) {
}
printf(
"\nWarning : Insufficient Memory to Load Faces!\n");
return -1;
}
for (i = 0; i <
numf; i++) {
}
return 0;
}
{
if (
numuv != model.numverts) {
for (i = 0; i <
numuv; i++) {
}
printf(
"\nWarning : Number of Vertices and Mapping Data do not match!\n");
return -1;
}
for (i = 0; i <
numuv; i++) {
}
return 0;
}
{
do {
}
}
while ((
c != 0) && (!
feof(
f)));
return 0;
}
{
return -1;
for (i = 0; i < model.numverts; ++i) {
ts[
nummodels]->SetVertex(i, model.vlist[i].x, model.vlist[i].y, model.vlist[i].z);
}
for (i = 0; i < model.numfaces; ++i) {
ts[
nummodels]->SetTriangle(i, model.flist[i].v1, model.flist[i].v2, model.flist[i].v3);
}
if (
strcmp(model.matname, material[i]->name) == 0) {
ts[
nummodels]->SetMainColorRGB(material[i]->color[0], material[i]->color[1], material[i]->color[2]);
break;
}
}
return 0;
}
{
for (i = 0; i < 2048; i++)
for (i = 0; i < 1024; i++)
material[i] = 0;
model.vlist = 0;
model.flist = 0;
ts[i]->GenerateTriangleNormals();
}
}
}
if (material[i] != 0)
delete material[i];
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEveManager * gEve
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
virtual void AddElement(TEveElement *el)
Add el to the list of children.
void AddElement(TEveElement *element, TEveElement *parent=nullptr)
Add an element.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Made from a list of vertices and a list of triangles (triplets of vertex indices).
virtual void SetName(const char *name)
Set the name of the TNamed.
void Vertex(const Double_t *v)