Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020_068
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2020_068
2020_068
Commits
7f866d01
Commit
7f866d01
authored
Jul 14, 2020
by
VihangiSalgado
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Structure tools
parent
cfe4dca8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
337 additions
and
41 deletions
+337
-41
New_File_Type/ConsoleApp1/Program.cs
New_File_Type/ConsoleApp1/Program.cs
+11
-2
New_File_Type/ConsoleApp1/Structure.cs
New_File_Type/ConsoleApp1/Structure.cs
+41
-39
New_File_Type/ConsoleApp1/StructureTools.cs
New_File_Type/ConsoleApp1/StructureTools.cs
+228
-0
New_File_Type/dum.usa.txt
New_File_Type/dum.usa.txt
+13
-0
New_File_Type/structure of the usa.txt
New_File_Type/structure of the usa.txt
+44
-0
No files found.
New_File_Type/ConsoleApp1/Program.cs
View file @
7f866d01
using
System
;
using
System.IO
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -8,9 +9,17 @@ namespace ConsoleApp1
{
class
Program
{
static
void
Main
(
string
[]
arg
s
)
static
void
Main
(
string
[]
arg
)
{
// loard strings
string
[]
Strings
=
File
.
ReadAllLines
(
"dum.usa.txt"
);
// Get data
Structure
.
UsaFile
usa
=
StructureTools
.
StringArrayToUsaFile
(
Strings
);
// write data to file
byte
[]
tstFile
=
StructureTools
.
UsaFileToBytes
(
usa
);
File
.
WriteAllBytes
(
"test.usa"
,
tstFile
);
}
}
}
New_File_Type/ConsoleApp1/Structure.cs
View file @
7f866d01
...
...
@@ -15,7 +15,7 @@ namespace ConsoleApp1
#
region
usaFile
//USA main format structure
public
struct
u
saFile
public
struct
U
saFile
{
public
char
[]
header
;
// usa header
public
UInt64
fileSize
;
// file size
...
...
@@ -23,64 +23,66 @@ namespace ConsoleApp1
public
string
userName
;
// user nam of the person
public
string
step
;
// step of the model
public
string
comments
;
// cooments about file
public
geometry
[]
geometries
;
// geometry of the 3D model
public
apearance
[]
apearances
;
// aparance of the 3D model
public
scene
Scene
;
// scene of the 3D model
public
animation
[]
animations
;
// animation of the 3D model
public
UInt32
numberOfGeo
;
// number of geomtries
public
UInt64
[]
geoOffSets
;
// place in binary file to reach geo data
public
Geometry
[]
geometries
;
// geometry of the 3D model
public
UInt32
numOfAp
;
// number of app
public
UInt64
[]
apOffSet
;
//place in binary file to reach app data
public
Apearance
[]
apearances
;
// aparance of the 3D model
public
UInt64
numOfCam
;
// number of cam
public
UInt64
[]
camOffset
;
// place in binary file to reach cam data
public
Camera
[]
cam
;
// camera data
public
UInt64
numOfLight
;
// number of lights
public
UInt64
[]
lightOffSet
;
// place in binary file to reach light data
public
Light
[]
light
;
// light data
public
UInt64
numOfAnime
;
// number of animes
public
UInt64
[]
animeOffSet
;
// place in binary file to reach anime data
public
Animation
[]
animations
;
// animation of the 3D model
}
// Encording geometry of the 3D model
public
struct
g
eometry
public
struct
G
eometry
{
public
UInt
16
serfaceID
;
// ID of the each triangle serface
public
UInt
Ptr
point1
;
// first vertx of the triangle
public
UInt
Ptr
point2
;
// second vertex of the triangle
public
UInt
Ptr
point3
;
// third vertex of the triangle
public
UInt
Ptr
nPoint1
;
// first vertex of the outword normal vector
public
UInt
Ptr
nPoint2
;
// second vertex of the outword normal vector
public
UInt
64
serfaceID
;
// ID of the each triangle serface
public
UInt
32
point1
;
// first vertx of the triangle
public
UInt
32
point2
;
// second vertex of the triangle
public
UInt
32
point3
;
// third vertex of the triangle
public
UInt
32
nPoint1
;
// first vertex of the outword normal vector
public
UInt
32
nPoint2
;
// second vertex of the outword normal vector
}
// storing apearance of the 3D model
public
struct
a
pearance
public
struct
A
pearance
{
public
UInt
16
serfaceID2
;
//ID of the each serface
public
UInt
32
aColor
;
// colour of the ech serface
public
UInt
64
serfaceID2
;
//ID of the each serface
public
UInt
64
aColor
;
// colour of the ech serface
public
UInt64
texture
;
// texture of the serface
public
UInt
32
matirial
;
// material of ther serface
public
UInt
64
matirial
;
// material of ther serface
}
//
saving scene inform
tion
public
struct
scene
//
Scene informa
tion
public
struct
Camera
{
public
camera
cam
;
public
light
lightSource
;
public
UInt32
magPoint
;
// magnification point of the camera
public
UInt32
location
;
// Location of the camra
public
UInt32
direction
;
// direction of thee camera
public
UInt32
up
;
//which dirction is the up
}
// camra information
public
struct
camera
public
struct
Light
{
public
UIntPtr
magPoint
;
// magnification point of the camera
public
UIntPtr
location
;
// Location of the camra
public
UIntPtr
direction
;
// direction of thee camera
public
bool
up
;
//which dirction is the up
}
//light source information
public
struct
light
{
public
UIntPtr
lLoction
;
// direction of the light source
public
UInt32
lLoction
;
// direction of the light source
public
UInt32
lColour
;
// colour of the source light
public
UInt32
intensity
;
// intencity of the light source
}
//Encording Animation
public
struct
a
nimation
public
struct
A
nimation
{
public
float
rotation
;
// rotation of the virtual bone
public
float
scale
;
// scale of the bone
public
UInt
Ptr
shear
;
// shear of the bone
public
UInt
Ptr
translation
;
// translation of th bone
}
public
UInt32
rotation
;
// rotation of the virtual bone
public
UInt32
scale
;
// scale of the bone
public
UInt
32
shear
;
// shear of the bone
public
UInt
32
translation
;
// translation of th bone
}
#
endregion
...
...
New_File_Type/ConsoleApp1/StructureTools.cs
View file @
7f866d01
using
System
;
using
System.IO
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -8,5 +9,232 @@ namespace ConsoleApp1
{
public
static
class
StructureTools
{
#
region
usafFile
// Take string from text file and convert it to USA structure
public
static
Structure
.
UsaFile
StringArrayToUsaFile
(
string
[]
Strings
)
{
// Make new USA file
Structure
.
UsaFile
usa
=
new
Structure
.
UsaFile
();
usa
.
userName
=
Strings
[
0
];
// set user name
usa
.
step
=
Strings
[
1
];
// set step
usa
.
comments
=
Strings
[
2
];
// set comments
usa
.
numberOfGeo
=
UInt32
.
Parse
(
Strings
[
3
]);
Structure
.
Geometry
[]
geometries
=
new
Structure
.
Geometry
[
usa
.
numberOfGeo
];
for
(
int
i
=
4
;
i
<
usa
.
numberOfGeo
;
i
++)
{
string
[]
values
=
Strings
[
4
].
Split
(
','
);
geometries
[
4
].
serfaceID
=
UInt64
.
Parse
(
values
[
0
]);
geometries
[
4
].
point1
=
UInt32
.
Parse
(
values
[
1
]);
geometries
[
4
].
point2
=
UInt32
.
Parse
(
values
[
2
]);
geometries
[
4
].
point3
=
UInt32
.
Parse
(
values
[
3
]);
geometries
[
4
].
nPoint1
=
UInt32
.
Parse
(
values
[
4
]);
geometries
[
4
].
nPoint2
=
UInt32
.
Parse
(
values
[
5
]);
}
usa
.
geometries
=
geometries
;
usa
.
numOfAp
=
UInt32
.
Parse
(
Strings
[
5
]);
Structure
.
Apearance
[]
apearances
=
new
Structure
.
Apearance
[
usa
.
numOfAp
];
for
(
int
i
=
4
;
i
<
usa
.
numOfAp
;
i
++)
{
string
[]
values1
=
Strings
[
5
].
Split
(
','
);
apearances
[
6
].
serfaceID2
=
UInt64
.
Parse
(
values1
[
0
]);
apearances
[
6
].
aColor
=
UInt32
.
Parse
(
values1
[
1
]);
apearances
[
6
].
texture
=
UInt32
.
Parse
(
values1
[
2
]);
apearances
[
6
].
matirial
=
UInt32
.
Parse
(
values1
[
3
]);
}
usa
.
apearances
=
apearances
;
usa
.
numOfCam
=
UInt64
.
Parse
(
Strings
[
7
]);
Structure
.
Camera
[]
cameras
=
new
Structure
.
Camera
[
usa
.
numOfCam
];
string
[]
values2
=
Strings
[
4
].
Split
(
','
);
cameras
[
8
].
magPoint
=
UInt32
.
Parse
(
values2
[
0
]);
cameras
[
8
].
location
=
UInt32
.
Parse
(
values2
[
1
]);
cameras
[
8
].
direction
=
UInt32
.
Parse
(
values2
[
2
]);
cameras
[
8
].
up
=
UInt32
.
Parse
(
values2
[
3
]);
usa
.
cam
=
cameras
;
usa
.
numOfLight
=
UInt64
.
Parse
(
Strings
[
9
]);
Structure
.
Light
[]
lights
=
new
Structure
.
Light
[
usa
.
numOfLight
];
string
[]
values3
=
Strings
[
4
].
Split
(
','
);
lights
[
10
].
lLoction
=
UInt32
.
Parse
(
values3
[
0
]);
lights
[
10
].
lColour
=
UInt32
.
Parse
(
values3
[
1
]);
lights
[
10
].
intensity
=
UInt32
.
Parse
(
values3
[
2
]);
usa
.
cam
=
cameras
;
usa
.
numOfAnime
=
UInt64
.
Parse
(
Strings
[
11
]);
Structure
.
Animation
[]
animations
=
new
Structure
.
Animation
[
usa
.
numOfAnime
];
string
[]
values4
=
Strings
[
4
].
Split
(
','
);
animations
[
12
].
rotation
=
UInt32
.
Parse
(
values4
[
0
]);
animations
[
12
].
scale
=
UInt32
.
Parse
(
values4
[
1
]);
animations
[
12
].
shear
=
UInt32
.
Parse
(
values4
[
2
]);
animations
[
12
].
translation
=
UInt32
.
Parse
(
values4
[
3
]);
usa
.
animations
=
animations
;
usa
.
version
=
1
;
// set file specific data
// set header
char
[]
header
=
{
'U'
,
'S'
,
'A'
};
usa
.
header
=
header
;
// UInt64 offset = (UInt64)(usa.header.Length + 8 + 8 + usa.userName.Length + 1 + usa.step.Length + 1 + usa.comments.Length + 1);
//calculate the starting offset
UInt64
offset
=
(
UInt64
)
(
usa
.
header
.
Length
+
8
+
8
+
usa
.
userName
.
Length
+
1
+
usa
.
step
.
Length
+
1
+
usa
.
comments
.
Length
+
1
+
8
+
usa
.
geoOffSets
.
Length
*
8
+
8
+
usa
.
apOffSet
.
Length
*
8
+
8
+
usa
.
camOffset
.
Length
*
8
+
8
+
usa
.
lightOffSet
.
Length
*
8
+
8
+
usa
.
animeOffSet
.
Length
*
8
);
// graully st and increse bytes
UInt64
[]
offsets1
=
new
UInt64
[
usa
.
numberOfGeo
];
for
(
int
i
=
0
;
i
<
offsets1
.
Length
;
i
++)
{
// set initial value
offsets1
[
i
]
=
offset
;
// increment
offset
+=
(
UInt64
)(
8
+
4
+
4
+
4
+
4
+
4
);
}
UInt64
[]
offsets2
=
new
UInt64
[
usa
.
numOfAp
];
for
(
int
i
=
0
;
i
<
offsets2
.
Length
;
i
++)
{
// set initial value
offsets2
[
i
]
=
offset
;
// increment
offset
+=
(
UInt64
)(
8
+
8
+
8
+
8
);
}
UInt64
[]
offsets3
=
new
UInt64
[
usa
.
numOfCam
];
for
(
int
i
=
0
;
i
<
offsets3
.
Length
;
i
++)
{
// set initial value
offsets3
[
i
]
=
offset
;
// increment
offset
+=
(
UInt64
)(
4
+
4
+
4
+
4
);
}
UInt64
[]
offsets4
=
new
UInt64
[
usa
.
numOfLight
];
for
(
int
i
=
0
;
i
<
offsets4
.
Length
;
i
++)
{
// set initial value
offsets4
[
i
]
=
offset
;
// increment
offset
+=
(
UInt64
)(
4
+
4
+
4
);
}
UInt64
[]
offsets
=
new
UInt64
[
usa
.
numOfAnime
];
for
(
int
i
=
0
;
i
<
offsets
.
Length
;
i
++)
{
// set initial value
offsets
[
i
]
=
offset
;
// increment
offset
+=
(
UInt64
)(
4
+
4
+
4
+
4
);
}
//set file size
usa
.
fileSize
=
offset
;
// return the final data
return
usa
;
}
// save the usa fil to a bin to be rad later
public
static
byte
[]
UsaFileToBytes
(
Structure
.
UsaFile
usa
)
{
// make memory stream
MemoryStream
o
=
new
MemoryStream
();
// make binary write to write stream
BinaryWriter
bw
=
new
BinaryWriter
(
o
);
bw
.
Write
(
usa
.
header
);
bw
.
Write
(
usa
.
fileSize
);
bw
.
Write
(
usa
.
version
);
bw
.
Write
(
usa
.
userName
);
bw
.
Write
(
usa
.
step
);
bw
.
Write
(
usa
.
comments
);
bw
.
Write
(
usa
.
numberOfGeo
);
foreach
(
UInt64
offset
in
usa
.
geoOffSets
)
{
bw
.
Write
(
offset
);
}
foreach
(
Structure
.
Geometry
Geometry
in
usa
.
geometries
)
{
bw
.
Write
(
Geometry
.
serfaceID
);
bw
.
Write
(
Geometry
.
point1
);
bw
.
Write
(
Geometry
.
point2
);
bw
.
Write
(
Geometry
.
point3
);
bw
.
Write
(
Geometry
.
nPoint1
);
bw
.
Write
(
Geometry
.
nPoint2
);
}
bw
.
Write
(
usa
.
numOfAp
);
foreach
(
UInt64
offset
in
usa
.
apOffSet
)
{
bw
.
Write
(
offset
);
}
foreach
(
Structure
.
Apearance
Apearance
in
usa
.
apearances
)
{
bw
.
Write
(
Apearance
.
serfaceID2
);
bw
.
Write
(
Apearance
.
aColor
);
bw
.
Write
(
Apearance
.
texture
);
bw
.
Write
(
Apearance
.
matirial
);
}
bw
.
Write
(
usa
.
numOfCam
);
foreach
(
UInt64
offset
in
usa
.
camOffset
)
{
bw
.
Write
(
offset
);
}
foreach
(
Structure
.
Camera
Camera
in
usa
.
cam
)
{
bw
.
Write
(
Camera
.
magPoint
);
bw
.
Write
(
Camera
.
location
);
bw
.
Write
(
Camera
.
direction
);
bw
.
Write
(
Camera
.
up
);
}
bw
.
Write
(
usa
.
numOfLight
);
foreach
(
UInt64
offset
in
usa
.
lightOffSet
)
{
bw
.
Write
(
offset
);
}
foreach
(
Structure
.
Light
Light
in
usa
.
light
)
{
bw
.
Write
(
Light
.
lLoction
);
bw
.
Write
(
Light
.
lColour
);
bw
.
Write
(
Light
.
intensity
);
}
bw
.
Write
(
usa
.
numOfAnime
);
foreach
(
UInt64
offset
in
usa
.
animeOffSet
)
{
bw
.
Write
(
offset
);
}
foreach
(
Structure
.
Animation
Animation
in
usa
.
animations
)
{
bw
.
Write
(
Animation
.
rotation
);
bw
.
Write
(
Animation
.
scale
);
bw
.
Write
(
Animation
.
shear
);
bw
.
Write
(
Animation
.
translation
);
}
// return final bytes
return
o
.
ToArray
();
}
#
endregion
}
}
New_File_Type/dum.usa.txt
0 → 100644
View file @
7f866d01
vihangis
anm
animation of the hand
01
001,2,4,6,8,10
01
001,13127648,13127648,13127648
01
1,2,3,4
01
5,13127648,13127648
01
90,50,5,2
\ No newline at end of file
New_File_Type/structure of the usa.txt
0 → 100644
View file @
7f866d01
user name
step
comments
Encording geometry of the 3D model
{
// Approximate mesh
Serfce ID
Vertices of the Trangle
Outword normal vector
}
Storing apearance of the 3D model
{
// Face attributes
Serface ID
colour
texture
matirial type
}
Saving scene information
{
camera
{
magnification and principle point
location
direction of the camera is facing
which direction is up
}
Light source
{
location of th light source
colour
intensity
}
}
Encording Animation
{
//Skeletal Animation
// represent virtual bones by 4x3 matrix
1st colomn - rotation
2nd colomn - scale
3rd colomn - shear
4th colomn - trnslation.
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment